Raycasting and Compound Collisions

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Raycasting and Compound Collisions

Postby Cote-Duke » Wed Sep 29, 2010 1:24 pm

Hello there,

I am using compound collisions quite extensively: almost all static connections are made by combining collisions into compounds. Currently the building process is:

1. I have an array of all collision primitives (boxes, spheres, convex hulls)
2. I make a Convex Collision Modifier for each and single one of them (that's right - one modifier per primitive)
3. Using NewtonCollisionSetUserID I set an unique ID (within a single compound collison) for each Collision Modifier, so that during ray casting pre-filter function I could identify, which part of the compound collision was hit by the ray.

Identifying the subset of a compound collision is very crucial for my application, and it seems that there is no alternative way of doing it.

I would like to know whether I am actually abusing Newton (which potentially may cause performance hits) by creating compound collisions out of unique Convex Collision Modifiers. Please note that Modifiers themselves are constructed from shared collision primitives. (i.e. one collision -> many collision modifiers).

Maybe there are other, more friendly ways of identifying collision subsets of a compound collision when ray casting.

Thanks ahead for your time.
Cote-Duke
 
Posts: 8
Joined: Fri Dec 03, 2004 12:03 pm

Re: Raycasting and Compound Collisions

Postby Julio Jerez » Wed Sep 29, 2010 2:17 pm

creating convex collision each with unique id does not changes the code performce. It just dicard the shape cache since each shape will be unique
This is actual a limitation in Newton, because a collision shape can not have local data, in the future I will improve that by making the Collision instance.

If you are using the modifier as a trick to place the ID on the shape, this will be ok if you have many shared shapes, if not then modifires make sence only of you scale different than 1.0
using scaling for all subshape in a compund might give you some small perfromace hit since the engine does not have a way for define fio teh Scale in and Uniform and Horthonoemal
threfore it must use general transformation funtions.
Otherwise you should be fine.

The is not limit of how many child shapes a compound can have, The performance cost is almostt identical to a Collison tree.
In fact for same size meshed a compund will be faster than a collision tree since the compund will have fewer nodes because the mesh will be solid.

There is another solution you can try, the scenecollision.
Basically a scenecollison is a static compound, but the shape are wrapedd into a Proxi that can contain user data.
also the compund can contain other kind of shapes like Threes, convex, hieghtmap.
Julio Jerez
Moderator
Moderator
 
Posts: 12258
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Raycasting and Compound Collisions

Postby Cote-Duke » Wed Sep 29, 2010 2:29 pm

Good to know, since compound collisions are pretty much the backbone for my entire scene graph. : )
Cote-Duke
 
Posts: 8
Joined: Fri Dec 03, 2004 12:03 pm

Re: Raycasting and Compound Collisions

Postby Julio Jerez » Wed Sep 29, 2010 2:39 pm

Compound had being hieghtly optimized since 2.08 because they are used for the Fractal destrution with in will come back in 2.25 again.

Maybe this weekend I will post newton 2.25 with have some newt features related to compound.
Julio Jerez
Moderator
Moderator
 
Posts: 12258
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Raycasting and Compound Collisions

Postby Cote-Duke » Thu Sep 30, 2010 8:33 am

And another thing :)

I don't know whether it's a bug, or I am doing something wrong, but - documentation says, that in NewtonWorldRayFilterCallback:

"int collisionID - convex primitive collision ID or face ID for collision trees"

However, when using compound collisions - neither shapeID of primitives nor NewtonCollisionSetUserID does the trick. When newton enters the filter function, all I get in collisionID seems like uninitialized garbage, numbers like: -858993460
Cote-Duke
 
Posts: 8
Joined: Fri Dec 03, 2004 12:03 pm

Re: Raycasting and Compound Collisions

Postby Julio Jerez » Thu Sep 30, 2010 1:35 pm

see
http://newtondynamics.com/wiki/index.php5?title=Tutorials#Newton_2.0

advance material system, ther are example there that use compund collision with ID for playing sound.
Julio Jerez
Moderator
Moderator
 
Posts: 12258
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Raycasting and Compound Collisions

Postby Aphex » Sun Oct 03, 2010 9:02 am

Hmm another change here... I use this functionality a lot and noticed the id appeared broken again.
So how would I (a) set this id up, and (b) get a material (or contact) from a ray hit?
Aphex
 
Posts: 144
Joined: Fri Jun 18, 2004 6:08 am
Location: UK

Re: Raycasting and Compound Collisions

Postby Julio Jerez » Sun Oct 03, 2010 11:34 am

I am confuded, is this related to collision callback or raycast callback or both?
I know the demos in the tutorials can identify subshapes in contact callback, there is a dumbell with three pieces and each piece plays different sound when they collide.
so subsheps can be IDs in contact callback.
this must be for Ray cast callback them
does not the Raycast callback provide the teh shape ID and the body.
Maybe is is better to change the call back for this from this

Code: Select all
 dFloat RayCastCallback (const NewtonBody* body, const dFloat* normal, int collisionID, void* userData, dFloat intersetParam)

to this
Code: Select all
dFloat RayCastCallback (const NewtonBody* body, const NewtonBody* castedshape, const dFloat* normal, int collisionID, void* userData, dFloat intersetParam)


would that make it better?
Julio Jerez
Moderator
Moderator
 
Posts: 12258
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Raycasting and Compound Collisions

Postby Aphex » Sun Oct 03, 2010 11:45 am

Either way is fine... the problem is the value we're getting in 'collisionID' - I always get 0xcccccccc (= uninitialised memory?)
Aphex
 
Posts: 144
Joined: Fri Jun 18, 2004 6:08 am
Location: UK

Re: Raycasting and Compound Collisions

Postby Julio Jerez » Sun Oct 03, 2010 1:40 pm

Oh so there is a Bug them.
can you post thsi in teh Bug Track furum, please
Julio Jerez
Moderator
Moderator
 
Posts: 12258
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Raycasting and Compound Collisions

Postby Aldeminor » Wed Oct 06, 2010 4:20 am

If we have a compound object, can we get info about collisions of parts of this compound with other bodies out of it? Please, can anyone post example or just indicate required functions?

Sorry if the matter was considered earlier, I'm not found such posts.
Aldeminor
 
Posts: 31
Joined: Tue Jun 29, 2010 6:37 am

Re: Raycasting and Compound Collisions

Postby JernejL » Wed Oct 06, 2010 7:13 am

Aldeminor wrote:If we have a compound object, can we get info about collisions of parts of this compound with other bodies out of it? Please, can anyone post example or just indicate required functions?

Sorry if the matter was considered earlier, I'm not found such posts.


With NewtonCollisionGetInfo you can obtain a pointer to array of collision ids contained, see: http://newtondynamics.com/wiki/index.ph ... InfoRecord

For a compound collision you get this structre with which you can again obtain original sompound pieces.

Code: Select all
      struct NewtonCompoundCollisionParam
      {
         int m_chidrenCount;
         NewtonCollision** m_chidren;
      };
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 3 guests