From c85fd3fe264527604a63ce5bd10f3df471aef73a Mon Sep 17 00:00:00 2001 From: William Linna Date: Sat, 21 May 2016 23:26:56 +0300 Subject: [PATCH] Add/remove all PhysicsControls even when a RigidBodyControl is present --- .../src/main/java/com/jme3/bullet/PhysicsSpace.java | 10 ++++------ .../src/main/java/com/jme3/bullet/PhysicsSpace.java | 10 ++++------ 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/jme3-bullet/src/main/java/com/jme3/bullet/PhysicsSpace.java b/jme3-bullet/src/main/java/com/jme3/bullet/PhysicsSpace.java index debd36959..c582eb2a1 100644 --- a/jme3-bullet/src/main/java/com/jme3/bullet/PhysicsSpace.java +++ b/jme3-bullet/src/main/java/com/jme3/bullet/PhysicsSpace.java @@ -487,9 +487,10 @@ public class PhysicsSpace { * @param spatial the rootnode containing the physics objects */ public void addAll(Spatial spatial) { + add(spatial); + if (spatial.getControl(RigidBodyControl.class) != null) { RigidBodyControl physicsNode = spatial.getControl(RigidBodyControl.class); - add(physicsNode); //add joints with physicsNode as BodyA List joints = physicsNode.getJoints(); for (Iterator it1 = joints.iterator(); it1.hasNext();) { @@ -499,8 +500,6 @@ public class PhysicsSpace { add(physicsJoint); } } - } else { - add(spatial); } //recursion if (spatial instanceof Node) { @@ -529,10 +528,9 @@ public class PhysicsSpace { //remove(physicsJoint.getBodyB()); } } - remove(physicsNode); - } else if (spatial.getControl(PhysicsControl.class) != null) { - remove(spatial); } + + remove(spatial); //recursion if (spatial instanceof Node) { List children = ((Node) spatial).getChildren(); diff --git a/jme3-jbullet/src/main/java/com/jme3/bullet/PhysicsSpace.java b/jme3-jbullet/src/main/java/com/jme3/bullet/PhysicsSpace.java index 483343f72..b69332490 100644 --- a/jme3-jbullet/src/main/java/com/jme3/bullet/PhysicsSpace.java +++ b/jme3-jbullet/src/main/java/com/jme3/bullet/PhysicsSpace.java @@ -458,9 +458,10 @@ public class PhysicsSpace { * @param spatial the rootnode containing the physics objects */ public void addAll(Spatial spatial) { + add(spatial); + if (spatial.getControl(RigidBodyControl.class) != null) { RigidBodyControl physicsNode = spatial.getControl(RigidBodyControl.class); - add(physicsNode); //add joints with physicsNode as BodyA List joints = physicsNode.getJoints(); for (Iterator it1 = joints.iterator(); it1.hasNext();) { @@ -470,8 +471,6 @@ public class PhysicsSpace { add(physicsJoint); } } - } else { - add(spatial); } //recursion if (spatial instanceof Node) { @@ -500,10 +499,9 @@ public class PhysicsSpace { //remove(physicsJoint.getBodyB()); } } - remove(physicsNode); - } else if (spatial.getControl(PhysicsControl.class) != null) { - remove(spatial); } + + remove(spatial); //recursion if (spatial instanceof Node) { List children = ((Node) spatial).getChildren();