Add/remove all PhysicsControls even when a RigidBodyControl is present

This commit is contained in:
William Linna 2016-05-21 23:26:56 +03:00
parent 60a031dc02
commit c85fd3fe26
2 changed files with 8 additions and 12 deletions

View File

@ -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<PhysicsJoint> joints = physicsNode.getJoints();
for (Iterator<PhysicsJoint> 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<Spatial> children = ((Node) spatial).getChildren();

View File

@ -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<PhysicsJoint> joints = physicsNode.getJoints();
for (Iterator<PhysicsJoint> 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<Spatial> children = ((Node) spatial).getChildren();