Skip to content

Commit

Permalink
use array constructors and array setters
Browse files Browse the repository at this point in the history
  • Loading branch information
stephengold committed Feb 25, 2025
1 parent 9e7cb88 commit 88057dc
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 27 deletions.
16 changes: 6 additions & 10 deletions src/main/java/com/github/stephengold/joltjni/Character.java
Original file line number Diff line number Diff line change
Expand Up @@ -551,8 +551,7 @@ public RVec3 getCenterOfMassPosition(boolean lockBodies) {
long characterVa = va();
double[] storeDoubles = new double[3];
getCenterOfMassPosition(characterVa, storeDoubles, lockBodies);
RVec3 result
= new RVec3(storeDoubles[0], storeDoubles[1], storeDoubles[2]);
RVec3 result = new RVec3(storeDoubles);

return result;
}
Expand Down Expand Up @@ -608,7 +607,7 @@ public Vec3 getLinearVelocity(boolean lockBodies) {
long characterVa = va();
float[] storeFloats = new float[3];
getLinearVelocity(characterVa, storeFloats, lockBodies);
Vec3 result = new Vec3(storeFloats[0], storeFloats[1], storeFloats[2]);
Vec3 result = new Vec3(storeFloats);

return result;
}
Expand Down Expand Up @@ -637,8 +636,7 @@ public RVec3 getPosition(boolean lockBodies) {
long characterVa = va();
double[] storeDoubles = new double[3];
getPosition(characterVa, storeDoubles, lockBodies);
RVec3 result
= new RVec3(storeDoubles[0], storeDoubles[1], storeDoubles[2]);
RVec3 result = new RVec3(storeDoubles);

return result;
}
Expand Down Expand Up @@ -676,9 +674,8 @@ public void getPositionAndRotation(
float[] storeFloats = new float[4];
getPositionAndRotation(
characterVa, storeDoubles, storeFloats, lockBodies);
storeLocation.set(storeDoubles[0], storeDoubles[1], storeDoubles[2]);
storeOrientation.set(
storeFloats[0], storeFloats[1], storeFloats[2], storeFloats[3]);
storeLocation.set(storeDoubles);
storeOrientation.set(storeFloats);
}

/**
Expand All @@ -705,8 +702,7 @@ public Quat getRotation(boolean lockBodies) {
long characterVa = va();
float[] storeFloats = new float[4];
getRotation(characterVa, storeFloats, lockBodies);
Quat result = new Quat(
storeFloats[0], storeFloats[1], storeFloats[2], storeFloats[3]);
Quat result = new Quat(storeFloats);

return result;
}
Expand Down
16 changes: 6 additions & 10 deletions src/main/java/com/github/stephengold/joltjni/CharacterRef.java
Original file line number Diff line number Diff line change
Expand Up @@ -270,8 +270,7 @@ public RVec3 getCenterOfMassPosition(boolean lockBodies) {
double[] storeDoubles = new double[3];
com.github.stephengold.joltjni.Character.getCenterOfMassPosition(
characterVa, storeDoubles, lockBodies);
RVec3 result
= new RVec3(storeDoubles[0], storeDoubles[1], storeDoubles[2]);
RVec3 result = new RVec3(storeDoubles);

return result;
}
Expand Down Expand Up @@ -473,7 +472,7 @@ public Vec3 getLinearVelocity(boolean lockBodies) {
float[] storeFloats = new float[3];
com.github.stephengold.joltjni.Character.getLinearVelocity(
characterVa, storeFloats, lockBodies);
Vec3 result = new Vec3(storeFloats[0], storeFloats[1], storeFloats[2]);
Vec3 result = new Vec3(storeFloats);

return result;
}
Expand Down Expand Up @@ -503,8 +502,7 @@ public RVec3 getPosition(boolean lockBodies) {
double[] storeDoubles = new double[3];
com.github.stephengold.joltjni.Character.getPosition(
characterVa, storeDoubles, lockBodies);
RVec3 result
= new RVec3(storeDoubles[0], storeDoubles[1], storeDoubles[2]);
RVec3 result = new RVec3(storeDoubles);

return result;
}
Expand Down Expand Up @@ -542,9 +540,8 @@ public void getPositionAndRotation(
float[] storeFloats = new float[4];
com.github.stephengold.joltjni.Character.getPositionAndRotation(
characterVa, storeDoubles, storeFloats, lockBodies);
storeLocation.set(storeDoubles[0], storeDoubles[1], storeDoubles[2]);
storeOrientation.set(
storeFloats[0], storeFloats[1], storeFloats[2], storeFloats[3]);
storeLocation.set(storeDoubles);
storeOrientation.set(storeFloats);
}

/**
Expand Down Expand Up @@ -572,8 +569,7 @@ public Quat getRotation(boolean lockBodies) {
float[] storeFloats = new float[4];
com.github.stephengold.joltjni.Character.getRotation(
characterVa, storeFloats, lockBodies);
Quat result = new Quat(
storeFloats[0], storeFloats[1], storeFloats[2], storeFloats[3]);
Quat result = new Quat(storeFloats);

return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public void getCenterOfMassAndVolume(Vec3 storeCom, float[] storeVolume) {
long builderVa = va();
float[] storeFloats = new float[4];
getCenterOfMassAndVolume(builderVa, storeFloats);
storeCom.set(storeFloats[0], storeFloats[1], storeFloats[2]);
storeCom.set(storeFloats);
storeVolume[0] = storeFloats[3];
}

Expand Down
3 changes: 1 addition & 2 deletions src/main/java/com/github/stephengold/joltjni/Mat44.java
Original file line number Diff line number Diff line change
Expand Up @@ -493,8 +493,7 @@ public Quat getQuaternion() {
long matrixVa = va();
float[] storeFloats = new float[4];
getQuaternion(matrixVa, storeFloats);
Quat result = new Quat(
storeFloats[0], storeFloats[1], storeFloats[2], storeFloats[3]);
Quat result = new Quat(storeFloats);

return result;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (c) 2024 Stephen Gold
Copyright (c) 2024-2025 Stephen Gold
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -103,7 +103,7 @@ public void getPointOnPath(float amount, Vec3 storeLocation,
long pathVa = va();
float[] storeFloats = new float[12];
getPointOnPath(pathVa, amount, storeFloats);
storeLocation.set(storeFloats[0], storeFloats[1], storeFloats[2]);
storeLocation.set(storeFloats);
storeTangent.set(storeFloats[3], storeFloats[4], storeFloats[5]);
storeNormal.set(storeFloats[6], storeFloats[7], storeFloats[8]);
storeBinormal.set(storeFloats[9], storeFloats[10], storeFloats[11]);
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/com/github/stephengold/joltjni/RMat44.java
Original file line number Diff line number Diff line change
Expand Up @@ -412,8 +412,7 @@ public Quat getQuaternion() {
long matrixVa = va();
float[] storeFloats = new float[4];
getQuaternion(matrixVa, storeFloats);
Quat result = new Quat(
storeFloats[0], storeFloats[1], storeFloats[2], storeFloats[3]);
Quat result = new Quat(storeFloats);

return result;
}
Expand Down

0 comments on commit 88057dc

Please sign in to comment.