not able to get collision callbacks to be called

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

not able to get collision callbacks to be called

Postby ruggy » Sun Apr 22, 2012 12:00 am

Hello.

I'll post code in my next post if people suggest it. However, I wanted to see if we can identify my problem more easily than making anyone read my code.

The setup I have right now is that I have two rigid bodies, and I want a collision callback to be called when they start touching each other. I successfully set up the SetTransform and SetForceTorque callbacks, and I see my bodies move the way I want them to when NewtonUpdate is called.

I've assigned both bodies the same material ID with NewtonBodySetMaterialGroupID and then I called:

NewtonMaterialSetCollisionCallback (
g_world,
materialID,
materialID,
NULL, // void* userData,
AABBOverlapProcess, // NewtonOnAABBOverlap aabbOverlap,
ContactCallback
);

I believe everything looks good right now, as both rigid bodies have large extends (as defined with NewtonCreateBox and then NewtonCreateBody). When I look at my rendered objects, they clearly overlap, even perfectly coincide at some point (which SHOULD imply that even if I somehow messed their bodies/offsets, they should collide while being almost perfectly coincident).

But neither AABBOverlapProcess nor ContactCallback are being called.

Anyone have ideas what's missing in this setup? I don't mind showing code but I'd like to investigate it by working 'backwards' from my call to NewtonMaterialSetCollisionCallback. In other words, I'd like help reviewing the assumptions I need to satisfy in order for this callback setup to work.

For the time being, I have a nagging sensation that my bounding boxes might be inappropriate, yet I set them up as described in the tutorials, and it's really fairly straightforward. The two boxes have the same X,Y coords, and one of them is falling towards the other, with Z decreasing. Callbacks never called! Why!?

Thanks for your time anyone who reads this!
ruggy
 
Posts: 11
Joined: Sat Feb 25, 2012 4:57 pm

Re: not able to get collision callbacks to be called

Postby Julio Jerez » Sun Apr 22, 2012 9:17 am

are you using core 300?

if you are using core 300, there si a new feature call serialzation, that you can use to serialize the world, and load it in the sdk demo framework.

this is the inerface, you jsu nee to wriet two call backs and you will be able to see what happens in teh visualizer

Code: Select all
void NewtonSerializeBodyArray (const NewtonWorld* const newtonWorld, NewtonBody** const bodyArray, int bodyCount, NewtonOnBodySerializationCallback serializeBody, NewtonSerializeCallback serializeFunction, void* const serializeHandle);
void NewtonDeserializeBodyArray (const NewtonWorld* const newtonWorld, NewtonOnBodyDeserializationCallback deserializeBody, NewtonDeserializeCallback serializeFunction, void* const serializeHandle);
Julio Jerez
Moderator
Moderator
 
Posts: 10168
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: not able to get collision callbacks to be called

Postby ruggy » Sun Apr 22, 2012 11:43 am

Hello,

No, I am not using core 300. I was under the impression that it's not as complete/stable as 2.35. Also, I'm not totally sure how serialization would help me. I was trying to understand whether my two objects would overlap. I have my own rendering system, and while the rendered sizes of the objects possibly don't exactly match the object sizes that Newton sees, the objects fall through each other for a long period which includes a moment where they are almost perfectly sharing the same volume. I don't think their sizes are so small that they keep missing collision due to not having the exact same center. Something is missing. I guess I should post code, if my initial post doesn't reveal any obvious flaws in my setup?
ruggy
 
Posts: 11
Joined: Sat Feb 25, 2012 4:57 pm

Re: not able to get collision callbacks to be called

Postby Julio Jerez » Sun Apr 22, 2012 12:19 pm

you need to render the collision shapes. are you doing that.

the serialization in core 300 hundred will help you to inspect the scene because you cna then load a serialize scene or sub-scene and load it in the SDK demo tool.
this tool will beacome the framework of teh Visual debugger.

The reason I am doing this work is that move away form hading to analize code each time some one has a bug.
By doin that you can jsut see what is going one, and later w\you will be able to see in real tiem form with in your game.
It will also allow people who have NDA restriction to debug theis code without comprising thirs NDA cluase.

but you need to move to core 300, it is no too difficult. it take few ourt to make the transition.
just download teh later SNV build and run teh demos so that you can see it before you decide to make the switch.
Julio Jerez
Moderator
Moderator
 
Posts: 10168
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: not able to get collision callbacks to be called

Postby ruggy » Sun Apr 22, 2012 1:35 pm

I had a look at the results of NewtonCollisionCalculateAABB, and it seems that no matter what size of box I define when calling NewtonCreateBox, the min and max AABB vertices as returned by NewtonCollisionCalculateAABB are always .25 in size! I'm stumped, but having a look at the internals a bit to figure out if maybe I did something wrong when calling NewtonCreateBox.
ruggy
 
Posts: 11
Joined: Sat Feb 25, 2012 4:57 pm

Re: not able to get collision callbacks to be called

Postby Julio Jerez » Sun Apr 22, 2012 1:57 pm

where did you looked at the results?
Julio Jerez
Moderator
Moderator
 
