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

Method setFlagsInternal

physx/source/physx/src/NpShape.cpp:536–603  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

534}
535
536void NpShape::setFlagsInternal(PxShapeFlags inFlags)
537{
538 const bool hasMeshTypeGeom = mShape.getGeometryType() == PxGeometryType::eTRIANGLEMESH || mShape.getGeometryType() == PxGeometryType::eHEIGHTFIELD;
539
540 if(hasMeshTypeGeom && (inFlags & PxShapeFlag::eTRIGGER_SHAPE))
541 {
542 Ps::getFoundation().error(PxErrorCode::eINVALID_PARAMETER, __FILE__, __LINE__,
543 "PxShape::setFlag(s): triangle mesh and heightfield triggers are not supported!");
544 return;
545 }
546
547 if((inFlags & PxShapeFlag::eSIMULATION_SHAPE) && (inFlags & PxShapeFlag::eTRIGGER_SHAPE))
548 {
549 Ps::getFoundation().error(PxErrorCode::eINVALID_PARAMETER, __FILE__, __LINE__,
550 "PxShape::setFlag(s): shapes cannot simultaneously be trigger shapes and simulation shapes.");
551 return;
552 }
553
554 const PxShapeFlags oldFlags = mShape.getFlags();
555
556 const bool oldIsSimShape = oldFlags & PxShapeFlag::eSIMULATION_SHAPE;
557 const bool isSimShape = inFlags & PxShapeFlag::eSIMULATION_SHAPE;
558
559 if(mActor)
560 {
561 const PxType type = mActor->getConcreteType();
562
563 // PT: US5732 - support kinematic meshes
564 bool isKinematic = false;
565 if(type==PxConcreteType::eRIGID_DYNAMIC)
566 {
567 PxRigidDynamic* rigidDynamic = static_cast<PxRigidDynamic*>(mActor);
568 isKinematic = rigidDynamic->getRigidBodyFlags() & PxRigidBodyFlag::eKINEMATIC;
569 }
570
571 if((type != PxConcreteType::eRIGID_STATIC) && !isKinematic && isSimShape && !oldIsSimShape && (hasMeshTypeGeom || mShape.getGeometryType() == PxGeometryType::ePLANE))
572 {
573 Ps::getFoundation().error(PxErrorCode::eINVALID_PARAMETER, __FILE__, __LINE__,
574 "PxShape::setFlag(s): triangle mesh, heightfield and plane shapes can only be simulation shapes if part of a PxRigidStatic!");
575 return;
576 }
577 }
578
579 const bool oldHasSceneQuery = oldFlags & PxShapeFlag::eSCENE_QUERY_SHAPE;
580 const bool hasSceneQuery = inFlags & PxShapeFlag::eSCENE_QUERY_SHAPE;
581
582 mShape.setFlags(inFlags);
583
584 if(oldHasSceneQuery != hasSceneQuery && mActor)
585 {
586 NpScene* npScene = getAPIScene();
587 NpShapeManager* shapeManager = NpActor::getShapeManager(*mActor);
588 if(npScene)
589 {
590 if(hasSceneQuery)
591 shapeManager->setupSceneQuery(npScene->getSceneQueryManagerFast(), *mActor, *this);
592 else
593 shapeManager->teardownSceneQuery(npScene->getSceneQueryManagerFast(), *this);

Callers

nothing calls this directly

Calls 9

errorMethod · 0.80
getRigidBodyFlagsMethod · 0.80
setupSceneQueryMethod · 0.80
teardownSceneQueryMethod · 0.80
getGeometryTypeMethod · 0.45
getFlagsMethod · 0.45
getConcreteTypeMethod · 0.45
setFlagsMethod · 0.45
invalidateMethod · 0.45

Tested by

no test coverage detected