From 2388de3f958f019255c1eb50cafb540e87a3ca3a Mon Sep 17 00:00:00 2001 From: prep Date: Tue, 3 Apr 2012 13:06:21 -0400 Subject: Added normal support to navmesh tri renderer. --- indra/llrender/llrendernavprim.cpp | 3 ++- indra/llrender/llrendernavprim.h | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'indra/llrender') diff --git a/indra/llrender/llrendernavprim.cpp b/indra/llrender/llrendernavprim.cpp index d6da722e0c..7dd042271a 100644 --- a/indra/llrender/llrendernavprim.cpp +++ b/indra/llrender/llrendernavprim.cpp @@ -62,12 +62,13 @@ void LLRenderNavPrim::renderTri( const LLVector3& a, const LLVector3& b, const L gGL.end(); } //============================================================================= -void LLRenderNavPrim::renderLLTri( const LLVector3& a, const LLVector3& b, const LLVector3& c, const LLColor4U& color ) const +void LLRenderNavPrim::renderLLTri( const LLVector3& a, const LLVector3& b, const LLVector3& c, const LLColor4U& color, const LLVector3& n ) const { LLColor4 cV(color); gGL.color4fv( cV.mV ); gGL.begin(LLRender::TRIANGLES); { + glNormal3f( n.mV[0],n.mV[1],n.mV[2] ); gGL.vertex3fv( a.mV ); gGL.vertex3fv( b.mV ); gGL.vertex3fv( c.mV ); diff --git a/indra/llrender/llrendernavprim.h b/indra/llrender/llrendernavprim.h index d5899471a6..7fbd02de93 100644 --- a/indra/llrender/llrendernavprim.h +++ b/indra/llrender/llrendernavprim.h @@ -43,8 +43,8 @@ public: void renderLLSegment( const LLVector3& start, const LLVector3& end, const LLColor4U& color ) const; //Draw simple tri void renderTri( const LLVector3& a, const LLVector3& b, const LLVector3& c, int color ) const; - //Draw simple tri - void renderLLTri( const LLVector3& a, const LLVector3& b, const LLVector3& c, const LLColor4U& color ) const; + //Draw simple tri + void renderLLTri( const LLVector3& a, const LLVector3& b, const LLVector3& c, const LLColor4U& color, const LLVector3& n ) const; //Draw the contents of vertex buffer void renderNavMeshVB( LLVertexBuffer* pVBO, int vertCnt ); //Draw a star -- cgit v1.2.3 From 68a4e0ee992fc6f2f1e3a733788f6fe31b85b549 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Tue, 3 Apr 2012 16:12:33 -0500 Subject: Fix build. Axe deprecated glNormal call. Don't show the world just because navmesh isn't checked. --- indra/llrender/llrendernavprim.cpp | 193 ++++++++++++++++++------------------- 1 file changed, 96 insertions(+), 97 deletions(-) (limited to 'indra/llrender') diff --git a/indra/llrender/llrendernavprim.cpp b/indra/llrender/llrendernavprim.cpp index 7dd042271a..56b176d39c 100644 --- a/indra/llrender/llrendernavprim.cpp +++ b/indra/llrender/llrendernavprim.cpp @@ -1,97 +1,96 @@ -/** - * @file LLRenderNavPrim.cpp - * @brief Renderable primitives used by the pathing library - * - * $LicenseInfo:firstyear=2001&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - - -#include "linden_common.h" -#include "llrendernavprim.h" -#include "llerror.h" -#include "llglheaders.h" -#include "llvertexbuffer.h" -#include "llglslshader.h" - -//============================================================================= -LLRenderNavPrim gRenderNav; -//============================================================================= -void LLRenderNavPrim::renderLLSegment( const LLVector3& start, const LLVector3& end, const LLColor4U& color ) const -{ - LLColor4 colorA( color ); - gGL.color3fv( colorA.mV ); - - gGL.begin(LLRender::LINES); - { - gGL.vertex3fv( start.mV ); - gGL.vertex3fv( end.mV ); - } - gGL.end(); -} -//============================================================================= -void LLRenderNavPrim::renderTri( const LLVector3& a, const LLVector3& b, const LLVector3& c, int color ) const -{ - LLColor4 colorA( color ); - colorA*=1.25f; - gGL.color4fv( colorA.mV ); - gGL.begin(LLRender::TRIANGLES); - { - gGL.vertex3fv( a.mV ); - gGL.vertex3fv( b.mV ); - gGL.vertex3fv( c.mV ); - } - gGL.end(); -} -//============================================================================= -void LLRenderNavPrim::renderLLTri( const LLVector3& a, const LLVector3& b, const LLVector3& c, const LLColor4U& color, const LLVector3& n ) const -{ - LLColor4 cV(color); - gGL.color4fv( cV.mV ); - gGL.begin(LLRender::TRIANGLES); - { - glNormal3f( n.mV[0],n.mV[1],n.mV[2] ); - gGL.vertex3fv( a.mV ); - gGL.vertex3fv( b.mV ); - gGL.vertex3fv( c.mV ); - } - gGL.end(); -} -//============================================================================= -void LLRenderNavPrim::renderNavMeshVB( LLVertexBuffer* pVBO, int vertCnt ) -{ - pVBO->setBuffer( LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_COLOR | LLVertexBuffer::MAP_NORMAL ); - pVBO->drawArrays( LLRender::TRIANGLES, 0, vertCnt ); -} -//============================================================================= -void LLRenderNavPrim::renderStar( const LLVector3& center, const float scale, const LLColor4U& color ) const -{ - for (int k=0; k<3; k++) - { - LLVector3 star, pt1, pt2; - star = LLVector3( 0.0f,0.0f,0.0f); - star[k] = 0.5f; - pt1 = center + star; - pt2 = center - star; - renderLLSegment( pt1, pt2, color ); - } -} -//============================================================================= +/** + * @file LLRenderNavPrim.cpp + * @brief Renderable primitives used by the pathing library + * + * $LicenseInfo:firstyear=2001&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2010, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + + +#include "linden_common.h" +#include "llrendernavprim.h" +#include "llerror.h" +#include "llglheaders.h" +#include "llvertexbuffer.h" +#include "llglslshader.h" + +//============================================================================= +LLRenderNavPrim gRenderNav; +//============================================================================= +void LLRenderNavPrim::renderLLSegment( const LLVector3& start, const LLVector3& end, const LLColor4U& color ) const +{ + LLColor4 colorA( color ); + gGL.color3fv( colorA.mV ); + + gGL.begin(LLRender::LINES); + { + gGL.vertex3fv( start.mV ); + gGL.vertex3fv( end.mV ); + } + gGL.end(); +} +//============================================================================= +void LLRenderNavPrim::renderTri( const LLVector3& a, const LLVector3& b, const LLVector3& c, int color ) const +{ + LLColor4 colorA( color ); + colorA*=1.25f; + gGL.color4fv( colorA.mV ); + gGL.begin(LLRender::TRIANGLES); + { + gGL.vertex3fv( a.mV ); + gGL.vertex3fv( b.mV ); + gGL.vertex3fv( c.mV ); + } + gGL.end(); +} +//============================================================================= +void LLRenderNavPrim::renderLLTri( const LLVector3& a, const LLVector3& b, const LLVector3& c, const LLColor4U& color, const LLVector3& n ) const +{ + LLColor4 cV(color); + gGL.color4fv( cV.mV ); + gGL.begin(LLRender::TRIANGLES); + { + gGL.vertex3fv( a.mV ); + gGL.vertex3fv( b.mV ); + gGL.vertex3fv( c.mV ); + } + gGL.end(); +} +//============================================================================= +void LLRenderNavPrim::renderNavMeshVB( LLVertexBuffer* pVBO, int vertCnt ) +{ + pVBO->setBuffer( LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_COLOR | LLVertexBuffer::MAP_NORMAL ); + pVBO->drawArrays( LLRender::TRIANGLES, 0, vertCnt ); +} +//============================================================================= +void LLRenderNavPrim::renderStar( const LLVector3& center, const float scale, const LLColor4U& color ) const +{ + for (int k=0; k<3; k++) + { + LLVector3 star, pt1, pt2; + star = LLVector3( 0.0f,0.0f,0.0f); + star[k] = 0.5f; + pt1 = center + star; + pt2 = center - star; + renderLLSegment( pt1, pt2, color ); + } +} +//============================================================================= -- cgit v1.2.3 From b752a3a689ea2000398c9f93e801d87a2681223c Mon Sep 17 00:00:00 2001 From: prep Date: Thu, 5 Apr 2012 11:08:31 -0400 Subject: Navmesh edges are now rendered via vertex buffers. Enjoy the speedup! --- indra/llrender/llrendernavprim.cpp | 6 ++ indra/llrender/llrendernavprim.h | 120 +++++++++++++++++++------------------ 2 files changed, 67 insertions(+), 59 deletions(-) (limited to 'indra/llrender') diff --git a/indra/llrender/llrendernavprim.cpp b/indra/llrender/llrendernavprim.cpp index 56b176d39c..2632428dfd 100644 --- a/indra/llrender/llrendernavprim.cpp +++ b/indra/llrender/llrendernavprim.cpp @@ -81,6 +81,12 @@ void LLRenderNavPrim::renderNavMeshVB( LLVertexBuffer* pVBO, int vertCnt ) pVBO->drawArrays( LLRender::TRIANGLES, 0, vertCnt ); } //============================================================================= +void LLRenderNavPrim::renderNavMeshEdgeVB( LLVertexBuffer* pVBO, int vertCnt ) +{ + pVBO->setBuffer( LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_COLOR | LLVertexBuffer::MAP_NORMAL ); + pVBO->drawArrays( LLRender::LINES, 0, vertCnt ); +} +//============================================================================= void LLRenderNavPrim::renderStar( const LLVector3& center, const float scale, const LLColor4U& color ) const { for (int k=0; k<3; k++) diff --git a/indra/llrender/llrendernavprim.h b/indra/llrender/llrendernavprim.h index 7fbd02de93..809debb006 100644 --- a/indra/llrender/llrendernavprim.h +++ b/indra/llrender/llrendernavprim.h @@ -1,59 +1,61 @@ -/** - * @file LLRenderNavPrim.h - * @brief - * - * $LicenseInfo:firstyear=2001&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -#ifndef LL_RENDER_NAVPRIM_H -#define LL_RENDER_NAVPRIM_H - -#include "llmath.h" -#include "v3math.h" -#include "v4math.h" -#include "m3math.h" -#include "m4math.h" -#include "v4color.h" -#include "llgl.h" - - -class LLRenderNavPrim -{ -public: - //Draw a line - void renderLLSegment( const LLVector3& start, const LLVector3& end, const LLColor4U& color ) const; - //Draw simple tri - void renderTri( const LLVector3& a, const LLVector3& b, const LLVector3& c, int color ) const; - //Draw simple tri - void renderLLTri( const LLVector3& a, const LLVector3& b, const LLVector3& c, const LLColor4U& color, const LLVector3& n ) const; - //Draw the contents of vertex buffer - void renderNavMeshVB( LLVertexBuffer* pVBO, int vertCnt ); - //Draw a star - void renderStar( const LLVector3& center, const float scale, const LLColor4U& color ) const; - //Flush the device - void flushDevice() { gGL.flush(); } -private: -}; - -extern LLRenderNavPrim gRenderNav; - -#endif +/** + * @file LLRenderNavPrim.h + * @brief + * + * $LicenseInfo:firstyear=2001&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2010, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#ifndef LL_RENDER_NAVPRIM_H +#define LL_RENDER_NAVPRIM_H + +#include "llmath.h" +#include "v3math.h" +#include "v4math.h" +#include "m3math.h" +#include "m4math.h" +#include "v4color.h" +#include "llgl.h" + + +class LLRenderNavPrim +{ +public: + //Draw a line + void renderLLSegment( const LLVector3& start, const LLVector3& end, const LLColor4U& color ) const; + //Draw simple tri + void renderTri( const LLVector3& a, const LLVector3& b, const LLVector3& c, int color ) const; + //Draw simple tri + void renderLLTri( const LLVector3& a, const LLVector3& b, const LLVector3& c, const LLColor4U& color, const LLVector3& n ) const; + //Draw the contents of vertex buffer + void renderNavMeshVB( LLVertexBuffer* pVBO, int vertCnt ); + //Draw the contents of the edge vertex buffer + void renderNavMeshEdgeVB( LLVertexBuffer* pVBO, int vertCnt ); + //Draw a star + void renderStar( const LLVector3& center, const float scale, const LLColor4U& color ) const; + //Flush the device + void flushDevice() { gGL.flush(); } +private: +}; + +extern LLRenderNavPrim gRenderNav; + +#endif -- cgit v1.2.3 From fef78653cd2a81efb032d7570fc5e5a0814086b7 Mon Sep 17 00:00:00 2001 From: prep Date: Thu, 5 Apr 2012 14:27:05 -0400 Subject: consolidate navmesh rendering calls --- indra/llrender/llrendernavprim.cpp | 10 ++-------- indra/llrender/llrendernavprim.h | 4 +--- 2 files changed, 3 insertions(+), 11 deletions(-) (limited to 'indra/llrender') diff --git a/indra/llrender/llrendernavprim.cpp b/indra/llrender/llrendernavprim.cpp index 2632428dfd..100b614aae 100644 --- a/indra/llrender/llrendernavprim.cpp +++ b/indra/llrender/llrendernavprim.cpp @@ -75,16 +75,10 @@ void LLRenderNavPrim::renderLLTri( const LLVector3& a, const LLVector3& b, const gGL.end(); } //============================================================================= -void LLRenderNavPrim::renderNavMeshVB( LLVertexBuffer* pVBO, int vertCnt ) +void LLRenderNavPrim::renderNavMeshVB( U32 mode, LLVertexBuffer* pVBO, int vertCnt ) { pVBO->setBuffer( LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_COLOR | LLVertexBuffer::MAP_NORMAL ); - pVBO->drawArrays( LLRender::TRIANGLES, 0, vertCnt ); -} -//============================================================================= -void LLRenderNavPrim::renderNavMeshEdgeVB( LLVertexBuffer* pVBO, int vertCnt ) -{ - pVBO->setBuffer( LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_COLOR | LLVertexBuffer::MAP_NORMAL ); - pVBO->drawArrays( LLRender::LINES, 0, vertCnt ); + pVBO->drawArrays( mode, 0, vertCnt ); } //============================================================================= void LLRenderNavPrim::renderStar( const LLVector3& center, const float scale, const LLColor4U& color ) const diff --git a/indra/llrender/llrendernavprim.h b/indra/llrender/llrendernavprim.h index 809debb006..97d1c805af 100644 --- a/indra/llrender/llrendernavprim.h +++ b/indra/llrender/llrendernavprim.h @@ -46,9 +46,7 @@ public: //Draw simple tri void renderLLTri( const LLVector3& a, const LLVector3& b, const LLVector3& c, const LLColor4U& color, const LLVector3& n ) const; //Draw the contents of vertex buffer - void renderNavMeshVB( LLVertexBuffer* pVBO, int vertCnt ); - //Draw the contents of the edge vertex buffer - void renderNavMeshEdgeVB( LLVertexBuffer* pVBO, int vertCnt ); + void renderNavMeshVB( U32 mode, LLVertexBuffer* pVBO, int vertCnt ); //Draw a star void renderStar( const LLVector3& center, const float scale, const LLColor4U& color ) const; //Flush the device -- cgit v1.2.3