Skip to content
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 physics queries not filtering out disabled collision shapes #45863

Merged

Conversation

pouleyKetchoupp
Copy link
Contributor

This change allows collide_shape, intersect_shape, cast_motion and rest_info in both 2D and 3D to ignore disabled shapes and make them consistent with the physics simulation when testing for collision against the physics space.

In some other cases, _cull_aabb_for_body is used and filters shapes out internally, but whenever a physics query uses the broadphase directly without calling _cull_aabb_for_body, disabled shapes can be returned and need to be filtered out.

It looks like there's no issue reported about this bug, so it's probably safer to fix it only on master for now as some users might rely on the current behavior in 3.2.

This change allows collide_shape, intersect_shape, cast_motion and
rest_info in both 2D and 3D to ignore disabled shapes and make them
consistent with the physics simulation.

In some other cases, _cull_aabb_for_body is used and filters shapes out
internally, but whenever a physics query uses the broadphase directly
without calling _cull_aabb_for_body, disabled shapes can be returned
and need to be filtered out.
@pouleyKetchoupp pouleyKetchoupp force-pushed the physics-queries-disabled-shapes branch from dd2822c to 50501f2 Compare February 10, 2021 02:14
@akien-mga akien-mga merged commit a930472 into godotengine:master Feb 24, 2021
@akien-mga
Copy link
Member

Thanks!

@Sslaxx
Copy link

Sslaxx commented Feb 24, 2021

@jitspoe - is this related to the problem you had on stream the other day?

@pouleyKetchoupp pouleyKetchoupp deleted the physics-queries-disabled-shapes branch February 24, 2021 14:58
@jitspoe
Copy link
Contributor

jitspoe commented Feb 25, 2021

Sounds like it, Sslax. I tried to make a small repro test, but naturally couldn't reproduce it in that environment. I think it requires some sort of complex shapes interacting with each other. What I was trying to do was create a loop (something like in Sonic), so half of the loop had physics enabled, then after you touched the top of the loop, the other half would be enabled and the first half disabled.

I did find a post mentioning it on the Godot forums, but I couldn't find a github issue. The workaround was to set the collision layers/mask instead of using the disabled flag.

Edit: not the thread I was looking for, but maybe relevant: https://godotengine.org/qa/57186/disable-collisionshape2d-$collisionshape2d-disabled-godot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants