SceneCollisions & Face Attributes

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

SceneCollisions & Face Attributes

Postby Spek » Thu Oct 22, 2015 7:23 pm

Not sure what I'm doing wrong here... how to get a Face Attribute from a CollisionTree?

In the past, I just called:
Code: Select all
contactPoint := NewtonContactJointGetFirstContact( contact );
...
contactMaterial := NewtonContactGetMaterial( contactPoint );
faceAttribute   := NewtonMaterialGetContactFaceAttribute( contactMaterial );

And while creating the collisionTree, the "addFace" command would get numbers (pointers actually, thus big numbers). But now the "faceAttibute" is always 0.


I *think* it has to do with using NewtonSceneCollisionXXX functions. Before, I had a separate body
with its own CollisionTree for each part (say Room) of the world. Now there is just 1 body for the
entire world, and rooms are added as follow:
Code: Select all
            nCollisionScene := NewtonBodyGetCollision( nSceneBody );
            NewtonSceneCollisionBeginAddRemove( nCollisionScene );
           
            NewtonCollision tempRoomCollision := makeRoomCollision(); <--- produces tree, adds faces
            nodePtr := NewtonSceneCollisionAddSubCollision( nCollisionScene, roomCollision );
           
            NewtonDestroyCollision( tempRoomCollision );

The collisions and everything just works, but as said, I can't get the FaceAttribute. Nor the
userData I attached to that "tempRoomCollision" object with
tempRoomCollision := NewtonCreateTreeCollision( ..., myStuff ); or
NewtonCollisionSetUserData( tempRoomCollision, myStuff );

I don't really have to know the exact Face ID. Just a custom pointer per subnode is enough.
Spek
 
Posts: 66
Joined: Sat Oct 04, 2008 8:54 am

Re: SceneCollisions & Face Attributes

Postby Spek » Sat Oct 24, 2015 3:08 pm

Excuses, had a bug on my side that prevented me from finding the nCollision owner via:
Code: Select all
contactMaterial := NewtonContactGetMaterial( contactPoint );
...
NewtonCollision colShape := NewtonMaterialGetBodyCollidingShape( contactMaterial, nBodyWorld  );
myStuff := NewtonCollisionGetUserData( colShape  );


So, the issue is solved. Yet I wonder what "NewtonMaterialGetContactFaceAttribute" is supposed to return then. In my case its always 0, while I definitely define a number via "NewtonTreeCollisionAddFace( ...., int(myStuff) );"

In my case I don't really need per-polygon info, but just in case I would... how to get that information?
Spek
 
Posts: 66
Joined: Sat Oct 04, 2008 8:54 am


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 0 guests

cron