-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
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
[3.x] Fix KinematicBody axis lock #45176
[3.x] Fix KinematicBody axis lock #45176
Conversation
I'm not strongly against this, and for the presented reason it seems a good change. However, the physics server API are generally not so fast especially if compared to This is not a blocker if the physics team still think worth it. |
By the way, just noticed the type of |
@AndreaCatania The rest of the For info, #25798 is only present on 3.2, since on master |
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.
Just one thing I'd like to change. In order to clean things completely, let's add a helper method on KinematicBody3D
instead of calling the physics server directly.
Something like:
void KinematicBody::_apply_axis_lock(Vector3 &p_motion) const {
if (get_axis_lock(PhysicsServer::BODY_AXIS_LINEAR_X)) {
p_motion.x = 0.0f;
}
if (get_axis_lock(PhysicsServer::BODY_AXIS_LINEAR_Y)) {
p_motion.y = 0.0f;
}
if (get_axis_lock(PhysicsServer::BODY_AXIS_LINEAR_Z)) {
p_motion.z = 0.0f;
}
}
And then:
_apply_axis_lock(result.motion);
Instead of:
for (int i = 0; i < 3; i++) { {
if (PhysicsServer3D::get_singleton()->body_is_axis_locked(get_rid(), PhysicsServer3D::BodyAxis(1 << i))) {
result.motion[i] = 0;
}
}
So the code in KinematicBody
won't rely on actual values from the physics server to work properly.
@AndreaCatania I considered if we could replace |
@pouleyKetchoupp What if the helper method was located on PhysicsServer3D? This would avoid the repeated calls to |
@aaronfranke It's not a bad idea, but currently I don't think it's worth the extra changes in the Physics Server API, and having to implement it in both Bullet and Godot Physics. I would rather do that later, only if for some reason we need it for optimization purpose. |
9225ca7
to
b50cbc9
Compare
See #45175 (comment). #25798 was fixed with #38852, but never backported to 3.2. I think the better approach is a backport of #38852. |
b50cbc9
to
bb3f91d
Compare
bb3f91d
to
65f5ff4
Compare
65f5ff4
to
a73ecd8
Compare
a73ecd8
to
a366afa
Compare
a366afa
to
3665c9c
Compare
919e990
to
a6bf1ae
Compare
a6bf1ae
to
432e338
Compare
432e338
to
d2f733f
Compare
d2f733f
to
ee69b57
Compare
I updated this PR so that now it's a 3.x backport of #38852. This also includes backporting the renames, but the old names are kept as aliases for compatibility, and this PR also updates the documentation. |
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!
This fixes #25798 in 3.x.