Signed/Unsigned shadeID

Report any bugs here and we'll post fixes

Moderators: Sascha Willems, Thomas

Signed/Unsigned shadeID

Postby Markus » Fri May 06, 2011 1:44 pm

I was just looking into how to implement an advanced material interaction similar to the one in the tutorial. It uses the shapeID (collisionID) to store the id of a custom material. I wanted to do something similar; my materials have unique names (strings) and I wanted to use a hash function that returns an unsigned integer for the material name. I want to pass this value to functions like NewtonCreateBox, NewtonTreeCollisionAddFace etc. to assign a material to it. In the contact callback I use NewtonMaterialGetBodyCollisionID and NewtonMaterialGetContactFaceAttribute to retrieve the id and search for the material name with the same hash value.

The problem is that while NewtonMaterialGetBodyCollisionID and NewtonMaterialGetContactFaceAttribute correctly return an unsigned integer, NewtonCreateBox and NewtonTreeCollisionAddFace accept a signed integer. I assume the function NewtonCollisionSetUserID is used to set the shapeID of a collision after it was created, this function also takes an unsigned integer. My fear is that a hash value with a value bigger than INT_MAX (but smaller than UINT_MAX) will not be represented correctly because it will be converted to a signed integer and later back to an unsigned integer.

I realized that in the method "dgCollision* dgWorld::CreateBox" you cast the shapeID from dgInt32 to dgUnsigned32. With the tree face attribute you do some weird casting I do not understand and cannot follow as too many classes are involved.
Markus
 
Posts: 52
Joined: Sat Mar 19, 2011 6:31 am

Return to Bugs and Fixes

Who is online

Users browsing this forum: No registered users and 1 guest

cron