diff options
author | Palmer <palmer@lindenlab.com> | 2009-11-11 15:16:49 -0800 |
---|---|---|
committer | Palmer <palmer@lindenlab.com> | 2009-11-11 15:16:49 -0800 |
commit | 6f3536d5979efa6db28098056ab5e3a158020225 (patch) | |
tree | aae087995fa1c3df3cebbdf345fca7a2e7c1b548 /indra/newview/llworldmap.h | |
parent | 7fa698252060a72be6b5ebc52f0ff01bcea6134c (diff) | |
parent | 25d8cf689aa04a1bd4ebb336714730d29040d05c (diff) |
Merged in viewer 2 changes, adjusted xui problems, added mesh folder type and more mesh inventory type info
Diffstat (limited to 'indra/newview/llworldmap.h')
-rw-r--r-- | indra/newview/llworldmap.h | 332 |
1 files changed, 186 insertions, 146 deletions
diff --git a/indra/newview/llworldmap.h b/indra/newview/llworldmap.h index 366de8f071..7e37727b86 100644 --- a/indra/newview/llworldmap.h +++ b/indra/newview/llworldmap.h @@ -33,203 +33,243 @@ #ifndef LL_LLWORLDMAP_H #define LL_LLWORLDMAP_H -#include <map> -#include <string> -#include <vector> +#include "llworldmipmap.h" #include <boost/function.hpp> -#include "v3math.h" #include "v3dmath.h" -#include "llframetimer.h" -#include "llmapimagetype.h" #include "lluuid.h" #include "llpointer.h" #include "llsingleton.h" +#include "llviewerregion.h" #include "llviewertexture.h" -#include "lleventinfo.h" -#include "v3color.h" - -class LLMessageSystem; - +// Description of objects like hubs, events, land for sale, people and more (TBD). +// Note: we don't store a "type" in there so we need to store instances of this class in +// well known objects (i.e. list of objects which type is "well known"). class LLItemInfo { public: - LLItemInfo(F32 global_x, F32 global_y, const std::string& name, LLUUID id, S32 extra = 0, S32 extra2 = 0); - - std::string mName; - std::string mToolTip; - LLVector3d mPosGlobal; - LLUUID mID; - BOOL mSelected; - S32 mExtra; - S32 mExtra2; - U64 mRegionHandle; -}; + LLItemInfo(F32 global_x, F32 global_y, const std::string& name, LLUUID id); + + // Setters + void setTooltip(std::string& tooltip) { mToolTip = tooltip; } + void setElevation(F64 z) { mPosGlobal.mdV[VZ] = z; } + void setCount(S32 count) { mCount = count; } +// void setSelected(bool selected) { mSelected = selected; } +// void setColor(LLColor4 color) { mColor = color; } + + // Accessors + const LLVector3d& getGlobalPosition() const { return mPosGlobal; } + const std::string& getName() const { return mName; } + const std::string& getToolTip() const { return mToolTip; } + const LLUUID& getUUID() const { return mID; } + S32 getCount() const { return mCount; } + + U64 getRegionHandle() const { return to_region_handle(mPosGlobal); } // Build the handle on the fly -// Map layers, see indra_constants.h -// 0 - Prim -// 1 - Terrain Only -// 2 - Overlay: Land For Sale + bool isName(const std::string& name) const { return (mName == name); } // True if name same as item's name +// bool isSelected() const { return mSelected; } +private: + std::string mName; // Name of the individual item + std::string mToolTip; // Tooltip : typically, something to be displayed to the user when selecting this item + LLVector3d mPosGlobal; // Global world position + LLUUID mID; // UUID of the item + S32 mCount; // Number of elements in item (e.g. people count) + // Currently not used but might prove useful one day so we comment out +// bool mSelected; // Selected or not: updated by the viewer UI, not the simulator or asset DB +// LLColor4 mColor; // Color of the item +}; + +// Info per region +// Such records are stored in a global map hold by the LLWorldMap and indexed by region handles. +// To avoid creating too many of them, they are requested in "blocks" corresponding to areas covered by the screen. +// Unfortunately, when the screen covers the whole world (zoomed out), that can translate in requesting info for +// every sim on the grid... Not good... +// To avoid this, the code implements a cut-off threshold for overlay graphics and, therefore, all LLSimInfo. +// In other words, when zooming out too much, we simply stop requesting LLSimInfo and +// LLItemInfo and just display the map tiles. +// As they are stored in different structures (LLSimInfo and LLWorldMipmap), this strategy is now workable. class LLSimInfo { public: - LLSimInfo(); + LLSimInfo(U64 handle); - LLVector3d getGlobalPos(LLVector3 local_pos) const; + // Convert local region coordinates into world coordinates + LLVector3d getGlobalPos(const LLVector3& local_pos) const; + // Get the world coordinates of the SW corner of that region + LLVector3d getGlobalOrigin() const; LLVector3 getLocalPos(LLVector3d global_pos) const; -public: - U64 mHandle; - std::string mName; - - F64 mAgentsUpdateTime; - BOOL mShowAgentLocations; // are agents visible? + void clearImage(); // Clears the reference to the Land for sale image for that region + void dropImagePriority(); // Drops the boost level of the Land for sale image for that region + void updateAgentCount(F64 time); // Send an item request for agent count on that region if time's up - U8 mAccess; - U32 mRegionFlags; - F32 mWaterHeight; + // Setters + void setName(std::string& name) { mName = name; } + void setAccess (U32 accesscode) { mAccess = accesscode; } + void setRegionFlags (U32 region_flags) { mRegionFlags = region_flags; } + void setLandForSaleImage (LLUUID image_id); +// void setWaterHeight (F32 water_height) { mWaterHeight = water_height; } - F32 mAlpha; + // Accessors + std::string getName() const { return mName; } + const std::string getFlagsString() const { return LLViewerRegion::regionFlagsToString(mRegionFlags); } + const std::string getAccessString() const { return LLViewerRegion::accessToString((U8)mAccess); } - // Image ID for the current overlay mode. - LLUUID mMapImageID[MAP_SIM_IMAGE_TYPES]; + const S32 getAgentCount() const; // Compute the total agents count + LLPointer<LLViewerFetchedTexture> getLandForSaleImage(); // Get the overlay image, fetch it if necessary - // Hold a reference to the currently displayed image. - LLPointer<LLViewerFetchedTexture> mCurrentImage; - LLPointer<LLViewerFetchedTexture> mOverlayImage; -}; + bool isName(const std::string& name) const; + bool isDown() { return (mAccess == SIM_ACCESS_DOWN); } + bool isPG() { return (mAccess <= SIM_ACCESS_PG); } -#define MAP_BLOCK_RES 256 + // Debug only + void dump() const; // Print the region info to the standard output -struct LLWorldMapLayer -{ - BOOL LayerDefined; - LLPointer<LLViewerFetchedTexture> LayerImage; - LLUUID LayerImageID; - LLRect LayerExtents; + // Items lists handling + typedef std::vector<LLItemInfo> item_info_list_t; + void clearItems(); + + void insertTeleHub(const LLItemInfo& item) { mTelehubs.push_back(item); } + void insertInfoHub(const LLItemInfo& item) { mInfohubs.push_back(item); } + void insertPGEvent(const LLItemInfo& item) { mPGEvents.push_back(item); } + void insertMatureEvent(const LLItemInfo& item) { mMatureEvents.push_back(item); } + void insertAdultEvent(const LLItemInfo& item) { mAdultEvents.push_back(item); } + void insertLandForSale(const LLItemInfo& item) { mLandForSale.push_back(item); } + void insertLandForSaleAdult(const LLItemInfo& item) { mLandForSaleAdult.push_back(item); } + void insertAgentLocation(const LLItemInfo& item); + + const LLSimInfo::item_info_list_t& getTeleHub() const { return mTelehubs; } + const LLSimInfo::item_info_list_t& getInfoHub() const { return mInfohubs; } + const LLSimInfo::item_info_list_t& getPGEvent() const { return mPGEvents; } + const LLSimInfo::item_info_list_t& getMatureEvent() const { return mMatureEvents; } + const LLSimInfo::item_info_list_t& getAdultEvent() const { return mAdultEvents; } + const LLSimInfo::item_info_list_t& getLandForSale() const { return mLandForSale; } + const LLSimInfo::item_info_list_t& getLandForSaleAdult() const { return mLandForSaleAdult; } + const LLSimInfo::item_info_list_t& getAgentLocation() const { return mAgentLocations; } - LLWorldMapLayer() : LayerDefined(FALSE) { } +private: + U64 mHandle; // This is a hash of the X and Y world coordinates of the SW corner of the sim + std::string mName; // Region name + + F64 mAgentsUpdateTime; // Time stamp giving the last time the agents information was requested for that region + bool mFirstAgentRequest; // Init agent request flag + + U32 mAccess; // Down/up and maturity rating of the region + U32 mRegionFlags; // Tell us if the siminfo has been received (if non 0) and what kind of region it is (Sandbox, allow damage) + // Currently not used but might prove useful one day so we comment out +// F32 mWaterHeight; // Water height on the region (not actively used) + + // Handling the "land for sale / land for auction" overlay image + LLUUID mMapImageID; // Image ID of the overlay image + LLPointer<LLViewerFetchedTexture> mOverlayImage; // Reference to the overlay image + + // Items for this region + // Those are data received through item requests (as opposed to block requests for the rest of the data) + item_info_list_t mTelehubs; // List of tele hubs in the region + item_info_list_t mInfohubs; // List of info hubs in the region + item_info_list_t mPGEvents; // List of PG events in the region + item_info_list_t mMatureEvents; // List of Mature events in the region + item_info_list_t mAdultEvents; // List of Adult events in the region (AO) + item_info_list_t mLandForSale; // List of Land for sales in the region + item_info_list_t mLandForSaleAdult; // List of Adult Land for sales in the region (AO) + item_info_list_t mAgentLocations; // List of agents in the region }; +// We request region data on the world by "blocks" of (MAP_BLOCK_SIZE x MAP_BLOCK_SIZE) regions +// This is to reduce the number of requests to the asset DB and get things in big "blocks" +const S32 MAP_MAX_SIZE = 2048; +const S32 MAP_BLOCK_SIZE = 4; +const S32 MAP_BLOCK_RES = (MAP_MAX_SIZE / MAP_BLOCK_SIZE); class LLWorldMap : public LLSingleton<LLWorldMap> { public: - typedef boost::function<void(U64 region_handle, const std::string& url, const LLUUID& snapshot_id, bool teleport)> - url_callback_t; - LLWorldMap(); ~LLWorldMap(); - // clears the list + // Clear all: list of region info, tiles, blocks and items void reset(); - // clear the visible items - void eraseItems(); + void clearImageRefs(); // Clears the image references + void dropImagePriorities(); // Drops the priority of the images being fetched + void reloadItems(bool force = false); // Reload the items (people, hub, etc...) - // Removes references to cached images - void clearImageRefs(); + // Region Map access + typedef std::map<U64, LLSimInfo*> sim_info_map_t; + const LLWorldMap::sim_info_map_t& getRegionMap() const { return mSimInfoMap; } + void updateRegions(S32 x0, S32 y0, S32 x1, S32 y1); // Requests region info for a rectangle of regions (in grid coordinates) - // Clears the flags indicating that we've received sim infos - // Causes a re-request of the sim info without erasing extisting info - void clearSimFlags(); + // Insert a region and items in the map global instance + // Note: x_world and y_world in world coordinates (meters) + static bool insertRegion(U32 x_world, U32 y_world, std::string& name, LLUUID& uuid, U32 accesscode, U32 region_flags); + static bool insertItem(U32 x_world, U32 y_world, std::string& name, LLUUID& uuid, U32 type, S32 extra, S32 extra2); - // Returns simulator information, or NULL if out of range + // Get info on sims (region) : note that those methods only search the range of loaded sims (the one that are being browsed) + // *not* the entire world. So a NULL return does not mean a down or unexisting region, just an out of range region. LLSimInfo* simInfoFromHandle(const U64 handle); - - // Returns simulator information, or NULL if out of range LLSimInfo* simInfoFromPosGlobal(const LLVector3d& pos_global); - - // Returns simulator information for named sim, or NULL if non-existent LLSimInfo* simInfoFromName(const std::string& sim_name); - // Gets simulator name for a global position, returns true if it was found + // Gets simulator name from a global position, returns true if found bool simNameFromPosGlobal(const LLVector3d& pos_global, std::string& outSimName ); - // Sets the current layer - void setCurrentLayer(S32 layer, bool request_layer = false); - - void sendMapLayerRequest(); - void sendMapBlockRequest(U16 min_x, U16 min_y, U16 max_x, U16 max_y, bool return_nonexistent = false); - void sendNamedRegionRequest(std::string region_name); - void sendNamedRegionRequest(std::string region_name, - url_callback_t callback, - const std::string& callback_url, - bool teleport); - void sendHandleRegionRequest(U64 region_handle, - url_callback_t callback, - const std::string& callback_url, - bool teleport); - void sendItemRequest(U32 type, U64 handle = 0); - - static void processMapLayerReply(LLMessageSystem*, void**); - static void processMapBlockReply(LLMessageSystem*, void**); - static void processMapItemReply(LLMessageSystem*, void**); - - void dump(); - - // Extend the bounding box of the list of simulators. Returns true - // if the extents changed. - BOOL extendAABB(U32 x_min, U32 y_min, U32 x_max, U32 y_max); - - // build coverage maps for telehub region visualization - void updateTelehubCoverage(); - BOOL coveredByTelehub(LLSimInfo* infop); - - // Bounds of the world, in meters - U32 getWorldWidth() const; - U32 getWorldHeight() const; -public: - // Map from region-handle to simulator info - typedef std::map<U64, LLSimInfo*> sim_info_map_t; - sim_info_map_t mSimInfoMap; + // Debug only + void dump(); // Print the world info to the standard output - BOOL mIsTrackingUnknownLocation, mInvalidLocation, mIsTrackingDoubleClick, mIsTrackingCommit; - LLVector3d mUnknownLocation; + // Track handling + void cancelTracking() { mIsTrackingLocation = false; mIsTrackingFound = false; mIsInvalidLocation = false; mIsTrackingDoubleClick = false; mIsTrackingCommit = false; } - bool mRequestLandForSale; + void setTracking(const LLVector3d& loc) { mIsTrackingLocation = true; mTrackingLocation = loc; mIsTrackingFound = false; mIsInvalidLocation = false; mIsTrackingDoubleClick = false; mIsTrackingCommit = false;} + void setTrackingInvalid() { mIsTrackingFound = true; mIsInvalidLocation = true; } + void setTrackingValid() { mIsTrackingFound = true; mIsInvalidLocation = false; } + void setTrackingDoubleClick() { mIsTrackingDoubleClick = true; } + void setTrackingCommit() { mIsTrackingCommit = true; } - typedef std::vector<LLItemInfo> item_info_list_t; - item_info_list_t mTelehubs; - item_info_list_t mInfohubs; - item_info_list_t mPGEvents; - item_info_list_t mMatureEvents; - item_info_list_t mAdultEvents; - item_info_list_t mLandForSale; - item_info_list_t mLandForSaleAdult; - - std::map<U64,S32> mNumAgents; - - typedef std::map<U64, item_info_list_t> agent_list_map_t; - agent_list_map_t mAgentLocationsMap; - - std::vector<LLWorldMapLayer> mMapLayers[MAP_SIM_IMAGE_TYPES]; - BOOL mMapLoaded[MAP_SIM_IMAGE_TYPES]; - BOOL * mMapBlockLoaded[MAP_SIM_IMAGE_TYPES]; - S32 mCurrentMap; - - // AABB of the list of simulators - U32 mMinX; - U32 mMaxX; - U32 mMinY; - U32 mMaxY; - - U8* mNeighborMap; - U8* mTelehubCoverageMap; - S32 mNeighborMapWidth; - S32 mNeighborMapHeight; + bool isTracking() { return mIsTrackingLocation; } + bool isTrackingValidLocation() { return mIsTrackingFound && !mIsInvalidLocation; } + bool isTrackingInvalidLocation() { return mIsTrackingFound && mIsInvalidLocation; } + bool isTrackingDoubleClick() { return mIsTrackingDoubleClick; } + bool isTrackingCommit() { return mIsTrackingCommit; } + bool isTrackingInRectangle(F64 x0, F64 y0, F64 x1, F64 y1); + + LLVector3d getTrackedPositionGlobal() const { return mTrackingLocation; } + + // World Mipmap delegation: currently used when drawing the mipmap + void equalizeBoostLevels(); + LLPointer<LLViewerFetchedTexture> getObjectsTile(U32 grid_x, U32 grid_y, S32 level, bool load = true) { return mWorldMipmap.getObjectsTile(grid_x, grid_y, level, load); } private: - LLTimer mRequestTimer; - - // search for named region for url processing - std::string mSLURLRegionName; - U64 mSLURLRegionHandle; - std::string mSLURL; - url_callback_t mSLURLCallback; - bool mSLURLTeleport; + bool clearItems(bool force = false); // Clears the item lists + void clearSimFlags(); // Clears the block flags indicating that we've already requested region infos + + // Create a region record corresponding to the handle, insert it in the region map and returns a pointer + LLSimInfo* createSimInfoFromHandle(const U64 handle); + + // Map from region-handle to region info + sim_info_map_t mSimInfoMap; + + // Holds the tiled mipmap of the world. This is the structure that contains the images used for rendering. + LLWorldMipmap mWorldMipmap; + + // The World is divided in "blocks" of (MAP_BLOCK_SIZE x MAP_BLOCK_SIZE) regions that get requested at once. + // This boolean table avoids "blocks" to be requested multiple times. + // Issue: Not sure this scheme is foolproof though as I've seen + // cases where a block is never retrieved and, because of this boolean being set, never re-requested + bool * mMapBlockLoaded; // Telling us if the block of regions has been requested or not + + // Track location data : used while there's nothing tracked yet by LLTracker + bool mIsTrackingLocation; // True when we're tracking a point + bool mIsTrackingFound; // True when the tracking position has been found, valid or not + bool mIsInvalidLocation; // The region is down or the location does not correspond to an existing region + bool mIsTrackingDoubleClick; // User double clicked to set the location (i.e. teleport when found please...) + bool mIsTrackingCommit; // User used the search or landmark fields to set the location + LLVector3d mTrackingLocation; // World global position being tracked + + // General grid items request timing flags (used for events,hubs and land for sale) + LLTimer mRequestTimer; + bool mFirstRequest; }; #endif |