![]() |
Jolt Physics
A multi core friendly Game Physics Engine
|
#include <BodyLock.h>
Additional Inherited Members | |
Public Member Functions inherited from BodyLockBase< false, const Body > | |
| BodyLockBase (const BodyLockInterface &inBodyLockInterface, const BodyID &inBodyID) | |
| Constructor will lock the body. More... | |
| void | ReleaseLock () |
| Explicitly release the lock (normally this is done in the destructor) More... | |
| ~BodyLockBase () | |
| Destructor will unlock the body. More... | |
| bool | Succeeded () const |
| Test if the lock was successful (if the body ID was valid) More... | |
| bool | SucceededAndIsInBroadPhase () const |
| Test if the lock was successful (if the body ID was valid) and the body is still in the broad phase. More... | |
| const Body & | GetBody () const |
| Access the body. More... | |
Public Member Functions inherited from NonCopyable | |
| NonCopyable ()=default | |
| NonCopyable (const NonCopyable &)=delete | |
| void | operator= (const NonCopyable &)=delete |
A body lock takes a body ID and locks the underlying body so that other threads cannot access its members
The common usage pattern is:
BodyLockInterface lock_interface = physics_system.GetBodyLockInterface(); // Or non-locking interface if the lock is already taken
BodyID body_id = ...; // Obtain ID to body
// Scoped lock
{
BodyLockRead lock(lock_interface, body_id);
if (lock.Succeeded()) // body_id may no longer be valid
{
const Body &body = lock.GetBody();
// Do something with body
...
}
}