[OpenSim] Fix World Map Textures on Minimap of Variable Size Regions.

Thanks to Shyotl for the helpies~
This commit is contained in:
Inusaito Sayori
2015-01-10 03:01:02 -05:00
parent 658c617c75
commit 5140affe07
3 changed files with 55 additions and 32 deletions

View File

@@ -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;
// <FS:CR> 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 ;
// </FS:CR> 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]

View File

@@ -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<LLPointer<LLViewerTexture> >::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<LLViewerTexture> 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]

View File

@@ -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<std::vector<LLPointer<LLViewerTexture> > > tex_matrix_t;
const tex_matrix_t& getWorldMapTiles() const;
// [/SL:KB]
void setWaterHeight(F32 water_level);
@@ -474,7 +475,7 @@ private:
LLDynamicArray<U32> mCacheMissCRC;
// [SL:KB] - Patch: World-MinimapOverlay | Checked: 2012-07-26 (Catznip-3.3)
mutable LLPointer<LLViewerTexture> mWorldMapTile;
mutable tex_matrix_t mWorldMapTiles;
// [/SL:KB]
bool mAlive; // can become false if circuit disconnects