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

[Bullet] RayCasts get_collider_shape erroneously returns triangle index when colliding with ConcaveCollisionShape(s) #47989

Closed
Tracked by #45022
Eoin-ONeill-Yokai opened this issue Apr 17, 2021 · 5 comments · Fixed by #55533

Comments

@Eoin-ONeill-Yokai
Copy link
Contributor

Godot version:
3.X

OS/device including version:
x86_64 Linux 5.10.26-1-MANJARO

Issue description:
When using a raycast, I want to be able to fetch the CollisionShape (child of StaticBody) using the api provided. I should be able to fetch the collider (using get_collider()) and then get the desired collision shape by using get_collider_shape(), and the associated shape_owner_* functions from the collider.

However, the raycast is erroneously telling me the triangle I collided with (as an indice) which doesn't give me the ability to correctly fetch the shape owner! The ID returned by get_collider_shape() should be giving us the appropriate index so that shape_owner_* functions can be used correctly!

Steps to reproduce:
Best way to reproduce is create a scene with a static body and a concave collision mesh shape. Then, create a raycast object and use a quick built-in script to try to poll information about the collision. There should be 1 id for the whole mesh, and it shouldn't change when colliding with different triangles. However, it will currently always change when hitting a new triangle.

@Eoin-ONeill-Yokai
Copy link
Contributor Author

@Calinou
Here's a test project for easy reproduction.
bug_47989_project.zip

@Xrayez
Copy link
Contributor

Xrayez commented Apr 18, 2021

There should be 1 id for the whole mesh, and it shouldn't change when colliding with different triangles.

I don't quite understand the confusion here. Different triangles means different shapes, since the object is the entire object which is composed of triangles. It would be similar to grid map shapes, and each would return a different shape ID.

I think this is a misunderstanding of collision shape owners. In a typical case, a collision object will have a single shape owner, which has a collection of shapes (triangles in this case). So, retrieving the shape owner for this case would be: shape_owner_get_shape(0, shape_id).

If you have more than one shape owner, then yeah perhaps that may be a limitation. But if those shape IDs are unique across shape owners, then you can use the PhysicsServer API directly to handle that. The "owner" is a concept unique to collision objects, but the PhysicsServer doesn't have those implemented, therefore you'd be basically limited to what the PhysicsServer provides.

I haven't dealt with 3D extensively to tell if there's a major difference with how 2D handles it, but the logic should be similar I guess...

I've always found the "owner" terminology confusing myself, see godotengine/godot-proposals#1574.

@pouleyKetchoupp
Copy link
Contributor

It seems like it could be related to #39767, but for raycasting. In this case it's Bullet specific and could be solved by doing a fix similar to #42881.

@pouleyKetchoupp
Copy link
Contributor

I can confirm in 3.3.2. It's similar to #39767, and doesn't happen when switching to Godot Physics in project settings.

@pouleyKetchoupp pouleyKetchoupp changed the title RayCasts get_collider_shape erroneously returns triangle index when colliding with ConcaveCollisionShape(s) [Bullet] RayCasts get_collider_shape erroneously returns triangle index when colliding with ConcaveCollisionShape(s) Jun 7, 2021
@akien-mga akien-mga added this to the 3.5 milestone Dec 1, 2021
@Eoin-ONeill-Yokai
Copy link
Contributor Author

@pouleyKetchoupp Thanks for fixing this! I'll give it a test sometime.

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

Successfully merging a pull request may close this issue.

5 participants