From a8f0e47fd5deee1e45b4126ee43955a7bc68bb5d Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Fri, 4 Jun 2010 12:07:55 -0500 Subject: Normal debug display and fix for bad bump mapping and planar texture coordinates. --- indra/llmath/llvolume.cpp | 2 + indra/newview/app_settings/settings.xml | 13 ++++- indra/newview/llspatialpartition.cpp | 57 +++++++++++++++++++++- indra/newview/llviewermenu.cpp | 4 ++ indra/newview/pipeline.h | 1 + indra/newview/skins/default/xui/en/menu_viewer.xml | 10 ++++ 6 files changed, 85 insertions(+), 2 deletions(-) diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp index 72833c019f..8cb9475994 100644 --- a/indra/llmath/llvolume.cpp +++ b/indra/llmath/llvolume.cpp @@ -6076,6 +6076,8 @@ void LLVolumeFace::createBinormals() for (U32 i = 0; i < mNumVertices; i++) { binorm[i].normalize3fast(); + //bump map/planar projection code requires normals to be normalized + mNormals[i].normalize3fast(); } } } diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index 9b7cc04120..a95100d9ba 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -6280,7 +6280,18 @@ Value 0 - RenderDebugPipeline + RenderDebugNormalScale + + Comment + Scale of normals in debug display. + Persist + 1 + Type + F32 + Value + 0.03 + + RenderDebugPipeline Comment Enable strict pipeline debugging. diff --git a/indra/newview/llspatialpartition.cpp b/indra/newview/llspatialpartition.cpp index 05e7bbb6cd..77d36b1c2e 100644 --- a/indra/newview/llspatialpartition.cpp +++ b/indra/newview/llspatialpartition.cpp @@ -2704,7 +2704,56 @@ void renderBoundingBox(LLDrawable* drawable, BOOL set_color = TRUE) { drawBoxOutline(pos,size); } - +} + +void renderNormals(LLDrawable* drawablep) +{ + LLVertexBuffer::unbind(); + + LLVOVolume* vol = drawablep->getVOVolume(); + if (vol) + { + LLVolume* volume = vol->getVolume(); + gGL.pushMatrix(); + glMultMatrixf((F32*) vol->getRelativeXform().mMatrix); + + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); + + LLVector4a scale(gSavedSettings.getF32("RenderDebugNormalScale")); + + for (S32 i = 0; i < volume->getNumVolumeFaces(); ++i) + { + const LLVolumeFace& face = volume->getVolumeFace(i); + + gGL.begin(LLRender::LINES); + + for (S32 j = 0; j < face.mNumVertices; ++j) + { + LLVector4a n,p; + + n.setMul(face.mNormals[j], scale); + p.setAdd(face.mPositions[j], n); + + gGL.color4f(1,1,1,1); + gGL.vertex3fv(face.mPositions[j].getF32()); + gGL.vertex3fv(p.getF32()); + + if (face.mBinormals) + { + n.setMul(face.mBinormals[j], scale); + p.setAdd(face.mPositions[j], n); + + gGL.color4f(0,1,1,1); + gGL.vertex3fv(face.mPositions[j].getF32()); + gGL.vertex3fv(p.getF32()); + } + } + + gGL.end(); + } + + gGL.popMatrix(); + } } void renderTexturePriority(LLDrawable* drawable) @@ -3081,6 +3130,11 @@ public: { renderBoundingBox(drawable); } + + if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_NORMALS)) + { + renderNormals(drawable); + } if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_BUILD_QUEUE)) { @@ -3280,6 +3334,7 @@ void LLSpatialPartition::renderDebug() LLPipeline::RENDER_DEBUG_LIGHTS | LLPipeline::RENDER_DEBUG_BATCH_SIZE | LLPipeline::RENDER_DEBUG_BBOXES | + LLPipeline::RENDER_DEBUG_NORMALS | LLPipeline::RENDER_DEBUG_POINTS | LLPipeline::RENDER_DEBUG_TEXTURE_PRIORITY | LLPipeline::RENDER_DEBUG_TEXTURE_ANIM | diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp index b63ef921ac..eb2ee94af3 100644 --- a/indra/newview/llviewermenu.cpp +++ b/indra/newview/llviewermenu.cpp @@ -857,6 +857,10 @@ U32 info_display_from_string(std::string info_display) { return LLPipeline::RENDER_DEBUG_BBOXES; } + else if ("normals" == info_display) + { + return LLPipeline::RENDER_DEBUG_NORMALS; + } else if ("points" == info_display) { return LLPipeline::RENDER_DEBUG_POINTS; diff --git a/indra/newview/pipeline.h b/indra/newview/pipeline.h index 52f943cd1d..4e8760947c 100644 --- a/indra/newview/pipeline.h +++ b/indra/newview/pipeline.h @@ -440,6 +440,7 @@ public: RENDER_DEBUG_AVATAR_VOLUME = 0x0100000, RENDER_DEBUG_BUILD_QUEUE = 0x0200000, RENDER_DEBUG_AGENT_TARGET = 0x0400000, + RENDER_DEBUG_NORMALS = 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..9cc1a481f5 100644 --- a/indra/newview/skins/default/xui/en/menu_viewer.xml +++ b/indra/newview/skins/default/xui/en/menu_viewer.xml @@ -1925,6 +1925,16 @@ function="Advanced.ToggleInfoDisplay" parameter="bboxes" /> + + + + -- cgit v1.2.3