Connected joints changing material group ID?

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Connected joints changing material group ID?

Postby int13h » Tue Mar 31, 2009 8:59 am

Hello board,

Im currently working on a game where we connect ragdolls to different objects using some custom joints.
The problem im having is when i connect a ragdoll (might be at several locations/bones) to another newton object (using custom rigid or ball joint) the objects stop colliding with SOME other objects.

For instance there is a flying machine in the game, it has its own material in the materialsystem and is NOT a custom joint of any kind.
When i connect a ragdoll to it (the ragdoll has its own ragdoll material) the aircraft stops reporting collisions with other ragdolls in the game.
It still reports collisions with other materials such as the ground.

It gets even weirder because our trees also use the ragdoll material and another type of custom ragdoll joint and they still collide with the vehicle.
The only difference between the trees and the other ragdolls is that the trees are connected to the ground using a rigid joint.

Is there some kind of material "bleeding" when using joints or is it some kind of bug/feature of NewtonBodySetJointRecursiveCollision that im missing.
(ive tried setting all joints to recursive collision enabled and the only difference is horrible performance)

Greetz David
int13h
 
Posts: 4
Joined: Mon Sep 25, 2006 11:58 am

Re: Connected joints changing material group ID?

Postby int13h » Tue Mar 31, 2009 9:29 am

I did solve it. It did turn out i wasnt setting RecursiveCollision on all the ragdoll joints that i connect after all. Once i did this i did get the collisions. Im still uncertain WHY though, because the ragdolls
are not connected to the other ragdolls in any way so the recursive collision part seemed redundant. And ofcourse with recursive collisions on the performance is worse :(.

Could anyone explain why this is happening so i can try some other way around it.

Btw. Our ragdolls are more or less the same as the ones in the Beta17 sdk samples.

// David
int13h
 
Posts: 4
Joined: Mon Sep 25, 2006 11:58 am

Re: Connected joints changing material group ID?

Postby Julio Jerez » Tue Mar 31, 2009 10:05 am

recurice collison is slower because it need to walk the full array of conected bodies, so for compel array it may be harder.

By defaul joint do not collide with with teh bodies tehy connect, but if you want,
you can set the joint to collision with conected bodies you can set sust the attachent joint to collidable, and use material and using infomation to handle the collision you want and teh collision you do not want.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Connected joints changing material group ID?

Postby int13h » Tue May 05, 2009 7:28 am

Well, actually julio the problem wasnt that the ragdolls didnt collide with connected bodies (i dont need that), they stopped colliding with other ragdolls in the game (that are not connected). The solution for now was enabling recursive collisions which ofcourse does come with a performance penalty. As it hasnt turned out to be a serious hit to performance (yet) I'll just go with the recursive solution for now.
int13h
 
Posts: 4
Joined: Mon Sep 25, 2006 11:58 am

Re: Connected joints changing material group ID?

Postby Julio Jerez » Tue May 05, 2009 11:07 am

you do not need recursive collision, you can use a combination of a materia and bit field you make a bollean operation that determine
the hierachical conectivity of the body part of the rad doll, this is very very cheap.
you can use a Ragdoll material, then you can enumrate the body parts of a rag doll with a unique ragdoll ID.
then in the callback for a Ragdoll you can read the information kept in some user data saved with the body to check that it is the same Ragdoll or different Ragdoll
different ragdoll return collidion on immediatly.

you can check for the bit field doll part the indicate what part of the Rag doll can collide or not.
for example you can make a 16, 32 or 64 bit index of flags indication collition with other part
say you have a simple rag doll with three parth Head, Neck, torso, and pelvis.

you need a bit field that enumarate the position of the part in the ragdoll something like this
head is part 0 and bit field is 1<<0
neck is part 1 and bit field is 1<<1
torso is part 2 and bit field is 1<<2
pevis is part 3 and bit field is 1<<3

the bitfield on each body part is set at creation time,
you cna set it with a defintion table for teh bit field, and some monotonically increasing enumeraion ID for the ragdoll ID

say you create a head and the head collide withe torso and the pelvis but no with the neck
the the bit field mask fo rteh hear part is the (1<<2) or (1<<3) Or (1<<0)

then you add teh pevis and the pelvis collide with the head, and the neck but not with the torso
the the bit field mask for the hear part is the (1<<1) or (1<<0) or (1<<3)

and so on

then in the call back all tyou nee to do is this

Code: Select all
callback (body0, body1)
{
    RadDollData* data0;
    RadDollData* data1;

  data0 = getUsradDataBody0();
  data1 = getUsradDataBody1();

  if( (data0.RadDollMask & (1 <<data1.bodyIndivodualBit) == 0) {
     // part do not collide only if they are part of the same ragdoll
      if (data0.RadDollID ==   data1.RadDollID) {
              return not collidion.
        }
    }

  //if the code get her teh tow body part are part of eth same RAD doll and teh have teh same collision bit onn
  //for example if body0 wa a head and body 1 was torso  then
//  body0 will have bit0 set to one becaus eit is it own flag, plsu the head can collide with the pevis threfore the pevis bit is also on
//  Body1 will have bit3 on becaus eit is it on flag plus the pelvis is allow to collid wi the head 
//  therefore the and test will be different than zero.

//  if body zeor was teh head and body one was the neck then
//  body0 will have bit0 set to one because it is it own flag, plus the head do not can collide with the neck threfore the pevis bit is also off
//  Body1 will have bit1 on because it is it on flag plus the but bit0 will seff off becaus the do not collide 
//  threfore teh above test will pass

  you can test teh oeteh way too,
  if( (data1.RadDollMask & (1 <<data0.bodyIndivodualBit) == 0) {
     // part do not collide only if they are part of the same ragdoll
      if (data0.RadDollID ==   data1.RadDollID) {
              return not collidion.
        }

   }
  it does no makes a difference

  //  them from here on you have two body in the same call back that are collidable, and you do not need to set recursive collision

I hope this help.













}
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 17 guests

cron