- add/remove multiple physics controls via PhysicsSpace.add / .remove

experimental
Normen Hansen 10 years ago
parent 6fdf0dffd3
commit 3aa8aed142
  1. 14
      jme3-bullet/src/main/java/com/jme3/bullet/PhysicsSpace.java
  2. 14
      jme3-jbullet/src/main/java/com/jme3/bullet/PhysicsSpace.java

@ -405,8 +405,11 @@ public class PhysicsSpace {
((PhysicsControl) obj).setPhysicsSpace(this);
} else if (obj instanceof Spatial) {
Spatial node = (Spatial) obj;
PhysicsControl control = node.getControl(PhysicsControl.class);
control.setPhysicsSpace(this);
for (int i = 0; i < node.getNumControls(); i++) {
if (node.getControl(i) instanceof PhysicsControl) {
add(((PhysicsControl) node.getControl(i)));
}
}
} else if (obj instanceof PhysicsCollisionObject) {
addCollisionObject((PhysicsCollisionObject) obj);
} else if (obj instanceof PhysicsJoint) {
@ -438,7 +441,12 @@ public class PhysicsSpace {
if (obj instanceof PhysicsControl) {
((PhysicsControl) obj).setPhysicsSpace(null);
} else if (obj instanceof Spatial) {
remove(((Spatial) obj).getControl(PhysicsControl.class));
Spatial node = (Spatial) obj;
for (int i = 0; i < node.getNumControls(); i++) {
if (node.getControl(i) instanceof PhysicsControl) {
remove(((PhysicsControl) node.getControl(i)));
}
}
} else if (obj instanceof PhysicsCollisionObject) {
removeCollisionObject((PhysicsCollisionObject) obj);
} else if (obj instanceof PhysicsJoint) {

@ -391,7 +391,12 @@ public class PhysicsSpace {
if (obj instanceof PhysicsControl) {
((PhysicsControl) obj).setPhysicsSpace(this);
} else if (obj instanceof Spatial) {
add(((Spatial) obj).getControl(PhysicsControl.class));
Spatial node = (Spatial) obj;
for (int i = 0; i < node.getNumControls(); i++) {
if (node.getControl(i) instanceof PhysicsControl) {
add(((PhysicsControl) node.getControl(i)));
}
}
} else if (obj instanceof PhysicsCollisionObject) {
addCollisionObject((PhysicsCollisionObject) obj);
} else if (obj instanceof PhysicsJoint) {
@ -423,7 +428,12 @@ public class PhysicsSpace {
if (obj instanceof PhysicsControl) {
((PhysicsControl) obj).setPhysicsSpace(null);
} else if (obj instanceof Spatial) {
remove(((Spatial) obj).getControl(PhysicsControl.class));
Spatial node = (Spatial) obj;
for (int i = 0; i < node.getNumControls(); i++) {
if (node.getControl(i) instanceof PhysicsControl) {
remove(((PhysicsControl) node.getControl(i)));
}
}
} else if (obj instanceof PhysicsCollisionObject) {
removeCollisionObject((PhysicsCollisionObject) obj);
} else if (obj instanceof PhysicsJoint) {

Loading…
Cancel
Save