Physics engine integrated, and sphere-terrain collision done.

Terrain collision was a little harder than I thought it would be. This is owing to the fact that the terrain is a concave body, and many contacts are possible with a single sphere and the terrain. Contrast this with two convex bodies (which many physics engines use exclusively) where only a single contact point is possible, and that point is also the closest point between the two objects.

Anyways, terrain-sphere collision works now, and the new terrain engine is integrated into the game. Simulating 400 spheres on the PC takes only ~3ms per update (single threaded). This should make 400 spheres viable on the XBOX 360, which will have about 33ms per update on a CPU core dedicated to physics. This is about a 5-10x speed increase over the performace I was seeing with the default BEPU physics setup.

Sphere-terrain collision.

Sphere-terrain collision.

This entry was posted in Coding, DBP2011, XNA and tagged , , . Bookmark the permalink.

3 Responses to Physics engine integrated, and sphere-terrain collision done.

  1. Norbo says:

    Hi again! Nice project :)

    I noticed the performance numbers you were running into for BEPU seem much slower than expected. In a quick test, 400 spheres on the terrain demo came out to 3 milliseconds per frame, single threaded, with continuous collision detection enabled. This was on a single core of my Q6600 @ 2.4ghz. It can be tuned to be a bit faster, but that’s with the default setup.

    On the Xbox360, the same simulation (still singlethreaded) takes about 25 milliseconds per frame.

    The speed sounds pretty close, which is expected. Sphere-sphere contact with some kind of iterative solver will tend to produce a similar result.

    Just wanted to clear that up so that if, later, you found yourself needing more features, you don’t feel like you have to keep building a complete physics engine just for performance reasons :)

    If you do decide to use BEPUphysics at some point in the future, I’ll gladly help you try to figure out where the performance issue is coming from.

  2. olhovsky says:

    Hey Norbo! Thanks for the input. I’m surprised to see those numbers. In that case, I’ll play around with BEPU again tomorrow and see if I made a mistake benchmarking or if there’s something else strange going on. If the performance is similar, then of course I’d prefer to use BEPU.

  3. Pingback: My own physics or BEPU? | Olhovsky

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>