From e26f0f133b0936b06afe0814b8f6dc643964e06a Mon Sep 17 00:00:00 2001 From: javasabr Date: Fri, 3 Feb 2017 09:16:06 +0300 Subject: [PATCH] fixed cloning and saving some contorls. --- .../java/com/jme3/bullet/control/CharacterControl.java | 10 ++++++---- .../java/com/jme3/bullet/control/VehicleControl.java | 10 +++++++--- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/jme3-bullet/src/common/java/com/jme3/bullet/control/CharacterControl.java b/jme3-bullet/src/common/java/com/jme3/bullet/control/CharacterControl.java index 7ef80778c..d12e5991a 100644 --- a/jme3-bullet/src/common/java/com/jme3/bullet/control/CharacterControl.java +++ b/jme3-bullet/src/common/java/com/jme3/bullet/control/CharacterControl.java @@ -121,6 +121,7 @@ public class CharacterControl extends PhysicsCharacter implements PhysicsControl control.setUpAxis(getUpAxis()); control.setApplyPhysicsLocal(isApplyPhysicsLocal()); control.spatial = this.spatial; + control.setEnabled(isEnabled()); return control; } @@ -207,11 +208,12 @@ public class CharacterControl extends PhysicsCharacter implements PhysicsControl added = false; } } else { - if (this.space == space) { - return; + 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; } - space.addCollisionObject(this); - added = true; } this.space = space; } diff --git a/jme3-bullet/src/common/java/com/jme3/bullet/control/VehicleControl.java b/jme3-bullet/src/common/java/com/jme3/bullet/control/VehicleControl.java index 7ad36b3ae..5f6af8175 100644 --- a/jme3-bullet/src/common/java/com/jme3/bullet/control/VehicleControl.java +++ b/jme3-bullet/src/common/java/com/jme3/bullet/control/VehicleControl.java @@ -200,6 +200,7 @@ public class VehicleControl extends PhysicsVehicle implements PhysicsControl, Jm newWheel.setWheelSpatial(wheel.getWheelSpatial()); } control.setApplyPhysicsLocal(isApplyPhysicsLocal()); + control.setEnabled(isEnabled()); control.spatial = spatial; return control; @@ -268,9 +269,12 @@ public class VehicleControl extends PhysicsVehicle implements PhysicsControl, Jm 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; }