Latest beta and contact callbacks

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Latest beta and contact callbacks

Postby Nitrogenycs » Tue Sep 09, 2008 6:45 am

Hello,

I've downloaded the very latest beta and I noticed the begin/process/end callbacks have been changed to the aaboverlaps/process callbacks. I having a problem with this. The new code should look like this:

Code: Select all
   for (void* contact = NewtonContactJointGetFirstContact (contactJoint); contact; contact = NewtonContactJointGetNextContact (contactJoint, contact))
            {
      NewtonMaterial* material;

      material = NewtonContactGetMaterial (contact);
      NewtonMaterialSetContactElasticity (material, restitution);
   }

(code taken from the BasicRestitution demo).

How does NewtonMaterialSetContactElasticity know for which contact I am setting the elasiticity? Does NewtonContactJointGetFirst/NextContact remember which contact it returned last and this one is used?
Is there a way to do this here:

Code: Select all
void* contact1 = NewtonContactJointGetFirstContact (contactJoint);
void* contact2 = NewtonContactJointGetNextContact (contactJoint, contact1);

NewtonMaterialSetContactElasticity (material, 0.5f);    // this should affect contact1
NewtonMaterialSetContactElasticity (material, 0.2f);    // this should affect contact2


Maybe NewtonMaterialSetContactElasticity can look like
Code: Select all
NEWTON_API void NewtonMaterialSetContactElasticity (const NewtonMaterial* material, const void* contact, dFloat restitution);
or
NEWTON_API void NewtonMaterialSetContactElasticity (const void* contact, dFloat restitution);
?

Then I could do
Code: Select all
void* contact1 = NewtonContactJointGetFirstContact (contactJoint);
void* contact2 = NewtonContactJointGetNextContact (contactJoint, contact1);

NewtonMaterialSetContactElasticity (material, contact1, restitution);    // this should affect contact1 (first version)
or
NewtonMaterialSetContactElasticity (contact2, restitution);    // this should affect contact2 (second version)


The same question applies to all the other NewtonMaterialSetContact* functions like NewtonMaterialSetContactNormalAcceleration, NewtonMaterialContactRotateTangentDirections, etc..

-Matthias

P.S.: Any chance this is integrated into one of the next versions? http://www.newtongamedynamics.com/forum ... a64ccf423f
Nitrogenycs
 
Posts: 12
Joined: Fri Apr 07, 2006 4:45 am

Re: Latest beta and contact callbacks

Postby Julio Jerez » Tue Sep 09, 2008 8:00 am

the ansewer is yeat to all because material = NewtonContactGetMaterial (contact);
return a copy of the material defition

say the material have a restititiuon 0f 0.5

the

void* contact = NewtonContactJointGetFirstContact (contactJoint);
material = NewtonContactGetMaterial (contact);
NewtonMaterialSetContactElasticity (material, 0.1);

contact = NewtonContactJointGetNextContact (contactJoint, contact))
material = NewtonContactGetMaterial (contact);
NewtonMaterialSetContactElasticity (material, 0.7);

in the nexx frame
void* contact = NewtonContactJointGetFirstContact (contactJoint);
material = NewtonContactGetMaterial (contact);
the restitition will be 0.5 gain.
Julio Jerez
Moderator
Moderator
 
Posts: 11155
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Latest beta and contact callbacks

Postby Nitrogenycs » Tue Sep 09, 2008 12:25 pm

Ok, thanks for the help. I'll just call NewtonContactGetMaterial() for the contact I am currently working with first and it'll all be fine.
Nitrogenycs
 
Posts: 12
Joined: Fri Apr 07, 2006 4:45 am


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 2 guests

cron