diff --git a/engine/src/bullet-common/com/jme3/bullet/control/KinematicRagdollControl.java b/engine/src/bullet-common/com/jme3/bullet/control/KinematicRagdollControl.java index 73cbba18f..0376f0031 100644 --- a/engine/src/bullet-common/com/jme3/bullet/control/KinematicRagdollControl.java +++ b/engine/src/bullet-common/com/jme3/bullet/control/KinematicRagdollControl.java @@ -65,33 +65,29 @@ import java.util.*; import java.util.logging.Level; import java.util.logging.Logger; -/**This control is still a WIP, use it at your own risk
- * To use this control you need a model with an AnimControl and a SkeletonControl.
- * This should be the case if you imported an animated model from Ogre or blender.
- * Note enabling/disabling the control add/removes it from the physic space
- *

- * This control creates collision shapes for each bones of the skeleton when you call spatial.addControl(ragdollControl). - *

- *

- *

- *There are 2 modes for this control : - *

- *

+/** + * This control is still a WIP, use it at your own risk
To + * use this control you need a model with an AnimControl and a + * SkeletonControl.
This should be the case if you imported an animated + * model from Ogre or blender.
Note enabling/disabling the control + * add/removes it from the physic space

This control creates collision + * shapes for each bones of the skeleton when you call + * spatial.addControl(ragdollControl).

There are 2 modes for this control :

* * @author Normen Hansen and Rémy Bouquet (Nehon) */ @@ -206,7 +202,7 @@ public class KinematicRagdollControl extends AbstractPhysicsControl implements P TempVars vars = TempVars.get(); Quaternion tmpRot1 = vars.quat1; Quaternion tmpRot2 = vars.quat2; - + for (PhysicsBoneLink link : boneLinks.values()) { Vector3f position = vars.vect1; @@ -334,20 +330,15 @@ public class KinematicRagdollControl extends AbstractPhysicsControl implements P * after it's been initialized, same as reattaching. */ public void reBuild() { - if (added) { - removePhysics(space); - setSpatial(targetModel); - addPhysics(space); - } else { - setSpatial(targetModel); + if (spatial == null) { + return; } + removeSpatialData(spatial); + createSpatialData(spatial); } @Override protected void createSpatialData(Spatial model) { - if (added) { - removePhysics(space); - } targetModel = model; Node parent = model.getParent(); @@ -390,7 +381,6 @@ public class KinematicRagdollControl extends AbstractPhysicsControl implements P protected void removeSpatialData(Spatial spat) { if (added) { removePhysics(space); - added = false; } boneLinks.clear(); } @@ -852,7 +842,7 @@ public class KinematicRagdollControl extends AbstractPhysicsControl implements P InputCapsule ic = im.getCapsule(this); String[] loadedBoneList = ic.readStringArray("boneList", new String[0]); boneList.addAll(Arrays.asList(loadedBoneList)); - PhysicsBoneLink[] loadedBoneLinks = (PhysicsBoneLink[])ic.readSavableArray("boneList", new PhysicsBoneLink[0]); + PhysicsBoneLink[] loadedBoneLinks = (PhysicsBoneLink[]) ic.readSavableArray("boneList", new PhysicsBoneLink[0]); for (PhysicsBoneLink physicsBoneLink : loadedBoneLinks) { boneLinks.put(physicsBoneLink.bone.getName(), physicsBoneLink); }