Simple CCD for a game

Started by
3 comments, last by Finalspace 8 years, 3 months ago

Hello! I have read some stuff on the web, but still couldn't get a clear answer/solution.

So i try to ask here. What would be the best approach for simulating game world consisting out of static mesh (tris) and not rotating spheres and capsules/cylinders

the requirements:

1) very stable, in sense no tunneling should occur at all (very fast moving objects will be present)

2) spheres should be able to slide around on mesh (and collide between each other) and behave like rigid physical objects should.

3) fast algorithms/approaches, cause i need to code it in lua. (some solves/algorithms may be simplified, the most important is to prevent tunneling)

from what i have found i tend to implement speculative contacts, but for now i have some issues with contact solver (i mean the right way to implement it, cause most papers etc cover more complicated cases with rotations etc, and it may be an overdo for my case)

appreciate any helpful input!

Advertisement

You can use speculative contacts just fine, but you will lose the ability to control the bounce.

But thats not a problem when you just need sliding ability - for example in a zelda/platformer like game.

Also you can use friction to get a more non-sliding feeling :-)

If you want CCD for a player or character controller the Conservative Advancement (CA) algorithm works very well. If you want to simulate many shapes doing CCD with the static environment then I recommend looking into Catto's GDC presentation on CCD. He makes some comments about the case where you can do linear casts without any rotation, and this simple approach may be good enough for you since you have no rotation, and you might get away with CA in this case too.

If you want CCD between all the moving objects with one another... Well be prepared for an N^2 algorithm. To do CCD between moving things and then resolve the collision you need to find the first time of impact, resolve, and continue until you exhaust the entire timestep, which means you run an N^2 algorithm an unknown number of times. I'm sure you can see why games don't really do this.

Thanks for the replies! Ok, so i will try first to impelement speculative contacts, if it will work sufficient/well probably will stay with it, otherwise i will give a try to Conservative Advancement.

but you will lose the ability to control the bounce.
why exactly? due the possible time cutting? and what about accumulation?

recommend looking into Catto's GDC presentation on CCD
i will, thank you!
but you will lose the ability to control the bounce.
why exactly? due the possible time cutting? and what about accumulation?

With speculative contacts, you adjust the velocities so that the objects just touch each other. This results in cutting of energy which may be used to let the object bounce. But you can regain that lost energy by saving the contacts from the last frame and save the separation impulse and include this in the final impulse for the new frame.

This topic is closed to new replies.

Advertisement