Jolt Physics
A multi core friendly Game Physics Engine
Loading...
Searching...
No Matches
BodyLockRead Class Reference

#include <BodyLock.h>

Inheritance diagram for BodyLockRead:
BodyLockBase< false, const Body > NonCopyable

Additional Inherited Members

- Public Member Functions inherited from BodyLockBase< false, const Body >
 BodyLockBase (const BodyLockInterface &inBodyLockInterface, const BodyID &inBodyID)
 Constructor will lock the body.
 
void ReleaseLock ()
 Explicitly release the lock (normally this is done in the destructor)
 
 ~BodyLockBase ()
 Destructor will unlock the body.
 
bool Succeeded () const
 Test if the lock was successful (if the body ID was valid)
 
bool SucceededAndIsInBroadPhase () const
 Test if the lock was successful (if the body ID was valid) and the body is still in the broad phase.
 
const BodyGetBody () const
 Access the body.
 
- Public Member Functions inherited from NonCopyable
 NonCopyable ()=default
 
 NonCopyable (const NonCopyable &)=delete
 
void operator= (const NonCopyable &)=delete
 

Detailed Description

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
        ...
    }
} 

The documentation for this class was generated from the following file: