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

Method visualize

deps/physx/physx/source/physx/src/NpShapeManager.cpp:761–820  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

759}
760
761void NpShapeManager::visualize(RenderOutput& out, NpScene* scene, const PxRigidActor& actor)
762{
763 const PxReal scale = scene->getVisualizationParameter(PxVisualizationParameter::eSCALE);
764 if(!scale)
765 return;
766
767 const PxU32 nbShapes = getNbShapes();
768 NpShape*const* PX_RESTRICT shapes = getShapes();
769
770 const bool visualizeCompounds = (nbShapes>1) && scene->getVisualizationParameter(PxVisualizationParameter::eCOLLISION_COMPOUNDS)!=0.0f;
771
772 // PT: moved all these out of the loop, no need to grab them once per shape
773 const PxBounds3& cullbox = scene->getScene().getVisualizationCullingBox();
774 const bool visualizeAABBs = scene->getVisualizationParameter(PxVisualizationParameter::eCOLLISION_AABBS)!=0.0f;
775 const bool visualizeShapes = scene->getVisualizationParameter(PxVisualizationParameter::eCOLLISION_SHAPES)!=0.0f;
776 const bool visualizeEdges = scene->getVisualizationParameter(PxVisualizationParameter::eCOLLISION_EDGES)!=0.0f;
777 const float fNormals = scene->getVisualizationParameter(PxVisualizationParameter::eCOLLISION_FNORMALS);
778 const bool visualizeFNormals = fNormals!=0.0f;
779 const bool visualizeCollision = visualizeShapes || visualizeFNormals || visualizeEdges;
780 const bool useCullBox = !cullbox.isEmpty();
781 const bool needsShapeBounds0 = visualizeCompounds || (visualizeCollision && useCullBox);
782 const PxReal collisionAxes = scale * scene->getVisualizationParameter(PxVisualizationParameter::eCOLLISION_AXES);
783 const PxReal fscale = scale * fNormals;
784
785 const PxTransform actorPose = actor.getGlobalPose();
786
787 PxBounds3 compoundBounds(PxBounds3::empty());
788 for(PxU32 i=0;i<nbShapes;i++)
789 {
790 const Scb::Shape& scbShape = shapes[i]->getScbShape();
791
792 const PxTransform absPose = actorPose * scbShape.getShape2Actor();
793 const PxGeometry& geom = scbShape.getGeometry();
794
795 const bool shapeDebugVizEnabled = scbShape.getFlags() & PxShapeFlag::eVISUALIZATION;
796
797 const bool needsShapeBounds = needsShapeBounds0 || (visualizeAABBs && shapeDebugVizEnabled);
798 const PxBounds3 currentShapeBounds = needsShapeBounds ? Gu::computeBounds(geom, absPose) : PxBounds3::empty();
799
800 if(shapeDebugVizEnabled)
801 {
802 if(visualizeAABBs)
803 out << PxU32(PxDebugColor::eARGB_YELLOW) << PxMat44(PxIdentity) << DebugBox(currentShapeBounds);
804
805 if(collisionAxes != 0.0f)
806 out << PxMat44(absPose) << DebugBasis(PxVec3(collisionAxes), 0xcf0000, 0x00cf00, 0x0000cf);
807
808 if(visualizeCollision)
809 {
810 if(!useCullBox || cullbox.intersects(currentShapeBounds))
811 ::visualize(geom, out, absPose, cullbox, fscale, visualizeShapes, visualizeEdges, useCullBox);
812 }
813 }
814
815 if(visualizeCompounds)
816 compoundBounds.include(currentShapeBounds);
817 }
818 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
emptyFunction · 0.50
PxMat44Class · 0.50
PxVec3Class · 0.50
getSceneMethod · 0.45
isEmptyMethod · 0.45

Tested by

no test coverage detected