MCPcopy Create free account
hub / github.com/NVIDIAGameWorks/PhysX / createInstance

Method createInstance

physx/source/physx/src/NpPhysics.cpp:174–223  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

172}
173
174NpPhysics* 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
225PxU32 NpPhysics::releaseInstance()
226{

Callers

nothing calls this directly

Calls 9

PX_UNUSEDFunction · 0.85
snprintfFunction · 0.85
incRefCountFunction · 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