Package com.github.stephengold.joltjni
Class BodyLockWrite
java.lang.Object
com.github.stephengold.joltjni.JoltPhysicsObject
com.github.stephengold.joltjni.NonCopyable
com.github.stephengold.joltjni.BodyLockWrite
- All Implemented Interfaces:
ConstJoltPhysicsObject,AutoCloseable,Comparable<ConstJoltPhysicsObject>
Lock a body for read-write access.
-
Constructor Summary
ConstructorsConstructorDescriptionBodyLockWrite(BodyLockInterface bli, ConstBodyId id) Acquire a lock using the specified interface and ID. -
Method Summary
Modifier and TypeMethodDescriptiongetBody()Access the body.voidExplicitly release the lock.booleanTest whether the lock was successfully acquired.booleanTest whether the lock was acquired and the body is still in broadphase.Methods inherited from class com.github.stephengold.joltjni.JoltPhysicsObject
close, compareTo, equals, hasAssignedNativeObject, hashCode, ownsNativeObject, setVirtualAddress, startCleaner, toString, va
-
Constructor Details
-
BodyLockWrite
Acquire a lock using the specified interface and ID.- Parameters:
bli- the interface to use (not null, unaffected)id- the ID of the body (not null, unaffected)
-
-
Method Details
-
getBody
Access the body.- Returns:
- a new JVM object with the pre-existing native object assigned
-
releaseLock
public void releaseLock()Explicitly release the lock. Normally this is done in the destructor. -
succeeded
public boolean succeeded()Test whether the lock was successfully acquired.- Returns:
- true if acquired, otherwise false
-
succeededAndIsInBroadPhase
public boolean succeededAndIsInBroadPhase()Test whether the lock was acquired and the body is still in broadphase.- Returns:
- true if both conditions are met, otherwise false
-