Merge remote branch 'origin/unimap2'
This commit is contained in:
@@ -494,6 +494,7 @@ set(viewer_SOURCE_FILES
|
||||
llwlparamset.cpp
|
||||
llworld.cpp
|
||||
llworldmap.cpp
|
||||
llworldmipmap.cpp
|
||||
llmapresponders.cpp
|
||||
llworldmapview.cpp
|
||||
llxmlrpctransaction.cpp
|
||||
@@ -968,6 +969,7 @@ set(viewer_HEADER_FILES
|
||||
llwlparamset.h
|
||||
llworld.h
|
||||
llworldmap.h
|
||||
llworldmipmap.h
|
||||
llmapresponders.h
|
||||
llworldmapview.h
|
||||
llxmlrpctransaction.h
|
||||
|
||||
@@ -167,7 +167,6 @@ LLFloaterWorldMap::LLFloaterWorldMap()
|
||||
{
|
||||
LLCallbackMap::map_t factory_map;
|
||||
factory_map["objects_mapview"] = LLCallbackMap(createWorldMapView, NULL);
|
||||
factory_map["terrain_mapview"] = LLCallbackMap(createWorldMapView, NULL);
|
||||
LLUICtrlFactory::getInstance()->buildFloater(this, "floater_world_map.xml", &factory_map);
|
||||
}
|
||||
|
||||
@@ -179,30 +178,15 @@ void* LLFloaterWorldMap::createWorldMapView(void* data)
|
||||
|
||||
BOOL LLFloaterWorldMap::postBuild()
|
||||
{
|
||||
mTabs = getChild<LLTabContainer>("maptab");
|
||||
if (!mTabs) return FALSE;
|
||||
|
||||
LLPanel *panel;
|
||||
|
||||
panel = mTabs->getChild<LLPanel>("objects_mapview");
|
||||
if (panel)
|
||||
{
|
||||
mTabs->setTabChangeCallback(panel, onCommitBackground);
|
||||
mTabs->setTabUserData(panel, this);
|
||||
}
|
||||
panel = mTabs->getChild<LLPanel>("terrain_mapview");
|
||||
if (panel)
|
||||
{
|
||||
mTabs->setTabChangeCallback(panel, onCommitBackground);
|
||||
mTabs->setTabUserData(panel, this);
|
||||
}
|
||||
|
||||
|
||||
// The following callback syncs the worlmap tabs with the images.
|
||||
// Commented out since it was crashing when LLWorldMap became a singleton.
|
||||
// We should be fine without it but override the onOpen method and put it
|
||||
// there if it turns out to be needed. -MG
|
||||
//
|
||||
//onCommitBackground((void*)this, false);
|
||||
|
||||
mPanel = getChild<LLPanel>("objects_mapview");
|
||||
|
||||
childSetCommitCallback("friend combo", onAvatarComboCommit, this);
|
||||
|
||||
@@ -263,7 +247,7 @@ BOOL LLFloaterWorldMap::postBuild()
|
||||
LLFloaterWorldMap::~LLFloaterWorldMap()
|
||||
{
|
||||
// All cleaned up by LLView destructor
|
||||
mTabs = NULL;
|
||||
mPanel = NULL;
|
||||
|
||||
// Inventory deletes all observers on shutdown
|
||||
mInventory = NULL;
|
||||
@@ -296,7 +280,7 @@ void LLFloaterWorldMap::show(void*, BOOL center_on_target)
|
||||
gFloaterWorldMap->open(); /* Flawfinder: ignore */
|
||||
|
||||
LLWorldMapView* map_panel;
|
||||
map_panel = (LLWorldMapView*)gFloaterWorldMap->mTabs->getCurrentPanel();
|
||||
map_panel = (LLWorldMapView*)gFloaterWorldMap->mPanel;
|
||||
map_panel->clearLastClick();
|
||||
|
||||
if (!was_visible)
|
||||
@@ -314,9 +298,8 @@ void LLFloaterWorldMap::show(void*, BOOL center_on_target)
|
||||
// Reload any maps that may have changed
|
||||
LLWorldMap::getInstance()->clearSimFlags();
|
||||
|
||||
const S32 panel_num = gFloaterWorldMap->mTabs->getCurrentPanelIndex();
|
||||
const bool request_from_sim = true;
|
||||
LLWorldMap::getInstance()->setCurrentLayer(panel_num, request_from_sim);
|
||||
LLWorldMap::getInstance()->setCurrentLayer(0, request_from_sim);
|
||||
|
||||
// We may already have a bounding box for the regions of the world,
|
||||
// so use that to adjust the view.
|
||||
@@ -1033,9 +1016,7 @@ void LLFloaterWorldMap::adjustZoomSliderBounds()
|
||||
world_height_regions++;
|
||||
|
||||
// Find how much space we have to display the world
|
||||
LLWorldMapView* map_panel;
|
||||
map_panel = (LLWorldMapView*)mTabs->getCurrentPanel();
|
||||
LLRect view_rect = map_panel->getRect();
|
||||
LLRect view_rect = mPanel->getRect();
|
||||
|
||||
// View size in pixels
|
||||
S32 view_width = view_rect.getWidth();
|
||||
@@ -1084,7 +1065,7 @@ void LLFloaterWorldMap::onPanBtn( void* userdata )
|
||||
}
|
||||
|
||||
LLWorldMapView* map_panel;
|
||||
map_panel = (LLWorldMapView*)gFloaterWorldMap->mTabs->getCurrentPanel();
|
||||
map_panel = (LLWorldMapView*)gFloaterWorldMap->mPanel;
|
||||
map_panel->translatePan( pan_x, pan_y );
|
||||
}
|
||||
|
||||
@@ -1566,17 +1547,6 @@ void LLFloaterWorldMap::flyToAvatar()
|
||||
}
|
||||
}
|
||||
|
||||
// static
|
||||
void LLFloaterWorldMap::onCommitBackground(void* userdata, bool from_click)
|
||||
{
|
||||
LLFloaterWorldMap* self = (LLFloaterWorldMap*) userdata;
|
||||
|
||||
// Find my index
|
||||
S32 index = self->mTabs->getCurrentPanelIndex();
|
||||
|
||||
LLWorldMap::getInstance()->setCurrentLayer(index);
|
||||
}
|
||||
|
||||
void LLFloaterWorldMap::updateSims(bool found_null_sim)
|
||||
{
|
||||
if (mCompletingRegionName == "")
|
||||
|
||||
@@ -123,8 +123,6 @@ protected:
|
||||
static void onAvatarComboPrearrange( LLUICtrl* ctrl, void* data );
|
||||
static void onAvatarComboCommit( LLUICtrl* ctrl, void* data );
|
||||
|
||||
static void onCommitBackground(void* data, bool from_click);
|
||||
|
||||
static void onComboTextEntry( LLLineEditor* ctrl, void* data );
|
||||
static void onSearchTextEntry( LLLineEditor* ctrl, void* data );
|
||||
|
||||
@@ -162,8 +160,8 @@ protected:
|
||||
void cacheLandmarkPosition();
|
||||
|
||||
protected:
|
||||
LLTabContainer* mTabs;
|
||||
|
||||
LLPanel* mPanel; // Panel displaying the map
|
||||
|
||||
// Sets sMapScale, in pixels per region
|
||||
F32 mCurZoomVal;
|
||||
LLFrameTimer mZoomTimer;
|
||||
|
||||
@@ -203,6 +203,8 @@ void LLWorldMap::eraseItems()
|
||||
|
||||
void LLWorldMap::clearImageRefs()
|
||||
{
|
||||
mWorldMipmap.reset();
|
||||
|
||||
for (sim_info_map_t::iterator it = mSimInfoMap.begin(); it != mSimInfoMap.end(); ++it)
|
||||
{
|
||||
LLSimInfo* info = (*it).second;
|
||||
@@ -231,6 +233,12 @@ void LLWorldMap::clearSimFlags()
|
||||
}
|
||||
}
|
||||
|
||||
void LLWorldMap::equalizeBoostLevels()
|
||||
{
|
||||
mWorldMipmap.equalizeBoostLevels();
|
||||
return;
|
||||
}
|
||||
|
||||
LLSimInfo* LLWorldMap::simInfoFromPosGlobal(const LLVector3d& pos_global)
|
||||
{
|
||||
U64 handle = to_region_handle(pos_global);
|
||||
@@ -294,6 +302,7 @@ bool LLWorldMap::simNameFromPosGlobal(const LLVector3d& pos_global, std::string
|
||||
|
||||
void LLWorldMap::setCurrentLayer(S32 layer, bool request_layer)
|
||||
{
|
||||
//TODO: we only have 1 layer -SG
|
||||
mCurrentMap = layer;
|
||||
if (!mMapLoaded[layer] || request_layer)
|
||||
{
|
||||
@@ -1070,3 +1079,19 @@ void LLWorldMap::updateTelehubCoverage()
|
||||
mTelehubCoverageMap[index] *= mNeighborMap[index];
|
||||
}*/
|
||||
}
|
||||
|
||||
// Drop priority of all images being fetched by the map
|
||||
void LLWorldMap::dropImagePriorities()
|
||||
{
|
||||
// Drop the download of tiles priority to nil
|
||||
mWorldMipmap.dropBoostLevels();
|
||||
// Same for the "land for sale" tiles per region
|
||||
for (sim_info_map_t::iterator it = mSimInfoMap.begin(); it != mSimInfoMap.end(); ++it)
|
||||
{
|
||||
LLSimInfo* info = it->second;
|
||||
if (!info->mOverlayImage.isNull())
|
||||
{
|
||||
info->mOverlayImage->setBoostLevel(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,6 +41,7 @@
|
||||
#include "v3dmath.h"
|
||||
#include "llframetimer.h"
|
||||
#include "llmapimagetype.h"
|
||||
#include "llworldmipmap.h"
|
||||
#include "lluuid.h"
|
||||
#include "llmemory.h"
|
||||
#include "llviewerimage.h"
|
||||
@@ -133,6 +134,9 @@ public:
|
||||
// Clears the flags indicating that we've received sim infos
|
||||
// Causes a re-request of the sim info without erasing extisting info
|
||||
void clearSimFlags();
|
||||
|
||||
// Drops the priority of the images being fetched
|
||||
void dropImagePriorities();
|
||||
|
||||
// Returns simulator information, or NULL if out of range
|
||||
LLSimInfo* simInfoFromHandle(const U64 handle);
|
||||
@@ -183,6 +187,13 @@ public:
|
||||
// Bounds of the world, in meters
|
||||
U32 getWorldWidth() const;
|
||||
U32 getWorldHeight() const;
|
||||
|
||||
// World Mipmap delegation: currently used when drawing the mipmap
|
||||
void equalizeBoostLevels();
|
||||
LLPointer<LLViewerImage> getObjectsTile(U32 grid_x, U32 grid_y, S32 level, bool load = true) {
|
||||
return mWorldMipmap.getObjectsTile(grid_x, grid_y, level, load);
|
||||
}
|
||||
|
||||
public:
|
||||
// Map from region-handle to simulator info
|
||||
typedef std::map<U64, LLSimInfo*> sim_info_map_t;
|
||||
@@ -224,6 +235,9 @@ public:
|
||||
S32 mNeighborMapHeight;
|
||||
|
||||
private:
|
||||
|
||||
LLWorldMipmap mWorldMipmap;
|
||||
|
||||
LLTimer mRequestTimer;
|
||||
|
||||
// search for named region for url processing
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -87,6 +87,7 @@ public:
|
||||
LLVector3d viewPosToGlobal(S32 x,S32 y);
|
||||
|
||||
virtual void draw();
|
||||
void drawTiles(S32 width, S32 height);
|
||||
void drawGenericItems(const LLWorldMap::item_info_list_t& items, LLUIImagePtr image);
|
||||
void drawGenericItem(const LLItemInfo& item, LLUIImagePtr image);
|
||||
void drawImage(const LLVector3d& global_pos, LLUIImagePtr image, const LLColor4& color = LLColor4::white);
|
||||
@@ -94,6 +95,8 @@ public:
|
||||
void drawAgents();
|
||||
void drawEvents();
|
||||
void drawFrustum();
|
||||
void drawMipmap(S32 width, S32 height);
|
||||
bool drawMipmapLevel(S32 width, S32 height, S32 level, bool load = true);
|
||||
|
||||
static void cleanupTextures();
|
||||
|
||||
@@ -173,6 +176,7 @@ public:
|
||||
static F32 sTargetPanY; // in pixels
|
||||
static S32 sTrackingArrowX;
|
||||
static S32 sTrackingArrowY;
|
||||
static bool sVisibleTilesLoaded;
|
||||
|
||||
// Are we mid-pan from a user drag?
|
||||
BOOL mPanning;
|
||||
|
||||
274
indra/newview/llworldmipmap.cpp
Normal file
274
indra/newview/llworldmipmap.cpp
Normal file
@@ -0,0 +1,274 @@
|
||||
/**
|
||||
* @file llworldmipmap.cpp
|
||||
* @brief Data storage for the S3 mipmap of the entire world.
|
||||
*
|
||||
* $LicenseInfo:firstyear=2003&license=viewergpl$
|
||||
*
|
||||
* Copyright (c) 2003-2009, Linden Research, Inc.
|
||||
*
|
||||
* Second Life Viewer Source Code
|
||||
* The source code in this file ("Source Code") is provided by Linden Lab
|
||||
* to you under the terms of the GNU General Public License, version 2.0
|
||||
* ("GPL"), unless you have obtained a separate licensing agreement
|
||||
* ("Other License"), formally executed by you and Linden Lab. Terms of
|
||||
* the GPL can be found in doc/GPL-license.txt in this distribution, or
|
||||
* online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
|
||||
*
|
||||
* There are special exceptions to the terms and conditions of the GPL as
|
||||
* it is applied to this Source Code. View the full text of the exception
|
||||
* in the file doc/FLOSS-exception.txt in this software distribution, or
|
||||
* online at
|
||||
* http://secondlifegrid.net/programs/open_source/licensing/flossexception
|
||||
*
|
||||
* By copying, modifying or distributing this software, you acknowledge
|
||||
* that you have read and understood your obligations described above,
|
||||
* and agree to abide by those obligations.
|
||||
*
|
||||
* ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
|
||||
* WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
|
||||
* COMPLETENESS OR PERFORMANCE.
|
||||
* $/LicenseInfo$
|
||||
*/
|
||||
|
||||
#include "llviewerprecompiledheaders.h"
|
||||
|
||||
#include "llworldmipmap.h"
|
||||
|
||||
#include "llviewercontrol.h"
|
||||
#include "llviewerimagelist.h"
|
||||
#include "math.h" // log()
|
||||
|
||||
// Turn this on to output tile stats in the standard output
|
||||
#define DEBUG_TILES_STAT 0
|
||||
|
||||
LLWorldMipmap::LLWorldMipmap() :
|
||||
mCurrentLevel(0)
|
||||
{
|
||||
}
|
||||
|
||||
LLWorldMipmap::~LLWorldMipmap()
|
||||
{
|
||||
reset();
|
||||
}
|
||||
|
||||
// Delete all sublevel maps and clean them
|
||||
void LLWorldMipmap::reset()
|
||||
{
|
||||
for (int level = 0; level < MAP_LEVELS; level++)
|
||||
{
|
||||
mWorldObjectsMipMap[level].clear();
|
||||
}
|
||||
}
|
||||
|
||||
// This method should be called before each use of the mipmap (typically, before each draw), so that to let
|
||||
// the boost level of unused tiles to drop to 0 (BOOST_NONE).
|
||||
// Tiles that are accessed have had their boost level pushed to BOOST_MAP_VISIBLE so we can identify them.
|
||||
// The result of this strategy is that if a tile is not used during 2 consecutive loops, its boost level drops to 0.
|
||||
void LLWorldMipmap::equalizeBoostLevels()
|
||||
{
|
||||
#if DEBUG_TILES_STAT
|
||||
S32 nb_missing = 0;
|
||||
S32 nb_tiles = 0;
|
||||
S32 nb_visible = 0;
|
||||
#endif // DEBUG_TILES_STAT
|
||||
// For each level
|
||||
for (S32 level = 0; level < MAP_LEVELS; level++)
|
||||
{
|
||||
sublevel_tiles_t& level_mipmap = mWorldObjectsMipMap[level];
|
||||
// For each tile
|
||||
for (sublevel_tiles_t::iterator iter = level_mipmap.begin(); iter != level_mipmap.end(); iter++)
|
||||
{
|
||||
LLPointer<LLViewerImage> img = iter->second;
|
||||
S32 current_boost_level = img->getBoostLevel();
|
||||
if (current_boost_level == LLViewerImageBoostLevel::BOOST_MAP_VISIBLE)
|
||||
{
|
||||
// If level was BOOST_MAP_VISIBLE, the tile has been used in the last draw so keep it high
|
||||
img->setBoostLevel(LLViewerImageBoostLevel::BOOST_MAP);
|
||||
}
|
||||
else
|
||||
{
|
||||
// If level was BOOST_MAP only (or anything else...), the tile wasn't used in the last draw
|
||||
// so we drop its boost level to BOOST_NONE.
|
||||
img->setBoostLevel(LLViewerImageBoostLevel::BOOST_NONE);
|
||||
}
|
||||
#if DEBUG_TILES_STAT
|
||||
// Increment some stats if compile option on
|
||||
nb_tiles++;
|
||||
if (current_boost_level == LLViewerImageBoostLevel::BOOST_MAP_VISIBLE)
|
||||
{
|
||||
nb_visible++;
|
||||
}
|
||||
if (img->isMissingAsset())
|
||||
{
|
||||
nb_missing++;
|
||||
}
|
||||
#endif // DEBUG_TILES_STAT
|
||||
}
|
||||
}
|
||||
#if DEBUG_TILES_STAT
|
||||
LL_INFOS("World Map") << "LLWorldMipmap tile stats : total requested = " << nb_tiles << ", visible = " << nb_visible << ", missing = " << nb_missing << LL_ENDL;
|
||||
#endif // DEBUG_TILES_STAT
|
||||
}
|
||||
|
||||
// This method should be used when the mipmap is not actively used for a while, e.g., the map UI is hidden
|
||||
void LLWorldMipmap::dropBoostLevels()
|
||||
{
|
||||
// For each level
|
||||
for (S32 level = 0; level < MAP_LEVELS; level++)
|
||||
{
|
||||
sublevel_tiles_t& level_mipmap = mWorldObjectsMipMap[level];
|
||||
// For each tile
|
||||
for (sublevel_tiles_t::iterator iter = level_mipmap.begin(); iter != level_mipmap.end(); iter++)
|
||||
{
|
||||
LLPointer<LLViewerImage> img = iter->second;
|
||||
img->setBoostLevel(LLViewerImageBoostLevel::BOOST_NONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
LLPointer<LLViewerImage> LLWorldMipmap::getObjectsTile(U32 grid_x, U32 grid_y, S32 level, bool load)
|
||||
{
|
||||
// Check the input data
|
||||
llassert(level <= MAP_LEVELS);
|
||||
llassert(level >= 1);
|
||||
|
||||
// If the *loading* level changed, cleared the new level from "missed" tiles
|
||||
// so that we get a chance to reload them
|
||||
if (load && (level != mCurrentLevel))
|
||||
{
|
||||
cleanMissedTilesFromLevel(level);
|
||||
mCurrentLevel = level;
|
||||
}
|
||||
|
||||
// Build the region handle
|
||||
U64 handle = convertGridToHandle(grid_x, grid_y);
|
||||
|
||||
// Check if the image is around already
|
||||
sublevel_tiles_t& level_mipmap = mWorldObjectsMipMap[level-1];
|
||||
sublevel_tiles_t::iterator found = level_mipmap.find(handle);
|
||||
|
||||
// If not there and load on, go load it
|
||||
if (found == level_mipmap.end())
|
||||
{
|
||||
if (load)
|
||||
{
|
||||
// Load it
|
||||
LLPointer<LLViewerImage> img = loadObjectsTile(grid_x, grid_y, level);
|
||||
// Insert the image in the map
|
||||
level_mipmap.insert(sublevel_tiles_t::value_type( handle, img ));
|
||||
// Find the element again in the map (it's there now...)
|
||||
found = level_mipmap.find(handle);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Return with NULL if not found and we're not trying to load
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
// Get the image pointer and check if this asset is missing
|
||||
LLPointer<LLViewerImage> img = found->second;
|
||||
if (img->isMissingAsset())
|
||||
{
|
||||
// Return NULL if asset missing
|
||||
return NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Boost the tile level so to mark it's in use *if* load on
|
||||
if (load)
|
||||
{
|
||||
img->setBoostLevel(LLViewerImageBoostLevel::BOOST_MAP_VISIBLE);
|
||||
}
|
||||
return img;
|
||||
}
|
||||
}
|
||||
|
||||
LLPointer<LLViewerImage> LLWorldMipmap::loadObjectsTile(U32 grid_x, U32 grid_y, S32 level)
|
||||
{
|
||||
// Get the grid coordinates
|
||||
std::string imageurl = gSavedSettings.getString("MapServerURL") + llformat("map-%d-%d-%d-objects.jpg", level, grid_x, grid_y);
|
||||
|
||||
// DO NOT COMMIT!! DEBUG ONLY!!!
|
||||
// Use a local jpeg for every tile to test map speed without S3 access
|
||||
//imageurl = "file://C:\\Develop\\mapserver-distribute-3\\indra\\build-vc80\\mapserver\\relwithdebinfo\\regions\\00995\\01001\\region-995-1001-prims.jpg";
|
||||
// END DEBUG
|
||||
//LL_INFOS("World Map") << "LLWorldMipmap::loadObjectsTile(), URL = " << imageurl << LL_ENDL;
|
||||
|
||||
LLPointer<LLViewerImage> img = gImageList.getImageFromUrl(imageurl);
|
||||
img->setBoostLevel(LLViewerImageBoostLevel::BOOST_MAP);
|
||||
|
||||
// Return the smart pointer
|
||||
return img;
|
||||
}
|
||||
|
||||
// This method is used to clean up a level from tiles marked as "missing".
|
||||
// The idea is to allow tiles that have been improperly marked missing to be reloaded when retraversing the level again.
|
||||
// When zooming in and out rapidly, some tiles are never properly loaded and, eventually marked missing.
|
||||
// This creates "blue" areas in a subresolution that never got a chance to reload if we don't clean up the level.
|
||||
void LLWorldMipmap::cleanMissedTilesFromLevel(S32 level)
|
||||
{
|
||||
// Check the input data
|
||||
llassert(level <= MAP_LEVELS);
|
||||
llassert(level >= 0);
|
||||
|
||||
// This happens when the object is first initialized
|
||||
if (level == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Iterate through the subresolution level and suppress the tiles that are marked as missing
|
||||
// Note: erasing in a map while iterating through it is bug prone. Using a postfix increment is mandatory here.
|
||||
sublevel_tiles_t& level_mipmap = mWorldObjectsMipMap[level-1];
|
||||
sublevel_tiles_t::iterator it = level_mipmap.begin();
|
||||
while (it != level_mipmap.end())
|
||||
{
|
||||
LLPointer<LLViewerImage> img = it->second;
|
||||
if (img->isMissingAsset())
|
||||
{
|
||||
level_mipmap.erase(it++);
|
||||
}
|
||||
else
|
||||
{
|
||||
++it;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// static methods
|
||||
// Compute the level in the world mipmap (between 1 and MAP_LEVELS, as in the URL) given the scale (size of a sim in screen pixels)
|
||||
S32 LLWorldMipmap::scaleToLevel(F32 scale)
|
||||
{
|
||||
// If scale really small, picks up the higest level there is (lowest resolution)
|
||||
if (scale <= F32_MIN)
|
||||
return MAP_LEVELS;
|
||||
// Compute the power of two resolution level knowing the base level
|
||||
S32 level = llfloor((log(REGION_WIDTH_METERS/scale)/log(2.0f)) + 1.0f);
|
||||
// Check bounds and return the value
|
||||
if (level > MAP_LEVELS)
|
||||
return MAP_LEVELS;
|
||||
else if (level < 1)
|
||||
return 1;
|
||||
else
|
||||
return level;
|
||||
}
|
||||
|
||||
// Convert world coordinates to mipmap grid coordinates at a given level (between 1 and MAP_LEVELS)
|
||||
void LLWorldMipmap::globalToMipmap(F64 global_x, F64 global_y, S32 level, U32* grid_x, U32* grid_y)
|
||||
{
|
||||
// Check the input data
|
||||
llassert(level <= MAP_LEVELS);
|
||||
llassert(level >= 1);
|
||||
|
||||
// Convert world coordinates into grid coordinates
|
||||
*grid_x = lltrunc(global_x/REGION_WIDTH_METERS);
|
||||
*grid_y = lltrunc(global_y/REGION_WIDTH_METERS);
|
||||
// Compute the valid grid coordinates at that level of the mipmap
|
||||
S32 regions_in_tile = 1 << (level - 1);
|
||||
*grid_x = *grid_x - (*grid_x % regions_in_tile);
|
||||
*grid_y = *grid_y - (*grid_y % regions_in_tile);
|
||||
}
|
||||
|
||||
|
||||
100
indra/newview/llworldmipmap.h
Normal file
100
indra/newview/llworldmipmap.h
Normal file
@@ -0,0 +1,100 @@
|
||||
/**
|
||||
* @file llworldmipmap.h
|
||||
* @brief Data storage for the S3 mipmap of the entire world.
|
||||
*
|
||||
* $LicenseInfo:firstyear=2003&license=viewergpl$
|
||||
*
|
||||
* Copyright (c) 2003-2009, Linden Research, Inc.
|
||||
*
|
||||
* Second Life Viewer Source Code
|
||||
* The source code in this file ("Source Code") is provided by Linden Lab
|
||||
* to you under the terms of the GNU General Public License, version 2.0
|
||||
* ("GPL"), unless you have obtained a separate licensing agreement
|
||||
* ("Other License"), formally executed by you and Linden Lab. Terms of
|
||||
* the GPL can be found in doc/GPL-license.txt in this distribution, or
|
||||
* online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
|
||||
*
|
||||
* There are special exceptions to the terms and conditions of the GPL as
|
||||
* it is applied to this Source Code. View the full text of the exception
|
||||
* in the file doc/FLOSS-exception.txt in this software distribution, or
|
||||
* online at
|
||||
* http://secondlifegrid.net/programs/open_source/licensing/flossexception
|
||||
*
|
||||
* By copying, modifying or distributing this software, you acknowledge
|
||||
* that you have read and understood your obligations described above,
|
||||
* and agree to abide by those obligations.
|
||||
*
|
||||
* ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
|
||||
* WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
|
||||
* COMPLETENESS OR PERFORMANCE.
|
||||
* $/LicenseInfo$
|
||||
*/
|
||||
|
||||
#ifndef LL_LLWORLDMIPMAP_H
|
||||
#define LL_LLWORLDMIPMAP_H
|
||||
|
||||
#include <map>
|
||||
|
||||
#include "llmemory.h" // LLPointer
|
||||
#include "indra_constants.h" // REGION_WIDTH_UNITS
|
||||
#include "llregionhandle.h" // to_region_handle()
|
||||
|
||||
class LLViewerImage;
|
||||
|
||||
// LLWorldMipmap : Mipmap handling of all the tiles used to render the world at any resolution.
|
||||
// This class provides a clean structured access to the hierarchy of tiles stored in the
|
||||
// Amazon S3 repository and abstracts its directory/file structure.
|
||||
// The interface of this class though still assumes that the caller knows the general level/tiles
|
||||
// structure (at least, that it exists...) but doesn't requite the caller to know the details of it.
|
||||
// IOW, you need to know that rendering levels exists as well as grid coordinates for regions,
|
||||
// but you can ignore where those tiles are located, how to get them, etc...
|
||||
// The class API gives you back LLPointer<LLViewerImage> per tile.
|
||||
|
||||
// See llworldmipmapview.cpp for the implementation of a class who knows how to render an LLWorldMipmap.
|
||||
|
||||
// Implementation notes:
|
||||
// - On the S3 servers, the tiles are rendered in 2 flavors: Objects and Terrain.
|
||||
// - For the moment, LLWorldMipmap implements access only to the Objects tiles.
|
||||
class LLWorldMipmap
|
||||
{
|
||||
public:
|
||||
// Parameters of the mipmap
|
||||
static const S32 MAP_LEVELS = 8; // Number of subresolution levels computed by the mapserver
|
||||
static const S32 MAP_TILE_SIZE = 256; // Width in pixels of the tiles computed by the mapserver
|
||||
|
||||
LLWorldMipmap();
|
||||
~LLWorldMipmap();
|
||||
|
||||
// Clear up the maps and release all image handles
|
||||
void reset();
|
||||
// Manage the boost levels between loops (typically draw() loops)
|
||||
void equalizeBoostLevels();
|
||||
// Drop the boost levels to none (used when hiding the map)
|
||||
void dropBoostLevels();
|
||||
// Get the tile smart pointer, does the loading if necessary
|
||||
LLPointer<LLViewerImage> getObjectsTile(U32 grid_x, U32 grid_y, S32 level, bool load = true);
|
||||
|
||||
// Helper functions: those are here as they depend solely on the topology of the mipmap though they don't access it
|
||||
// Convert sim scale (given in sim width in display pixels) into a mipmap level
|
||||
static S32 scaleToLevel(F32 scale);
|
||||
// Convert world coordinates to mipmap grid coordinates at a given level
|
||||
static void globalToMipmap(F64 global_x, F64 global_y, S32 level, U32* grid_x, U32* grid_y);
|
||||
|
||||
private:
|
||||
// Get a handle (key) from grid coordinates
|
||||
U64 convertGridToHandle(U32 grid_x, U32 grid_y) { return to_region_handle(grid_x * REGION_WIDTH_UNITS, grid_y * REGION_WIDTH_UNITS); }
|
||||
// Load the relevant tile from S3
|
||||
LLPointer<LLViewerImage> loadObjectsTile(U32 grid_x, U32 grid_y, S32 level);
|
||||
// Clear a level from its "missing" tiles
|
||||
void cleanMissedTilesFromLevel(S32 level);
|
||||
|
||||
// The mipmap is organized by resolution level (MAP_LEVELS of them). Each resolution level is an std::map
|
||||
// using a region_handle as a key and storing a smart pointer to the image as a value.
|
||||
typedef std::map<U64, LLPointer<LLViewerImage> > sublevel_tiles_t;
|
||||
sublevel_tiles_t mWorldObjectsMipMap[MAP_LEVELS];
|
||||
// sublevel_tiles_t mWorldTerrainMipMap[MAP_LEVELS];
|
||||
|
||||
S32 mCurrentLevel; // The level last accessed by a getObjectsTile()
|
||||
};
|
||||
|
||||
#endif // LL_LLWORLDMIPMAP_H
|
||||
@@ -2,13 +2,8 @@
|
||||
<floater can_close="true" can_drag_on_left="false" can_minimize="true" can_resize="true"
|
||||
height="711" min_height="520" min_width="410" name="worldmap"
|
||||
rect_control="FloaterWorldMapRect2" title="World Map" width="1243">
|
||||
<tab_container bottom="-701" follows="left|top|right|bottom" height="681" left="15"
|
||||
mouse_opaque="false" name="maptab" tab_position="top" width="995">
|
||||
<panel bottom="-680" follows="left|top|right|bottom" height="664" label="Objects"
|
||||
left="1" mouse_opaque="true" name="objects_mapview" width="993" />
|
||||
<panel bottom="-680" follows="left|top|right|bottom" height="664" label="Terrain"
|
||||
left="1" mouse_opaque="true" name="terrain_mapview" width="993" />
|
||||
</tab_container>
|
||||
<panel bottom="-701" follows="left|top|right|bottom" height="681"
|
||||
left="15" mouse_opaque="true" name="objects_mapview" width="995" />
|
||||
<icon bottom="-50" color="1, 1, 1, 1" follows="top|right" height="16"
|
||||
image_name="map_avatar_16.tga" left="1013" mouse_opaque="true" name="self"
|
||||
width="16" />
|
||||
|
||||
Reference in New Issue
Block a user