A place to discuss everything related to Newton Dynamics.
Moderators: Sascha Willems, walaber
by Pyritie » Mon May 10, 2010 1:57 pm
When you get the NewtonContact and you get the body0 and body1 from it, how is it decided which body is body0 and which is body1?
Does it depend on the MaterialID, which was created first, or what?
-

Pyritie
-
- Posts: 36
- Joined: Tue Mar 02, 2010 8:13 pm
by JernejL » Mon May 10, 2010 2:17 pm
Which version of newton are you using? this sounds like it used to be in 1.53?
-

JernejL
-
- Posts: 1587
- Joined: Mon Dec 06, 2004 2:00 pm
- Location: Slovenia
-
by Pyritie » Mon May 10, 2010 2:30 pm
Okay fine, I'm using MogreNewt (which uses 2.x) and the method I use there is called OnProcess() and I get a ContactJoint instead of NewtonContact, but it's the same idea.
-

Pyritie
-
- Posts: 36
- Joined: Tue Mar 02, 2010 8:13 pm
by JernejL » Mon May 10, 2010 5:11 pm
It doesn't work the same in newton 2.0 anymore.
To answer your question, the order is totally random in 1.53, while it's predictable (same simulation input will repeat calls in same order) in 2.0 if you use a specific newton initialization setup.
-

JernejL
-
- Posts: 1587
- Joined: Mon Dec 06, 2004 2:00 pm
- Location: Slovenia
-
by Pyritie » Mon May 10, 2010 5:18 pm
What sort of setup?
-

Pyritie
-
- Posts: 36
- Joined: Tue Mar 02, 2010 8:13 pm
by Julio Jerez » Mon May 10, 2010 6:29 pm
yo uyget teh bodyes by makin call to the contact joint in teh call back, from the SDK here is a contact callback sample
- Code: Select all
void GenericContactProcess (const NewtonJoint* contactJoint, dFloat timestep, int threadIndex)
{
NewtonBody* body0 = NewtonJointGetBody0 (contactJoint);
NewtonBody* body1 = NewtonJointGetBody1 (contactJoint);
for (void* contact = NewtonContactJointGetFirstContact (contactJoint); contact; contact = NewtonContactJointGetNextContact (contactJoint, contact)) {
dFloat speed;
dVector point;
dVector normal;
dVector dir0;
dVector dir1;
NewtonMaterial* material;
material = NewtonContactGetMaterial (contact);
NewtonMaterialGetContactPositionAndNormal (material, &point.m_x, &normal.m_x);
NewtonMaterialGetContactTangentDirections (material, &dir0.m_x, &dir1.m_x);
speed = NewtonMaterialGetContactNormalSpeed(material);
//speed = NewtonMaterialGetContactNormalSpeed(material);
// play sound base of the contact speed.
//
}
// the application can implement some kind of contact debug here
ShowJointContacts (contactJoint);
}
-
Julio Jerez
- Moderator

-
- Posts: 12426
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by Pyritie » Mon May 10, 2010 6:45 pm
Yes I got that. I just want to know how newton decides which is body0 and which is body1.
-

Pyritie
-
- Posts: 36
- Joined: Tue Mar 02, 2010 8:13 pm
by Julio Jerez » Mon May 10, 2010 8:21 pm
The collision system pick then depend on whitch one is found first in the multigrid.
you need to use functions GetBody0, GetBody1 as the order is not guaranteed.
-
Julio Jerez
- Moderator

-
- Posts: 12426
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by Pyritie » Tue May 11, 2010 4:06 am
So I'll just have to check every time then. Okay thanks for answering.
-

Pyritie
-
- Posts: 36
- Joined: Tue Mar 02, 2010 8:13 pm
Return to General Discussion
Who is online
Users browsing this forum: No registered users and 1 guest