Browse Source

Merge pull request #612 from JavaSaBr/fixed_cloning_and_saving_RigidBodyControl-2

Fixed saving/cloning enabled state of a RigidBodyControl.
empirephoenix 8 years ago
parent
commit
071e449a3e

+ 9 - 3
jme3-bullet/src/common/java/com/jme3/bullet/control/RigidBodyControl.java

@@ -53,6 +53,7 @@ import com.jme3.scene.shape.Box;
 import com.jme3.scene.shape.Sphere;
 import com.jme3.util.clone.Cloner;
 import com.jme3.util.clone.JmeCloneable;
+
 import java.io.IOException;
 
 /**
@@ -143,6 +144,8 @@ public class RigidBodyControl extends PhysicsRigidBody implements PhysicsControl
         }
         control.setApplyPhysicsLocal(isApplyPhysicsLocal());
         control.spatial = this.spatial;
+        control.setEnabled(isEnabled());
+
         return control;
     }     
 
@@ -273,9 +276,12 @@ public class RigidBodyControl extends PhysicsRigidBody implements PhysicsControl
                 added = false;
             }
         } else {
-            if(this.space==space) return;
-            space.addCollisionObject(this);
-            added = true;
+            if (this.space == space) return;
+            // if this object isn't enabled, it will be added when it will be enabled.
+            if (isEnabled()) {
+                space.addCollisionObject(this);
+                added = true;
+            }
         }
         this.space = space;
     }