Userdata for ndBody in 4.0

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Userdata for ndBody in 4.0

Postby Bird » Fri Nov 11, 2022 10:25 am

Hi Julio,

I don't see a way to bind my scene node to ndBody like I could in 3.14

Code: Select all
// save my node as the user data for this body
NewtonBodySetUserData(newtonBody, node.get());


I need to found out which of my nodes are colliding in OnAabbOverlap() as in the demo scenes. Is there a way to do it?

Code: Select all
bool ndContactCallback::OnAabbOverlap(const ndContact* const contactJoint, ndFloat32 timestep)
{
   const ndApplicationMaterial* const material = (ndApplicationMaterial*)contactJoint->GetMaterial();
   ndAssert(material);

   const ndBodyKinematic* const body0 = contactJoint->GetBody0();
   const ndBodyKinematic* const body1 = contactJoint->GetBody1();
   const ndShapeInstance& instanceShape0 = body0->GetCollisionShape();
   const ndShapeInstance& instanceShape1 = body1->GetCollisionShape();
   return material->OnAabbOverlap(contactJoint, timestep, instanceShape0, instanceShape1);
}
Bird
 
Posts: 623
Joined: Tue Nov 22, 2011 1:27 am

Re: Userdata for ndBody in 4.0

Postby Julio Jerez » Fri Nov 11, 2022 10:31 am

When You subclass from ndBodyNotify
And there you can add all the data from you app.

Them you call body-> GetNotify().
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Userdata for ndBody in 4.0

Postby Bird » Fri Nov 11, 2022 11:58 am

Got it working. Thanks for the help.
Bird
 
Posts: 623
Joined: Tue Nov 22, 2011 1:27 am


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 32 guests