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

Method createShape

physx/source/physx/src/NpFactory.cpp:474–540  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

472///////////////////////////////////////////////////////////////////////////////
473
474NpShape* NpFactory::createShape(const PxGeometry& geometry,
475 PxShapeFlags shapeFlags,
476 PxMaterial*const* materials,
477 PxU16 materialCount,
478 bool isExclusive)
479{
480 switch(geometry.getType())
481 {
482 case PxGeometryType::eBOX:
483 PX_CHECK_AND_RETURN_NULL(static_cast<const PxBoxGeometry&>(geometry).isValid(), "Supplied PxGeometry is not valid. Shape creation method returns NULL.");
484 break;
485 case PxGeometryType::eSPHERE:
486 PX_CHECK_AND_RETURN_NULL(static_cast<const PxSphereGeometry&>(geometry).isValid(), "Supplied PxGeometry is not valid. Shape creation method returns NULL.");
487 break;
488 case PxGeometryType::eCAPSULE:
489 PX_CHECK_AND_RETURN_NULL(static_cast<const PxCapsuleGeometry&>(geometry).isValid(), "Supplied PxGeometry is not valid. Shape creation method returns NULL.");
490 break;
491 case PxGeometryType::eCONVEXMESH:
492 PX_CHECK_AND_RETURN_NULL(static_cast<const PxConvexMeshGeometry&>(geometry).isValid(), "Supplied PxGeometry is not valid. Shape creation method returns NULL.");
493 break;
494 case PxGeometryType::ePLANE:
495 PX_CHECK_AND_RETURN_NULL(static_cast<const PxPlaneGeometry&>(geometry).isValid(), "Supplied PxGeometry is not valid. Shape creation method returns NULL.");
496 break;
497 case PxGeometryType::eHEIGHTFIELD:
498 PX_CHECK_AND_RETURN_NULL(static_cast<const PxHeightFieldGeometry&>(geometry).isValid(), "Supplied PxGeometry is not valid. Shape creation method returns NULL.");
499 break;
500 case PxGeometryType::eTRIANGLEMESH:
501 PX_CHECK_AND_RETURN_NULL(static_cast<const PxTriangleMeshGeometry&>(geometry).isValid(), "Supplied PxGeometry is not valid. Shape creation method returns NULL.");
502 break;
503 case PxGeometryType::eGEOMETRY_COUNT:
504 case PxGeometryType::eINVALID:
505 PX_ASSERT(0);
506 }
507
508 //
509 // Check for invalid material table setups
510 //
511
512#if PX_CHECKED
513 if (!NpShape::checkMaterialSetup(geometry, "Shape creation", materials, materialCount))
514 return NULL;
515#endif
516
517 Ps::InlineArray<PxU16, 4> materialIndices("NpFactory::TmpMaterialIndexBuffer");
518 materialIndices.resize(materialCount);
519 if(materialCount == 1)
520 materialIndices[0] = Ps::to16((static_cast<NpMaterial*>(materials[0]))->getHandle());
521 else
522 NpMaterial::getMaterialIndices(materials, materialIndices.begin(), materialCount);
523
524 NpShape* npShape;
525 {
526 Ps::Mutex::ScopedLock lock(mShapePoolLock);
527 PxU16* mi = materialIndices.begin(); // required to placate pool constructor arg passing
528 npShape = mShapePool.construct(geometry, shapeFlags, mi, materialCount, isExclusive);
529 }
530
531 if(!npShape)

Callers 15

createStackFunction · 0.45
createStackFunction · 0.45
createCollectionsFunction · 0.45
generateExampleFilesFunction · 0.45
createStackFunction · 0.45
createLargeSphereFunction · 0.45
createStackFunction · 0.45
createStackFunction · 0.45
createStackFunction · 0.45
createStackFunction · 0.45
createStackFunction · 0.45
initPhysicsFunction · 0.45

Calls 9

to16Function · 0.85
getTypeMethod · 0.45
isValidMethod · 0.45
resizeMethod · 0.45
getHandleMethod · 0.45
beginMethod · 0.45
constructMethod · 0.45
incRefCountMethod · 0.45
getMaterialMethod · 0.45

Tested by

no test coverage detected