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

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

    Fields
    Modifier and Type
    Field
    Description
    static final float
    default rounding of corners in convex shapes (in meters)
    static final int
    empty sub-shape ID
    static final int
    invalid body ID
    static final int
    standard 2nd argument to the JobSystemThreadPool constructor
    static final int
    standard first argument to the JobSystemThreadPool constructor
    static final float
    single-precision value of Pi
    static final Object
    generic null pointer (to expedite translation of C++ code)
    static final int
    index of the X component, for swizzling
    static final int
    index of the Y component, for swizzling
    static final int
    index of the Z component, for swizzling
  • Method Summary

    Modifier and Type
    Method
    Description
    static float
    aCos(float ratio)
    Return the inverse cosine of the specified single-precision ratio.
    static float
    aTan(float ratio)
    Return the inverse tangent of the specified single-precision ratio.
    static float
    aTan2(float opposite, float adjacent)
    Return the angle of the specified single-precision right triangle.
    static String
    Return the Jolt-JNI build-type string that's hard-coded in the native library.
    static float
    cos(float angle)
    Return the cosine of the specified single-precision angle.
    static float
    degreesToRadians(float degrees)
    Convert the specified angle from degrees to radians.
    static void
    Destroy the factory for deserialization of saved data.
    static void
    detLog(String message)
    Append a message to the determinism log.
    static String
    Return a string containing important configuration settings.
    static long
    hashBytes(long dataVa, int inSize)
    Return a hash code for the specified data bytes.
    static long
    hashBytes(QuatArg quaternion, long oldHash)
    Combine the specified quaternion with the specified hash code.
    static long
    hashBytes(RVec3Arg vector, long oldHash)
    Combine the specified vector with the specified hash code.
    static long
    hashCombine(long oldHash, int iValue)
    Combine the specified 32-bit integer with the specified hash code.
    static long
    hashCombine(long oldHash, long lValue)
    Combine the specified 64-bit integer with the specified hash code.
    static long
    hashCombine(long oldHash, RVec3Arg vector)
    Combine the specified location vector with the specified hash code.
    static long
    hashCombine(long oldHash, Vec3Arg vec)
    Combine the specified vector with the specified hash code.
    static boolean
    Test whether the native library implements debug rendering.
    static boolean
    Test whether the native library implements extra logging to help debug determinism issues.
    static void
    Install the default assert callback.
    static void
    Install the default trace callback.
    static boolean
    Test whether the native library uses double-precision location vectors.
    static ByteBuffer
    newDirectByteBuffer(int numBytes)
    Create a direct ByteBuffer with the specified capacity.
    newDirectDoubleBuffer(int numDoubles)
    Create a direct DoubleBuffer with native byte order and the specified capacity.
    newDirectFloatBuffer(int numFloats)
    Create a direct FloatBuffer with native byte order and the specified capacity.
    static IntBuffer
    newDirectIntBuffer(int numInts)
    Create a direct IntBuffer with native byte order and the specified capacity.
    newDirectShortBuffer(int numShorts)
    Create a direct ShortBuffer with native byte order and the specified capacity.
    static boolean
    Create a factory for deserialization of saved data.
    static float
    perlinNoise3(float x, float y, float z, int xWrap, int yWrap, int zWrap)
    Generate 3-D Perlin noise.
    static void
    Dump profiler data.
    static void
    Terminate the profiler.
    static void
    Increment the profiler's frame counter.
    static void
    Start an instrumented code section.
    static float
    radiansToDegrees(float radians)
    Convert the specified angle from radians to degrees.
    static boolean
    rayAaBoxHits(Vec3Arg startLocation, Vec3Arg offset, Vec3Arg minimum, Vec3Arg maximum)
    Intersect the specified axis-aligned box with the specified ray.
    static void
    Register the allocation hook to use malloc/free.
    static void
    Register all physics types with the factory and install their collision handlers.
    static void
    setTraceAllocations(boolean setting)
    Enable or disable allocation tracing in Debug native libraries.
    static float
    sign(float input)
    Return the (binary) sign of the specified single-precision value.
    static float
    sin(float angle)
    Return the sine of the specified single-precision angle.
    static float
    square(float value)
    Return the square of the specified single-precision value.
    static int
    square(int value)
    Return the square of the specified integer value.
    static void
    Set the next available character ID to 1.
    static void
    sSetNextCharacterId(int nextValue)
    Set the next available character ID to the specified value.
    static boolean
    Test whether the native library supports the ObjectStream format.
    static float
    tan(float angle)
    Return the tangent ratio of the specified single-precision angle.
    static void
    Unregister all physics types with the factory.
    static String
    Return the Jolt-JNI version string that's hard-coded in the native library.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • cDefaultConvexRadius

      public static final float cDefaultConvexRadius
      default rounding of corners in convex shapes (in meters)
      See Also:
    • JPH_PI

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

      public static final int cEmptySubShapeId
      empty sub-shape ID

      value should match Jolt/Physics/Collision/Shape/SubShapeID.h

      See Also:
    • cInvalidBodyId

      public static final int cInvalidBodyId
      invalid body ID

      value should match Jolt/Physics/Body/BodyID.h

      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:
    • SWIZZLE_X

      public static final int SWIZZLE_X
      index of the X component, for swizzling
      See Also:
    • SWIZZLE_Y

      public static final int SWIZZLE_Y
      index of the Y component, for swizzling
      See Also:
    • SWIZZLE_Z

      public static final int SWIZZLE_Z
      index of the Z component, for swizzling
      See Also:
    • nullptr

      public static final Object nullptr
      generic null pointer (to expedite translation of C++ code)
  • Method Details

    • aCos

      public static float aCos(float ratio)
      Return the inverse cosine of the specified single-precision ratio.
      Parameters:
      ratio - the input cosine ratio (≥-1, ≤1)
      Returns:
      the angle (in radians)
    • aTan

      public static float aTan(float ratio)
      Return the inverse tangent of the specified single-precision ratio.
      Parameters:
      ratio - the input tangent ratio
      Returns:
      the angle (in radians)
    • aTan2

      public static float aTan2(float opposite, float adjacent)
      Return the angle of the specified single-precision right triangle.
      Parameters:
      opposite - the signed length of the opposite side
      adjacent - the signed length of the adjacent side
      Returns:
      the angle (in radians)
    • buildType

      public static String buildType()
      Return the Jolt-JNI build-type string that's hard-coded in the native library.
      Returns:
      either "Debug" or "Release"
    • cos

      public static float cos(float angle)
      Return the cosine of the specified single-precision angle.
      Parameters:
      angle - the input angle (in radians)
      Returns:
      the cosine ratio
    • 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(QuatArg 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(RVec3Arg 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
    • hashCombine

      public static long hashCombine(long oldHash, int iValue)
      Combine the specified 32-bit integer with the specified hash code.
      Parameters:
      oldHash - the old hash code
      iValue - the integer value to combine
      Returns:
      the new hash code
    • hashCombine

      public static long hashCombine(long oldHash, long lValue)
      Combine the specified 64-bit integer with the specified hash code.
      Parameters:
      oldHash - the old hash code
      lValue - the integer value to combine
      Returns:
      the new hash code
    • hashCombine

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

      public static long hashCombine(long oldHash, Vec3Arg vec)
      Combine the specified vector with the specified hash code.
      Parameters:
      oldHash - the old hash code
      vec - the vector to combine (not null, unaffected)
      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
    • newDirectByteBuffer

      public static ByteBuffer newDirectByteBuffer(int numBytes)
      Create a direct ByteBuffer with the specified capacity.
      Parameters:
      numBytes - the desired capacity (in bytes)
      Returns:
      a new direct buffer, zeroed and rewound but not flipped
    • 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
    • newDirectDoubleBuffer

      public static DoubleBuffer newDirectDoubleBuffer(int numDoubles)
      Create a direct DoubleBuffer with 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
    • 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 ints)
      Returns:
      a new direct buffer, zeroed and rewound but not flipped
    • newDirectShortBuffer

      public static ShortBuffer newDirectShortBuffer(int numShorts)
      Create a direct ShortBuffer with native byte order and the specified capacity.
      Parameters:
      numShorts - the desired capacity (in ints)
      Returns:
      a new direct buffer, zeroed and rewound but not flipped
    • perlinNoise3

      public static float perlinNoise3(float x, float y, float z, int xWrap, int yWrap, int zWrap)
      Generate 3-D Perlin noise.
      Parameters:
      x - the X coordinate
      y - the Y coordinate
      z - the Z coordinate
      xWrap - the wraparound interval for the X coordinate (power of 2) or 0 for don't care
      yWrap - the wraparound interval for the Y coordinate (power of 2) or 0 for don't care
      zWrap - the wraparound interval for the Z coordinate (power of 2) or 0 for don't care
      Returns:
      a sample value
    • 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 the 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 boolean newFactory()
      Create a factory for deserialization of saved data.
      Returns:
      true if successful, otherwise false
      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)
    • sign

      public static float sign(float input)
      Return the (binary) sign of the specified single-precision value.
      Parameters:
      input - the input value
      Returns:
      -1 if the input is negative, otherwise +1
    • sin

      public static float sin(float angle)
      Return the sine of the specified single-precision angle.
      Parameters:
      angle - the input angle (in radians)
      Returns:
      the sine ratio
    • square

      public static float square(float value)
      Return the square of the specified single-precision value.
      Parameters:
      value - the input value
      Returns:
      the square
    • square

      public static int square(int value)
      Return the square of the specified integer value.
      Parameters:
      value - the input value
      Returns:
      the square
    • sSetNextCharacterId

      public static void sSetNextCharacterId()
      Set the next available character ID to 1.
    • sSetNextCharacterId

      public static void sSetNextCharacterId(int nextValue)
      Set the next available character ID to the specified value.
      Parameters:
      nextValue - the desired next ID
    • 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
    • tan

      public static float tan(float angle)
      Return the tangent ratio of the specified single-precision angle.
      Parameters:
      angle - the input angle (in radians)
      Returns:
      the tangent ratio
    • 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 that's hard-coded in the native library.
      Returns:
      the version string (not null, not empty)