Merge pull request #498 from TripleSnail/master
Add/remove all PhysicsControls even when a RigidBodyControl is present
This commit is contained in:
commit
bfbb0d61ea
@ -489,9 +489,10 @@ public class PhysicsSpace {
|
|||||||
* @param spatial the rootnode containing the physics objects
|
* @param spatial the rootnode containing the physics objects
|
||||||
*/
|
*/
|
||||||
public void addAll(Spatial spatial) {
|
public void addAll(Spatial spatial) {
|
||||||
|
add(spatial);
|
||||||
|
|
||||||
if (spatial.getControl(RigidBodyControl.class) != null) {
|
if (spatial.getControl(RigidBodyControl.class) != null) {
|
||||||
RigidBodyControl physicsNode = spatial.getControl(RigidBodyControl.class);
|
RigidBodyControl physicsNode = spatial.getControl(RigidBodyControl.class);
|
||||||
add(physicsNode);
|
|
||||||
//add joints with physicsNode as BodyA
|
//add joints with physicsNode as BodyA
|
||||||
List<PhysicsJoint> joints = physicsNode.getJoints();
|
List<PhysicsJoint> joints = physicsNode.getJoints();
|
||||||
for (Iterator<PhysicsJoint> it1 = joints.iterator(); it1.hasNext();) {
|
for (Iterator<PhysicsJoint> it1 = joints.iterator(); it1.hasNext();) {
|
||||||
@ -501,8 +502,6 @@ public class PhysicsSpace {
|
|||||||
add(physicsJoint);
|
add(physicsJoint);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
add(spatial);
|
|
||||||
}
|
}
|
||||||
//recursion
|
//recursion
|
||||||
if (spatial instanceof Node) {
|
if (spatial instanceof Node) {
|
||||||
@ -531,10 +530,9 @@ public class PhysicsSpace {
|
|||||||
//remove(physicsJoint.getBodyB());
|
//remove(physicsJoint.getBodyB());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
remove(physicsNode);
|
|
||||||
} else if (spatial.getControl(PhysicsControl.class) != null) {
|
|
||||||
remove(spatial);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
remove(spatial);
|
||||||
//recursion
|
//recursion
|
||||||
if (spatial instanceof Node) {
|
if (spatial instanceof Node) {
|
||||||
List<Spatial> children = ((Node) spatial).getChildren();
|
List<Spatial> children = ((Node) spatial).getChildren();
|
||||||
|
@ -458,9 +458,10 @@ public class PhysicsSpace {
|
|||||||
* @param spatial the rootnode containing the physics objects
|
* @param spatial the rootnode containing the physics objects
|
||||||
*/
|
*/
|
||||||
public void addAll(Spatial spatial) {
|
public void addAll(Spatial spatial) {
|
||||||
|
add(spatial);
|
||||||
|
|
||||||
if (spatial.getControl(RigidBodyControl.class) != null) {
|
if (spatial.getControl(RigidBodyControl.class) != null) {
|
||||||
RigidBodyControl physicsNode = spatial.getControl(RigidBodyControl.class);
|
RigidBodyControl physicsNode = spatial.getControl(RigidBodyControl.class);
|
||||||
add(physicsNode);
|
|
||||||
//add joints with physicsNode as BodyA
|
//add joints with physicsNode as BodyA
|
||||||
List<PhysicsJoint> joints = physicsNode.getJoints();
|
List<PhysicsJoint> joints = physicsNode.getJoints();
|
||||||
for (Iterator<PhysicsJoint> it1 = joints.iterator(); it1.hasNext();) {
|
for (Iterator<PhysicsJoint> it1 = joints.iterator(); it1.hasNext();) {
|
||||||
@ -470,8 +471,6 @@ public class PhysicsSpace {
|
|||||||
add(physicsJoint);
|
add(physicsJoint);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
add(spatial);
|
|
||||||
}
|
}
|
||||||
//recursion
|
//recursion
|
||||||
if (spatial instanceof Node) {
|
if (spatial instanceof Node) {
|
||||||
@ -500,10 +499,9 @@ public class PhysicsSpace {
|
|||||||
//remove(physicsJoint.getBodyB());
|
//remove(physicsJoint.getBodyB());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
remove(physicsNode);
|
|
||||||
} else if (spatial.getControl(PhysicsControl.class) != null) {
|
|
||||||
remove(spatial);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
remove(spatial);
|
||||||
//recursion
|
//recursion
|
||||||
if (spatial instanceof Node) {
|
if (spatial instanceof Node) {
|
||||||
List<Spatial> children = ((Node) spatial).getChildren();
|
List<Spatial> children = ((Node) spatial).getChildren();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user