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

Method spawnDebugObject

deps/physx/physx/samples/samplebase/PhysXSample.cpp:2292–2340  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2290///////////////////////////////////////////////////////////////////////////////
2291
2292void PhysXSample::spawnDebugObject()
2293{
2294 PxSceneWriteLock scopedLock(*mScene);
2295 PxU32 types = getDebugObjectTypes();
2296
2297 if (!types)
2298 return;
2299
2300 //select legal type
2301 while ((mDebugObjectType & types) == 0)
2302 mDebugObjectType = (mDebugObjectType << 1) ? 0 : 1;
2303
2304 if ((mDebugObjectType & DEBUG_OBJECT_ALL) == 0)
2305 return;
2306
2307 const PxVec3 pos = getCamera().getPos();
2308 const PxVec3 vel = getCamera().getViewDir() * getDebugObjectsVelocity();
2309
2310 PxRigidDynamic* actor = NULL;
2311
2312 switch (mDebugObjectType)
2313 {
2314 case DEBUG_OBJECT_SPHERE:
2315 actor = createSphere(pos, getDebugSphereObjectRadius(), &vel, mManagedMaterials[MATERIAL_GREEN], mDefaultDensity);
2316 break;
2317 case DEBUG_OBJECT_BOX:
2318 actor = createBox(pos, getDebugBoxObjectExtents(), &vel, mManagedMaterials[MATERIAL_RED], mDefaultDensity);
2319 break;
2320 case DEBUG_OBJECT_CAPSULE:
2321 actor = createCapsule(pos, getDebugCapsuleObjectRadius(), getDebugCapsuleObjectHalfHeight(), &vel, mManagedMaterials[MATERIAL_BLUE], mDefaultDensity);
2322 break;
2323 case DEBUG_OBJECT_CONVEX:
2324 actor = createConvex(pos, &vel, mManagedMaterials[MATERIAL_YELLOW], mDefaultDensity);
2325 break;
2326 case DEBUG_OBJECT_COMPOUND:
2327 actor = createTestCompound(pos, 320, 0.1f, 2.0f, &vel, NULL, mDefaultDensity, true);
2328 break;
2329 }
2330
2331 actor->setWakeCounter(1000000);
2332
2333 if (actor)
2334 onDebugObjectCreation(actor);
2335
2336 //switch type
2337 mDebugObjectType = mDebugObjectType << 1;
2338 while ((mDebugObjectType & types) == 0)
2339 mDebugObjectType = (mDebugObjectType << 1) ? 0 : 1;
2340}
2341
2342///////////////////////////////////////////////////////////////////////////////
2343

Callers

nothing calls this directly

Calls 4

getViewDirMethod · 0.80
createBoxFunction · 0.50
getPosMethod · 0.45
setWakeCounterMethod · 0.45

Tested by

no test coverage detected