12template <
bool Write,
class BodyType>
18 mBodyLockInterface(inBodyLockInterface)
23 mBodyLockMutex =
nullptr;
29 mBodyLockMutex = Write? inBodyLockInterface.
LockWrite(inBodyID) : inBodyLockInterface.
LockRead(inBodyID);
32 mBody = inBodyLockInterface.
TryGetBody(inBodyID);
39 if (mBodyLockMutex !=
nullptr)
46 mBodyLockMutex =
nullptr;
60 return mBody !=
nullptr;
66 return mBody !=
nullptr && mBody->IsInBroadPhase();
72 JPH_ASSERT(mBody !=
nullptr,
"Should check Succeeded() first");
#define JPH_NAMESPACE_END
Definition: Core.h:378
#define JPH_NAMESPACE_BEGIN
Definition: Core.h:372
#define JPH_ASSERT(...)
Definition: IssueReporting.h:33
ID of a body. This is a way of reasoning about bodies in a multithreaded simulation while avoiding ra...
Definition: BodyID.h:13
Base class for locking bodies for the duration of the scope of this class (do not use directly)
Definition: BodyLock.h:14
~BodyLockBase()
Destructor will unlock the body.
Definition: BodyLock.h:52
BodyLockBase(const BodyLockInterface &inBodyLockInterface, const BodyID &inBodyID)
Constructor will lock the body.
Definition: BodyLock.h:17
bool Succeeded() const
Test if the lock was successful (if the body ID was valid)
Definition: BodyLock.h:58
bool SucceededAndIsInBroadPhase() const
Test if the lock was successful (if the body ID was valid) and the body is still in the broad phase.
Definition: BodyLock.h:64
BodyType & GetBody() const
Access the body.
Definition: BodyLock.h:70
void ReleaseLock()
Explicitly release the lock (normally this is done in the destructor)
Definition: BodyLock.h:37
Base class interface for locking a body. Usually you will use BodyLockRead / BodyLockWrite / BodyLock...
Definition: BodyLockInterface.h:17
virtual void UnlockRead(SharedMutex *inMutex) const =0
Body * TryGetBody(const BodyID &inBodyID) const
Convert body ID to body.
Definition: BodyLockInterface.h:50
virtual void UnlockWrite(SharedMutex *inMutex) const =0
virtual SharedMutex * LockRead(const BodyID &inBodyID) const =0
virtual SharedMutex * LockWrite(const BodyID &inBodyID) const =0
Definition: BodyLock.h:101
Specialization that locks a body for writing to.
Definition: BodyLock.h:107
Class that makes another class non-copyable. Usage: Inherit from NonCopyable.
Definition: NonCopyable.h:11