java.lang.Object
com.github.stephengold.joltjni.JoltPhysicsObject
com.github.stephengold.joltjni.NonCopyable
com.github.stephengold.joltjni.BodyLockWrite
- All Implemented Interfaces:
ConstJoltPhysicsObject
,AutoCloseable
,Comparable<JoltPhysicsObject>
Lock a body for read-write access.
-
Constructor Summary
ConstructorsConstructorDescriptionBodyLockWrite
(BodyLockInterface bli, int bodyId) Acquire a lock using the specified interface and body ID. -
Method Summary
Modifier and TypeMethodDescriptiongetBody()
Access the body.void
Explicitly release the lock.boolean
Test whether the lock was successfully acquired.boolean
Test whether the lock was acquired and the body is still in broadphase.Methods inherited from class com.github.stephengold.joltjni.JoltPhysicsObject
close, compareTo, equals, getContainingObject, hasAssignedNativeObject, hashCode, ownsNativeObject, setVirtualAddress, setVirtualAddress, startCleaner, targetVa, toString, va
-
Constructor Details
-
BodyLockWrite
Acquire a lock using the specified interface and body ID.- Parameters:
bli
- the interface to use (not null, unaffected)bodyId
- the ID of the body to lock
-
-
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, otherwisefalse
-
succeededAndIsInBroadPhase
public boolean succeededAndIsInBroadPhase()Test whether the lock was acquired and the body is still in broadphase.- Returns:
true
if both conditions are met, otherwisefalse
-