- 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
3.0
nor..67 12 years ago
parent a53071ca4d
commit 56244c7744
  1. 28
      engine/src/bullet-common/com/jme3/bullet/control/KinematicRagdollControl.java

@ -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();
}
/**

Loading…
Cancel
Save