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

Contact between a ball and cuboid sometimes and has no contact pair #255

Open
Dooskington opened this issue Apr 11, 2020 · 2 comments
Open

Comments

@Dooskington
Copy link

Dooskington commented Apr 11, 2020

Not sure if this is only reproducible with a Ball hitting a Cuboid, but I have not tested two Cuboids or other shapes.

Essentially, with my cuboid colliders and ball rigidbody, every once in a while the ball will collide and have no contact pair when I query. This means I can't react to the collision properly and my game just kind of breaks. It is strange though, because the rigidbody is reacting to the collision, either stopping in its place, or sliding along the box collider that it hit.

I made my game repo public with a repro branch here, and the physics code is here. The ball (created in ball.rs) has a mass of 1.0 and the rest of the colliders and paddle are just boxes set up in game/mod.rs.

If you manage to compile and run it and want to actually repro, use A/D or Left/Right to move the paddle, and spacebar to launch the ball. This seems to be easiest to repro if you just bounce the ball back and forth on the Y axis, hitting the paddle (collider index 0) and the brick directly above. Eventually, the ball will reflect strangely or stop entirely and you can observe that no contact pair was found:

contact started: handle1: Index { index: 54, generation: 0 }, handle2: Index { index: 0, generation: 0 }
No contact pair found for collision!

If you enable the println!() under the physics.step(), we can see that this isn't a case of a contact event starting and stopping on the same step (there would be a 'contact stopped' logged):

step
contact started: handle1: Index { index: 54, generation: 0 }, handle2: Index { index: 0, generation: 0 }
No contact pair found for collision!
step
step

Messing with the ccd parameters doesn't seem to help. Disabling CCD seems to improve the situation but does not fix it.

@Dooskington
Copy link
Author

Managed to capture a gif of it happening, and the log at the same time. 55 is the ball, 45 is the brick that it gets stuck on.

step
contact started: handle1: Index { index: 55, generation: 4 }, handle2: Index { index: 45, generation: 0 }
No contact pair found for collision!
step

6tbjBvhKO5

It seems like it happens more often at the borders of the bricks, i.e. where two Cuboids are basically stacked right next to each other.

@Dooskington
Copy link
Author

Dooskington commented Apr 11, 2020

I just had this happen again, but CCD was disabled:

step
contact started: handle1: Index { index: 54, generation: 0 }, handle2: Index { index: 44, generation: 0 }
No contact pair found for collision!
step
step
contact started: handle1: Index { index: 54, generation: 0 }, handle2: Index { index: 43, generation: 0 }
No contact pair found for collision!
step
step
step
contact stopped: handle1: Index { index: 54, generation: 0 }, handle2: Index { index: 44, generation: 0 }

I think this may not be specific to CCD, but having it enabled seems to make it worse.

@Dooskington Dooskington changed the title Contact between a CCD enabled ball and cuboid sometimes and has no contact pair Contact between a ball and cuboid sometimes and has no contact pair Apr 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant