Package com.github.stephengold.joltjni
Class JoltPhysicsObject
java.lang.Object
com.github.stephengold.joltjni.JoltPhysicsObject
- All Implemented Interfaces:
ConstJoltPhysicsObject,AutoCloseable,Comparable<ConstJoltPhysicsObject>
- Direct Known Subclasses:
AaBox,Array,BodyActivationListener,BodyCreationSettings,BodyId,BodyManagerDrawSettings,BroadPhaseCastResult,CastRayCollector,CastShapeCollector,CharacterBaseSettings,CharacterContactSettings,CollidePointCollector,CollidePointResult,CollideSettingsBase,CollideShapeBodyCollector,CollideShapeCollector,CollideShapeResult,CollisionGroup,CombineFunction,Contact,ContactListener,ContactManifold,ContactSettings,CustomCharacterContactListener,CustomPhysicsStepListener,DefaultRandomEngine,ExtendedUpdateSettings,IndexedTriangleNoMaterial,JointState,MassProperties,Mat44,MotionProperties,MotorSettings,Mt19937,NarrowPhaseStat,NonCopyable,PhysicsScene,PhysicsSettings,PhysicsStepListenerContext,RagdollSettings,RayCast,RayCastBodyCollector,RayCastSettings,Ref,RMat44,RRayCast,RShapeCast,ShapeRefC,ShapeResult,SharedMutexBase,SkeletalAnimation,Skeleton,SkeletonPose,SkeletonPoseDrawSettings,SpringSettings,StateRecorderFilter,SubShape,SubShapeId,SubShapeIdPair,Triangle,UniformIntDistribution,UniformRealDistribution
public abstract class JoltPhysicsObject
extends Object
implements AutoCloseable, ConstJoltPhysicsObject
An abstract class to represent a (native) Jolt Physics object.
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedInstantiate with no native object assigned. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Free and unassign the native object if the JVM object owns it.intcompareTo(ConstJoltPhysicsObject other) Compare (by virtual address) with another physics object.booleanTest for type and virtual-address equality with another object.final booleanTest whether a native object is assigned.inthashCode()Return the hash code of the physics object.final booleanTest whether the JVM object owns (is responsible for freeing) its assigned native object.protected final voidsetVirtualAddress(long virtualAddress, Runnable action) Assign a native object, assuming there's none already assigned.static voidStart a daemon thread to process the phantom reachable objects and invoke freeing actions.toString()Represent the physics object as a String.final longva()Return the virtual address of the assigned native object, assuming one is assigned.
-
Constructor Details
-
JoltPhysicsObject
protected JoltPhysicsObject()Instantiate with no native object assigned.
-
-
Method Details
-
startCleaner
public static void startCleaner()Start a daemon thread to process the phantom reachable objects and invoke freeing actions. -
setVirtualAddress
Assign a native object, assuming there's none already assigned.- Parameters:
virtualAddress- the virtual address of the native object to assign (not zero)action- freeing action if the JVM object will own (be responsible for freeing) the native object, ornullif none
-
close
public void close()Free and unassign the native object if the JVM object owns it.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceConstJoltPhysicsObject
-
compareTo
Compare (by virtual address) with another physics object. The current instance is unaffected.- Specified by:
compareToin interfaceComparable<ConstJoltPhysicsObject>- Parameters:
other- (not null, unaffected)- Returns:
- 0 if the objects have the same virtual address; negative if this comes before other; positive if this comes after other
-
hasAssignedNativeObject
public final boolean hasAssignedNativeObject()Test whether a native object is assigned. Both objects are unaffected.- Specified by:
hasAssignedNativeObjectin interfaceConstJoltPhysicsObject- Returns:
- true if one is assigned, otherwise false
-
ownsNativeObject
public final boolean ownsNativeObject()Test whether the JVM object owns (is responsible for freeing) its assigned native object. Both objects are unaffected.- Specified by:
ownsNativeObjectin interfaceConstJoltPhysicsObject- Returns:
- true if owner, otherwise false
-
va
public final long va()Return the virtual address of the assigned native object, assuming one is assigned. Both objects are unaffected.- Specified by:
vain interfaceConstJoltPhysicsObject- Returns:
- the virtual address (not zero)
-
equals
Test for type and virtual-address equality with another object. The current instance is unaffected. -
hashCode
public int hashCode()Return the hash code of the physics object. The object is unaffected.Note: operations that alter the virtual address are likely to affect the hash code as well!
-
toString
Represent the physics object as a String. The physics object is unaffected.
-