| 172 | } |
| 173 | |
| 174 | NpPhysics* NpPhysics::createInstance(PxU32 version, PxFoundation& foundation, const PxTolerancesScale& scale, bool trackOutstandingAllocations, pvdsdk::PsPvd* pvd) |
| 175 | { |
| 176 | PX_UNUSED(foundation); |
| 177 | |
| 178 | #if PX_SWITCH |
| 179 | NpSetMiddlewareInfo(); // register middleware info such that PhysX usage can be tracked |
| 180 | #endif |
| 181 | |
| 182 | if (version!=PX_PHYSICS_VERSION) |
| 183 | { |
| 184 | char buffer[256]; |
| 185 | Ps::snprintf(buffer, 256, "Wrong version: PhysX version is 0x%08x, tried to create 0x%08x", PX_PHYSICS_VERSION, version); |
| 186 | foundation.getErrorCallback().reportError(PxErrorCode::eINVALID_PARAMETER, buffer, __FILE__, __LINE__); |
| 187 | return NULL; |
| 188 | } |
| 189 | |
| 190 | if (!scale.isValid()) |
| 191 | { |
| 192 | foundation.getErrorCallback().reportError(PxErrorCode::eINVALID_PARAMETER, "Scale invalid.\n", __FILE__, __LINE__); |
| 193 | return NULL; |
| 194 | } |
| 195 | |
| 196 | if(0 == mRefCount) |
| 197 | { |
| 198 | PX_ASSERT(static_cast<Ps::Foundation*>(&foundation) == &Ps::Foundation::getInstance()); |
| 199 | |
| 200 | Ps::Foundation::incRefCount(); |
| 201 | |
| 202 | // init offset tables for Pxs/Sc/Scb/Px conversions |
| 203 | PxvOffsetTable pxvOffsetTable; |
| 204 | initOffsetTables(pxvOffsetTable); |
| 205 | |
| 206 | //SerialFactory::createInstance(); |
| 207 | mInstance = PX_NEW (NpPhysics)(scale, pxvOffsetTable, trackOutstandingAllocations, pvd); |
| 208 | NpFactory::createInstance(); |
| 209 | |
| 210 | #if PX_SUPPORT_PVD |
| 211 | if(pvd) |
| 212 | { |
| 213 | NpFactory::getInstance().setNpFactoryListener( *mInstance->mPvdPhysicsClient ); |
| 214 | pvd->addClient(mInstance->mPvdPhysicsClient); |
| 215 | } |
| 216 | #endif |
| 217 | |
| 218 | NpFactory::getInstance().addFactoryListener(mInstance->mDeletionMeshListener); |
| 219 | } |
| 220 | ++mRefCount; |
| 221 | |
| 222 | return mInstance; |
| 223 | } |
| 224 | |
| 225 | PxU32 NpPhysics::releaseInstance() |
| 226 | { |
nothing calls this directly
no test coverage detected