From 898079a39bc86598d8e998a24845d0932c88cdca Mon Sep 17 00:00:00 2001 From: Cosmic Linden Date: Tue, 25 Jan 2022 17:25:46 -0800 Subject: SL-16857: Display parcel borders on the minimap, enable by default, right click context menu option to disable --- indra/newview/llviewerparceloverlay.cpp | 64 +++++++++++++++++++++++++++++++-- 1 file changed, 61 insertions(+), 3 deletions(-) mode change 100644 => 100755 indra/newview/llviewerparceloverlay.cpp (limited to 'indra/newview/llviewerparceloverlay.cpp') diff --git a/indra/newview/llviewerparceloverlay.cpp b/indra/newview/llviewerparceloverlay.cpp old mode 100644 new mode 100755 index 7c3dd00e1a..c170a240a8 --- a/indra/newview/llviewerparceloverlay.cpp +++ b/indra/newview/llviewerparceloverlay.cpp @@ -907,8 +907,8 @@ S32 LLViewerParcelOverlay::renderPropertyLines () // Always fudge a little vertically. pull_toward_camera.mV[VZ] += 0.01f; - gGL.matrixMode(LLRender::MM_MODELVIEW); - gGL.pushMatrix(); + gGL.matrixMode(LLRender::MM_MODELVIEW); + gGL.pushMatrix(); // Move to appropriate region coords LLVector3 origin = mRegion->getOriginAgent(); @@ -1013,7 +1013,65 @@ S32 LLViewerParcelOverlay::renderPropertyLines () } - gGL.popMatrix(); + gGL.popMatrix(); return drawn; } + +// Draw half of a single cell (no fill) in a grid drawn from left to right and from bottom to top +void grid_2d_part_lines(const F32 left, const F32 top, const F32 right, const F32 bottom, bool has_left, bool has_bottom) +{ + gGL.begin(LLRender::LINES); + + if (has_left) + { + gGL.vertex2f(left, bottom); + gGL.vertex2f(left, top); + } + if (has_bottom) + { + gGL.vertex2f(left, bottom); + gGL.vertex2f(right, bottom); + } + + gGL.end(); +} + +void LLViewerParcelOverlay::renderPropertyLinesOnMinimap(F32 scale_pixels_per_meter, const F32 *parcel_outline_color) +{ + if (!mOwnership) + { + return; + } + if (!gSavedSettings.getBOOL("MiniMapShowPropertyLines")) + { + return; + } + + LLVector3 origin_agent = mRegion->getOriginAgent(); + LLVector3 rel_region_pos = origin_agent - gAgentCamera.getCameraPositionAgent(); + F32 region_left = rel_region_pos.mV[0] * scale_pixels_per_meter; + F32 region_bottom = rel_region_pos.mV[1] * scale_pixels_per_meter; + F32 map_parcel_width = PARCEL_GRID_STEP_METERS * scale_pixels_per_meter; + const S32 GRIDS_PER_EDGE = mParcelGridsPerEdge; + + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); + glLineWidth(1.0f); + gGL.color4fv(parcel_outline_color); + for (S32 i = 0; i < GRIDS_PER_EDGE + 1; i++) + { + F32 bottom = region_bottom + (i * map_parcel_width); + F32 top = bottom + map_parcel_width; + for (S32 j = 0; j < GRIDS_PER_EDGE + 1; j++) + { + F32 left = region_left + (j * map_parcel_width); + F32 right = left + map_parcel_width; + U8 overlay = mOwnership[(i * GRIDS_PER_EDGE) + j]; + // The property line vertices are three-dimensional, but here we only care about the x and y coordinates, as we are drawing on a + // 2D map + const bool has_left = i != GRIDS_PER_EDGE && (j == GRIDS_PER_EDGE || (overlay & PARCEL_WEST_LINE)); + const bool has_bottom = j != GRIDS_PER_EDGE && (i == GRIDS_PER_EDGE || (overlay & PARCEL_SOUTH_LINE)); + grid_2d_part_lines(left, top, right, bottom, has_left, has_bottom); + } + } +} -- cgit v1.2.3 From 25900c179cdc963cab207ec821a739a196cf1d29 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Fri, 22 Jul 2022 03:03:00 +0300 Subject: SL-17815 Crash at parcelLineFlags Col ended up negative --- indra/newview/llviewerparceloverlay.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'indra/newview/llviewerparceloverlay.cpp') diff --git a/indra/newview/llviewerparceloverlay.cpp b/indra/newview/llviewerparceloverlay.cpp index 4d1a7e0ba3..31587549e8 100755 --- a/indra/newview/llviewerparceloverlay.cpp +++ b/indra/newview/llviewerparceloverlay.cpp @@ -264,7 +264,7 @@ BOOL LLViewerParcelOverlay::isSoundLocal(const LLVector3& pos) const { S32 row = S32(pos.mV[VY] / PARCEL_GRID_STEP_METERS); S32 column = S32(pos.mV[VX] / PARCEL_GRID_STEP_METERS); - return PARCEL_SOUND_LOCAL & mOwnership[row * mParcelGridsPerEdge + column]; + return parcelFlags(row, column, PARCEL_SOUND_LOCAL); } U8 LLViewerParcelOverlay::ownership( const LLVector3& pos) const @@ -278,12 +278,19 @@ U8 LLViewerParcelOverlay::parcelLineFlags(const LLVector3& pos) const { S32 row = S32(pos.mV[VY] / PARCEL_GRID_STEP_METERS); S32 column = S32(pos.mV[VX] / PARCEL_GRID_STEP_METERS); - return parcelLineFlags(row, column); + return parcelFlags(row, column, PARCEL_WEST_LINE | PARCEL_SOUTH_LINE); } U8 LLViewerParcelOverlay::parcelLineFlags(S32 row, S32 col) const { - U8 flags = PARCEL_WEST_LINE | PARCEL_SOUTH_LINE; - if (row > mParcelGridsPerEdge || col > mParcelGridsPerEdge) + return parcelFlags(row, col, PARCEL_WEST_LINE | PARCEL_SOUTH_LINE); +} + +U8 LLViewerParcelOverlay::parcelFlags(S32 row, S32 col, U8 flags) const +{ + if (row >= mParcelGridsPerEdge + || col >= mParcelGridsPerEdge + || row < 0 + || col < 0) { LL_WARNS() << "Attempted to get ownership out of region's overlay, row: " << row << " col: " << col << LL_ENDL; return flags; -- cgit v1.2.3 From 1521221e56de368a3b28c170a1e69e3c7dde7507 Mon Sep 17 00:00:00 2001 From: Cosmic Linden Date: Tue, 26 Jul 2022 11:31:01 -0700 Subject: SL-17826: Fix index out of bounds in mOwnership when drawing parcel lines --- indra/newview/llviewerparceloverlay.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'indra/newview/llviewerparceloverlay.cpp') diff --git a/indra/newview/llviewerparceloverlay.cpp b/indra/newview/llviewerparceloverlay.cpp index 31587549e8..785c84c38d 100755 --- a/indra/newview/llviewerparceloverlay.cpp +++ b/indra/newview/llviewerparceloverlay.cpp @@ -1068,13 +1068,14 @@ void LLViewerParcelOverlay::renderPropertyLinesOnMinimap(F32 scale_pixels_per_me gGL.color4fv(parcel_outline_color); for (S32 i = 0; i < GRIDS_PER_EDGE + 1; i++) { - F32 bottom = region_bottom + (i * map_parcel_width); - F32 top = bottom + map_parcel_width; + const F32 bottom = region_bottom + (i * map_parcel_width); + const F32 top = bottom + map_parcel_width; for (S32 j = 0; j < GRIDS_PER_EDGE + 1; j++) { - F32 left = region_left + (j * map_parcel_width); - F32 right = left + map_parcel_width; - U8 overlay = mOwnership[(i * GRIDS_PER_EDGE) + j]; + const F32 left = region_left + (j * map_parcel_width); + const F32 right = left + map_parcel_width; + const bool is_region_boundary = i == GRIDS_PER_EDGE || j == GRIDS_PER_EDGE; + const U8 overlay = is_region_boundary ? 0 : mOwnership[(i * GRIDS_PER_EDGE) + j]; // The property line vertices are three-dimensional, but here we only care about the x and y coordinates, as we are drawing on a // 2D map const bool has_left = i != GRIDS_PER_EDGE && (j == GRIDS_PER_EDGE || (overlay & PARCEL_WEST_LINE)); -- cgit v1.2.3