-
-
Notifications
You must be signed in to change notification settings - Fork 21.8k
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] Collision queries with a mesh collider detect things they don't touch even when changing margin #48905
Comments
Looking at your setup, this result is expected as Bullet uses margins for the shape you test overlap against. It's not just for rigid body physics, but more related to the internal algorithm Bullet uses for performance. Margins are needed for both performance and stability reasons in the collision detection system, including overlap tests. You can decrease the Let me know if that helps! Also for info: |
I see that by default the margin of So changing it to 0.01 seems better, and likely I'll have to duplicate them so that shapes with a higher margin get used for world physics while duplicates are used temporarily for placement checks. However I still have to scale down the model... ideally I should not even need to scale it, because that's not usable with some different shapes: what reduces overlap with one shape could create overlaps with others (concave ones for example). But if margin can't be zero does that mean what I need is impossible? |
It seems to add up for me. The shape is 1.0 wide, and has margins of 0.04 on both sides, applied whatever the scale. So you would need to make a size decrease of 0.08 in order to avoid overlaps. On top of that, this collision margin seems to be applied on both the query shape and the static body shape, so that's a total of 0.16, which corresponds to a 84% scale. That's what I experience in your scene. It probably gets worse with rotations.
No, actually it's different (I'm discovering these different parameters with same names and I agree it's not great). That will get much better when godot physics can become the default again and we get rid of shape margins.
It's a Bullet limitation unfortunately. I see different possibilities to get better results though:
Edit: I've added a documentation tag to keep this issue as a reminder to make the query margin documentation clearer. |
Switching to Godot Physics is quite an bet for a problem like this, because that affects the entire game, both feature-wise and performance-wise (in the longer run, think Space Engineers kind of game). I thought of other workarounds, which are painful but I don't see another way without switching/customizing the physics engine:
|
Godot 3.3
Windows 10 64 bits
Bullet
Issue description:
I'm making a block-based building game prototype, which requires to verify relatively accurately wether or not a shape collides with others.
Some shapes use mesh colliders, but when they do, they keep detecting collisions with other shapes, even if they don't touch. They are right next to each other, so I thought adding a bit of
margin
, but that didnt have any effect.I understand the existence of a margin for rigidbody physics, which I am okay with. However in this case I need to do simple collision queries such as "is it colliding, or not, just now" from code. I need precision for these, but I can't seem to make it work. The only workaround I found so far is to scale down the shape until it stops having false positives, however in my prototype I found I have to scale by about 0.81 sometimes until it stops happening (it varies with orientation for some reason, from 0.8 to 0.9). This is not suitable because not only it is too much, but also won't work with more complex shapes.
Minimal reproduction project:
Example project using a PrismMesh as collision shape. You can play with sliders to see when it detects an overlap and when it doesn't. In this example,
margin
does not have any effect, onlyscale
does, below0.84
.PrismCollisionQuery.zip
The text was updated successfully, but these errors were encountered: