MCPcopy Create free account
hub / github.com/RavEngine/RavEngine / createInstance

Method createInstance

deps/physx/physx/source/physx/src/NpPhysics.cpp:178–227  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 10

PX_UNUSEDFunction · 0.85
snprintfFunction · 0.85
incRefCountFunction · 0.85
createInstanceFunction · 0.85
getErrorCallbackMethod · 0.80
setNpFactoryListenerMethod · 0.80
addFactoryListenerMethod · 0.80
reportErrorMethod · 0.45
isValidMethod · 0.45
addClientMethod · 0.45

Tested by

no test coverage detected