From 44e9e6d2310c598011d7af59ced43f32abbf68b0 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Sat, 8 May 2010 16:10:05 -0500 Subject: Physics shape fetching. --- indra/newview/llspatialpartition.cpp | 49 +++++++++++++++++++++- indra/newview/llviewermenu.cpp | 4 ++ indra/newview/pipeline.h | 1 + indra/newview/skins/default/xui/en/menu_viewer.xml | 10 +++++ 4 files changed, 63 insertions(+), 1 deletion(-) diff --git a/indra/newview/llspatialpartition.cpp b/indra/newview/llspatialpartition.cpp index 77c38798d1..6787018f5a 100644 --- a/indra/newview/llspatialpartition.cpp +++ b/indra/newview/llspatialpartition.cpp @@ -44,6 +44,7 @@ #include "llviewerregion.h" #include "llcamera.h" #include "pipeline.h" +#include "llmeshrepository.h" #include "llrender.h" #include "lloctree.h" #include "llvoavatar.h" @@ -2658,6 +2659,46 @@ void renderBoundingBox(LLDrawable* drawable, BOOL set_color = TRUE) } +void renderPhysicsShape(LLDrawable* drawable) +{ + LLVOVolume* volume = drawable->getVOVolume(); + if (volume) + { + if (volume->isMesh()) + { + LLUUID mesh_id = volume->getVolume()->getParams().getSculptID(); + const LLMeshDecomposition* decomp = gMeshRepo.getDecomposition(mesh_id); + if (decomp) + { + gGL.pushMatrix(); + glLoadMatrixd(gGLModelView); + gGL.flush(); + glPointSize(4.f); + gGL.begin(LLRender::POINTS); + static std::vector color; + + for (U32 i = 0; i < decomp->mHull.size(); ++i) + { + if (color.size() <= i) + { + color.push_back(LLColor4U(rand()%128+127, rand()%128+127, rand()%128+127)); + } + gGL.color4ubv(color[i].mV); + for (U32 j = 0; j < decomp->mHull[i].size(); ++j) + { + LLVector3 v = volume->volumePositionToAgent(decomp->mHull[i][j]); + gGL.vertex3fv(v.mV); + } + } + gGL.end(); + gGL.flush(); + gGL.popMatrix(); + glPointSize(1.f); + } + } + } +} + void renderTexturePriority(LLDrawable* drawable) { for (int face=0; facegetNumFaces(); ++face) @@ -2974,6 +3015,11 @@ public: renderBoundingBox(drawable); } + if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_PHYSICS_SHAPES)) + { + renderPhysicsShape(drawable); + } + if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_BUILD_QUEUE)) { if (drawable->isState(LLDrawable::IN_REBUILD_Q2)) @@ -3173,7 +3219,8 @@ void LLSpatialPartition::renderDebug() LLPipeline::RENDER_DEBUG_AVATAR_VOLUME | LLPipeline::RENDER_DEBUG_AGENT_TARGET | LLPipeline::RENDER_DEBUG_BUILD_QUEUE | - LLPipeline::RENDER_DEBUG_SHADOW_FRUSTA)) + LLPipeline::RENDER_DEBUG_SHADOW_FRUSTA | + LLPipeline::RENDER_DEBUG_PHYSICS_SHAPES)) { return; } diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp index b63ef921ac..04c1c64f8f 100644 --- a/indra/newview/llviewermenu.cpp +++ b/indra/newview/llviewermenu.cpp @@ -869,6 +869,10 @@ U32 info_display_from_string(std::string info_display) { return LLPipeline::RENDER_DEBUG_SHADOW_FRUSTA; } + else if ("physics shapes" == info_display) + { + return LLPipeline::RENDER_DEBUG_PHYSICS_SHAPES; + } else if ("occlusion" == info_display) { return LLPipeline::RENDER_DEBUG_OCCLUSION; diff --git a/indra/newview/pipeline.h b/indra/newview/pipeline.h index be878ae667..11c350000f 100644 --- a/indra/newview/pipeline.h +++ b/indra/newview/pipeline.h @@ -413,6 +413,7 @@ public: RENDER_DEBUG_AVATAR_VOLUME = 0x0100000, RENDER_DEBUG_BUILD_QUEUE = 0x0200000, RENDER_DEBUG_AGENT_TARGET = 0x0400000, + RENDER_DEBUG_PHYSICS_SHAPES = 0x0800000, }; public: diff --git a/indra/newview/skins/default/xui/en/menu_viewer.xml b/indra/newview/skins/default/xui/en/menu_viewer.xml index bdc171ea52..b540619431 100644 --- a/indra/newview/skins/default/xui/en/menu_viewer.xml +++ b/indra/newview/skins/default/xui/en/menu_viewer.xml @@ -1945,6 +1945,16 @@ function="Advanced.ToggleInfoDisplay" parameter="shadow frusta" /> + + + + -- cgit v1.2.3 From b2906b594470ced996f102f4797eef7671ad009c Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Wed, 12 May 2010 17:17:39 -0500 Subject: Moved LLPhysicsDecomp to llmeshrepository. Better convex hull visualization. --- indra/newview/llspatialpartition.cpp | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/indra/newview/llspatialpartition.cpp b/indra/newview/llspatialpartition.cpp index 6787018f5a..ed99f8648f 100644 --- a/indra/newview/llspatialpartition.cpp +++ b/indra/newview/llspatialpartition.cpp @@ -2671,10 +2671,8 @@ void renderPhysicsShape(LLDrawable* drawable) if (decomp) { gGL.pushMatrix(); - glLoadMatrixd(gGLModelView); - gGL.flush(); - glPointSize(4.f); - gGL.begin(LLRender::POINTS); + glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); + glMultMatrixf((F32*) volume->getRelativeXform().mMatrix); static std::vector color; for (U32 i = 0; i < decomp->mHull.size(); ++i) @@ -2683,17 +2681,15 @@ void renderPhysicsShape(LLDrawable* drawable) { color.push_back(LLColor4U(rand()%128+127, rand()%128+127, rand()%128+127)); } - gGL.color4ubv(color[i].mV); - for (U32 j = 0; j < decomp->mHull[i].size(); ++j) - { - LLVector3 v = volume->volumePositionToAgent(decomp->mHull[i][j]); - gGL.vertex3fv(v.mV); - } + glColor4ubv(color[i].mV); + + LLVertexBuffer* buff = decomp->mMesh; + + buff->setBuffer(LLVertexBuffer::MAP_VERTEX); + buff->drawArrays(LLRender::TRIANGLES, 0, buff->getNumVerts()); } - gGL.end(); - gGL.flush(); + glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); gGL.popMatrix(); - glPointSize(1.f); } } } -- cgit v1.2.3