From dd58fc16622978afab803f07dd8b7877c80f4d9c Mon Sep 17 00:00:00 2001 From: Frederick Martian Date: Sat, 11 Oct 2025 22:00:29 +0200 Subject: [PATCH 1/2] Fix gray background tiles in the Minimap This resolves the issue with the Minimap showing a gray tile and never updating after this until the Worldmap is opened too --- indra/newview/llsurface.cpp | 83 ++++++++++++++++++++----------------- indra/newview/llsurface.h | 14 ++----- 2 files changed, 50 insertions(+), 47 deletions(-) diff --git a/indra/newview/llsurface.cpp b/indra/newview/llsurface.cpp index 18268850697..c09935b330b 100644 --- a/indra/newview/llsurface.cpp +++ b/indra/newview/llsurface.cpp @@ -28,9 +28,6 @@ #include "llsurface.h" -#include "llrender.h" - -#include "llviewertexturelist.h" #include "llpatchvertexarray.h" #include "patch_dct.h" #include "patch_code.h" @@ -39,26 +36,21 @@ #include "llregionhandle.h" #include "llagent.h" #include "llagentcamera.h" -#include "llappviewer.h" #include "llworld.h" #include "llviewercontrol.h" #include "llviewertexture.h" #include "llsurfacepatch.h" -#include "llvosurfacepatch.h" #include "llvowater.h" #include "pipeline.h" #include "llviewerregion.h" -#include "llvlcomposition.h" -#include "noise.h" -#include "llviewercamera.h" -#include "llglheaders.h" #include "lldrawpoolterrain.h" -#include "lldrawable.h" #include "llworldmipmap.h" extern LLPipeline gPipeline; extern bool gShiftFrame; +#define MIN_TEXTURE_REQUEST_INTERVAL 1.f + LLColor4U MAX_WATER_COLOR(0, 48, 96, 240); @@ -74,18 +66,18 @@ LLSurface::LLSurface(U32 type, LLViewerRegion *regionp) : mType(type), mDetailTextureScale(0.f), mOriginGlobal(0.0, 0.0, 0.0), - mSTexturep(NULL), + mSTexturep(nullptr), mGridsPerPatchEdge(0), mMetersPerGrid(1.0f), mMetersPerEdge(1.0f), mRegionp(regionp) { // Surface data - mSurfaceZ = NULL; - mNorm = NULL; + mSurfaceZ = nullptr; + mNorm = nullptr; // Patch data - mPatchList = NULL; + mPatchList = nullptr; // One of each for each camera mVisiblePatchCount = 0; @@ -95,14 +87,14 @@ LLSurface::LLSurface(U32 type, LLViewerRegion *regionp) : mMinZ = 10000.f; mMaxZ = -10000.f; - mWaterObjp = NULL; + mWaterObjp = nullptr; // In here temporarily. mSurfacePatchUpdateCount = 0; for (S32 i = 0; i < 8; i++) { - mNeighbors[i] = NULL; + mNeighbors[i] = nullptr; } } @@ -110,7 +102,7 @@ LLSurface::LLSurface(U32 type, LLViewerRegion *regionp) : LLSurface::~LLSurface() { delete [] mSurfaceZ; - mSurfaceZ = NULL; + mSurfaceZ = nullptr; delete [] mNorm; @@ -129,7 +121,7 @@ LLSurface::~LLSurface() { gPipeline.removePool(poolp); // Don't enable this until we blitz the draw pool for it as well. -- djs - mSTexturep = NULL; + mSTexturep = nullptr; } else { @@ -144,7 +136,7 @@ void LLSurface::initClasses() void LLSurface::setRegion(LLViewerRegion *regionp) { mRegionp = regionp; - mWaterObjp = NULL; // depends on regionp, needs recreating + mWaterObjp = nullptr; // depends on regionp, needs recreating } // Assumes that arguments are powers of 2, and that @@ -202,7 +194,7 @@ void LLSurface::create(const S32 grids_per_edge, LLViewerTexture* LLSurface::getSTexture() { - if (mSTexturep.notNull() && !mSTexturep->hasGLTexture()) + if (mSTexturep.isNull() || !mSTexturep->hasGLTexture()) { createSTexture(); } @@ -211,7 +203,24 @@ LLViewerTexture* LLSurface::getSTexture() void LLSurface::createSTexture() { - if (!mSTexturep) + bool update = true; + if (mSTexturep.isNull()) + { + mTimer.setTimerExpirySec(MIN_TEXTURE_REQUEST_INTERVAL); + } + else if (!mSTexturep->hasGLTexture()) + { + // if we haven't gotten a valid texture yet, throttle the number of requests to avoid server flooding + update = mTimer.checkExpirationAndReset(MIN_TEXTURE_REQUEST_INTERVAL); + } + else + { + // What are we doing here? + LL_WARNS() << "Called LLSurface::createSTexture() while we already have a valid texture!" << LL_ENDL; + return; + } + + if (update) { U64 handle = mRegionp->getHandle(); @@ -285,7 +294,7 @@ void LLSurface::getNeighboringRegions( std::vector& uniqueRegio S32 i; for (i = 0; i < 8; i++) { - if ( mNeighbors[i] != NULL ) + if (mNeighbors[i] != nullptr) { uniqueRegions.push_back( mNeighbors[i]->getRegion() ); } @@ -298,7 +307,7 @@ void LLSurface::getNeighboringRegionsStatus( std::vector& regions ) S32 i; for (i = 0; i < 8; i++) { - if ( mNeighbors[i] != NULL ) + if (mNeighbors[i] != nullptr) { regions.push_back( i ); } @@ -498,7 +507,7 @@ void LLSurface::disconnectNeighbor(LLSurface *surfacep) { if (surfacep == mNeighbors[i]) { - mNeighbors[i] = NULL; + mNeighbors[i] = nullptr; } } @@ -518,7 +527,7 @@ void LLSurface::disconnectAllNeighbors() if (mNeighbors[i]) { mNeighbors[i]->disconnectNeighbor(this); - mNeighbors[i] = NULL; + mNeighbors[i] = nullptr; } } } @@ -910,7 +919,7 @@ LLSurfacePatch *LLSurface::resolvePatchRegion(const F32 x, const F32 y) const if(0 == mNumberOfPatches) { LL_WARNS() << "No patches for current region!" << LL_ENDL; - return NULL; + return nullptr; } S32 old_index = index; index = llclamp(old_index, 0, (mNumberOfPatches - 1)); @@ -996,7 +1005,7 @@ void LLSurface::createPatchData() } else { - patchp->setNeighborPatch(EAST, NULL); + patchp->setNeighborPatch(EAST, nullptr); } if (j < mPatchesPerEdge-1) @@ -1005,7 +1014,7 @@ void LLSurface::createPatchData() } else { - patchp->setNeighborPatch(NORTH, NULL); + patchp->setNeighborPatch(NORTH, nullptr); } if (i > 0) @@ -1014,7 +1023,7 @@ void LLSurface::createPatchData() } else { - patchp->setNeighborPatch(WEST, NULL); + patchp->setNeighborPatch(WEST, nullptr); } if (j > 0) @@ -1023,7 +1032,7 @@ void LLSurface::createPatchData() } else { - patchp->setNeighborPatch(SOUTH, NULL); + patchp->setNeighborPatch(SOUTH, nullptr); } if (i < (mPatchesPerEdge-1) && j < (mPatchesPerEdge-1)) @@ -1032,7 +1041,7 @@ void LLSurface::createPatchData() } else { - patchp->setNeighborPatch(NORTHEAST, NULL); + patchp->setNeighborPatch(NORTHEAST, nullptr); } if (i > 0 && j < (mPatchesPerEdge-1)) @@ -1041,7 +1050,7 @@ void LLSurface::createPatchData() } else { - patchp->setNeighborPatch(NORTHWEST, NULL); + patchp->setNeighborPatch(NORTHWEST, nullptr); } if (i > 0 && j > 0) @@ -1050,7 +1059,7 @@ void LLSurface::createPatchData() } else { - patchp->setNeighborPatch(SOUTHWEST, NULL); + patchp->setNeighborPatch(SOUTHWEST, nullptr); } if (i < (mPatchesPerEdge-1) && j > 0) @@ -1059,7 +1068,7 @@ void LLSurface::createPatchData() } else { - patchp->setNeighborPatch(SOUTHEAST, NULL); + patchp->setNeighborPatch(SOUTHEAST, nullptr); } LLVector3d origin_global; @@ -1077,7 +1086,7 @@ void LLSurface::destroyPatchData() // Delete all of the cached patch data for these patches. delete [] mPatchList; - mPatchList = NULL; + mPatchList = nullptr; mVisiblePatchCount = 0; } @@ -1105,12 +1114,12 @@ LLSurfacePatch *LLSurface::getPatch(const S32 x, const S32 y) const if ((x < 0) || (x >= mPatchesPerEdge)) { LL_ERRS() << "Asking for patch out of bounds" << LL_ENDL; - return NULL; + return nullptr; } if ((y < 0) || (y >= mPatchesPerEdge)) { LL_ERRS() << "Asking for patch out of bounds" << LL_ENDL; - return NULL; + return nullptr; } return mPatchList + x + y*mPatchesPerEdge; diff --git a/indra/newview/llsurface.h b/indra/newview/llsurface.h index fc72ab7db7f..a599019ca50 100644 --- a/indra/newview/llsurface.h +++ b/indra/newview/llsurface.h @@ -29,14 +29,8 @@ #include "v3math.h" #include "v3dmath.h" -#include "v4math.h" -#include "m3math.h" -#include "m4math.h" -#include "llquaternion.h" - -#include "v4coloru.h" -#include "v4color.h" +#include "lltimer.h" #include "llvowater.h" #include "llpatchvertexarray.h" #include "llviewertexture.h" @@ -65,7 +59,7 @@ class LLGroupHeader; class LLSurface { public: - LLSurface(U32 type, LLViewerRegion *regionp = NULL); + LLSurface(U32 type, LLViewerRegion *regionp = nullptr); virtual ~LLSurface(); static void initClasses(); // Do class initialization for LLSurface and its child classes. @@ -169,14 +163,13 @@ class LLSurface F32 mDetailTextureScale; // Number of times to repeat detail texture across this surface -protected: +private: void createSTexture(); void initTextures(); void createPatchData(); // Allocates memory for patches. void destroyPatchData(); // Deallocates memory for patches. -protected: LLVector3d mOriginGlobal; // In absolute frame LLSurfacePatch *mPatchList; // Array of all patches @@ -212,6 +205,7 @@ class LLSurface private: LLViewerRegion *mRegionp; // Patch whose coordinate system this surface is using. static S32 sTextureSize; // Size of the surface texture + LLTimer mTimer; // timer to throttle initial requests until the mSTexture is fully fetched }; extern template bool LLSurface::idleUpdate(F32 max_update_time); From 70fbf11f2d3f6d81acee9f43fd35626f4963aa28 Mon Sep 17 00:00:00 2001 From: RolfKal Date: Wed, 15 Oct 2025 22:58:12 +0200 Subject: [PATCH 2/2] Improve the code according to the suggestions by Copilot and rework the conditional logic a little more --- indra/newview/llsurface.cpp | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/indra/newview/llsurface.cpp b/indra/newview/llsurface.cpp index c09935b330b..64359b6cbe6 100644 --- a/indra/newview/llsurface.cpp +++ b/indra/newview/llsurface.cpp @@ -49,11 +49,13 @@ extern LLPipeline gPipeline; extern bool gShiftFrame; -#define MIN_TEXTURE_REQUEST_INTERVAL 1.f +namespace +{ + static constexpr float MIN_TEXTURE_REQUEST_INTERVAL = 5.0f; +} LLColor4U MAX_WATER_COLOR(0, 48, 96, 240); - S32 LLSurface::sTextureSize = 256; // ---------------- LLSurface:: Public Members --------------- @@ -194,7 +196,7 @@ void LLSurface::create(const S32 grids_per_edge, LLViewerTexture* LLSurface::getSTexture() { - if (mSTexturep.isNull() || !mSTexturep->hasGLTexture()) + if (mSTexturep.notNull() && !mSTexturep->hasGLTexture()) { createSTexture(); } @@ -203,33 +205,29 @@ LLViewerTexture* LLSurface::getSTexture() void LLSurface::createSTexture() { - bool update = true; if (mSTexturep.isNull()) { mTimer.setTimerExpirySec(MIN_TEXTURE_REQUEST_INTERVAL); } - else if (!mSTexturep->hasGLTexture()) - { - // if we haven't gotten a valid texture yet, throttle the number of requests to avoid server flooding - update = mTimer.checkExpirationAndReset(MIN_TEXTURE_REQUEST_INTERVAL); - } - else + else if (mSTexturep->hasGLTexture()) { - // What are we doing here? + // Unexpected: createSTexture() called when a valid texture already exists. + // This may indicate a logic error in the caller, as textures should not be recreated unnecessarily. LL_WARNS() << "Called LLSurface::createSTexture() while we already have a valid texture!" << LL_ENDL; return; } - - if (update) + else if (!mTimer.checkExpirationAndReset(MIN_TEXTURE_REQUEST_INTERVAL)) { - U64 handle = mRegionp->getHandle(); + // We haven't gotten a valid texture yet, but throttle the number of requests to avoid server flooding + return; + } - U32 grid_x, grid_y; + U64 handle = mRegionp->getHandle(); + U32 grid_x, grid_y; - grid_from_region_handle(handle, &grid_x, &grid_y); + grid_from_region_handle(handle, &grid_x, &grid_y); - mSTexturep = LLWorldMipmap::loadObjectsTile(grid_x, grid_y, 1); - } + mSTexturep = LLWorldMipmap::loadObjectsTile(grid_x, grid_y, 1); } void LLSurface::initTextures()