-
-
Notifications
You must be signed in to change notification settings - Fork 21.7k
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
body_shape_entered yields extraneous shape indices on rigidbodies with only one shape (RigidBody with Bullet) #39767
Comments
Confirmed in 3.2.2 RC 3. This seems to happen with Bullet but not GodotPhysics, so I guess Bullet is using some uninitialized memory. |
Here's what I found about this issue. The members godot/thirdparty/bullet/BulletCollision/CollisionDispatch/btManifoldResult.h Lines 60 to 71 in b92477d
In bullet, this is only set when These indices are set to child shape indices for compound shapes (which is what we want): godot/thirdparty/bullet/BulletCollision/CollisionDispatch/btCompoundCompoundCollisionAlgorithm.cpp Lines 198 to 199 in b92477d
And they are also set to triangle indices for concave shapes (which is not what we want): godot/thirdparty/bullet/BulletCollision/CollisionDispatch/btConvexConcaveCollisionAlgorithm.cpp Lines 122 to 133 in b92477d
That means a static body with multiple concave shapes also reports wrong values if what we expect is the shape index, as it would be the triangle index instead (tested on 4.0 branch, that's what happens with Bullet, while GodotPhysics reports the shape index as expected). So there's an easy quick fix we can do on Godot side to solve the current issue in simple cases, by making sure the shape index is set to 0 in case of single shapes in godot/modules/bullet/space_bullet.cpp Lines 835 to 846 in b92477d
By using something like that:
But that wouldn't solve the case with a body with multiple concave shapes, as this would still report triangle indices instead of shape indices. The information about shape indices is currently lost in this case AFAIK. @AndreaCatania: Do you know of any way to work around this issue with concave shape manifolds reporting triangle indices instead of shape indices? Or do you think it's something that would require a fix in Bullet? |
I'm seeing what looks like the same issue using This is a significant blocker for 3D physics work - I'm currently trying to implement a custom As an aside, i's interesting that the incorrect values are being driven by triangle index for |
I think the "easy, quick fix" makes sense. We could also set it to zero if the
It looks like the problem is the other way around. The index should be the triangle index, but compound shapes have hijacked it to report the child index. The change to support the triangle index was done here, and later the change to use it to store the child index was done here. So there's no easy fix. |
Godot version:
v3.2.1 mono 64 bits
OS/device including version:
Windows 10, also happens in linux machines
Issue description:
When a rigidbody with only one shape in it (either added by a collision shape or one added programatically with the shape_owner syntax) the body_shape_entered signal yields extraneous shape indices (this can happen both on the body_shape and the local_shape parameters). The signal seems to work correctly more than one shape are present. This error is present both in GDScript and in c# (examples for the latter not included).
Steps to reproduce:
Minimal reproduction project:
Tests
All the tests print the body_shape and local_shape of the signal in question, catched by the upper sphere.
Test 1 and 4 showcase the error in question (1 adds the shapes programatically while 4 uses CollisionShapes from the editor).
Test 2 shows the signal working correctly by adding one more shape to the same shape owner.
Test 3 shows the signal working by adding a different shape owner with a different shape to the rigidbody.
The text was updated successfully, but these errors were encountered: