- separate update() call in KinematicRagdollControl to multiple methods to make them run hot quicker

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@10374 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
This commit is contained in:
nor..67 2013-02-09 13:02:05 +00:00
parent a53071ca4d
commit 56244c7744

View File

@ -193,13 +193,20 @@ public class KinematicRagdollControl extends AbstractPhysicsControl implements P
if (!enabled) {
return;
}
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)) {
ragDollUpdate(tpf);
} else {
kinematicUpdate(tpf);
}
}
protected void ragDollUpdate(float tpf) {
TempVars vars = TempVars.get();
Quaternion tmpRot1 = vars.quat1;
Quaternion tmpRot2 = vars.quat2;
for (PhysicsBoneLink link : boneLinks.values()) {
Vector3f position = vars.vect1;
@ -247,12 +254,16 @@ public class KinematicRagdollControl extends AbstractPhysicsControl implements P
}
}
}
} else {
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
for (PhysicsBoneLink link : boneLinks.values()) {
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();
}
/**