TreeCollision or multiple primitive shapes

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

TreeCollision or multiple primitive shapes

Postby fractile » Tue Feb 01, 2011 7:43 am

I'm working on a platformer style game, which currently uses multiple box primitives (created using NewtonCreateBox()) in a compound collision for level collision geometry. This is working quite well, but I would like the collision geometry to match the visual geometry a little more accurately. I have been thinking of building a tree collision for level geometry instead of the compound collision.

A normal level collision geometry currently consists of a few hundred boxes and I'm guessing the tree collision would contain 20-30 triangles in place of each box on average. The question is, which type of collision geometry would be more efficient?

How sensitive is collision tree to slightly intersecting geometry (minor intersections have not caused any problems with the compound collision)? Intersections can of course be removed, but that will make the triangle mesh generation much more complicated..

Here is a screenshot to show what type of levels I'm talking about:
Image
fractile
 
Posts: 37
Joined: Wed Jun 07, 2006 2:26 pm

Re: TreeCollision or multiple primitive shapes

Postby JernejL » Tue Feb 01, 2011 9:42 am

A trimesh would fit very well with this, and don't forget to serialize it once it's generated, then it will load MUCH faster.
Help improving the Newton Game Dynamics WIKI
User avatar
JernejL
 
Posts: 1587
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia

Re: TreeCollision or multiple primitive shapes

Postby fractile » Sat Feb 05, 2011 6:36 am

Thanks. I'll add triangle mesh level geometry to my long to do -list then :)
fractile
 
Posts: 37
Joined: Wed Jun 07, 2006 2:26 pm

Re: TreeCollision or multiple primitive shapes

Postby fractile » Sun Jul 10, 2011 8:46 am

I now tried using tree collision for the level geometry. I add all the faces from the visible meshes to the collision tree, so the collision mesh should be identical to rendered mesh. If I disable optimization in NewtonTreeCollisionEndBuild() call, everything works as expected. With optimization enabled there seems to be holes in the collision mesh. Player and other dynamic bodies fall through floors in seemingly random places!

Some of the holes got fixed (or moved elsewhere) by just reordering level blocks. No vertex positions were changed at all, just order of faces added with NewtonTreeCollisionAddFace().

Does anybody have an idea what might be causing this?
fractile
 
Posts: 37
Joined: Wed Jun 07, 2006 2:26 pm

Re: TreeCollision or multiple primitive shapes

Postby JernejL » Sun Jul 10, 2011 2:53 pm

Can you post some screenshots?
Help improving the Newton Game Dynamics WIKI
User avatar
JernejL
 
Posts: 1587
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia

Re: TreeCollision or multiple primitive shapes

Postby fractile » Fri Jul 15, 2011 9:57 am

Here's a screenshot without collision optimization:
Image

And here with optimization enabled:
Image

The green transparent mesh contructed from data returned by NewtonTreeCollisionGetVertexListIndexListInAABB(). There are faces missing from the optimized version..
fractile
 
Posts: 37
Joined: Wed Jun 07, 2006 2:26 pm

Re: TreeCollision or multiple primitive shapes

Postby Julio Jerez » Mon Jul 18, 2011 8:37 am

your best option for that kind of game is the scenecollison.
there you can add mutiples small collison trees and also collision primitive in one simgle collision shape.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: TreeCollision or multiple primitive shapes

Postby fractile » Wed Jul 20, 2011 10:17 am

Ok, I will try scene collision later, but I don't think that fixes the problems I'm having with tree collision.. Why is the optimization removing unexpected faces and leaving holes in collision mesh?

One more thing: How significant is the performance difference of placing 100-200 boxes in a compound collision (as I previously did) vs. placing them in scene collision (as I should have done)?
fractile
 
Posts: 37
Joined: Wed Jun 07, 2006 2:26 pm

Re: TreeCollision or multiple primitive shapes

Postby Julio Jerez » Wed Jul 20, 2011 1:20 pm

The optimization should not remove any face at all, can you send me a demo for testiong?

The Scene collision will be faster if you have many different type collision shapes.
Even if you just have one big polygonal soup mesh, a scne collison add a very, very small overhead.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: TreeCollision or multiple primitive shapes

Postby fractile » Wed Jul 20, 2011 5:42 pm

I gave up on the tree collision for now and changed back to boxes-only geometry (now using scene collision as you suggested). I will probably later try it again and maybe set up a demo for you..
fractile
 
Posts: 37
Joined: Wed Jun 07, 2006 2:26 pm

Re: TreeCollision or multiple primitive shapes

Postby Julio Jerez » Fri Jul 22, 2011 9:15 pm

you can add all the boxes you want to the scene collision,
later when you want to add collision trees, you can add then without having to make modification,
the scene collision supports all collisions shapes with the exeption of another collisionscene.

I still do not get why the collison tree misses faces, that should not happens, can you provided a test for debuging?
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 1 guest