Skip to content

Commit

Permalink
library: simple refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
stephengold committed Jul 2, 2024
1 parent 8bf01e7 commit cc501e4
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -673,8 +673,7 @@ public List<PhysicsRayTestResult> rayTestRaw(
public void remove(Object object) {
if (object == null) {
return;
}
if (object instanceof PhysicsCollisionObject) {
} else if (object instanceof PhysicsCollisionObject) {
removeCollisionObject((PhysicsCollisionObject) object);
} else {
String typeName = object.getClass().getCanonicalName();
Expand Down
16 changes: 8 additions & 8 deletions MinieLibrary/src/main/java/com/jme3/bullet/PhysicsSpace.java
Original file line number Diff line number Diff line change
Expand Up @@ -1089,10 +1089,10 @@ public void add(Object object) {
if (object instanceof PhysicsControl) {
((PhysicsControl) object).setPhysicsSpace(this);
} else if (object instanceof Spatial) {
Spatial node = (Spatial) object;
for (int i = 0; i < node.getNumControls(); ++i) {
if (node.getControl(i) instanceof PhysicsControl) {
add(node.getControl(i));
Spatial spatial = (Spatial) object;
for (int i = 0; i < spatial.getNumControls(); ++i) {
if (spatial.getControl(i) instanceof PhysicsControl) {
add(spatial.getControl(i));
}
}
} else if (object instanceof PhysicsJoint) {
Expand Down Expand Up @@ -1225,10 +1225,10 @@ public void remove(Object object) {
if (object instanceof PhysicsControl) {
((PhysicsControl) object).setPhysicsSpace(null);
} else if (object instanceof Spatial) {
Spatial node = (Spatial) object;
for (int i = 0; i < node.getNumControls(); ++i) {
if (node.getControl(i) instanceof PhysicsControl) {
remove((node.getControl(i)));
Spatial spatial = (Spatial) object;
for (int i = 0; i < spatial.getNumControls(); ++i) {
if (spatial.getControl(i) instanceof PhysicsControl) {
remove((spatial.getControl(i)));
}
}
} else if (object instanceof PhysicsJoint) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -416,10 +416,10 @@ public void setSpatial(Spatial controlledSpatial) {
createCollisionShape();
rebuildRigidBody();
}
Vector3f translation = getSpatialTranslation(); // alias
setPhysicsLocation(translation);
Quaternion rotation = getSpatialRotation(); // alias
setPhysicsRotation(rotation);
Vector3f location = getSpatialTranslation(); // alias
setPhysicsLocation(location);
Quaternion orientation = getSpatialRotation(); // alias
setPhysicsRotation(orientation);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,9 @@ public int hashCode() {
*/
@Override
public String toString() {
String desc = String.format(
String result = String.format(
"shape=%x scale=%s margin=%f res=%d normals=%s",
shapeId, scale, margin, resolution, normals);
return desc;
return result;
}
}

0 comments on commit cc501e4

Please sign in to comment.