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 +++++++++++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) (limited to 'indra/newview/llspatialpartition.cpp') 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; } -- 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(-) (limited to 'indra/newview/llspatialpartition.cpp') 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