Skip to content

Commit

Permalink
Op: rename 25 public static methods
Browse files Browse the repository at this point in the history
  • Loading branch information
stephengold committed Nov 22, 2024
1 parent 5ed2901 commit 8549ae1
Show file tree
Hide file tree
Showing 53 changed files with 320 additions and 320 deletions.
2 changes: 1 addition & 1 deletion src/main/java/com/github/stephengold/joltjni/Quat.java
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ public float lengthSq() {
*/
@Override
public Quat normalized() {
Quat result = Op.multiply(1f / length(), this);
Quat result = Op.star(1f / length(), this);
return result;
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/github/stephengold/joltjni/Vec3.java
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ public float lengthSq() {
*/
@Override
public Vec3 normalized() {
Vec3 result = Op.multiply(1f / length(), this);
Vec3 result = Op.star(1f / length(), this);
return result;
}

Expand All @@ -569,7 +569,7 @@ public Vec3 normalizedOr(Vec3Arg zeroValue) {
if (length == 0f) {
result = new Vec3(zeroValue);
} else {
result = Op.multiply(1f / length, this);
result = Op.star(1f / length, this);
}
}

Expand Down
50 changes: 25 additions & 25 deletions src/main/java/com/github/stephengold/joltjni/operator/Op.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ private Op() {
* @param right the 2nd vector (not null, unaffected)
* @return a new vector
*/
public static RVec3 add(RVec3Arg left, RVec3Arg right) {
public static RVec3 plus(RVec3Arg left, RVec3Arg right) {
double xx = left.xx() + right.xx();
double yy = left.yy() + right.yy();
double zz = left.zz() + right.zz();
Expand All @@ -75,7 +75,7 @@ public static RVec3 add(RVec3Arg left, RVec3Arg right) {
* @param right the offset to add (not null, unaffected)
* @return a new vector
*/
public static RVec3 add(RVec3Arg left, Vec3Arg right) {
public static RVec3 plus(RVec3Arg left, Vec3Arg right) {
double xx = left.xx() + right.getX();
double yy = left.yy() + right.getY();
double zz = left.zz() + right.getZ();
Expand All @@ -92,7 +92,7 @@ public static RVec3 add(RVec3Arg left, Vec3Arg right) {
* @param right the 2nd vector (not null, unaffected)
* @return a new vector
*/
public static Vec3 add(Vec3Arg left, Vec3Arg right) {
public static Vec3 plus(Vec3Arg left, Vec3Arg right) {
float x = left.getX() + right.getX();
float y = left.getY() + right.getY();
float z = left.getZ() + right.getZ();
Expand All @@ -109,7 +109,7 @@ public static Vec3 add(Vec3Arg left, Vec3Arg right) {
* @param right the inverse scale to apply
* @return a new vector
*/
public static RVec3 divide(RVec3Arg left, double right) {
public static RVec3 slash(RVec3Arg left, double right) {
double xx = left.xx() / right;
double yy = left.yy() / right;
double zz = left.zz() / right;
Expand All @@ -126,7 +126,7 @@ public static RVec3 divide(RVec3Arg left, double right) {
* @param right the inverse scale to apply
* @return a new vector
*/
public static Vec3 divide(Vec3Arg left, float right) {
public static Vec3 slash(Vec3Arg left, float right) {
float x = left.getX() / right;
float y = left.getY() / right;
float z = left.getZ() / right;
Expand All @@ -142,7 +142,7 @@ public static Vec3 divide(Vec3Arg left, float right) {
* @param left the accumulating vector (not null, modified)
* @param right the denominator (not null, unaffected)
*/
public static void divideEquals(RVec3 left, double right) {
public static void slashEquals(RVec3 left, double right) {
double xx = left.xx() / right;
double yy = left.yy() / right;
double zz = left.zz() / right;
Expand All @@ -156,7 +156,7 @@ public static void divideEquals(RVec3 left, double right) {
* @param left the accumulating vector (not null, modified)
* @param right the denominator (not null, unaffected)
*/
public static void divideEquals(Vec3 left, float right) {
public static void slashEqual(Vec3 left, float right) {
float xx = left.getX() / right;
float yy = left.getY() / right;
float zz = left.getZ() / right;
Expand All @@ -170,7 +170,7 @@ public static void divideEquals(Vec3 left, float right) {
* @param right the 2nd ID to test (not null, unaffected)
* @return {@code true} if equal, {@code false} if unequal
*/
public static boolean equals(ConstBodyId left, ConstBodyId right) {
public static boolean isEqual(ConstBodyId left, ConstBodyId right) {
boolean result = left.isEqual(right);
return result;
}
Expand All @@ -183,7 +183,7 @@ public static boolean equals(ConstBodyId left, ConstBodyId right) {
* @param right the 2nd color to test (not null, unaffected)
* @return {@code true} if equal, {@code false} if unequal
*/
public static boolean equals(ConstColor left, ConstColor right) {
public static boolean isEqual(ConstColor left, ConstColor right) {
boolean result = left.getA() == right.getA()
&& left.getB() == right.getB()
&& left.getG() == right.getG()
Expand All @@ -199,7 +199,7 @@ public static boolean equals(ConstColor left, ConstColor right) {
* @param right the 2nd matrix (not null, unaffected)
* @return {@code true} if equal, otherwise {@code false}
*/
public static boolean equals(Mat44Arg left, Mat44Arg right) {
public static boolean isEqual(Mat44Arg left, Mat44Arg right) {
boolean result = left.isEqual(right);
return result;
}
Expand All @@ -225,7 +225,7 @@ public static void minusEquals(Vec3 left, Vec3Arg right) {
* @param right the input vector (not null, unaffected)
* @return a new vector
*/
public static RVec3 multiply(double left, RVec3Arg right) {
public static RVec3 star(double left, RVec3Arg right) {
double x = left * right.xx();
double y = left * right.yy();
double z = left * right.zz();
Expand All @@ -242,7 +242,7 @@ public static RVec3 multiply(double left, RVec3Arg right) {
* @param right the input quaternion (not null, unaffected)
* @return a new quaternion
*/
public static Quat multiply(float left, QuatArg right) {
public static Quat star(float left, QuatArg right) {
float w = left * right.getW();
float x = left * right.getX();
float y = left * right.getY();
Expand All @@ -260,7 +260,7 @@ public static Quat multiply(float left, QuatArg right) {
* @param right the input vector (not null, unaffected)
* @return a new vector
*/
public static Vec3 multiply(float left, Vec3Arg right) {
public static Vec3 star(float left, Vec3Arg right) {
float x = left * right.getX();
float y = left * right.getY();
float z = left * right.getZ();
Expand All @@ -278,7 +278,7 @@ public static Vec3 multiply(float left, Vec3Arg right) {
* @param right the right factor (not null, unaffected)
* @return a new vector
*/
public static Vec3 multiply(Mat44Arg left, Vec3Arg right) {
public static Vec3 star(Mat44Arg left, Vec3Arg right) {
Vec3 result = left.multiply3x4(right);
return result;
}
Expand All @@ -291,7 +291,7 @@ public static Vec3 multiply(Mat44Arg left, Vec3Arg right) {
* @param right the right factor (not null, unaffected)
* @return a new vector
*/
public static RMat44 multiply(RMat44Arg left, RMat44Arg right) {
public static RMat44 star(RMat44Arg left, RMat44Arg right) {
RMat44 result = left.multiply(right);
return result;
}
Expand All @@ -305,7 +305,7 @@ public static RMat44 multiply(RMat44Arg left, RMat44Arg right) {
* @param right the right factor (not null, unaffected)
* @return a new vector
*/
public static RVec3 multiply(RMat44Arg left, RVec3Arg right) {
public static RVec3 star(RMat44Arg left, RVec3Arg right) {
RVec3 result = left.multiply3x4(right);
return result;
}
Expand All @@ -319,7 +319,7 @@ public static RVec3 multiply(RMat44Arg left, RVec3Arg right) {
* @param right the right factor (not null, unaffected)
* @return a new vector
*/
public static RVec3 multiply(RMat44Arg left, Vec3Arg right) {
public static RVec3 star(RMat44Arg left, Vec3Arg right) {
RVec3 result = left.multiply3x4(right);
return result;
}
Expand All @@ -332,7 +332,7 @@ public static RVec3 multiply(RMat44Arg left, Vec3Arg right) {
* @param right the right factor (not null, unaffected)
* @return a new quaternion
*/
public static Quat multiply(QuatArg left, QuatArg right) {
public static Quat star(QuatArg left, QuatArg right) {
float lw = left.getW();
float lx = left.getX();
float ly = left.getY();
Expand Down Expand Up @@ -360,7 +360,7 @@ public static Quat multiply(QuatArg left, QuatArg right) {
* @param right the scale to apply
* @return a new vector
*/
public static Vec3 multiply(Vec3Arg left, float right) {
public static Vec3 star(Vec3Arg left, float right) {
float x = right * left.getX();
float y = right * left.getY();
float z = right * left.getZ();
Expand All @@ -377,7 +377,7 @@ public static Vec3 multiply(Vec3Arg left, float right) {
* @param right the 2nd vector (not null, unaffected)
* @return a new vector
*/
public static Vec3 multiply(Vec3Arg left, Vec3Arg right) {
public static Vec3 star(Vec3Arg left, Vec3Arg right) {
float x = left.getX() * right.getX();
float y = left.getY() * right.getY();
float z = left.getZ() * right.getZ();
Expand All @@ -393,7 +393,7 @@ public static Vec3 multiply(Vec3Arg left, Vec3Arg right) {
* @param right the input vector (not null, unaffected)
* @return a new vector
*/
public static Vec3 negate(Vec3Arg right) {
public static Vec3 minus(Vec3Arg right) {
float x = -right.getX();
float y = -right.getY();
float z = -right.getZ();
Expand Down Expand Up @@ -480,7 +480,7 @@ public static void plusEquals(Vec3 left, Vec3Arg right) {
* @param right the vector to apply it to (not null, unaffected)
* @return a new vector
*/
public static Vec3 rotate(QuatArg left, Vec3Arg right) {
public static Vec3 star(QuatArg left, Vec3Arg right) {
assert left.isNormalized();

float lw = left.getW();
Expand Down Expand Up @@ -528,7 +528,7 @@ public static void starEquals(Vec3 left, float right) {
* @param right the offset to subtract (not null, unaffected)
* @return a new vector
*/
public static RVec3 subtract(RVec3Arg left, RVec3Arg right) {
public static RVec3 minus(RVec3Arg left, RVec3Arg right) {
double xx = left.xx() - right.xx();
double yy = left.yy() - right.yy();
double zz = left.zz() - right.zz();
Expand All @@ -545,7 +545,7 @@ public static RVec3 subtract(RVec3Arg left, RVec3Arg right) {
* @param right the offset to subtract (not null, unaffected)
* @return a new vector
*/
public static RVec3 subtract(RVec3Arg left, Vec3Arg right) {
public static RVec3 minus(RVec3Arg left, Vec3Arg right) {
double xx = left.xx() - right.getX();
double yy = left.yy() - right.getY();
double zz = left.zz() - right.getZ();
Expand All @@ -562,7 +562,7 @@ public static RVec3 subtract(RVec3Arg left, Vec3Arg right) {
* @param right the vector to subtract (not null, unaffected)
* @return a new vector
*/
public static Vec3 subtract(Vec3Arg left, Vec3Arg right) {
public static Vec3 minus(Vec3Arg left, Vec3Arg right) {
float x = left.getX() - right.getX();
float y = left.getY() - right.getY();
float z = left.getZ() - right.getZ();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public void StartTest(PhysicsSystem inPhysicsSystem, EMotionQuality inMotionQu
JointState root = pose_copy.getJoint(0);
root.setTranslation (new Vec3(0, mVerticalSeparation * (i + 1), 0));
float angle = 2.0f * JPH_PI * (float)(i) / (float)(mPileSize);
root.setRotation ( Op.multiply(Quat.sRotation(Vec3.sAxisY(), angle) , root.getRotation()));
root.setRotation ( Op.star(Quat.sRotation(Vec3.sAxisY(), angle) , root.getRotation()));
pose_copy.calculateJointMatrices();

// Drive to pose
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/testjoltjni/app/samples/ShapeCreator.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ static ShapeRefC CreateTorusMesh(float inTorusRadius, float inTubeRadius, int in
{
// Create vertices
float tube_angle = (float)(tube_segment) * 2.0f * JPH_PI / inTubeSegments;
Vec3 pos = Op.multiply(rotation ,new Vec3(inTorusRadius + inTubeRadius * sin(tube_angle), inTubeRadius * cos(tube_angle), 0));
Vec3 pos = Op.star(rotation ,new Vec3(inTorusRadius + inTubeRadius * sin(tube_angle), inTubeRadius * cos(tube_angle), 0));
Float3 v=new Float3();
pos.storeFloat3(v);
mesh.addTriangleVertex(v);
Expand Down
10 changes: 5 additions & 5 deletions src/test/java/testjoltjni/app/samples/SoftBodyCreator.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ static SoftBodySharedSettingsRef CreateCloth(int inGridSizeX, int inGridSizeZ, f
for (int x = 0; x < inGridSizeX; ++x)
{
Vertex v=new Vertex();
Vec3 position = Op.add(inVertexPerturbation.apply(x, z) , new Vec3(cOffsetX + x * inGridSpacing, 0.0f, cOffsetZ + z * inGridSpacing));
Vec3 position = Op.plus(inVertexPerturbation.apply(x, z) , new Vec3(cOffsetX + x * inGridSpacing, 0.0f, cOffsetZ + z * inGridSpacing));
v.setPosition(position);
v.setInvMass ( inVertexGetInvMass.apply(x, z));
settings.addVertex(v);
Expand Down Expand Up @@ -107,7 +107,7 @@ static SoftBodySharedSettingsRef CreateCube(int inGridSize, float inGridSpacing)
for (int x = 0; x < inGridSize; ++x)
{
Vertex v=new Vertex();
v.setPosition(Op.add(cOffset , Op.multiply(Vec3.sReplicate(inGridSpacing), new Vec3((float)(x), (float)(y), (float)(z)))));
v.setPosition(Op.plus(cOffset , Op.star(Vec3.sReplicate(inGridSpacing), new Vec3((float)(x), (float)(y), (float)(z)))));
settings.addVertex(v);
}

Expand Down Expand Up @@ -249,14 +249,14 @@ static SoftBodySharedSettingsRef CreateSphere(float inRadius, int inNumTheta, in
// Doing it this way tests the pressure algorithm as it receives non-uniform triangles. Better is to use uniform triangles,
// see the use of DebugRenderer::Create8thSphere for an example.
Vertex v=new Vertex();
v.setPosition(Op.multiply(inRadius , Vec3.sUnitSpherical(0, 0)));
v.setPosition(Op.star(inRadius , Vec3.sUnitSpherical(0, 0)));
settings.addVertex(v);
v.setPosition(Op.multiply(inRadius , Vec3.sUnitSpherical(JPH_PI, 0)));
v.setPosition(Op.star(inRadius , Vec3.sUnitSpherical(JPH_PI, 0)));
settings.addVertex(v);
for (int theta = 1; theta < inNumTheta - 1; ++theta)
for (int phi = 0; phi < inNumPhi; ++phi)
{
v.setPosition(Op.multiply(inRadius , Vec3.sUnitSpherical(JPH_PI * theta / (inNumTheta - 1), 2.0f * JPH_PI * phi / inNumPhi)));
v.setPosition(Op.star(inRadius , Vec3.sUnitSpherical(JPH_PI * theta / (inNumTheta - 1), 2.0f * JPH_PI * phi / inNumPhi)));
settings.addVertex(v);
}

Expand Down
2 changes: 1 addition & 1 deletion src/test/java/testjoltjni/app/samples/Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public Body CreateFloor(float inSize)
{
final float scale = GetWorldScale();

Body floor = mBodyInterface.createBody(new BodyCreationSettings(new BoxShape(Op.multiply(scale,new Vec3(0.5f * inSize, 1.0f, 0.5f * inSize)), 0.0f),new RVec3(Op.multiply(scale,new Vec3(0.0f, -1.0f, 0.0f))), Quat.sIdentity(), EMotionType.Static, Layers.NON_MOVING));
Body floor = mBodyInterface.createBody(new BodyCreationSettings(new BoxShape(Op.star(scale,new Vec3(0.5f * inSize, 1.0f, 0.5f * inSize)), 0.0f),new RVec3(Op.star(scale,new Vec3(0.0f, -1.0f, 0.0f))), Quat.sIdentity(), EMotionType.Static, Layers.NON_MOVING));
mBodyInterface.addBody(floor.getId(), EActivation.DontActivate);
return floor;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ public void PrePhysicsUpdate( PreUpdateParams inParams)
{
// Create ray
DefaultRandomEngine random=new DefaultRandomEngine();
Vec3 from = Op.multiply(1000.0f , Vec3.sRandom(random));
RayCast ray = new RayCast(from, Op.multiply(-2.0f , from) );
Vec3 from = Op.star(1000.0f , Vec3.sRandom(random));
RayCast ray = new RayCast(from, Op.star(-2.0f , from) );

// Raycast before update
AllHitRayCastBodyCollector collector=new AllHitRayCastBodyCollector();
Expand All @@ -71,6 +71,6 @@ public void PrePhysicsUpdate( PreUpdateParams inParams)
// Draw results
for (int i = 0; i < num_hits; ++i)
DrawMarkerSP(mDebugRenderer, ray.getPointOnRay(results[i].getFraction()), Color.sGreen, 10.0f);
DrawLineSP(mDebugRenderer, ray.getOrigin(), Op.add(ray.getOrigin() , ray.getDirection()), Color.sRed);
DrawLineSP(mDebugRenderer, ray.getOrigin(), Op.plus(ray.getOrigin() , ray.getDirection()), Color.sRed);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public void PrePhysicsUpdate( PreUpdateParams inParams)
{
Body body = body_vector.get(body_selector.nextInt(mRandomGenerator));
assert(body.isInBroadPhase());
body.setPositionAndRotationInternal(Op.add(body.getPosition() , Op.multiply(translation_selector.nextFloat(mRandomGenerator) , Vec3.sRandom(mRandomGenerator))), Quat.sIdentity());
body.setPositionAndRotationInternal(Op.plus(body.getPosition() , Op.star(translation_selector.nextFloat(mRandomGenerator) , Vec3.sRandom(mRandomGenerator))), Quat.sIdentity());
bodies_to_move.set(i, body.getId());
}
mBroadPhase.notifyBodiesAabbChanged(bodies_to_move, cNumBodiesToMove);
Expand Down Expand Up @@ -103,8 +103,8 @@ public void PrePhysicsUpdate( PreUpdateParams inParams)

// Create ray
DefaultRandomEngine random=new DefaultRandomEngine();
Vec3 from = Op.multiply(1000.0f , Vec3.sRandom(random));
RayCast ray =new RayCast(from, Op.multiply(-2.0f , from) );
Vec3 from = Op.star(1000.0f , Vec3.sRandom(random));
RayCast ray =new RayCast(from, Op.star(-2.0f , from) );

// Raycast before update
AllHitRayCastBodyCollector hits_before=new AllHitRayCastBodyCollector();
Expand All @@ -114,7 +114,7 @@ public void PrePhysicsUpdate( PreUpdateParams inParams)
cout.printf("Before update: %d results found%n", num_before);

// Draw results
DrawLineSP(mDebugRenderer, ray.getOrigin(), Op.add(ray.getOrigin() , ray.getDirection()), Color.sRed);
DrawLineSP(mDebugRenderer, ray.getOrigin(), Op.plus(ray.getOrigin() , ray.getDirection()), Color.sRed);
for (int i = 0; i < num_before; ++i)
DrawMarkerSP(mDebugRenderer, ray.getPointOnRay(results_before[i].getFraction()), Color.sGreen, 10.0f);

Expand All @@ -135,7 +135,7 @@ public void PrePhysicsUpdate( PreUpdateParams inParams)
{
boolean found = false;
for (BroadPhaseCastResult rb : results_before)
if (Op.equals(ra.getBodyId() , rb.getBodyId()))
if (Op.isEqual(ra.getBodyId() , rb.getBodyId()))
{
found = true;
break;
Expand All @@ -149,7 +149,7 @@ public void PrePhysicsUpdate( PreUpdateParams inParams)
{
boolean found = false;
for (BroadPhaseCastResult r : results_after)
if (Op.equals(r.getBodyId() , b.getId()))
if (Op.isEqual(r.getBodyId() , b.getId()))
{
found = true;
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,12 @@ void CreateBalancedDistribution(BodyManager inBodyManager, int inNumBodies, floa
float n = (float)(inNumBodies);
Vec3 max_box_start = Vec3.sReplicate(inEnvironmentSize * (1.0f - pow(n, -1.0f / 3.0f)));
Vec3 min_box_size = Vec3.sReplicate(1.0f / inEnvironmentSize);
Vec3 max_box_size = Op.subtract(Vec3.sReplicate(inEnvironmentSize * pow(n, -1.0f / 3.0f)) , min_box_size);
Vec3 max_box_size = Op.minus(Vec3.sReplicate(inEnvironmentSize * pow(n, -1.0f / 3.0f)) , min_box_size);
for (int b = 0; b < inNumBodies; ++b)
{
AaBox box=new AaBox();
box.setMin ( Op.subtract(Op.multiply(max_box_start, new Vec3(zero_to_one.nextFloat(random), zero_to_one.nextFloat(random), zero_to_one.nextFloat(random))) , Vec3.sReplicate(0.5f * inEnvironmentSize)));
box.setMax ( Vec3.sum(box.getMin() , min_box_size , Op.multiply(max_box_size ,new Vec3(zero_to_one.nextFloat(random), zero_to_one.nextFloat(random), zero_to_one.nextFloat(random)))));
box.setMin ( Op.minus(Op.star(max_box_start, new Vec3(zero_to_one.nextFloat(random), zero_to_one.nextFloat(random), zero_to_one.nextFloat(random))) , Vec3.sReplicate(0.5f * inEnvironmentSize)));
box.setMax ( Vec3.sum(box.getMin() , min_box_size , Op.star(max_box_size ,new Vec3(zero_to_one.nextFloat(random), zero_to_one.nextFloat(random), zero_to_one.nextFloat(random)))));

BodyCreationSettings s=new BodyCreationSettings();
s.setShape(new BoxShape(box.getExtent(), 0.0f));
Expand Down
Loading

0 comments on commit 8549ae1

Please sign in to comment.