Posts: 10168
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: not able to get collision callbacks to be called

Postby ruggy » Sun Apr 22, 2012 2:04 pm

I created a box with

shape = NewtonCreateBox (g_world, 60000, 60000, 12000, 0, &boxOrigin[0][0]);

Then I call

NewtonCollisionCalculateAABB(
shape, // NewtonCollision *
&boxOrigin[0][0], // float*
&minBox[0], // float*
&maxBox[0] //float*
) ;

and after that,
minBox components are: -0.125000 -0.125000 -0.125000
maxBox components are: 0.125000 0.125000 0.125000

What's noteworthy to me is that even if I call
shape = NewtonCreateBox (g_world, 6000, 6000, 12000, 0, &boxOrigin[0][0]); (X and Y extents of the box are smaller by factors of 10),

I still get minBox and maxBox values identical to just noted above.
ruggy
 
Posts: 11
Joined: Sat Feb 25, 2012 4:57 pm

Re: not able to get collision callbacks to be called

Postby ruggy » Sun Apr 22, 2012 2:09 pm

Ok I think a problem I was having was that I wasn't using a proper matrix format with proper initialization. With some fiddling, I'm getting my callbacks to be called now! So, for the time being, I'm going to call this problem solved (by trial and error).

Thanks! Maybe soon I'll be able to actually use this :-D
ruggy
 
Posts: 11
Joined: Sat Feb 25, 2012 4:57 pm

Re: not able to get collision callbacks to be called

Postby Julio Jerez » Sun Apr 22, 2012 2:10 pm

thsi funtion
ruggy wrote:NewtonCollisionCalculateAABB(
shape, // NewtonCollision *
&boxOrigin[0][0], // float*
&minBox[0], // float*
&maxBox[0] //float*
) ;

will call this

Code: Select all
void dgCollisionBox::CalcAABB(const dgMatrix &matrix, dgVector &p0,
    dgVector &p1) const
{
  dgFloat32 x = m_size[0].m_x * dgAbsf(matrix[0][0])
      + m_size[0].m_y * dgAbsf(matrix[1][0])
      + m_size[0].m_z * dgAbsf(matrix[2][0]) + DG_MAX_COLLISION_PADDING;
  dgFloat32 y = m_size[0].m_x * dgAbsf(matrix[0][1])
      + m_size[0].m_y * dgAbsf(matrix[1][1])
      + m_size[0].m_z * dgAbsf(matrix[2][1]) + DG_MAX_COLLISION_PADDING;
  dgFloat32 z = m_size[0].m_x * dgAbsf(matrix[0][2])
      + m_size[0].m_y * dgAbsf(matrix[1][2])
      + m_size[0].m_z * dgAbsf(matrix[2][2]) + DG_MAX_COLLISION_PADDING;

  p0.m_x = matrix[3][0] - x;
  p1.m_x = matrix[3][0] + x;

  p0.m_y = matrix[3][1] - y;
  p1.m_y = matrix[3][1] + y;

  p0.m_z = matrix[3][2] - z;
  p1.m_z = matrix[3][2] + z;

  p0.m_w = dgFloat32(1.0f);
  p1.m_w = dgFloat32(1.0f);
}


you can set a break point and see if it hit that and check the values.

also you made a box of 60000 unit is side? isent that too big? what size is your world?
Julio Jerez
Moderator
Moderator
 
Posts: 10168
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: not able to get collision callbacks to be called

Postby ruggy » Sun Apr 22, 2012 2:13 pm

An hour or so ago I had a look at that function above, CalcAABB. Looking at it made me realize I should double-check my matrix type and whether it was being initialized in a way that matches defaults used by CalcAABB. Now thing are looking better, so I'm going to do more work and see if things will be fine from now on.

Thanks!
ruggy
 
Posts: 11
Joined: Sat Feb 25, 2012 4:57 pm

Re: not able to get collision callbacks to be called

Postby Lydia12 » Fri Aug 03, 2012 5:48 pm

Julio Jerez wrote:A lot of helpful information provided on this website, though I will try to help you. Are you using core 300?
Image
if you are using core 300, there si a new feature call serialzation, that you can use to serialize the world, and load it in the sdk demo framework.

this is the inerface, you jsu nee to wriet two call backs and you will be able to see what happens in teh visualizer

Code: Select all
void NewtonSerializeBodyArray (const NewtonWorld* const newtonWorld, NewtonBody** const bodyArray, int bodyCount, NewtonOnBodySerializationCallback serializeBody, NewtonSerializeCallback serializeFunction, void* const serializeHandle);
void NewtonDeserializeBodyArray (const NewtonWorld* const newtonWorld, NewtonOnBodyDeserializationCallback deserializeBody, NewtonDeserializeCallback serializeFunction, void* const serializeHandle);



Hello,

I am trying to use your code to serialize but it is not working, I cannot implement it correctly. can you help?
Thank you for your help.
Lydia12
 
Posts: 1
Joined: Fri Aug 03, 2012 5:44 pm


Return to General Discussion

Who is online

Users browsing this forum: Bing [Bot] and 2 guests

cron