java.lang.Object
com.github.stephengold.joltjni.MiscUtil
Seldom-used utility methods. Most of these relate to character IDs, collision
estimation, hashing, and ray intersections.
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidestimateCollisionResponse(ConstBody body1, ConstBody body2, ConstContactManifold manifold, CollisionEstimationResult storeResult, float combinedFriction, float combinedRestitution) Estimate the contact impulses and body velocity changes resulting from a collision.static voidestimateCollisionResponse(ConstBody body1, ConstBody body2, ConstContactManifold manifold, CollisionEstimationResult storeResult, float combinedFriction, float combinedRestitution, float minVelocity) Estimate the contact impulses and body velocity changes resulting from a collision.static voidestimateCollisionResponse(ConstBody body1, ConstBody body2, ConstContactManifold manifold, CollisionEstimationResult storeResult, float combinedFriction, float combinedRestitution, float minVelocity, int numIterations) Estimate the contact impulses and body velocity changes resulting from a collision.static longhashBytes(long dataVa, int inSize) Return a hash code for the specified data bytes.static longCombine the specified quaternion with the specified hash code.static longCombine the specified vector with the specified hash code.static longhashCombine(long oldHash, int iValue) Combine the specified 32-bit integer with the specified hash code.static longhashCombine(long oldHash, long lValue) Combine the specified 64-bit integer with the specified hash code.static longhashCombine(long oldHash, RVec3Arg vector) Combine the specified location vector with the specified hash code.static longhashCombine(long oldHash, Vec3Arg vector) Combine the specified vector with the specified hash code.listClasses(String packageName) List all classes in the specified Jolt-JNI package.static floatperlinNoise3(float x, float y, float z, int xWrap, int yWrap, int zWrap) Generate 3-D Perlin noise.static floatrayAaBox(Vec3Arg rayOrigin, RayInvDirection invDirection, Vec3Arg minimum, Vec3Arg maximum) Intersect the specified axis-aligned box with the specified ray.static booleanrayAaBoxHits(Vec3Arg startLocation, Vec3Arg offset, Vec3Arg minimum, Vec3Arg maximum) Intersect the specified axis-aligned box with the specified ray.static floatrayCapsule(Vec3Arg rayOrigin, Vec3Arg rayDirection, float capsuleHalfHeight, float capsuleRadius) Intersect the specified capsule with the specified ray.static floatrayCylinder(Vec3Arg rayOrigin, Vec3Arg rayDirection, float cylinderRadius) Intersect the specified infinite cylinder with the specified ray.static floatrayCylinder(Vec3Arg rayOrigin, Vec3Arg rayDirection, float cylinderHalfHeight, float cylinderRadius) Intersect the specified finite cylinder with the specified ray.static floatIntersect the specified sphere with the specified ray.static floatIntersect the specified triangle with the specified ray.static voidSet the next available character ID to 1.static voidsSetNextCharacterId(int nextValue) Set the next available character ID to the specified value.
-
Method Details
-
estimateCollisionResponse
public static void estimateCollisionResponse(ConstBody body1, ConstBody body2, ConstContactManifold manifold, CollisionEstimationResult storeResult, float combinedFriction, float combinedRestitution) Estimate the contact impulses and body velocity changes resulting from a collision. (see Physics/Collision/EstimateCollisionResponse.cpp)- Parameters:
body1- the first colliding body (notnull, unaffected)body2- the 2nd colliding body (notnull, unaffected)manifold- the collision manifold (notnull, unaffected)storeResult- storage for impulses and velocities (notnull, modified)combinedFriction- the combined friction of the 2 bodiescombinedRestitution- the combined restitution of the 2 bodies
-
estimateCollisionResponse
public static void estimateCollisionResponse(ConstBody body1, ConstBody body2, ConstContactManifold manifold, CollisionEstimationResult storeResult, float combinedFriction, float combinedRestitution, float minVelocity) Estimate the contact impulses and body velocity changes resulting from a collision. (see Physics/Collision/EstimateCollisionResponse.cpp)- Parameters:
body1- the first colliding body (notnull, unaffected)body2- the 2nd colliding body (notnull, unaffected)manifold- the collision manifold (notnull, unaffected)storeResult- storage for impulses and velocities (notnull, modified)combinedFriction- the combined friction of the 2 bodiescombinedRestitution- the combined restitution of the 2 bodiesminVelocity- the minimum speed for restitution to be applied (in meters per second, default=1)
-
estimateCollisionResponse
public static void estimateCollisionResponse(ConstBody body1, ConstBody body2, ConstContactManifold manifold, CollisionEstimationResult storeResult, float combinedFriction, float combinedRestitution, float minVelocity, int numIterations) Estimate the contact impulses and body velocity changes resulting from a collision. (see Physics/Collision/EstimateCollisionResponse.cpp)- Parameters:
body1- the first colliding body (notnull, unaffected)body2- the 2nd colliding body (notnull, unaffected)manifold- the collision manifold (notnull, unaffected)storeResult- storage for impulses and velocities (notnull, modified)combinedFriction- the combined friction of the 2 bodiescombinedRestitution- the combined restitution of the 2 bodiesminVelocity- the minimum speed for restitution to be applied (in meters per second, default=1)numIterations- the number of iterations the impulse solver to use (default=10)
-
hashBytes
public static long hashBytes(long dataVa, int inSize) Return a hash code for the specified data bytes. (see Jolt/Core/HashCombine.h)- Parameters:
dataVa- the virtual address of the data, or 0 for no datainSize- the number of data bytes, or 0 for no data- Returns:
- the hash code
-
hashBytes
Combine the specified quaternion with the specified hash code.- Parameters:
quaternion- the quaternion to combine (notnull, unaffected)oldHash- the old hash code- Returns:
- the new hash code
-
hashBytes
Combine the specified vector with the specified hash code.- Parameters:
vector- the vector to combine (notnull, 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. (see Jolt/Core/HashCombine.h)- Parameters:
oldHash- the old hash codeiValue- 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 codelValue- the integer value to combine- Returns:
- the new hash code
-
hashCombine
Combine the specified location vector with the specified hash code.- Parameters:
oldHash- the old hash codevector- the vector to combine (notnull, unaffected)- Returns:
- the new hash code
-
hashCombine
Combine the specified vector with the specified hash code.- Parameters:
oldHash- the old hash codevector- the vector to combine (notnull, unaffected)- Returns:
- the new hash code
-
listClasses
List all classes in the specified Jolt-JNI package.- Parameters:
packageName- the name of the package (must start with "com.github.stephengold.joltjni")- Returns:
- a new collection
-
perlinNoise3
public static float perlinNoise3(float x, float y, float z, int xWrap, int yWrap, int zWrap) Generate 3-D Perlin noise. (see TestFramework/External/Perlin.cpp)- Parameters:
x- the X coordinatey- the Y coordinatez- the Z coordinatexWrap- the wraparound interval for the X coordinate (power of 2) or 0 for don't careyWrap- the wraparound interval for the Y coordinate (power of 2) or 0 for don't carezWrap- the wraparound interval for the Z coordinate (power of 2) or 0 for don't care- Returns:
- a sample value
-
rayAaBox
public static float rayAaBox(Vec3Arg rayOrigin, RayInvDirection invDirection, Vec3Arg minimum, Vec3Arg maximum) Intersect the specified axis-aligned box with the specified ray. (see Jolt/Geometry/RayAABox.h)- Parameters:
rayOrigin- the origin of the ray (notnull, unaffected)invDirection- the inverse direction of the ray (notnull, unaffected)minimum- the minimum coordinates of the box (notnull, unaffected)maximum- the maximum coordinates of the box (notnull, unaffected)- Returns:
- the minimum distance along ray, or
FLT_MAXif the ray misses the box
-
rayAaBoxHits
public static boolean rayAaBoxHits(Vec3Arg startLocation, Vec3Arg offset, Vec3Arg minimum, Vec3Arg maximum) Intersect the specified axis-aligned box with the specified ray. (see Jolt/Geometry/RayAABox.h)- Parameters:
startLocation- the desired start location of the ray (notnull, unaffected)offset- the desired end offset from the start location (notnull, unaffected)minimum- the minimum coordinates of the box (notnull, unaffected)maximum- the maximum coordinates of the box (notnull, unaffected)- Returns:
trueif there is a hit, otherwisefalse
-
rayCapsule
public static float rayCapsule(Vec3Arg rayOrigin, Vec3Arg rayDirection, float capsuleHalfHeight, float capsuleRadius) Intersect the specified capsule with the specified ray. (see Jolt/Geometry/RayCapsule.h)- Parameters:
rayOrigin- the origin of the ray (notnull, unaffected)rayDirection- the direction of the ray (notnull, unaffected)capsuleHalfHeight- half the height of the capsulecapsuleRadius- the radius of the capsule- Returns:
- the minimum distance along ray, or
FLT_MAXif the ray misses the capsule
-
rayCylinder
Intersect the specified infinite cylinder with the specified ray. (see Jolt/Geometry/RayCylinder.h)- Parameters:
rayOrigin- the origin of the ray (notnull, unaffected)rayDirection- the direction of the ray (notnull, unaffected)cylinderRadius- the radius of the cylinder- Returns:
- the minimum distance along ray, or
FLT_MAXif the ray misses the cylinder
-
rayCylinder
public static float rayCylinder(Vec3Arg rayOrigin, Vec3Arg rayDirection, float cylinderHalfHeight, float cylinderRadius) Intersect the specified finite cylinder with the specified ray. (see Jolt/Geometry/RayCylinder.h)- Parameters:
rayOrigin- the origin of the ray (notnull, unaffected)rayDirection- the direction of the ray (notnull, unaffected)cylinderHalfHeight- half of the height of the cylindercylinderRadius- the radius of the cylinder- Returns:
- the minimum distance along ray, or
FLT_MAXif the ray misses the cylinder
-
raySphere
public static float raySphere(Vec3Arg rayOrigin, Vec3Arg rayDirection, Vec3Arg sphereCenter, float sphereRadius) Intersect the specified sphere with the specified ray. (see Jolt/Geometry/RaySphere.h)- Parameters:
rayOrigin- the origin of the ray (notnull, unaffected)rayDirection- the direction of the ray (notnull, unaffected)sphereCenter- the center of the sphere (notnull, unaffected)sphereRadius- the radius of the sphere- Returns:
- the minimum distance along ray, or
FLT_MAXif the ray misses the sphere
-
rayTriangle
public static float rayTriangle(Vec3Arg rayOrigin, Vec3Arg rayDirection, Vec3Arg v0, Vec3Arg v1, Vec3Arg v2) Intersect the specified triangle with the specified ray. (see Jolt/Geometry/RayTriangle.h)- Parameters:
rayOrigin- the origin of the ray (notnull, unaffected)rayDirection- the direction of the ray (notnull, unaffected)v0- the first vertex of the triangle (notnull, unaffected)v1- the 2nd vertex of the triangle (notnull, unaffected)v2- the 3rd vertex of the triangle (notnull, unaffected)- Returns:
- the minimum distance along ray, or
FLT_MAXif the ray misses the triangle
-
sSetNextCharacterId
public static void sSetNextCharacterId()Set the next available character ID to 1. (see Jolt/Physics/Character/CharacterID.h) -
sSetNextCharacterId
public static void sSetNextCharacterId(int nextValue) Set the next available character ID to the specified value. (native function:CharacterID::sSetNextCharacterID)- Parameters:
nextValue- the desired next ID
-