|
|
|
@ -193,13 +193,20 @@ public class KinematicRagdollControl extends AbstractPhysicsControl implements P |
|
|
|
|
if (!enabled) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
TempVars vars = TempVars.get(); |
|
|
|
|
|
|
|
|
|
//if the ragdoll has the control of the skeleton, we update each bone with its position in physic world space.
|
|
|
|
|
if (mode == mode.Ragdoll && targetModel.getLocalTranslation().equals(modelPosition)) { |
|
|
|
|
ragDollUpdate(tpf); |
|
|
|
|
} else { |
|
|
|
|
kinematicUpdate(tpf); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
protected void ragDollUpdate(float tpf) { |
|
|
|
|
TempVars vars = TempVars.get(); |
|
|
|
|
Quaternion tmpRot1 = vars.quat1; |
|
|
|
|
Quaternion tmpRot2 = vars.quat2; |
|
|
|
|
|
|
|
|
|
//if the ragdoll has the control of the skeleton, we update each bone with its position in physic world space.
|
|
|
|
|
if (mode == mode.Ragdoll && targetModel.getLocalTranslation().equals(modelPosition)) { |
|
|
|
|
for (PhysicsBoneLink link : boneLinks.values()) { |
|
|
|
|
|
|
|
|
|
Vector3f position = vars.vect1; |
|
|
|
@ -247,12 +254,16 @@ public class KinematicRagdollControl extends AbstractPhysicsControl implements P |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
//the ragdoll does not have the controll, so the keyframed animation updates the physic position of the physic bonces
|
|
|
|
|
for (PhysicsBoneLink link : boneLinks.values()) { |
|
|
|
|
vars.release(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
protected void kinematicUpdate(float tpf) { |
|
|
|
|
//the ragdoll does not have the controll, so the keyframed animation updates the physic position of the physic bonces
|
|
|
|
|
TempVars vars = TempVars.get(); |
|
|
|
|
Quaternion tmpRot1 = vars.quat1; |
|
|
|
|
Quaternion tmpRot2 = vars.quat2; |
|
|
|
|
Vector3f position = vars.vect1; |
|
|
|
|
|
|
|
|
|
for (PhysicsBoneLink link : boneLinks.values()) { |
|
|
|
|
//if blended control this means, keyframed animation is updating the skeleton,
|
|
|
|
|
//but to allow smooth transition, we blend this transformation with the saved position of the ragdoll
|
|
|
|
|
if (blendedControl) { |
|
|
|
@ -282,7 +293,6 @@ public class KinematicRagdollControl extends AbstractPhysicsControl implements P |
|
|
|
|
//setting skeleton transforms to the ragdoll
|
|
|
|
|
matchPhysicObjectToBone(link, position, tmpRot1); |
|
|
|
|
modelPosition.set(targetModel.getLocalTranslation()); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//time control for blending
|
|
|
|
@ -292,9 +302,7 @@ public class KinematicRagdollControl extends AbstractPhysicsControl implements P |
|
|
|
|
blendedControl = false; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
vars.release(); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|