NewtonMaterialSetCollisionCallback in SDK v2

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

NewtonMaterialSetCollisionCallback in SDK v2

Postby neimod » Fri Aug 08, 2008 5:53 pm

Hi all,

I've got a question about the function NewtonMaterialSetCollisionCallback that is available in the SDK v2 beta 17.

From what I can understand, the NewtonOnAABBOverlap callback is called when the AABB's of 2 bodies overlap, and the NewtonContactsProcess callback is called when 2 bodies actually hit eachother on atleast one point.

But the question I have here is, is it possible to generate a callback after the AABB's of 2 bodies overlap, but there is no contact whatsoever?

I am trying to simulate the behaviour in 1.53, where the begin callback would be called, and then the end callback, even if there were no contacts.
neimod
 
Posts: 8
Joined: Wed Apr 23, 2008 9:34 pm

Re: NewtonMaterialSetCollisionCallback in SDK v2

Postby Julio Jerez » Fri Aug 08, 2008 6:35 pm

neimod wrote:But the question I have here is, is it possible to generate a callback after the AABB's of 2 bodies overlap, but there is no contact whatsoever?

you have more choices now.

-the simplistic one is to return 0 from NewtonOnAABBOverlap but that will no call NewtonProccesContcat

-you can return 1 from NewtonOnAABBOverlap and delete all the contact in NewtonProccesContcat that will be the more expensive, and will be the same as 1.53 does now, since in 1.53 you have to return zero to reject each concat, now you need to explicitly remove the contactss from a critical section. (see tank track demo)

- Or you just can do the new feature (my favorite)
you can set the collision shape as a trigger volume, with this option you need to create a body that can be static of dynamics,
in NewtonOnAABBOverlap you return 1,
then you will get the contact process but there will be no contacts in the contact joint.
This is more efficient because if determine if the bodies intersect at the shape level but it do not do any of the more expensive contact calculation.
if you need to move the body to make a moving trigger volume, you can set the matrix on the trigger body to the same matrix or a carriers body.
See the demo Blackhole and whitehole, for demonstration
also the bouyancy demo in the SDK uses this feature, the swimming pool is a static body with teh shape set as trigger volume. This feature can be use to genarate force fields and other special effects much cheapper than in 1.53.
Julio Jerez
Moderator
Moderator
 
Posts: 11155
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: NewtonMaterialSetCollisionCallback in SDK v2

Postby neimod » Thu Aug 14, 2008 6:15 pm

Hi, I am trying the trigger volume way, and it does not seem to work with a tree collision.

Code: Select all
NewtonCollision* col = NewtonBodyGetCollision(body);
NewtonCollisionSetAsTriggerVolume( col, 1);
printf("trigger? %d\n", NewtonCollisionIsTriggerVolume(col));


Trying this code with a body which has a Tree collision will print "trigger? 0".

EDIT: I've noticed that when a body is inside a ellipsoid, or box, or any other implicit shape, then the contact callback is called. When a body is inside a tree collision, then no contact callback is called. Only when the body is touching the polygon of the tree collision then there are callbacks generated.


Do I need to use a convex hull instead of a tree collision ?

EDIT: Yep, using a convex hull works. Nice :)
Last edited by neimod on Thu Aug 14, 2008 7:22 pm, edited 1 time in total.
neimod
 
Posts: 8
Joined: Wed Apr 23, 2008 9:34 pm

Re: NewtonMaterialSetCollisionCallback in SDK v2

Postby Julio Jerez » Thu Aug 14, 2008 7:12 pm

the trigger volime is a funtion of cionvex shapes only. It will no work on trees.

Are you the one who had a problem with a ball rolling down a ramp and bouncing on the edges.
You sent me a link to yuo code for testing.
I actually did not mean for you to send me the entire project I meant and executable using the Newton DLL that I can run. you send me a link to the entire data base, and I do not do that.
I occasionally see source but only when is very small samples that issolate a bug.

if this peron is you and you still have the bug I still want to see if I can fix teh bug. Bceuas ethsi si one fo teh refinement of 2.0 and I liek to be near perfect.

anyway, yes you should use the trigger volume option with convex hulls and or convex implicit convex shapes.
Julio Jerez
Moderator
Moderator
 
Posts: 11155
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 9 guests

cron