Skip to content

Commit e6118bc

Browse files
committed
ConstVehicleConstraint: add the getWheel() method
1 parent baa6bfe commit e6118bc

File tree

3 files changed

+42
-17
lines changed

3 files changed

+42
-17
lines changed

src/main/java/com/github/stephengold/joltjni/VehicleConstraint.java

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -130,22 +130,6 @@ public VehicleCollisionTester getVehicleCollisionTester() {
130130
return tester;
131131
}
132132

133-
/**
134-
* Access the specified wheel.
135-
*
136-
* @param wheelIndex the index of the wheel to access (≥0)
137-
* @return a new JVM object with the pre-existing native object assigned
138-
*/
139-
public Wheel getWheel(int wheelIndex) {
140-
long constraintVa = va();
141-
long wheelVa = getWheel(constraintVa, wheelIndex);
142-
int ordinal = Constraint.getControllerType(constraintVa);
143-
VehicleConstraintRef ref = toRef();
144-
Wheel result = Wheel.newWheel(wheelVa, ordinal, ref);
145-
146-
return result;
147-
}
148-
149133
/**
150134
* Override the vehicle's gravity vector.
151135
*
@@ -356,6 +340,23 @@ public int getNumStepsBetweenCollisionTestInactive() {
356340
return result;
357341
}
358342

343+
/**
344+
* Access the specified wheel.
345+
*
346+
* @param wheelIndex the index of the wheel to access (≥0)
347+
* @return a new JVM object with the pre-existing native object assigned
348+
*/
349+
@Override
350+
public Wheel getWheel(int wheelIndex) {
351+
long constraintVa = va();
352+
long wheelVa = getWheel(constraintVa, wheelIndex);
353+
int ordinal = Constraint.getControllerType(constraintVa);
354+
VehicleConstraintRef ref = toRef();
355+
Wheel result = Wheel.newWheel(wheelVa, ordinal, ref);
356+
357+
return result;
358+
}
359+
359360
/**
360361
* Copy the basis vectors for the specified wheel.
361362
*
@@ -527,7 +528,7 @@ native static int getNumStepsBetweenCollisionTestInactive(
527528

528529
native private static long getVehicleCollisionTester(long constraintVa);
529530

530-
native private static long getWheel(long constraintVa, int wheelIndex);
531+
native static long getWheel(long constraintVa, int wheelIndex);
531532

532533
native static void getWheelLocalBasis(
533534
long constraintVa, long wheelVa, FloatBuffer storeFloats);

src/main/java/com/github/stephengold/joltjni/VehicleConstraintRef.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,22 @@ public EConstraintType getType() {
331331
return result;
332332
}
333333

334+
/**
335+
* Access the specified wheel.
336+
*
337+
* @param wheelIndex the index of the wheel to access (≥0)
338+
* @return a new JVM object with the pre-existing native object assigned
339+
*/
340+
@Override
341+
public Wheel getWheel(int wheelIndex) {
342+
long constraintVa = targetVa();
343+
long wheelVa = VehicleConstraint.getWheel(constraintVa, wheelIndex);
344+
int ordinal = Constraint.getControllerType(constraintVa);
345+
Wheel result = Wheel.newWheel(wheelVa, ordinal, this);
346+
347+
return result;
348+
}
349+
334350
/**
335351
* Copy the basis vectors for the specified wheel.
336352
*

src/main/java/com/github/stephengold/joltjni/readonly/ConstVehicleConstraint.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,14 @@ public interface ConstVehicleConstraint extends ConstConstraint {
102102
*/
103103
int getNumStepsBetweenCollisionTestInactive();
104104

105+
/**
106+
* Access the specified wheel. The constraint is unaffected.
107+
*
108+
* @param wheelIndex the index of the wheel to access (≥0)
109+
* @return a new JVM object with the pre-existing native object assigned
110+
*/
111+
ConstWheel getWheel(int wheelIndex);
112+
105113
/**
106114
* Copy the basis vectors for the specified wheel.
107115
*

0 commit comments

Comments
 (0)