Class Jolt

java.lang.Object
com.github.stephengold.joltjni.Jolt

public final class Jolt extends Object
Utility methods providing JNI access to Jolt Physics.
  • Field Details

    • JPH_PI

      public static final float JPH_PI
      single-precision value of Pi
      See Also:
    • cMaxPhysicsBarriers

      public static final int cMaxPhysicsBarriers
      standard 2nd argument to the JobSystemThreadPool constructor

      value should match Jolt/Physics/PhysicsSettings.h

      See Also:
    • cMaxPhysicsJobs

      public static final int cMaxPhysicsJobs
      standard first argument to the JobSystemThreadPool constructor

      value should match Jolt/Physics/PhysicsSettings.h

      See Also:
  • Method Details

    • buildType

      public static String buildType()
      Return the jolt-jni build-type string.
      Returns:
      either "Debug" or "Release"
    • degreesToRadians

      public static float degreesToRadians(float degrees)
      Convert the specified angle from degrees to radians.
      Parameters:
      degrees - the angle to convert (in degrees)
      Returns:
      the converted angle (in radians)
    • destroyFactory

      public static void destroyFactory()
      Destroy the factory for deserialization of saved data.
      See Also:
    • detLog

      public static void detLog(String message)
      Append a message to the determinism log.
      Parameters:
      message - (not null)
    • getConfigurationString

      public static String getConfigurationString()
      Return a string containing important configuration settings.
      Returns:
      the string value
    • hashBytes

      public static long hashBytes(long dataVa, int inSize)
      Return a hash code for the specified data bytes.
      Parameters:
      dataVa - the virtual address of the data, or 0 for no data
      inSize - the number of data bytes, or 0 for no data
      Returns:
      the hash code
    • hashBytes

      public static long hashBytes(Quat quaternion, long oldHash)
      Combine the specified quaternion with the specified hash code.
      Parameters:
      quaternion - the quaternion to combine (not null, unaffected)
      oldHash - the old hash code
      Returns:
      the new hash code
    • hashBytes

      public static long hashBytes(RVec3 vector, long oldHash)
      Combine the specified vector with the specified hash code.
      Parameters:
      vector - the vector to combine (not null, unaffected)
      oldHash - the old hash code
      Returns:
      the new hash code
    • implementsDebugRendering

      public static boolean implementsDebugRendering()
      Test whether the native library implements debug rendering. (native macro: JPH_DEBUG_RENDERER)
      Returns:
      true if implemented, otherwise false
    • implementsDeterminismLog

      public static boolean implementsDeterminismLog()
      Test whether the native library implements extra logging to help debug determinism issues. (native macro: JPH_DET_LOG)
      Returns:
      true if implemented, otherwise false
    • installDefaultAssertCallback

      public static void installDefaultAssertCallback()
      Install the default assert callback.
    • installDefaultTraceCallback

      public static void installDefaultTraceCallback()
      Install the default trace callback.
    • isDoublePrecision

      public static boolean isDoublePrecision()
      Test whether the native library uses double-precision location vectors. (native macro: JPH_DOUBLE_PRECISION)
      Returns:
      true if double-precision, otherwise false
    • newDirectFloatBuffer

      public static FloatBuffer newDirectFloatBuffer(int numFloats)
      Create a direct FloatBuffer with 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

      public static IntBuffer newDirectIntBuffer(int numInts)
      Create a direct IntBuffer with native byte order and the specified capacity.
      Parameters:
      numInts - the desired capacity (in floats)
      Returns:
      a new direct buffer, zeroed and rewound but not flipped
    • profileDump

      public static void profileDump(String message)
      Dump profiler data.
      Parameters:
      message - (not null)
    • profileEnd

      public static void profileEnd()
      Terminate the profiler.
    • profileNextFrame

      public static void profileNextFrame()
      Increment profiler's frame counter.
    • profileStart

      public static void profileStart(String name)
      Start an instrumented code section.
      Parameters:
      name - the section name (not null)
    • newFactory

      public static void newFactory()
      Create a factory for deserialization of saved data.
      See Also:
    • radiansToDegrees

      public static float radiansToDegrees(float radians)
      Convert the specified angle from radians to degrees.
      Parameters:
      radians - the angle to convert (in radians)
      Returns:
      the converted angle (in degrees)
    • rayAaBoxHits

      public static boolean rayAaBoxHits(Vec3Arg startLocation, Vec3Arg offset, Vec3Arg minimum, Vec3Arg maximum)
      Intersect the specified axis-aligned box with the specified ray.
      Parameters:
      startLocation - the desired start location (not null, unaffected)
      offset - the desired end offset from the start (not null, unaffected)
      minimum - the minimum coordinates of the box (not null, unaffected)
      maximum - the maximum coordinates of the box (not null, unaffected)
      Returns:
      true if there is a hit
    • registerDefaultAllocator

      public static void registerDefaultAllocator()
      Register the allocation hook to use malloc/free. This must be done before any other Jolt function is called.
    • registerTypes

      public static void registerTypes()
      Register all physics types with the factory and install their collision handlers.
      See Also:
    • setTraceAllocations

      public static void setTraceAllocations(boolean setting)
      Enable or disable allocation tracing in Debug native libraries.
      Parameters:
      setting - true to enable tracing, false to disable it (default=false)
    • supportsObjectStream

      public static boolean supportsObjectStream()
      Test whether the native library supports the ObjectStream format. (native macro: JPH_OBJECT_STREAM)
      Returns:
      true if supported, otherwise false
    • unregisterTypes

      public static void unregisterTypes()
      Unregister all physics types with the factory.
      See Also:
    • versionString

      public static String versionString()
      Return the jolt-jni version string.
      Returns:
      the version string (not null, not empty)