Fixed performance regression in godot 4.2 in RigidBody2D/3D and PhysicalBone3D
After change c118256865
the body state is synched 2x, but this is only needed if _integrate_forces is overridden.
Adding this extra if increases the FPS by 2.5% in a heavy physics scene, see: https://github.com/godot-jolt/godot-jolt/discussions/611
This commit is contained in:
parent
b905959f43
commit
eff7f27c48
|
@ -447,9 +447,12 @@ void RigidBody2D::_body_state_changed(PhysicsDirectBodyState2D *p_state) {
|
|||
lock_callback();
|
||||
|
||||
set_block_transform_notify(true); // don't want notify (would feedback loop)
|
||||
_sync_body_state(p_state);
|
||||
|
||||
GDVIRTUAL_CALL(_integrate_forces, p_state);
|
||||
if (GDVIRTUAL_IS_OVERRIDDEN(_integrate_forces)) {
|
||||
_sync_body_state(p_state);
|
||||
|
||||
GDVIRTUAL_CALL(_integrate_forces, p_state);
|
||||
}
|
||||
|
||||
_sync_body_state(p_state);
|
||||
set_block_transform_notify(false); // want it back
|
||||
|
|
|
@ -502,9 +502,12 @@ void RigidBody3D::_body_state_changed(PhysicsDirectBodyState3D *p_state) {
|
|||
lock_callback();
|
||||
|
||||
set_ignore_transform_notification(true);
|
||||
_sync_body_state(p_state);
|
||||
|
||||
GDVIRTUAL_CALL(_integrate_forces, p_state);
|
||||
if (GDVIRTUAL_IS_OVERRIDDEN(_integrate_forces)) {
|
||||
_sync_body_state(p_state);
|
||||
|
||||
GDVIRTUAL_CALL(_integrate_forces, p_state);
|
||||
}
|
||||
|
||||
_sync_body_state(p_state);
|
||||
set_ignore_transform_notification(false);
|
||||
|
@ -2935,9 +2938,12 @@ void PhysicalBone3D::_body_state_changed(PhysicsDirectBodyState3D *p_state) {
|
|||
}
|
||||
|
||||
set_ignore_transform_notification(true);
|
||||
_sync_body_state(p_state);
|
||||
|
||||
GDVIRTUAL_CALL(_integrate_forces, p_state);
|
||||
if (GDVIRTUAL_IS_OVERRIDDEN(_integrate_forces)) {
|
||||
_sync_body_state(p_state);
|
||||
|
||||
GDVIRTUAL_CALL(_integrate_forces, p_state);
|
||||
}
|
||||
|
||||
_sync_body_state(p_state);
|
||||
set_ignore_transform_notification(false);
|
||||
|
|
Loading…
Reference in New Issue