Fix transform sync in RigidBody*D::_body_state_changed
This commit is contained in:
parent
d5217b68db
commit
a3278c772e
2 changed files with 18 additions and 6 deletions
|
@ -451,10 +451,14 @@ void RigidBody2D::_body_state_changed(PhysicsDirectBodyState2D *p_state) {
|
|||
if (GDVIRTUAL_IS_OVERRIDDEN(_integrate_forces)) {
|
||||
_sync_body_state(p_state);
|
||||
|
||||
Transform2D old_transform = get_global_transform();
|
||||
GDVIRTUAL_CALL(_integrate_forces, p_state);
|
||||
Transform2D new_transform = get_global_transform();
|
||||
|
||||
// Update the physics server with any new transform, to prevent it from being overwritten at the sync below.
|
||||
force_update_transform();
|
||||
if (new_transform != old_transform) {
|
||||
// Update the physics server with the new transform, to prevent it from being overwritten at the sync below.
|
||||
PhysicsServer2D::get_singleton()->body_set_state(get_rid(), PhysicsServer2D::BODY_STATE_TRANSFORM, new_transform);
|
||||
}
|
||||
}
|
||||
|
||||
_sync_body_state(p_state);
|
||||
|
|
|
@ -506,10 +506,14 @@ void RigidBody3D::_body_state_changed(PhysicsDirectBodyState3D *p_state) {
|
|||
if (GDVIRTUAL_IS_OVERRIDDEN(_integrate_forces)) {
|
||||
_sync_body_state(p_state);
|
||||
|
||||
Transform3D old_transform = get_global_transform();
|
||||
GDVIRTUAL_CALL(_integrate_forces, p_state);
|
||||
Transform3D new_transform = get_global_transform();
|
||||
|
||||
// Update the physics server with any new transform, to prevent it from being overwritten at the sync below.
|
||||
force_update_transform();
|
||||
if (new_transform != old_transform) {
|
||||
// Update the physics server with the new transform, to prevent it from being overwritten at the sync below.
|
||||
PhysicsServer3D::get_singleton()->body_set_state(get_rid(), PhysicsServer3D::BODY_STATE_TRANSFORM, new_transform);
|
||||
}
|
||||
}
|
||||
|
||||
_sync_body_state(p_state);
|
||||
|
@ -2945,10 +2949,14 @@ void PhysicalBone3D::_body_state_changed(PhysicsDirectBodyState3D *p_state) {
|
|||
if (GDVIRTUAL_IS_OVERRIDDEN(_integrate_forces)) {
|
||||
_sync_body_state(p_state);
|
||||
|
||||
Transform3D old_transform = get_global_transform();
|
||||
GDVIRTUAL_CALL(_integrate_forces, p_state);
|
||||
Transform3D new_transform = get_global_transform();
|
||||
|
||||
// Update the physics server with any new transform, to prevent it from being overwritten at the sync below.
|
||||
force_update_transform();
|
||||
if (new_transform != old_transform) {
|
||||
// Update the physics server with the new transform, to prevent it from being overwritten at the sync below.
|
||||
PhysicsServer3D::get_singleton()->body_set_state(get_rid(), PhysicsServer3D::BODY_STATE_TRANSFORM, new_transform);
|
||||
}
|
||||
}
|
||||
|
||||
_sync_body_state(p_state);
|
||||
|
|
Loading…
Reference in a new issue