diff --git a/src/main/java/com/github/stephengold/joltjni/Character.java b/src/main/java/com/github/stephengold/joltjni/Character.java index eb3c0112..a14ccd74 100644 --- a/src/main/java/com/github/stephengold/joltjni/Character.java +++ b/src/main/java/com/github/stephengold/joltjni/Character.java @@ -484,29 +484,6 @@ public boolean setShape( // ************************************************************************* // CharacterBase methods - /** - * Count the active references to the native {@code Character}. The - * character is unaffected. - * - * @return the count (≥0) - */ - @Override - public int getRefCount() { - long characterVa = va(); - int result = getRefCount(characterVa); - - return result; - } - - /** - * Mark the native {@code Character} as embedded. - */ - @Override - public void setEmbedded() { - long characterVa = va(); - setEmbedded(characterVa); - } - /** * Create a counted reference to the native {@code Character}. * @@ -785,8 +762,6 @@ native static void getPosition( native static void getPositionAndRotation(long characterVa, double[] storeDoubles, float[] storeFloats, boolean lockBodies); - native private static int getRefCount(long characterVa); - native static void getRotation( long characterVa, float[] toreFloats, boolean lockBodies); @@ -799,8 +774,6 @@ native private static void postSimulation( native private static void removeFromPhysicsSystem( long characterVa, boolean lockBodies); - native private static void setEmbedded(long characterVa); - native private static void setLayer( long characterVa, int layer, boolean lockBodies); diff --git a/src/main/java/com/github/stephengold/joltjni/CharacterBase.java b/src/main/java/com/github/stephengold/joltjni/CharacterBase.java index 54834828..1ce9a677 100644 --- a/src/main/java/com/github/stephengold/joltjni/CharacterBase.java +++ b/src/main/java/com/github/stephengold/joltjni/CharacterBase.java @@ -26,7 +26,6 @@ of this software and associated documentation files (the "Software"), to deal import com.github.stephengold.joltjni.readonly.ConstPhysicsMaterial; import com.github.stephengold.joltjni.readonly.ConstShape; import com.github.stephengold.joltjni.readonly.Vec3Arg; -import com.github.stephengold.joltjni.template.Ref; import com.github.stephengold.joltjni.template.RefTarget; /** @@ -323,21 +322,21 @@ public void saveState(StateRecorder recorder) { * @return the count (≥0) */ @Override - abstract public int getRefCount(); + public int getRefCount() { + long characterVa = va(); + int result = getRefCount(characterVa); - /** - * Mark the native {@code CharacterBase} as embedded. - */ - @Override - abstract public void setEmbedded(); + return result; + } /** - * Create a counted reference to the native {@code CharacterBase}. - * - * @return a new JVM object with a new native object assigned + * Mark the native {@code CharacterBase} as embedded. */ @Override - abstract public Ref toRef(); + public void setEmbedded() { + long characterVa = va(); + setEmbedded(characterVa); + } // ************************************************************************* // native methods @@ -371,6 +370,8 @@ public void saveState(StateRecorder recorder) { native static float getGroundVelocityZ(long characterVa); + native private static int getRefCount(long characterVa); + native static long getShape(long characterVa); native static float getUpX(long characterVa); @@ -388,6 +389,8 @@ native static boolean isSlopeTooSteep( native static void saveState(long characterVa, long recorderVa); + native private static void setEmbedded(long characterVa); + native private static void setMaxSlopeAngle(long characterVa, float angle); native private static void setUp( diff --git a/src/main/java/com/github/stephengold/joltjni/CharacterVirtual.java b/src/main/java/com/github/stephengold/joltjni/CharacterVirtual.java index d92c06f3..5259b998 100644 --- a/src/main/java/com/github/stephengold/joltjni/CharacterVirtual.java +++ b/src/main/java/com/github/stephengold/joltjni/CharacterVirtual.java @@ -357,29 +357,6 @@ public void updateGroundVelocity() { // ************************************************************************* // CharacterBase methods - /** - * Count the active references to the native {@code CharacterVirtual}. The - * character is unaffected. - * - * @return the count (≥0) - */ - @Override - public int getRefCount() { - long characterVa = va(); - int result = getRefCount(characterVa); - - return result; - } - - /** - * Mark the native {@code CharacterVirtual} as embedded. - */ - @Override - public void setEmbedded() { - long characterVa = va(); - setEmbedded(characterVa); - } - /** * Create a counted reference to the native {@code CharacterVirtual}. * @@ -795,8 +772,6 @@ native private static void extendedUpdate(long characterVa, float deltaTime, native static double getPositionZ(long characterVa); - native private static int getRefCount(long characterVa); - native static float getRotationW(long characterVa); native static float getRotationX(long characterVa); @@ -823,8 +798,6 @@ native static boolean hasCollidedWithCharacter( native private static void setCharacterVsCharacterCollision( long characterVa, long interfaceVa); - native private static void setEmbedded(long characterVa); - native private static void setEnhancedInternalEdgeRemoval( long characterVa, boolean enable); diff --git a/src/main/native/glue/c/Character.cpp b/src/main/native/glue/c/Character.cpp index cb21c3fc..fce4aca2 100644 --- a/src/main/native/glue/c/Character.cpp +++ b/src/main/native/glue/c/Character.cpp @@ -218,19 +218,6 @@ JNIEXPORT void JNICALL Java_com_github_stephengold_joltjni_Character_getPosition pEnv->ReleaseFloatArrayElements(storeFloats, pStoreFloats, 0); } -/* - * Class: com_github_stephengold_joltjni_Character - * Method: getRefCount - * Signature: (J)I - */ -JNIEXPORT jint JNICALL Java_com_github_stephengold_joltjni_Character_getRefCount - (JNIEnv *, jclass, jlong characterVa) { - const Character * const pCharacter - = reinterpret_cast (characterVa); - const uint32 result = pCharacter->GetRefCount(); - return result; -} - /* * Class: com_github_stephengold_joltjni_Character * Method: getRotation @@ -288,17 +275,6 @@ JNIEXPORT void JNICALL Java_com_github_stephengold_joltjni_Character_removeFromP pCharacter->RemoveFromPhysicsSystem(lockBodies); } -/* - * Class: com_github_stephengold_joltjni_Character - * Method: setEmbedded - * Signature: (J)V - */ -JNIEXPORT void JNICALL Java_com_github_stephengold_joltjni_Character_setEmbedded - (JNIEnv *, jclass, jlong characterVa) { - Character * const pCharacter = reinterpret_cast (characterVa); - pCharacter->SetEmbedded(); -} - /* * Class: com_github_stephengold_joltjni_Character * Method: setLayer diff --git a/src/main/native/glue/c/CharacterBase.cpp b/src/main/native/glue/c/CharacterBase.cpp index ef4ba822..e5d66797 100644 --- a/src/main/native/glue/c/CharacterBase.cpp +++ b/src/main/native/glue/c/CharacterBase.cpp @@ -229,6 +229,19 @@ JNIEXPORT jfloat JNICALL Java_com_github_stephengold_joltjni_CharacterBase_getGr return result; } +/* + * Class: com_github_stephengold_joltjni_CharacterBase + * Method: getRefCount + * Signature: (J)I + */ +JNIEXPORT jint JNICALL Java_com_github_stephengold_joltjni_CharacterBase_getRefCount + (JNIEnv *, jclass, jlong characterVa) { + const CharacterBase * const pCharacter + = reinterpret_cast (characterVa); + const uint32 result = pCharacter->GetRefCount(); + return result; +} + /* * Class: com_github_stephengold_joltjni_CharacterBase * Method: getShape @@ -336,6 +349,18 @@ JNIEXPORT void JNICALL Java_com_github_stephengold_joltjni_CharacterBase_saveSta pCharacter->SaveState(*pRecorder); } +/* + * Class: com_github_stephengold_joltjni_CharacterBase + * Method: setEmbedded + * Signature: (J)V + */ +JNIEXPORT void JNICALL Java_com_github_stephengold_joltjni_CharacterBase_setEmbedded + (JNIEnv *, jclass, jlong characterVa) { + CharacterBase * const pCharacter + = reinterpret_cast (characterVa); + pCharacter->SetEmbedded(); +} + /* * Class: com_github_stephengold_joltjni_CharacterBase * Method: setMaxSlopeAngle diff --git a/src/main/native/glue/c/CharacterVirtual.cpp b/src/main/native/glue/c/CharacterVirtual.cpp index 5ce3e37a..5610968a 100644 --- a/src/main/native/glue/c/CharacterVirtual.cpp +++ b/src/main/native/glue/c/CharacterVirtual.cpp @@ -384,19 +384,6 @@ JNIEXPORT jdouble JNICALL Java_com_github_stephengold_joltjni_CharacterVirtual_g return result; } -/* - * Class: com_github_stephengold_joltjni_CharacterVirtual - * Method: getRefCount - * Signature: (J)I - */ -JNIEXPORT jint JNICALL Java_com_github_stephengold_joltjni_CharacterVirtual_getRefCount - (JNIEnv *, jclass, jlong characterVa) { - const CharacterVirtual * const pCharacter - = reinterpret_cast (characterVa); - const uint32 result = pCharacter->GetRefCount(); - return result; -} - /* * Class: com_github_stephengold_joltjni_CharacterVirtual * Method: getRotationW @@ -559,18 +546,6 @@ JNIEXPORT void JNICALL Java_com_github_stephengold_joltjni_CharacterVirtual_setC pCharacter->SetCharacterVsCharacterCollision(pInterface); } -/* - * Class: com_github_stephengold_joltjni_CharacterVirtual - * Method: setEmbedded - * Signature: (J)V - */ -JNIEXPORT void JNICALL Java_com_github_stephengold_joltjni_CharacterVirtual_setEmbedded - (JNIEnv *, jclass, jlong characterVa) { - CharacterVirtual * const pCharacter - = reinterpret_cast (characterVa); - pCharacter->SetEmbedded(); -} - /* * Class: com_github_stephengold_joltjni_CharacterVirtual * Method: setEnhancedInternalEdgeRemoval