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.
}