Skip to content

Commit

Permalink
Body: changed the semantics of the getId() method
Browse files Browse the repository at this point in the history
  • Loading branch information
stephengold committed Sep 21, 2024
1 parent 599ad01 commit 32738df
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
10 changes: 4 additions & 6 deletions src/main/java/com/github/stephengold/joltjni/Body.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ of this software and associated documentation files (the "Software"), to deal
import com.github.stephengold.joltjni.enumerate.EMotionType;
import com.github.stephengold.joltjni.readonly.ConstAaBox;
import com.github.stephengold.joltjni.readonly.ConstBody;
import com.github.stephengold.joltjni.readonly.ConstBodyId;
import com.github.stephengold.joltjni.readonly.ConstShape;
import com.github.stephengold.joltjni.readonly.QuatArg;
import com.github.stephengold.joltjni.readonly.RVec3Arg;
Expand Down Expand Up @@ -460,17 +459,16 @@ public float getFriction() {
}

/**
* Access the body's ID for use with {@code BodyInterface}. The body is
* Copy the body's ID for use with {@code BodyInterface}. The body is
* unaffected.
*
* @return a new immutable JVM object with the pre-existing native object
* assigned
* @return a new object
*/
@Override
public ConstBodyId getId() {
public BodyId getId() {
long bodyVa = va();
long bodyIdVa = getId(bodyVa);
ConstBodyId result = new BodyId(bodyIdVa, false);
BodyId result = new BodyId(bodyIdVa, true);

return result;
}
Expand Down
6 changes: 4 additions & 2 deletions src/main/native/glue/b/Body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -344,8 +344,10 @@ JNIEXPORT jfloat JNICALL Java_com_github_stephengold_joltjni_Body_getFriction
JNIEXPORT jlong JNICALL Java_com_github_stephengold_joltjni_Body_getId
(JNIEnv *, jclass, jlong bodyVa) {
const Body * const pBody = reinterpret_cast<Body *> (bodyVa);
const BodyID &result = pBody->GetID();
return reinterpret_cast<jlong> (&result);
const BodyID &id = pBody->GetID();
BodyId * pResult = new BodyID(id);
TRACE_NEW("BodyID", pResult)
return reinterpret_cast<jlong> (pResult);
}

inline static const Vec3 getLinearVelocity(jlong bodyVa) {
Expand Down

0 comments on commit 32738df

Please sign in to comment.