diff --git a/indra/newview/llnetmap.cpp b/indra/newview/llnetmap.cpp index 369e370275071a726915ddf933bb6b6194231814..ca3293a4ef0f013e0fbe958d9421b11db309fe07 100755 --- a/indra/newview/llnetmap.cpp +++ b/indra/newview/llnetmap.cpp @@ -53,7 +53,6 @@ #include "llsurface.h" #include "llviewercamera.h" #include "llviewercontrol.h" -#include "llviewernetwork.h" #include "llviewertexture.h" #include "llviewertexturelist.h" #include "llviewermenu.h" @@ -259,24 +258,34 @@ void LLNetMap::draw() // <alchemy> - if (use_world_map_image && LLGridManager::getInstance()->isInSecondlife()) + if (use_world_map_image) { - LLViewerTexture* img = regionp->getMapImage(); - if (img && img->hasGLTexture()) + const LLViewerRegion::tex_matrix_t& tiles(regionp->getWorldMapTiles()); + for (S32 i(0), scaled_width(real_width / region_width), square_width(scaled_width * scaled_width); + i < square_width; ++i) { - gGL.getTexUnit(0)->bind(img); - 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(); - - img->setBoostLevel(LLGLTexture::BOOST_MAP_VISIBLE); + 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* img = tiles[x * scaled_width + y]; + if (img && img->hasGLTexture()) + { + gGL.getTexUnit(0)->bind(img); + 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(); + img->setBoostLevel(LLViewerTexture::BOOST_MAP_VISIBLE); + } } } else diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp index 2bfbc097c51afffc47535f06106a0eee63a0bec5..38fe57c671a1ecb823c4fca33a44af2d73692ec7 100755 --- a/indra/newview/llviewerregion.cpp +++ b/indra/newview/llviewerregion.cpp @@ -541,6 +541,9 @@ LLViewerRegion::~LLViewerRegion() delete mImpl; mImpl = NULL; + + for (LLPointer<LLViewerTexture> tile : mWorldMapTiles) + tile->setBoostLevel(LLViewerTexture::BOOST_NONE); } LLEventPump& LLViewerRegion::getCapAPI() const @@ -3418,6 +3421,33 @@ void LLViewerRegion::setGodnames() } } +const LLViewerRegion::tex_matrix_t& LLViewerRegion::getWorldMapTiles() const +{ + if (mWorldMapTiles.empty()) + { + U32 gridX, gridY; + grid_from_region_handle(mHandle, &gridX, &gridY); + U32 totalX(getWidth() / REGION_WIDTH_U32); + if (!totalX) ++totalX; // If this region is too small, still get an image. + // *TODO: Non-square regions? + //U32 totalY(getLength()/REGION_WIDTH_U32); + //if (!totalY) ++totalY; // If this region is too small, still get an image. + const U32 totalY(totalX); + mWorldMapTiles.reserve(totalX * totalY); + for (U32 x = 0; x != totalX; ++x) + for (U32 y = 0; y != totalY; ++y) + { + const std::string map_url = getMapServerURL().append(llformat("map-1-%d-%d-objects.jpg", gridX + x, gridY + y)); + LL_WARNS() << "WOO! " << map_url << LL_ENDL; + LLPointer<LLViewerTexture> tex(LLViewerTextureManager::getFetchedTextureFromUrl(map_url, FTT_MAP_TILE, TRUE, + LLViewerTexture::BOOST_NONE, LLViewerTexture::LOD_TEXTURE)); + mWorldMapTiles.push_back(tex); + tex->setBoostLevel(LLViewerTexture::BOOST_MAP); + } + } + return mWorldMapTiles; +} + LLViewerTexture* LLViewerRegion::getMapImage() { if (mMapImage.isNull()) diff --git a/indra/newview/llviewerregion.h b/indra/newview/llviewerregion.h index a4344c3da42b7d98a1c5ac6555e6c23dc5999f03..528195c12aa270c6e4759aae83bee7eb3bc7ff9b 100755 --- a/indra/newview/llviewerregion.h +++ b/indra/newview/llviewerregion.h @@ -411,7 +411,10 @@ public: /// "God names" surname and full account names map std::set<std::string> getGods() const { return mGodNames; }; //@} - + + typedef std::vector<LLPointer<LLViewerTexture> > tex_matrix_t; + const tex_matrix_t& getWorldMapTiles() const; + LLViewerTexture* getMapImage(); // <alchemy/> private: @@ -576,8 +579,9 @@ private: LLFrameTimer mMaterialsCapThrottleTimer; LLFrameTimer mRenderInfoRequestTimer; + mutable tex_matrix_t mWorldMapTiles; LLPointer<LLViewerTexture> mMapImage; // <alchemy/> - std::set<std::string> mGodNames; + std::set<std::string> mGodNames; }; inline BOOL LLViewerRegion::getRegionProtocol(U64 protocol) const