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

Method visualize

physx/source/physx/src/NpShapeManager.cpp:739–798  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

737}
738
739void NpShapeManager::visualize(RenderOutput& out, NpScene* scene, const PxRigidActor& actor)
740{
741 const PxReal scale = scene->getVisualizationParameter(PxVisualizationParameter::eSCALE);
742 if(!scale)
743 return;
744
745 const PxU32 nbShapes = getNbShapes();
746 NpShape*const* PX_RESTRICT shapes = getShapes();
747
748 const bool visualizeCompounds = (nbShapes>1) && scene->getVisualizationParameter(PxVisualizationParameter::eCOLLISION_COMPOUNDS)!=0.0f;
749
750 // PT: moved all these out of the loop, no need to grab them once per shape
751 const PxBounds3& cullbox = scene->getScene().getVisualizationCullingBox();
752 const bool visualizeAABBs = scene->getVisualizationParameter(PxVisualizationParameter::eCOLLISION_AABBS)!=0.0f;
753 const bool visualizeShapes = scene->getVisualizationParameter(PxVisualizationParameter::eCOLLISION_SHAPES)!=0.0f;
754 const bool visualizeEdges = scene->getVisualizationParameter(PxVisualizationParameter::eCOLLISION_EDGES)!=0.0f;
755 const float fNormals = scene->getVisualizationParameter(PxVisualizationParameter::eCOLLISION_FNORMALS);
756 const bool visualizeFNormals = fNormals!=0.0f;
757 const bool visualizeCollision = visualizeShapes || visualizeFNormals || visualizeEdges;
758 const bool useCullBox = !cullbox.isEmpty();
759 const bool needsShapeBounds0 = visualizeCompounds || (visualizeCollision && useCullBox);
760 const PxReal collisionAxes = scale * scene->getVisualizationParameter(PxVisualizationParameter::eCOLLISION_AXES);
761 const PxReal fscale = scale * fNormals;
762
763 const PxTransform actorPose = actor.getGlobalPose();
764
765 PxBounds3 compoundBounds(PxBounds3::empty());
766 for(PxU32 i=0;i<nbShapes;i++)
767 {
768 const Scb::Shape& scbShape = shapes[i]->getScbShape();
769
770 const PxTransform absPose = actorPose * scbShape.getShape2Actor();
771 const PxGeometry& geom = scbShape.getGeometry();
772
773 const bool shapeDebugVizEnabled = scbShape.getFlags() & PxShapeFlag::eVISUALIZATION;
774
775 const bool needsShapeBounds = needsShapeBounds0 || (visualizeAABBs && shapeDebugVizEnabled);
776 const PxBounds3 currentShapeBounds = needsShapeBounds ? Gu::computeBounds(geom, absPose) : PxBounds3::empty();
777
778 if(shapeDebugVizEnabled)
779 {
780 if(visualizeAABBs)
781 out << PxU32(PxDebugColor::eARGB_YELLOW) << PxMat44(PxIdentity) << DebugBox(currentShapeBounds);
782
783 if(collisionAxes != 0.0f)
784 out << PxMat44(absPose) << DebugBasis(PxVec3(collisionAxes), 0xcf0000, 0x00cf00, 0x0000cf);
785
786 if(visualizeCollision)
787 {
788 if(!useCullBox || cullbox.intersects(currentShapeBounds))
789 ::visualize(geom, out, absPose, cullbox, fscale, visualizeShapes, visualizeEdges, useCullBox);
790 }
791 }
792
793 if(visualizeCompounds)
794 compoundBounds.include(currentShapeBounds);
795 }
796 if(visualizeCompounds && !compoundBounds.isEmpty())

Callers

nothing calls this directly

Calls 15

getNbShapesFunction · 0.85
computeBoundsFunction · 0.85
DebugBoxClass · 0.85
DebugBasisClass · 0.85
visualizeFunction · 0.70
PxMat44Class · 0.50
PxVec3Class · 0.50
getSceneMethod · 0.45
isEmptyMethod · 0.45
getGlobalPoseMethod · 0.45

Tested by

no test coverage detected