Page 1 of 1

Another Efficiency question.

Posted: Fri Aug 24, 2012 7:45 pm
by chebob69
First of all, I apologise for all the questions Norbo. I'm just new to physics engines and I'd rather get this out of the way now than have to change things later on. You'll hear less and less from me as I advance!

So I'd like to know more about the efficiency of terrain collisions. My game will have up to 1000-2000 bricks on a terrain. On top of that there will be various characters in play at the same time.
The thing is, I'm gonna restrict the bricks to flat parts of the terrain (as they will be stacked on each other). Would it therefore make sense to have invisible platforms under these flat terrain
areas so the bricks just rest on those instead, removing the need for the brick/terrain collisions? Only the characters would then need to collide with the terrain. (I could also have smaller terrain squares which would allow more detailed vertex-based texturing)

Can you give me any idea of how much more efficient this would be and also what's the easiest way to create a situation where there are 2 independent simulations running like this (bricks+planes and terrain+players)? Use 2 different Space() constructors? Or just 1 and stop certain models from interacting with each other?

Thanks in advance!

Re: Another Efficiency question.

Posted: Fri Aug 24, 2012 8:05 pm
by Norbo
A single flat box can be faster than a whole terrain. How much faster depends on the density of the terrain; if there's only around one triangle per object that needs testing, it won't be that much faster. If it's more like 20 triangles per object, then using a simplified representation would be a big win.

Questions of performance are best answered by actually testing and measuring the simulations in question, though. The measurements can reveal if this is useful and necessary (as in, the terrain is simply too slow and the box version is significantly faster).

If it turns out that the alternate representation is worth it, then the best implementation depends on the type of interactions possible in the simulation.

If the characters interact with both the terrain and the bricks, then they should all be in the same space. Collisions can be pruned using collision rules (see the documentation and the collision filtering demo in the BEPUphysicsDemos for more information).

If the characters only interact with either the terrain or the bricks (but not both at the same time), then two spaces might be okay. It would probably be simpler in the long run to just use the collision rules and one space.

Edit:
There is another issue to take into consideration: having a single extremely large box can introduce numerical problems when tested with other objects that do not have a special case with the box shape type. Right now, only boxes and spheres have special cases with boxes. So, bricks and SphereCharacterControllers could interact with an immense 'ground' box without any numerical issues, but the cylinder-based CharacterController must resort to a general convex-convex case which is more numerically sensitive and problems might be visible depending upon the box size.

Re: Another Efficiency question.

Posted: Fri Aug 24, 2012 10:20 pm
by chebob69
Cool, yeah I'll do some tests when I've got time. I won't be using many bricks at the moment though so I guess I won't notice a difference for now.
Thanks for pointing me at the Collision filtering demo. I did look through the demos but must have missed it. That looks pretty simple and I'd probably need
to use that at some point anyway so I'll stick with just the one space. Thanks a lot!