summaryrefslogtreecommitdiff
path: root/indra/newview/llviewerparceloverlay.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llviewerparceloverlay.cpp')
-rw-r--r--indra/newview/llviewerparceloverlay.cpp172
1 files changed, 87 insertions, 85 deletions
diff --git a/indra/newview/llviewerparceloverlay.cpp b/indra/newview/llviewerparceloverlay.cpp
index 3dc14caa2d..eee653b0c1 100644
--- a/indra/newview/llviewerparceloverlay.cpp
+++ b/indra/newview/llviewerparceloverlay.cpp
@@ -2,30 +2,25 @@
* @file llviewerparceloverlay.cpp
* @brief LLViewerParcelOverlay class implementation
*
- * $LicenseInfo:firstyear=2002&license=viewergpl$
- *
- * Copyright (c) 2002-2007, Linden Research, Inc.
- *
+ * $LicenseInfo:firstyear=2002&license=viewerlgpl$
* Second Life Viewer Source Code
- * The source code in this file ("Source Code") is provided by Linden Lab
- * to you under the terms of the GNU General Public License, version 2.0
- * ("GPL"), unless you have obtained a separate licensing agreement
- * ("Other License"), formally executed by you and Linden Lab. Terms of
- * the GPL can be found in doc/GPL-license.txt in this distribution, or
- * online at http://secondlife.com/developers/opensource/gplv2
+ * Copyright (C) 2010, Linden Research, Inc.
*
- * There are special exceptions to the terms and conditions of the GPL as
- * it is applied to this Source Code. View the full text of the exception
- * in the file doc/FLOSS-exception.txt in this software distribution, or
- * online at http://secondlife.com/developers/opensource/flossexception
+ * 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.
*
- * By copying, modifying or distributing this software, you acknowledge
- * that you have read and understood your obligations described above,
- * and agree to abide by those obligations.
+ * 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.
*
- * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
- * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
- * COMPLETENESS OR PERFORMANCE.
+ * 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$
*/
@@ -35,20 +30,25 @@
// indra includes
#include "llparcel.h"
+#include "llfloaterreg.h"
#include "llgl.h"
-#include "llglimmediate.h"
+#include "llrender.h"
#include "v4color.h"
#include "v2math.h"
// newview includes
-#include "llviewerimage.h"
+#include "llagentcamera.h"
+#include "llviewertexture.h"
#include "llviewercontrol.h"
#include "llsurface.h"
#include "llviewerregion.h"
-#include "llagent.h"
#include "llviewercamera.h"
-#include "llviewerimagelist.h"
+#include "llviewertexturelist.h"
+#include "llselectmgr.h"
+#include "llfloatertools.h"
#include "llglheaders.h"
+#include "pipeline.h"
+
const U8 OVERLAY_IMG_COMPONENTS = 4;
@@ -58,7 +58,6 @@ LLViewerParcelOverlay::LLViewerParcelOverlay(LLViewerRegion* region, F32 region_
mDirty( FALSE ),
mTimeSinceLastUpdate(),
mOverlayTextureIdx(-1),
- mLineImageID( gViewerArt.getString("propertyline.tga") ),
mVertexCount(0),
mVertexArray(NULL),
mColorArray(NULL)
@@ -66,14 +65,11 @@ LLViewerParcelOverlay::LLViewerParcelOverlay(LLViewerRegion* region, F32 region_
{
// Create a texture to hold color information.
// 4 components
- // Use mipmaps = FALSE, clamped, NEAREST filter, for sharp edges
- mTexture = new LLImageGL(FALSE);
+ // Use mipmaps = FALSE, clamped, NEAREST filter, for sharp edges
mImageRaw = new LLImageRaw(mParcelGridsPerEdge, mParcelGridsPerEdge, OVERLAY_IMG_COMPONENTS);
- mTexture->createGLTexture(0, mImageRaw);
- glActiveTextureARB(GL_TEXTURE0_ARB);
- mTexture->bind(0);
- mTexture->setClamp(TRUE, TRUE);
- mTexture->setMipFilterNearest(TRUE);
+ mTexture = LLViewerTextureManager::getLocalTexture(mImageRaw.get(), FALSE);
+ mTexture->setAddressMode(LLTexUnit::TAM_CLAMP);
+ mTexture->setFilteringOption(LLTexUnit::TFO_POINT);
//
// Initialize the GL texture with empty data.
@@ -85,7 +81,7 @@ LLViewerParcelOverlay::LLViewerParcelOverlay(LLViewerRegion* region, F32 region_
{
raw[i] = 0;
}
- mTexture->setSubImage(mImageRaw, 0, 0, mParcelGridsPerEdge, mParcelGridsPerEdge);
+ //mTexture->setSubImage(mImageRaw, 0, 0, mParcelGridsPerEdge, mParcelGridsPerEdge);
// Create storage for ownership information from simulator
// and initialize it.
@@ -95,8 +91,7 @@ LLViewerParcelOverlay::LLViewerParcelOverlay(LLViewerRegion* region, F32 region_
mOwnership[i] = PARCEL_PUBLIC;
}
- // Make sure the texture matches the ownership information.
- updateOverlayTexture();
+ gPipeline.markGLRebuild(this);
}
@@ -203,13 +198,12 @@ void LLViewerParcelOverlay::updateOverlayTexture()
{
return;
}
- // Can do this because gColors are actually stored as LLColor4U
- const LLColor4U avail = gColors.getColor4U("PropertyColorAvail");
- const LLColor4U owned = gColors.getColor4U("PropertyColorOther");
- const LLColor4U group = gColors.getColor4U("PropertyColorGroup");
- const LLColor4U self = gColors.getColor4U("PropertyColorSelf");
- const LLColor4U for_sale = gColors.getColor4U("PropertyColorForSale");
- const LLColor4U auction = gColors.getColor4U("PropertyColorAuction");
+ const LLColor4U avail = LLUIColorTable::instance().getColor("PropertyColorAvail").get();
+ const LLColor4U owned = LLUIColorTable::instance().getColor("PropertyColorOther").get();
+ const LLColor4U group = LLUIColorTable::instance().getColor("PropertyColorGroup").get();
+ const LLColor4U self = LLUIColorTable::instance().getColor("PropertyColorSelf").get();
+ const LLColor4U for_sale = LLUIColorTable::instance().getColor("PropertyColorForSale").get();
+ const LLColor4U auction = LLUIColorTable::instance().getColor("PropertyColorAuction").get();
// Create the base texture.
U8 *raw = mImageRaw->getData();
@@ -222,7 +216,7 @@ void LLViewerParcelOverlay::updateOverlayTexture()
{
U8 ownership = mOwnership[i];
- U8 r,g,b,a;
+ F32 r,g,b,a;
// Color stored in low three bits
switch( ownership & 0x7 )
@@ -271,10 +265,10 @@ void LLViewerParcelOverlay::updateOverlayTexture()
break;
}
- raw[pixel_index + 0] = r;
- raw[pixel_index + 1] = g;
- raw[pixel_index + 2] = b;
- raw[pixel_index + 3] = a;
+ raw[pixel_index + 0] = (U8)r;
+ raw[pixel_index + 1] = (U8)g;
+ raw[pixel_index + 2] = (U8)b;
+ raw[pixel_index + 3] = (U8)a;
pixel_index += OVERLAY_IMG_COMPONENTS;
}
@@ -282,6 +276,10 @@ void LLViewerParcelOverlay::updateOverlayTexture()
// Copy data into GL texture from raw data
if (i >= COUNT)
{
+ if (!mTexture->hasGLTexture())
+ {
+ mTexture->createGLTexture(0, mImageRaw);
+ }
mTexture->setSubImage(mImageRaw, 0, 0, mParcelGridsPerEdge, mParcelGridsPerEdge);
mOverlayTextureIdx = -1;
}
@@ -312,12 +310,11 @@ void LLViewerParcelOverlay::updatePropertyLines()
S32 row, col;
- // Can do this because gColors are actually stored as LLColor4U
- const LLColor4U self_coloru = gColors.getColor4U("PropertyColorSelf");
- const LLColor4U other_coloru = gColors.getColor4U("PropertyColorOther");
- const LLColor4U group_coloru = gColors.getColor4U("PropertyColorGroup");
- const LLColor4U for_sale_coloru = gColors.getColor4U("PropertyColorForSale");
- const LLColor4U auction_coloru = gColors.getColor4U("PropertyColorAuction");
+ const LLColor4U self_coloru = LLUIColorTable::instance().getColor("PropertyColorSelf").get();
+ const LLColor4U other_coloru = LLUIColorTable::instance().getColor("PropertyColorOther").get();
+ const LLColor4U group_coloru = LLUIColorTable::instance().getColor("PropertyColorGroup").get();
+ const LLColor4U for_sale_coloru = LLUIColorTable::instance().getColor("PropertyColorForSale").get();
+ const LLColor4U auction_coloru = LLUIColorTable::instance().getColor("PropertyColorAuction").get();
// Build into dynamic arrays, then copy into static arrays.
LLDynamicArray<LLVector3, 256> new_vertex_array;
@@ -709,8 +706,14 @@ void LLViewerParcelOverlay::setDirty()
mDirty = TRUE;
}
+void LLViewerParcelOverlay::updateGL()
+{
+ updateOverlayTexture();
+}
+
void LLViewerParcelOverlay::idleUpdate(bool force_update)
{
+ LLMemType mt_iup(LLMemType::MTYPE_IDLE_UPDATE_PARCEL_OVERLAY);
if (gGLManager.mIsDisabled)
{
return;
@@ -718,7 +721,7 @@ void LLViewerParcelOverlay::idleUpdate(bool force_update)
if (mOverlayTextureIdx >= 0 && (!(mDirty && force_update)))
{
// We are in the middle of updating the overlay texture
- updateOverlayTexture();
+ gPipeline.markGLRebuild(this);
return;
}
// Only if we're dirty and it's been a while since the last update.
@@ -747,23 +750,18 @@ S32 LLViewerParcelOverlay::renderPropertyLines ()
LLSurface& land = mRegion->getLand();
LLGLSUIDefault gls_ui; // called from pipeline
- LLGLSNoTexture gls_no_texture;
+ gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
LLGLDepthTest mDepthTest(GL_TRUE);
- // JC - This doesn't work.
- //gGLSUITextureDepth.set();
- //LLViewerImage* image = gImageList.getImage( mLineImageID );
- //image->bindTexture();
-
// Find camera height off the ground (not from zero)
- F32 ground_height_at_camera = land.resolveHeightGlobal( gAgent.getCameraPositionGlobal() );
- F32 camera_z = gCamera->getOrigin().mV[VZ];
+ F32 ground_height_at_camera = land.resolveHeightGlobal( gAgentCamera.getCameraPositionGlobal() );
+ F32 camera_z = LLViewerCamera::getInstance()->getOrigin().mV[VZ];
F32 camera_height = camera_z - ground_height_at_camera;
camera_height = llclamp(camera_height, 0.f, 100.f);
// Pull lines toward camera by 1 cm per meter off the ground.
- const LLVector3& CAMERA_AT = gCamera->getAtAxis();
+ const LLVector3& CAMERA_AT = LLViewerCamera::getInstance()->getAtAxis();
F32 pull_toward_camera_scale = 0.01f * camera_height;
LLVector3 pull_toward_camera = CAMERA_AT;
pull_toward_camera *= -pull_toward_camera_scale;
@@ -787,11 +785,11 @@ S32 LLViewerParcelOverlay::renderPropertyLines ()
const S32 vertex_per_edge = 3 + 2 * (GRID_STEP-1) + 3;
// Stomp the camera into two dimensions
- LLVector3 camera_region = mRegion->getPosRegionFromGlobal( gAgent.getCameraPositionGlobal() );
+ LLVector3 camera_region = mRegion->getPosRegionFromGlobal( gAgentCamera.getCameraPositionGlobal() );
// Set up a cull plane 2 * PARCEL_GRID_STEP_METERS behind
// the camera. The cull plane normal is the camera's at axis.
- LLVector3 cull_plane_point = gCamera->getAtAxis();
+ LLVector3 cull_plane_point = LLViewerCamera::getInstance()->getAtAxis();
cull_plane_point *= -2.f * PARCEL_GRID_STEP_METERS;
cull_plane_point += camera_region;
@@ -804,6 +802,7 @@ S32 LLViewerParcelOverlay::renderPropertyLines ()
S32 drawn = 0;
F32* vertexp;
U8* colorp;
+ bool render_hidden = LLSelectMgr::sRenderHiddenSelections && LLFloaterReg::instanceVisible("build");
const F32 PROPERTY_LINE_CLIP_DIST = 256.f;
@@ -830,7 +829,7 @@ S32 LLViewerParcelOverlay::renderPropertyLines ()
continue;
}
- gGL.begin(GL_TRIANGLE_STRIP);
+ gGL.begin(LLRender::TRIANGLE_STRIP);
for (j = 0; j < vertex_per_edge; j++)
{
@@ -844,32 +843,35 @@ S32 LLViewerParcelOverlay::renderPropertyLines ()
drawn += vertex_per_edge;
gGL.end();
-
- LLGLDepthTest depth(GL_TRUE, GL_FALSE, GL_GREATER);
- colorp = mColorArray + BYTES_PER_COLOR * i;
- vertexp = mVertexArray + FLOATS_PER_VERTEX * i;
+ if (render_hidden)
+ {
+ LLGLDepthTest depth(GL_TRUE, GL_FALSE, GL_GREATER);
+
+ colorp = mColorArray + BYTES_PER_COLOR * i;
+ vertexp = mVertexArray + FLOATS_PER_VERTEX * i;
- gGL.begin(GL_TRIANGLE_STRIP);
+ gGL.begin(LLRender::TRIANGLE_STRIP);
- for (j = 0; j < vertex_per_edge; j++)
- {
- U8 color[4];
- color[0] = colorp[0];
- color[1] = colorp[1];
- color[2] = colorp[2];
- color[3] = colorp[3]/4;
+ for (j = 0; j < vertex_per_edge; j++)
+ {
+ U8 color[4];
+ color[0] = colorp[0];
+ color[1] = colorp[1];
+ color[2] = colorp[2];
+ color[3] = colorp[3]/4;
- gGL.color4ubv(color);
- gGL.vertex3fv(vertexp);
+ gGL.color4ubv(color);
+ gGL.vertex3fv(vertexp);
- colorp += BYTES_PER_COLOR;
- vertexp += FLOATS_PER_VERTEX;
- }
+ colorp += BYTES_PER_COLOR;
+ vertexp += FLOATS_PER_VERTEX;
+ }
- drawn += vertex_per_edge;
+ drawn += vertex_per_edge;
- gGL.end();
+ gGL.end();
+ }
}