Skip to content

Commit c85fd3f

Browse files
author
William Linna
committed
Add/remove all PhysicsControls even when a RigidBodyControl is present
1 parent 60a031d commit c85fd3f

2 files changed

Lines changed: 8 additions & 12 deletions

File tree

jme3-bullet/src/main/java/com/jme3/bullet/PhysicsSpace.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -487,9 +487,10 @@ public void removeCollisionObject(PhysicsCollisionObject obj) {
487487
* @param spatial the rootnode containing the physics objects
488488
*/
489489
public void addAll(Spatial spatial) {
490+
add(spatial);
491+
490492
if (spatial.getControl(RigidBodyControl.class) != null) {
491493
RigidBodyControl physicsNode = spatial.getControl(RigidBodyControl.class);
492-
add(physicsNode);
493494
//add joints with physicsNode as BodyA
494495
List<PhysicsJoint> joints = physicsNode.getJoints();
495496
for (Iterator<PhysicsJoint> it1 = joints.iterator(); it1.hasNext();) {
@@ -499,8 +500,6 @@ public void addAll(Spatial spatial) {
499500
add(physicsJoint);
500501
}
501502
}
502-
} else {
503-
add(spatial);
504503
}
505504
//recursion
506505
if (spatial instanceof Node) {
@@ -529,10 +528,9 @@ public void removeAll(Spatial spatial) {
529528
//remove(physicsJoint.getBodyB());
530529
}
531530
}
532-
remove(physicsNode);
533-
} else if (spatial.getControl(PhysicsControl.class) != null) {
534-
remove(spatial);
535531
}
532+
533+
remove(spatial);
536534
//recursion
537535
if (spatial instanceof Node) {
538536
List<Spatial> children = ((Node) spatial).getChildren();

jme3-jbullet/src/main/java/com/jme3/bullet/PhysicsSpace.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -458,9 +458,10 @@ public void removeCollisionObject(PhysicsCollisionObject obj) {
458458
* @param spatial the rootnode containing the physics objects
459459
*/
460460
public void addAll(Spatial spatial) {
461+
add(spatial);
462+
461463
if (spatial.getControl(RigidBodyControl.class) != null) {
462464
RigidBodyControl physicsNode = spatial.getControl(RigidBodyControl.class);
463-
add(physicsNode);
464465
//add joints with physicsNode as BodyA
465466
List<PhysicsJoint> joints = physicsNode.getJoints();
466467
for (Iterator<PhysicsJoint> it1 = joints.iterator(); it1.hasNext();) {
@@ -470,8 +471,6 @@ public void addAll(Spatial spatial) {
470471
add(physicsJoint);
471472
}
472473
}
473-
} else {
474-
add(spatial);
475474
}
476475
//recursion
477476
if (spatial instanceof Node) {
@@ -500,10 +499,9 @@ public void removeAll(Spatial spatial) {
500499
//remove(physicsJoint.getBodyB());
501500
}
502501
}
503-
remove(physicsNode);
504-
} else if (spatial.getControl(PhysicsControl.class) != null) {
505-
remove(spatial);
506502
}
503+
504+
remove(spatial);
507505
//recursion
508506
if (spatial instanceof Node) {
509507
List<Spatial> children = ((Node) spatial).getChildren();

0 commit comments

Comments
 (0)