-
-
Notifications
You must be signed in to change notification settings - Fork 21.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix transform changes in _integrate_forces
being overwritten
#84799
Conversation
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
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me.
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_transform
after every_integrate_forces
call, in order to flush any pendingNOTIFICATION_TRANSFORM_CHANGED
that 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_state
that happens right after.Note that this results in a new
NOTIFICATION_TRANSFORM_CHANGED
notification 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.