Page 1 of 1

Velocity and collision

Posted: Sat Jun 30, 2012 4:12 pm
by Davidm44
it seems like the higher velocity an object has the less chance it has with colliding with another object.

I've only gotten to rendering cubes. What I'm doing is shooting a cube at another cube, if the velocity is too high sometimes the corners of the cubes won't hit eachother and if it's way too high it'll ignore any collision all together. I don't have a problem with the super high velocity issue since I don't really need that much velocity but the cubes' corners and sides not hitting eachother is kind of annoying.

Is there any explanation on why this is happening? Anything I can do to fix it?

Re: Velocity and collision

Posted: Sat Jun 30, 2012 4:30 pm
by Norbo
Does the graphic match the shape? The BEPUphysicsDrawer in the main source download can help verify this. Another option is just to recreate the simulation in a BEPUphysicsDemos demo to see if it behaves as expected.

If the graphics match, then it's likely just the discrete nature of time steps. Entities move forward a step at a time. Each step has a length of Space.TimeStepSettings.TimeStepDuration. If a colliison happens between two time steps but not at either surrounding time step, it can be missed.

Is the Space.TimeStepSettings.TimeStepDuration long compared to the simulation events? For example, the engine defaults to 1/60f and this is what is used in the BEPUphysicsDemos. The BEPUphysicsDemos simulations mostly involve blocks on the scale of roughly 1 unit and have a gravity of (0,-9.81, 0). For that scale, 1/60f tends to be very stable and is frequent enough to catch most collisions.

The phone demos, on the other hand, set the TimeStepDuration to 1/30f. This lowers the simulation quality but saves a little time. Since the discrete updates are spaced out more, collisions can be missed more frequently.

If the issue is just caused by an insufficient number of time steps, then decreasing the TimeStepDuration and calling Space.Update() more frequently (or just calling Space.Update(dt), which performs as many time steps as needed for the accumulated time) will mitigate the issue. This will cost a bit more.

Entities can also have their entity.PositionUpdateMode set to PositionUpdateMode.Continuous. This prevents the worst kinds of tunneling. By design, however, it does not try to stop some kinds of glancing collisions from being missed.