-
-
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 crash on RigidBody _direct_state_changed #47485
Conversation
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.
Three points:
- As mentioned in Executing
RigidBody.new()._direct_state_changed(BoxShape.new())
crashes Godot #46003 (comment), unless there is a reason this method is exposed, the better solution would be to unexpose this method. - This method also exists in KinematicBody, VehicleBody and the equivalents in 2D; so whatever solution is agreed on, those should be updated too.
- This will prevent the crash identified in Fix crash on RigidBody _direct_state_changed #47485 in debug mode only i.e. when run from the editor.
|
I agree we should just unexpose the method on master. The method binding seems to be used only because of an internal call (see #46003 (comment)). @rafallus If you're up for refactoring this fix, the proper changes are:
|
@rafallus Thanks for refactoring the PR! I haven't reviewed or tested yet, but for info some checks are failing because of compilation errors in test code:
It seems there are some more cases in |
Still there are some tests that haven't passed. I'll check that later |
Ok, the PR is ready for review |
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 except for 2 things:
-
There are currently errors when starting the editor or game because of
body_set_force_integration_callback
in physics servers has different arguments now. The method binding needs to be updated here:
godot/servers/physics_server_2d.cpp
Line 650 in 5c8505c
ClassDB::bind_method(D_METHOD("body_set_force_integration_callback", "body", "receiver", "method", "userdata"), &PhysicsServer2D::body_set_force_integration_callback, DEFVAL(Variant()));
(and the same in the 3d physics server) -
The documentation for physics servers needs to be updated too:
godot/doc/classes/PhysicsServer2D.xml
Lines 657 to 671 in 5c8505c
<method name="body_set_force_integration_callback"> <return type="void"> </return> <argument index="0" name="body" type="RID"> </argument> <argument index="1" name="receiver" type="Object"> </argument> <argument index="2" name="method" type="StringName"> </argument> <argument index="3" name="userdata" type="Variant" default="null"> </argument> <description> Sets the function used to calculate physics for an object, if that object allows it (see [method body_set_omit_force_integration]). </description> </method>
(again, for the 3d version as well)
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.
Suggested a couple additional cleanups, but looks great overall. Thanks!
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.
It looks good. Just, as suggested below, the original check this PR suggested either needs to be applied consistently or not at all.
Removed _direct_state_changed bindings Affects 2D and 3D nodes Callbacks now use Callable Tests were changed accordingly
Thanks! |
@twocountriestrus Please don't spam PRs with "Thanks" |
Fixes: #46003 for master branch