From 5140affe0747530a86ebbf097a189536fd711b55 Mon Sep 17 00:00:00 2001 From: Inusaito Sayori Date: Sat, 10 Jan 2015 03:01:02 -0500 Subject: [PATCH] [OpenSim] Fix World Map Textures on Minimap of Variable Size Regions. Thanks to Shyotl for the helpies~ --- indra/newview/llnetmap.cpp | 48 ++++++++++++++++++++------------ indra/newview/llviewerregion.cpp | 34 ++++++++++++++-------- indra/newview/llviewerregion.h | 5 ++-- 3 files changed, 55 insertions(+), 32 deletions(-) diff --git a/indra/newview/llnetmap.cpp b/indra/newview/llnetmap.cpp index 4d66276dd..89c8e3b3a 100644 --- a/indra/newview/llnetmap.cpp +++ b/indra/newview/llnetmap.cpp @@ -329,14 +329,15 @@ void LLNetMap::draw() F32 relative_x = (rel_region_pos.mV[0] / region_width) * mScale; F32 relative_y = (rel_region_pos.mV[1] / region_width) * mScale; + const F32 real_width(regionp->getWidth()); // Background region rectangle. F32 bottom = relative_y; F32 left = relative_x; // Aurora Sim //F32 top = bottom + mScale ; //F32 right = left + mScale ; - F32 top = bottom + (regionp->getWidth() / REGION_WIDTH_METERS) * mScale ; - F32 right = left + (regionp->getWidth() / REGION_WIDTH_METERS) * mScale ; + F32 top = bottom + (real_width / REGION_WIDTH_METERS) * mScale ; + F32 right = left + (real_width / REGION_WIDTH_METERS) * mScale ; // Aurora Sim if (regionp == region) gGL.color4fv(this_region_color().mV); @@ -349,23 +350,34 @@ void LLNetMap::draw() if (s_fUseWorldMapTextures) { - LLViewerTexture* pRegionImage = regionp->getWorldMapTile(); - if ( (pRegionImage) && (pRegionImage->hasGLTexture()) ) - { - gGL.getTexUnit(0)->bind(pRegionImage); - gGL.begin(LLRender::QUADS); - 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(1.f, 1.f); - gGL.vertex2f(right, top); - gGL.end(); + const LLViewerRegion::tex_matrix_t& tiles(regionp->getWorldMapTiles()); - pRegionImage->setBoostLevel(LLViewerTexture::BOOST_MAP_VISIBLE); - fRenderTerrain = false; + for (S32 i(0), scaled_width(real_width/region_width), square_width(scaled_width*scaled_width); i < square_width; ++i) + { + const F32 y(i/scaled_width); + const F32 x(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); + LLViewerTexture* pRegionImage = tiles[x][y]; + if (pRegionImage && pRegionImage->hasGLTexture()) + { + gGL.getTexUnit(0)->bind(pRegionImage); + gGL.begin(LLRender::QUADS); + 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(1.f, 1.f); + gGL.vertex2f(local_right, local_top); + gGL.end(); + + pRegionImage->setBoostLevel(LLViewerTexture::BOOST_MAP_VISIBLE); + fRenderTerrain = false; + } } } // [/SL:KB] diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp index 799513e93..f3f9f7c34 100644 --- a/indra/newview/llviewerregion.cpp +++ b/indra/newview/llviewerregion.cpp @@ -433,11 +433,9 @@ LLViewerRegion::~LLViewerRegion() mImpl = NULL; // [SL:KB] - Patch: World-MinimapOverlay | Checked: 2012-07-26 (Catznip-3.3) - if (mWorldMapTile) - { - mWorldMapTile->setBoostLevel(LLViewerTexture::BOOST_NONE); - mWorldMapTile = NULL; - } + for (tex_matrix_t::iterator i = mWorldMapTiles.begin(), iend = mWorldMapTiles.end(); i != iend; ++i) + for (std::vector >::iterator it = (*i).begin(), itend = (*i).end(); it != itend; ++it) + (*it)->setBoostLevel(LLViewerTexture::BOOST_NONE); // [/SL:KB] } @@ -1105,20 +1103,32 @@ F32 LLViewerRegion::getLandHeightRegion(const LLVector3& region_pos) } // [SL:KB] - Patch: World-MinimapOverlay | Checked: 2012-06-20 (Catznip-3.3.0) -LLViewerTexture* LLViewerRegion::getWorldMapTile() const +const LLViewerRegion::tex_matrix_t& LLViewerRegion::getWorldMapTiles() const { - if (!mWorldMapTile) + if (mWorldMapTiles.empty()) { U32 gridX, gridY; grid_from_region_handle(mHandle, &gridX, &gridY); // Singu Note: We must obey the override on certain grids! std::string simOverrideMap = LFSimFeatureHandler::instance().mapServerURL(); - std::string strImgURL = (simOverrideMap.empty() ? gSavedSettings.getString("MapServerURL") : simOverrideMap) + llformat("map-1-%d-%d-objects.jpg", gridX, gridY); - - mWorldMapTile = LLViewerTextureManager::getFetchedTextureFromUrl(strImgURL, TRUE, LLViewerTexture::BOOST_NONE, LLViewerTexture::LOD_TEXTURE); - mWorldMapTile->setBoostLevel(LLViewerTexture::BOOST_MAP); + std::string strImgURL = (simOverrideMap.empty() ? gSavedSettings.getString("MapServerURL") : simOverrideMap) + "map-1-"; + U32 totalX(getWidth()/REGION_WIDTH_U32); + if (!totalX) ++totalX; // If this region is too small, still get an image. + mWorldMapTiles.resize(totalX); + /* TODO: Nonsquare regions? + U32 totalY(getLength()/REGION_WIDTH_U32); + if (!totalY) ++totalY; // If this region is too small, still get an image. + */ + const U32 totalY(totalX); + for (U32 x = 0; x != totalX; ++x) + for (U32 y = 0; y != totalY; ++y) + { + LLPointer tex(LLViewerTextureManager::getFetchedTextureFromUrl(strImgURL+llformat("%d-%d-objects.jpg", gridX + x, gridY + y), TRUE, LLViewerTexture::BOOST_NONE, LLViewerTexture::LOD_TEXTURE)); + mWorldMapTiles[x].push_back(tex); + tex->setBoostLevel(LLViewerTexture::BOOST_MAP); + } } - return mWorldMapTile; + return mWorldMapTiles; } // [/SL:KB] diff --git a/indra/newview/llviewerregion.h b/indra/newview/llviewerregion.h index a2ef35c92..a7f0961d0 100644 --- a/indra/newview/llviewerregion.h +++ b/indra/newview/llviewerregion.h @@ -160,7 +160,8 @@ public: // [SL:KB] - Patch: World-MinimapOverlay | Checked: 2012-06-20 (Catznip-3.3.0) bool isAlive() const; // can become false if circuit disconnects - LLViewerTexture* getWorldMapTile() const; + typedef std::vector > > tex_matrix_t; + const tex_matrix_t& getWorldMapTiles() const; // [/SL:KB] void setWaterHeight(F32 water_level); @@ -474,7 +475,7 @@ private: LLDynamicArray mCacheMissCRC; // [SL:KB] - Patch: World-MinimapOverlay | Checked: 2012-07-26 (Catznip-3.3) - mutable LLPointer mWorldMapTile; + mutable tex_matrix_t mWorldMapTiles; // [/SL:KB] bool mAlive; // can become false if circuit disconnects