Skip to content

Commit

Permalink
Utils: add the loadAndInitializeNativeLibrary() method
Browse files Browse the repository at this point in the history
  • Loading branch information
stephengold committed Jul 12, 2024
1 parent 099e427 commit 864fa20
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 27 deletions.
23 changes: 23 additions & 0 deletions src/test/java/testjoltjni/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,29 @@ public static void assertEquals(
Assert.assertEquals("z component", z, actual.getZ(), tolerance);
}

/**
* Load and initialize some flavor of native library.
*/
public static void loadAndInitializeNativeLibrary() {
loadNativeLibrary();

String buildType = Jolt.buildType();
if (!buildType.equals("Release")) {
System.out.print(buildType + "-");
}
if (Jolt.isDoublePrecision()) {
System.out.print("Dp-");
}
System.out.println(
"jolt-jni version " + Jolt.versionString() + " initializing");

Jolt.registerDefaultAllocator();
Jolt.installDefaultTraceCallback();
Jolt.installDefaultAssertCallback();
Jolt.newFactory();
Jolt.registerTypes();
}

/**
* Load some flavor of Debug native library.
* <p>
Expand Down
7 changes: 1 addition & 6 deletions src/test/java/testjoltjni/app/ConvexVsMeshScene.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,7 @@ public class ConvexVsMeshScene {
private static final int BP_LAYER_MOVING = 1;
private static final int BP_NUM_LAYERS = 2;
public static void main(String[] argv) {
Utils.loadNativeLibrary();
Jolt.registerDefaultAllocator();
Jolt.installDefaultTraceCallback();
Jolt.installDefaultAssertCallback();
Jolt.newFactory();
Jolt.registerTypes();
Utils.loadAndInitializeNativeLibrary();
TempAllocatorImpl temp_allocator = new TempAllocatorImpl(32 << 20); // 32 MiB
JobSystemThreadPool job_system = new JobSystemThreadPool(Jolt.cMaxPhysicsJobs, Jolt.cMaxPhysicsBarriers, Utils.numThreads());
final int cMaxBodies = 1_800;
Expand Down
8 changes: 1 addition & 7 deletions src/test/java/testjoltjni/junit/Test001.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,7 @@ public class Test001 {
*/
@Test
public void test001() {
Utils.loadNativeLibrary();

Jolt.registerDefaultAllocator();
Jolt.installDefaultTraceCallback();
Jolt.installDefaultAssertCallback();
Jolt.newFactory();
Jolt.registerTypes();
Utils.loadAndInitializeNativeLibrary();

// object layers:
final int objLayerNonMoving = 0;
Expand Down
8 changes: 1 addition & 7 deletions src/test/java/testjoltjni/junit/Test002.java
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,7 @@ public class Test002 {
*/
@Test
public void test002() {
Utils.loadNativeLibrary();

Jolt.registerDefaultAllocator();
Jolt.installDefaultTraceCallback();
Jolt.installDefaultAssertCallback();
Jolt.newFactory();
Jolt.registerTypes();
Utils.loadAndInitializeNativeLibrary();

// broadphase layers:
int bpLayerNonMoving = 0;
Expand Down
8 changes: 1 addition & 7 deletions src/test/java/testjoltjni/junit/Test003.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,7 @@ public class Test003 {
*/
@Test
public void test003() {
Utils.loadNativeLibrary();

Jolt.registerDefaultAllocator();
Jolt.installDefaultTraceCallback();
Jolt.installDefaultAssertCallback();
Jolt.newFactory();
Jolt.registerTypes();
Utils.loadAndInitializeNativeLibrary();

// AaBox:
{
Expand Down

0 comments on commit 864fa20

Please sign in to comment.