diff --git a/src/main/java/com/github/stephengold/joltjni/PhysicsSceneRef.java b/src/main/java/com/github/stephengold/joltjni/PhysicsSceneRef.java index 761d6e29..498083ce 100644 --- a/src/main/java/com/github/stephengold/joltjni/PhysicsSceneRef.java +++ b/src/main/java/com/github/stephengold/joltjni/PhysicsSceneRef.java @@ -62,8 +62,7 @@ public PhysicsSceneRef() { * @return {@code true} if successful, otherwise {@code false} */ public boolean fixInvalidScales() { - long refVa = va(); - long sceneVa = getPtr(refVa); + long sceneVa = targetVa(); boolean result = PhysicsScene.fixInvalidScales(sceneVa); return result; @@ -76,8 +75,7 @@ public boolean fixInvalidScales() { * objects assigned */ public BodyCreationSettings[] getBodies() { - long refVa = va(); - long sceneVa = getPtr(refVa); + long sceneVa = targetVa(); int numBodies = PhysicsScene.getNumBodies(sceneVa); BodyCreationSettings[] result = new BodyCreationSettings[numBodies]; for (int bodyIndex = 0; bodyIndex < numBodies; ++bodyIndex) { @@ -95,8 +93,7 @@ public BodyCreationSettings[] getBodies() { * @return {@code true} if successful, otherwise {@code false} */ public boolean createBodies(PhysicsSystem system) { - long refVa = va(); - long sceneVa = getPtr(refVa); + long sceneVa = targetVa(); long systemVa = system.va(); boolean result = PhysicsScene.createBodies(sceneVa, systemVa); @@ -112,13 +109,25 @@ public boolean createBodies(PhysicsSystem system) { */ @Override public PhysicsScene getPtr() { - long refVa = va(); - long sceneVa = getPtr(refVa); + long sceneVa = targetVa(); PhysicsScene result = new PhysicsScene(sceneVa); return result; } + /** + * Return the address of the target object. No objects are affected. + * + * @return a virtual address (not zero) + */ + @Override + public long targetVa() { + long refVa = va(); + long result = getPtr(refVa); + + return result; + } + /** * Create another counted reference to the native {@code PhysicsScene}. *