| 759 | } |
| 760 | |
| 761 | void 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()) |
nothing calls this directly
no test coverage detected