java.lang.Object
com.github.stephengold.joltjni.Jolt
Utility methods providing JNI access to Jolt Physics.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final floatdefault rounding of corners in convex shapes (in meters)static final intempty sub-shape IDstatic final intinvalid body IDstatic final intinvalid character IDstatic final intstandard 2nd argument to theJobSystemThreadPoolconstructorstatic final intstandard first argument to theJobSystemThreadPoolconstructorstatic final Objectgeneric null pointer (to expedite porting of C++ code)static final intindex of the X component, for swizzlingstatic final intindex of the Y component, for swizzlingstatic final intindex of the Z component, for swizzling -
Method Summary
Modifier and TypeMethodDescriptionstatic StringReturn the Jolt-JNI build-type string that's hard-coded in the native library.static intReturn the cumulative number ofdeleteoperations in glue code, in Debug native libraries.static intReturn the cumulative number ofnewoperations in glue code, in Debug native libraries, excluding ref targets.static voidDestroy the factory used for collision dispatch and object-stream serialization.static voidAppend a message to the determinism log.static longReturn the installed assert callback.static StringReturn a string describing some important configuration settings of the native library.static booleanTest whether the native library implements CPU-based compute systems, which are intended mainly for debugging.static booleanTest whether the native library implements compute systems based on Microsoft's DirectX 12 API.static booleanTest whether the native library implements compute systems based on Apple's Metal API.static booleanTest whether the native library implements compute systems based on Khronos's Vulkan API.static booleanTest whether the native library implements debug rendering.static booleanTest whether the native library implements extra logging to help debug determinism issues.static voidinstallAndroidTraceCallback(int priority, String tag) Install an alternative trace callback that sends to the Android log with the specified priority and tag.static voidinstallAssertCallback(long callbackVa) Install the specified assert callback.static voidInstall an alternative trace callback that writes tocerr.static voidInstall an alternative assert callback that crashes the JVM with an EXCEPTION_ACCESS_VIOLATION or SIGILL.static voidInstall the default assert callback, which writes tocoutand triggers a native breakpoint.static voidInstall the default trace callback, which writes tocout.static voidInstall an alternative assert callback that silently ignores assertions.static voidinstallJavaTraceCallback(PrintStream stream) Install an alternative trace callback that writes to the specifiedPrintStream.static booleanTest whether the native library uses double-precision location vectors.static ByteBufferloadResourceAsBytes(String resourceName) Load raw bytes from the named classpath resource.static ByteBuffernewDirectByteBuffer(int numBytes) Create a directByteBufferwith native byte order and the specified capacity.static DoubleBuffernewDirectDoubleBuffer(int numDoubles) Create a directDoubleBufferwith native byte order and the specified capacity.static FloatBuffernewDirectFloatBuffer(int numFloats) Create a directFloatBufferwith native byte order and the specified capacity.static IntBuffernewDirectIntBuffer(int numInts) Create a directIntBufferwith native byte order and the specified capacity.static LongBuffernewDirectLongBuffer(int numLongs) Create a directLongBufferwith native byte order and the specified capacity.static ShortBuffernewDirectShortBuffer(int numShorts) Create a directShortBufferwith native byte order and the specified capacity.static booleanCreate a factory for collision dispatch and object-stream serialization.static voidprofileDump(String message) Dump profiler data.static voidTerminate the profiler.static voidIncrement the profiler's frame counter.static voidprofileStart(String name) Start an instrumented code section.static voidregisterCustomAllocator(long allocateVa, long reallocateVa, long freeVa, long alignedAllocateVa, long alignedFreeVa) Register the allocation hook to use the specified functions.static voidRegister the allocation hook to use malloc/free.static voidRegisterHairSettingswith the factory.static voidRegister all physics types exceptHairSettingswith the factory and install their collision handlers.static voidsetTraceAllocations(boolean setting) Enable or disable allocation tracing in Debug native libraries.static booleanTest whether the native library supports the ObjectStream format.static voidExecute a test written in native code.static voidUnregister all physics types with the factory.static StringReturn the Jolt-JNI version string that's hard-coded into the native library.
-
Field Details
-
cDefaultConvexRadius
public static final float cDefaultConvexRadiusdefault rounding of corners in convex shapes (in meters)value should match Jolt/Physics/PhysicsSettings.h
- See Also:
-
cEmptySubShapeId
public static final int cEmptySubShapeIdempty sub-shape IDvalue should match Jolt/Physics/Collision/Shape/SubShapeID.h
- See Also:
-
cInvalidBodyId
public static final int cInvalidBodyIdinvalid body IDvalue should match Jolt/Physics/Body/BodyID.h
- See Also:
-
cInvalidCharacterId
public static final int cInvalidCharacterIdinvalid character IDvalue should match Jolt/Physics/Character/CharacterID.h
- See Also:
-
cMaxPhysicsBarriers
public static final int cMaxPhysicsBarriersstandard 2nd argument to theJobSystemThreadPoolconstructorvalue should match Jolt/Physics/PhysicsSettings.h
- See Also:
-
cMaxPhysicsJobs
public static final int cMaxPhysicsJobsstandard first argument to theJobSystemThreadPoolconstructorvalue should match Jolt/Physics/PhysicsSettings.h
- See Also:
-
SWIZZLE_X
public static final int SWIZZLE_Xindex of the X component, for swizzling- See Also:
-
SWIZZLE_Y
public static final int SWIZZLE_Yindex of the Y component, for swizzling- See Also:
-
SWIZZLE_Z
public static final int SWIZZLE_Zindex of the Z component, for swizzling- See Also:
-
nullptr
generic null pointer (to expedite porting of C++ code)
-
-
Method Details
-
buildType
Return the Jolt-JNI build-type string that's hard-coded in the native library.- Returns:
- either "Debug" or "Release"
-
countDeletes
public static int countDeletes()Return the cumulative number ofdeleteoperations in glue code, in Debug native libraries.- Returns:
- the count (≥0)
-
countNews
public static int countNews()Return the cumulative number ofnewoperations in glue code, in Debug native libraries, excluding ref targets.- Returns:
- the count (≥0)
-
destroyFactory
public static void destroyFactory()Destroy the factory used for collision dispatch and object-stream serialization.- See Also:
-
detLog
Append a message to the determinism log. (native macro: JPH_DET_LOG)- Parameters:
message- (notnull)
-
getAssertCallback
public static long getAssertCallback()Return the installed assert callback.- Returns:
- the virtual address of the callback, or zero if none
- See Also:
-
getConfigurationString
Return a string describing some important configuration settings of the native library. (see Jolt/ConfigurationString.h)- Returns:
- the string value
-
implementsComputeCpu
public static boolean implementsComputeCpu()Test whether the native library implements CPU-based compute systems, which are intended mainly for debugging. (native macro: JPH_USE_CPU_COMPUTE)- Returns:
trueif implemented, otherwisefalse
-
implementsComputeDx12
public static boolean implementsComputeDx12()Test whether the native library implements compute systems based on Microsoft's DirectX 12 API. (native macro: JPH_USE_DX12)- Returns:
trueif implemented, otherwisefalse
-
implementsComputeMtl
public static boolean implementsComputeMtl()Test whether the native library implements compute systems based on Apple's Metal API. (native macro: JPH_USE_MTL)- Returns:
trueif implemented, otherwisefalse
-
implementsComputeVk
public static boolean implementsComputeVk()Test whether the native library implements compute systems based on Khronos's Vulkan API. (native macro: JPH_USE_VK)- Returns:
trueif implemented, otherwisefalse
-
implementsDebugRendering
public static boolean implementsDebugRendering()Test whether the native library implements debug rendering. (native macro: JPH_DEBUG_RENDERER)- Returns:
trueif implemented, otherwisefalse
-
implementsDeterminismLog
public static boolean implementsDeterminismLog()Test whether the native library implements extra logging to help debug determinism issues. (native macro: JPH_ENABLE_DETERMINISM_LOG)- Returns:
trueif implemented, otherwisefalse
-
installAndroidTraceCallback
Install an alternative trace callback that sends to the Android log with the specified priority and tag.- Parameters:
priority- the desired priority of trace output in the logtag- the log tag to identify trace output (may benull)
-
installAssertCallback
public static void installAssertCallback(long callbackVa) Install the specified assert callback.- Parameters:
callbackVa- the virtual address of the desired callback- See Also:
-
installCerrTraceCallback
public static void installCerrTraceCallback()Install an alternative trace callback that writes tocerr. -
installCrashAssertCallback
public static void installCrashAssertCallback()Install an alternative assert callback that crashes the JVM with an EXCEPTION_ACCESS_VIOLATION or SIGILL. Intended for testing only! -
installDefaultAssertCallback
public static void installDefaultAssertCallback()Install the default assert callback, which writes tocoutand triggers a native breakpoint. -
installDefaultTraceCallback
public static void installDefaultTraceCallback()Install the default trace callback, which writes tocout. -
installIgnoreAssertCallback
public static void installIgnoreAssertCallback()Install an alternative assert callback that silently ignores assertions. -
installJavaTraceCallback
Install an alternative trace callback that writes to the specifiedPrintStream.- Parameters:
stream- where to send trace output (notnull)
-
isDoublePrecision
public static boolean isDoublePrecision()Test whether the native library uses double-precision location vectors. (native macro: JPH_DOUBLE_PRECISION)- Returns:
trueif double-precision, otherwisefalse
-
loadResourceAsBytes
Load raw bytes from the named classpath resource.- Parameters:
resourceName- the name of the resource (notnull)- Returns:
- a new direct buffer
-
newDirectByteBuffer
Create a directByteBufferwith native byte order and the specified capacity.- Parameters:
numBytes- the desired capacity (in bytes)- Returns:
- a new direct buffer, zeroed and rewound but not flipped
-
newDirectDoubleBuffer
Create a directDoubleBufferwith native byte order and the specified capacity.- Parameters:
numDoubles- the desired capacity (in doubles)- Returns:
- a new direct buffer, zeroed and rewound but not flipped
-
newDirectFloatBuffer
Create a directFloatBufferwith native byte order and the specified capacity.- Parameters:
numFloats- the desired capacity (in floats)- Returns:
- a new direct buffer, zeroed and rewound but not flipped
-
newDirectIntBuffer
Create a directIntBufferwith native byte order and the specified capacity.- Parameters:
numInts- the desired capacity (in ints)- Returns:
- a new direct buffer, zeroed and rewound but not flipped
-
newDirectLongBuffer
Create a directLongBufferwith native byte order and the specified capacity.- Parameters:
numLongs- the desired capacity (in longs)- Returns:
- a new direct buffer, zeroed and rewound but not flipped
-
newDirectShortBuffer
Create a directShortBufferwith native byte order and the specified capacity.- Parameters:
numShorts- the desired capacity (in shorts)- Returns:
- a new direct buffer, zeroed and rewound but not flipped
-
newFactory
public static boolean newFactory()Create a factory for collision dispatch and object-stream serialization.- Returns:
trueif successful, otherwisefalse- See Also:
-
profileDump
Dump profiler data. (native macro: JPH_PROFILE_DUMP)- Parameters:
message- (notnull)
-
profileEnd
public static void profileEnd()Terminate the profiler. (native macro: JPH_PROFILE_END) -
profileNextFrame
public static void profileNextFrame()Increment the profiler's frame counter. (native macro: JPH_PROFILE_NEXTFRAME) -
profileStart
Start an instrumented code section. (native macro: JPH_PROFILE_START)- Parameters:
name- the section name (notnull)
-
registerCustomAllocator
public static void registerCustomAllocator(long allocateVa, long reallocateVa, long freeVa, long alignedAllocateVa, long alignedFreeVa) Register the allocation hook to use the specified functions. This must be done before any other Jolt function is called.- Parameters:
allocateVa- the virtual address of the desired Allocate functionreallocateVa- the virtual address of the desired Reallocate functionfreeVa- the virtual address of the desired Free functionalignedAllocateVa- the virtual address of the desired AlignedAllocate functionalignedFreeVa- the virtual address of the desired AlignedFree function
-
registerDefaultAllocator
public static void registerDefaultAllocator()Register the allocation hook to use malloc/free. This must be done before any other Jolt function is called. (see Jolt/Core/Memory.cpp) -
registerHair
public static void registerHair()RegisterHairSettingswith the factory. (see Jolt/RegisterTypes.h)- See Also:
-
registerTypes
public static void registerTypes()Register all physics types exceptHairSettingswith the factory and install their collision handlers. (see Jolt/RegisterTypes.h)- See Also:
-
setTraceAllocations
public static void setTraceAllocations(boolean setting) Enable or disable allocation tracing in Debug native libraries.- Parameters:
setting-trueto enable tracing,falseto disable it (default=false)
-
supportsObjectStream
public static boolean supportsObjectStream()Test whether the native library supports the ObjectStream format. (native macro: JPH_OBJECT_STREAM)- Returns:
trueif supported, otherwisefalse
-
test000
Execute a test written in native code. Intended for testing only.- Parameters:
args- command-line arguments
-
unregisterTypes
public static void unregisterTypes()Unregister all physics types with the factory. (see Jolt/RegisterTypes.h)- See Also:
-
versionString
Return the Jolt-JNI version string that's hard-coded into the native library.- Returns:
- the version string (not
null, not empty)
-