From 50089ec0549b8f1c2de34b90d07d1d1c8c2ce03d Mon Sep 17 00:00:00 2001 From: Hecklezz Date: Thu, 27 Mar 2025 22:58:27 +1000 Subject: [PATCH 1/2] Fixes the minimap in OpenSim for regions larger than 256x256. Also fixes the minimap not correctly rendering when you swap grid. --- indra/newview/llnetmap.cpp | 88 +++++++++++++++++++++++++++++++------- 1 file changed, 72 insertions(+), 16 deletions(-) diff --git a/indra/newview/llnetmap.cpp b/indra/newview/llnetmap.cpp index 4eeab0d8d3..3cc34e2516 100644 --- a/indra/newview/llnetmap.cpp +++ b/indra/newview/llnetmap.cpp @@ -91,6 +91,8 @@ #include "fscommon.h" #include "llstartup.h" +#include "llviewernetwork.h" // Access to GridManager + static LLDefaultChildRegistry::Register r1("net_map"); constexpr F32 LLNetMap::MAP_SCALE_MIN = 32; @@ -454,26 +456,80 @@ void LLNetMap::draw() gGL.color4f(1.f, 0.5f, 0.5f, 1.f); } - // Draw using texture. - gGL.getTexUnit(0)->bind(regionp->getLand().getSTexture()); - gGL.begin(LLRender::TRIANGLES); + // [FIRE-35147] OpenSim regions can be greater than 256x256 and need to be accounted for + if (!LLGridManager::getInstance()->isInSecondLife()) { - gGL.texCoord2f(0.f, 1.f); - gGL.vertex2f(left, top); - gGL.texCoord2f(0.f, 0.f); - gGL.vertex2f(left, bottom); - gGL.texCoord2f(1.f, 0.f); - gGL.vertex2f(right, bottom); + // Fixes OpenSim race condition on grid change not having updated Grid Info yet + bool isAgentTeleporting = gAgent.getTeleportState() != LLAgent::TELEPORT_NONE; + if (!isAgentTeleporting) + { + const LLViewerRegion::tex_matrix_t& tiles(regionp->getWorldMapTiles()); + for (S32 i(0), scaled_width((S32)(real_width / region_width)), square_width(scaled_width * scaled_width); + i < square_width; ++i) + { + const F32 y = (F32)(i / scaled_width); + const F32 x = (F32)(i - y * scaled_width); + const F32 local_left(left + x * mScale); + const F32 local_right(local_left + mScale); + const F32 local_bottom(bottom + y * mScale); + const F32 local_top(local_bottom + mScale); + LLPointer pRegionImage = tiles[(U64)(x * scaled_width + y)]; + if (pRegionImage.isNull()) + continue; - gGL.texCoord2f(0.f, 1.f); - gGL.vertex2f(left, top); - gGL.texCoord2f(1.f, 0.f); - gGL.vertex2f(right, bottom); - gGL.texCoord2f(1.f, 1.f); - gGL.vertex2f(right, top); + if (!pRegionImage->hasGLTexture()) + { + // Workaround that eventually forces the image to load if it has no GLTexture (such as when changing grid) + // I'm not exactly sure why this works, but at least it fixes the minimap when you go to a new grid. + pRegionImage->setBoostLevel(LLViewerTexture::BOOST_MAP_VISIBLE); + continue; + } + + gGL.getTexUnit(0)->bind(pRegionImage); + gGL.begin(LLRender::TRIANGLES); + { + gGL.texCoord2f(0.f, 1.f); + gGL.vertex2f(local_left, local_top); + gGL.texCoord2f(0.f, 0.f); + gGL.vertex2f(local_left, local_bottom); + gGL.texCoord2f(1.f, 0.f); + gGL.vertex2f(local_right, local_bottom); + + gGL.texCoord2f(0.f, 1.f); + gGL.vertex2f(local_left, local_top); + gGL.texCoord2f(1.f, 0.f); + gGL.vertex2f(local_right, local_bottom); + gGL.texCoord2f(1.f, 1.f); + gGL.vertex2f(local_right, local_top); + } + gGL.end(); + pRegionImage->setBoostLevel(LLViewerTexture::BOOST_MAP_VISIBLE); + } + } } - gGL.end(); + // + else + { + // Draw using texture. + gGL.getTexUnit(0)->bind(regionp->getLand().getSTexture()); + gGL.begin(LLRender::TRIANGLES); + { + gGL.texCoord2f(0.f, 1.f); + gGL.vertex2f(left, top); + gGL.texCoord2f(0.f, 0.f); + gGL.vertex2f(left, bottom); + gGL.texCoord2f(1.f, 0.f); + gGL.vertex2f(right, bottom); + gGL.texCoord2f(0.f, 1.f); + gGL.vertex2f(left, top); + gGL.texCoord2f(1.f, 0.f); + gGL.vertex2f(right, bottom); + gGL.texCoord2f(1.f, 1.f); + gGL.vertex2f(right, top); + } + gGL.end(); + } gGL.flush(); } From 48e7ff4e53d2d32993c9c3dc114756bc5712af2f Mon Sep 17 00:00:00 2001 From: Hecklezz Date: Fri, 28 Mar 2025 08:20:48 +1000 Subject: [PATCH 2/2] Refactored minimap opensim rendering fix --- indra/newview/llnetmap.cpp | 41 +++++++++++++++++--------------------- 1 file changed, 18 insertions(+), 23 deletions(-) diff --git a/indra/newview/llnetmap.cpp b/indra/newview/llnetmap.cpp index 3cc34e2516..3de843627f 100644 --- a/indra/newview/llnetmap.cpp +++ b/indra/newview/llnetmap.cpp @@ -477,32 +477,27 @@ void LLNetMap::draw() if (pRegionImage.isNull()) continue; - if (!pRegionImage->hasGLTexture()) + if (pRegionImage->hasGLTexture()) { - // Workaround that eventually forces the image to load if it has no GLTexture (such as when changing grid) - // I'm not exactly sure why this works, but at least it fixes the minimap when you go to a new grid. - pRegionImage->setBoostLevel(LLViewerTexture::BOOST_MAP_VISIBLE); - continue; - } + gGL.getTexUnit(0)->bind(pRegionImage); + gGL.begin(LLRender::TRIANGLES); + { + gGL.texCoord2f(0.f, 1.f); + gGL.vertex2f(local_left, local_top); + gGL.texCoord2f(0.f, 0.f); + gGL.vertex2f(local_left, local_bottom); + gGL.texCoord2f(1.f, 0.f); + gGL.vertex2f(local_right, local_bottom); - gGL.getTexUnit(0)->bind(pRegionImage); - gGL.begin(LLRender::TRIANGLES); - { - gGL.texCoord2f(0.f, 1.f); - gGL.vertex2f(local_left, local_top); - gGL.texCoord2f(0.f, 0.f); - gGL.vertex2f(local_left, local_bottom); - gGL.texCoord2f(1.f, 0.f); - gGL.vertex2f(local_right, local_bottom); - - gGL.texCoord2f(0.f, 1.f); - gGL.vertex2f(local_left, local_top); - gGL.texCoord2f(1.f, 0.f); - gGL.vertex2f(local_right, local_bottom); - gGL.texCoord2f(1.f, 1.f); - gGL.vertex2f(local_right, local_top); + gGL.texCoord2f(0.f, 1.f); + gGL.vertex2f(local_left, local_top); + gGL.texCoord2f(1.f, 0.f); + gGL.vertex2f(local_right, local_bottom); + gGL.texCoord2f(1.f, 1.f); + gGL.vertex2f(local_right, local_top); + } + gGL.end(); } - gGL.end(); pRegionImage->setBoostLevel(LLViewerTexture::BOOST_MAP_VISIBLE); } }