| 35 | using namespace physx; |
| 36 | |
| 37 | NpReadCheck::NpReadCheck(const NpScene* scene, const char* functionName) |
| 38 | : mScene(scene), mName(functionName), mErrorCount(0) |
| 39 | { |
| 40 | if (mScene) |
| 41 | { |
| 42 | if (!mScene->startRead()) |
| 43 | { |
| 44 | if (mScene->getScene().getFlags() & PxSceneFlag::eREQUIRE_RW_LOCK) |
| 45 | { |
| 46 | Ps::getFoundation().error(PxErrorCode::eINVALID_OPERATION, __FILE__, __LINE__, |
| 47 | "An API read call (%s) was made from thread %d but PxScene::lockRead() was not called first, note that " |
| 48 | "when PxSceneFlag::eREQUIRE_RW_LOCK is enabled all API reads and writes must be " |
| 49 | "wrapped in the appropriate locks.", mName, PxU32(Ps::Thread::getId())); |
| 50 | } |
| 51 | else |
| 52 | { |
| 53 | Ps::getFoundation().error(PxErrorCode::eINVALID_OPERATION, __FILE__, __LINE__, |
| 54 | "Overlapping API read and write call detected during %s from thread %d! Note that read operations to " |
| 55 | "the SDK must not be overlapped with write calls, else the resulting behavior is undefined.", mName, PxU32(Ps::Thread::getId())); |
| 56 | } |
| 57 | } |
| 58 | |
| 59 | // Record the NpScene read/write error counter which is |
| 60 | // incremented any time a NpScene::startWrite/startRead fails |
| 61 | // (see destructor for additional error checking based on this count) |
| 62 | mErrorCount = mScene->getReadWriteErrorCount(); |
| 63 | } |
| 64 | } |
| 65 | |
| 66 | |
| 67 | NpReadCheck::~NpReadCheck() |