Multiple bodies using the same collider

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Multiple bodies using the same collider

Postby Spek » Wed Apr 15, 2009 3:23 am

Hi,

A question about creating colliders. I would expect that a single collider can be used for multiple bodies. For example, when
initializing my app I create a collider made of 2 convex point clouds:
Code: Select all
   // build collider
   colliderCount   := 2;
   colliderArray[0]:= NewtonCreateConvexHull( nWorld, mesh[0].vertexCount, @mesh[0].vertex[0][0], 12, mesh[0].localMatrix[0][0] );
   colliderArray[1]:= NewtonCreateConvexHull( nWorld, mesh[1].vertexCount, @mesh[1].vertex[0][0], 12, mesh[1].localMatrix[0][0] );
   
   staticData.nCollider := NewtonCreateCompoundCollision( nWorld, colliderCount, colliderArray );


Later on, I make use of this collider:
Code: Select all
   // build body
   nCol  := staticData.nCollider;
   nBody := NewtonCreateBody( nWorld, nCol );

Everything goes ok for the first body. But when I use the same collider again for a second body it behaves strange. The body falls through the ground, it doesn't collide properly with other objects, it doesn't fall straight downwards, etcetera. As if its collision hull was messed up. However, if I draw the hulls with Newton's debug tools, the shapes are correct though.

The problem is solved when I rebuild the collider for every body again. But... do I really need to rebuild the collider each time again, or can I share a collider between multiple bodies and is there something I'm doing wrong now? By the way, the collider doesn't get released until the program ends.

Greetings,
Rick
Spek
 
Posts: 66
Joined: Sat Oct 04, 2008 8:54 am

Re: Multiple bodies using the same collider

Postby Julio Jerez » Wed Apr 15, 2009 3:28 pm

yes
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Multiple bodies using the same collider

Postby JernejL » Thu Apr 16, 2009 5:26 am

But only in newton 2.0, in newton 1.x compound collisions made with NewtonCreateCompoundCollision cannot be shared (if you share them they end up with strange glitchy behavour), if you use newton 2.0 you can reuse them as much as you want.

So while newton 1.x can share all other "colliders" just fine, it cannot share compound collision, but in newton 2.0 it can (i use it for massive spaceships so it definetly works in newton 2.0).
Help improving the Newton Game Dynamics WIKI
User avatar
JernejL
 
Posts: 1578
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia

Re: Multiple bodies using the same collider

Postby Spek » Fri Apr 17, 2009 4:31 pm

That explains. Allright, but Newton 2 is still in 'Beta' stage right? I've downloaded it a while ago, but couldn't compile it as I don't have C++. Is there a binary somewhere? The new SDK promises some nice improvements!

For now, I just recreate the collider then. I suppose each collider also takes some memory to store the point cloud. So when using many many objects (with the same collider), I should be aware of that... or not?

Thanks!
Rick
Spek
 
Posts: 66
Joined: Sat Oct 04, 2008 8:54 am

Re: Multiple bodies using the same collider

Postby JernejL » Fri Apr 17, 2009 6:18 pm

it is a very stable beta yes, and it comes only in compiled binary form.
Help improving the Newton Game Dynamics WIKI
User avatar
JernejL
 
Posts: 1578
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 15 guests

cron