Fix transform changes in _integrate_forces being overwritten#84799
Fix transform changes in _integrate_forces being overwritten#84799akien-mga merged 1 commit intogodotengine:masterfrom
_integrate_forces being overwritten#84799Conversation
|
There is an alternative implementation to this as well, which is to not use This has the benefit of not emitting The drawback of this is that it would likely need to look something like this: Transform3D old_transform = get_global_transform();
GDVIRTUAL_CALL(_integrate_forces, p_state);
Transform3D new_transform = get_global_transform();
if (new_transform != old_transform) {
PhysicsServer3D::get_singleton()->body_set_state(get_rid(), PhysicsServer3D::BODY_STATE_TRANSFORM, new_transform);
}... meaning every single
|
|
It seems like this PR has unearthed another bug related to extends RigidBody2D
func _integrate_forces(_state):
rotation_degrees = 45... you will never actually see that transformation happen until something changes the transform somewhere else. But if you do something like this instead: extends RigidBody2D
func _integrate_forces(state):
rotation_degrees += 45 * state.step... then everything is fine. Interestingly this last snippet doesn't seem to have worked even before #79977, so there's been some kind of give and take here at least. I'll see about making a separate PR to fix this new issue with |
|
Thanks! |
Fixes #83412.
This adds a
force_update_transformafter every_integrate_forcescall, in order to flush any pendingNOTIFICATION_TRANSFORM_CHANGEDthat might be needed and thereby push those transform changes to the physics server before we request it back from the physics server again at the next_sync_body_statethat happens right after.Note that this results in a new
NOTIFICATION_TRANSFORM_CHANGEDnotification that wasn't being emitted before, even when the user was explicitly modifying the transform. I would perhaps argue that the lack of this notification was also a bug and something that should have been emitted, seeing as how transform changes in any other method would emit that notification.