LLPointer<LLViewerFetchedTexture> 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<LLViewerFetchedTexture> 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<LLViewerFetchedTexture> 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(LLGLTexture::BOOST_MAP_VISIBLE); } return img; } }
// public static void LLWorldMap::processMapBlockReply(LLMessageSystem* msg, void**) { U32 agent_flags; msg->getU32Fast(_PREHASH_AgentData, _PREHASH_Flags, agent_flags); if ((S32)agent_flags < 0 || agent_flags >= MAP_SIM_IMAGE_TYPES) { llwarns << "Invalid map image type returned! " << agent_flags << llendl; return; } S32 num_blocks = msg->getNumberOfBlocksFast(_PREHASH_Data); bool found_null_sim = false; #ifdef IMMEDIATE_IMAGE_LOAD bool use_web_map_tiles = useWebMapTiles(); #endif BOOL adjust = FALSE; for (S32 block=0; block<num_blocks; ++block) { U16 x_regions; U16 y_regions; U16 x_size = 256; U16 y_size = 256; std::string name; U8 accesscode; U32 region_flags; U8 water_height; U8 agents; LLUUID image_id; msg->getU16Fast(_PREHASH_Data, _PREHASH_X, x_regions, block); msg->getU16Fast(_PREHASH_Data, _PREHASH_Y, y_regions, block); msg->getStringFast(_PREHASH_Data, _PREHASH_Name, name, block); msg->getU8Fast(_PREHASH_Data, _PREHASH_Access, accesscode, block); msg->getU32Fast(_PREHASH_Data, _PREHASH_RegionFlags, region_flags, block); msg->getU8Fast(_PREHASH_Data, _PREHASH_WaterHeight, water_height, block); msg->getU8Fast(_PREHASH_Data, _PREHASH_Agents, agents, block); msg->getUUIDFast(_PREHASH_Data, _PREHASH_MapImageID, image_id, block); if(msg->getNumberOfBlocksFast(_PREHASH_Size) > 0) { msg->getU16Fast(_PREHASH_Size, _PREHASH_SizeX, x_size, block); msg->getU16Fast(_PREHASH_Size, _PREHASH_SizeY, y_size, block); } if(x_size == 0 || (x_size % 16) != 0|| (y_size % 16) != 0) { x_size = 256; y_size = 256; } U32 x_meters = x_regions * REGION_WIDTH_UNITS; U32 y_meters = y_regions * REGION_WIDTH_UNITS; U64 handle = to_region_handle(x_meters, y_meters); if (accesscode == 255) { // This region doesn't exist if (LLWorldMap::getInstance()->mIsTrackingUnknownLocation && LLWorldMap::getInstance()->mUnknownLocation.mdV[0] >= x_meters && LLWorldMap::getInstance()->mUnknownLocation.mdV[0] < x_meters + 256 && LLWorldMap::getInstance()->mUnknownLocation.mdV[1] >= y_meters && LLWorldMap::getInstance()->mUnknownLocation.mdV[1] < y_meters + 256) { // We were tracking this location, but it doesn't exist LLWorldMap::getInstance()->mInvalidLocation = TRUE; } found_null_sim = true; } else { adjust = LLWorldMap::getInstance()->extendAABB(x_meters, y_meters, x_meters+REGION_WIDTH_UNITS, y_meters+REGION_WIDTH_UNITS) || adjust; //LL_INFOS("World Map") << "Map sim : " << name << ", ID : " << image_id.getString() << LL_ENDL; // Insert the region in the region map of the world map // Loading the LLSimInfo object with what we got and insert it in the map LLSimInfo* siminfo = LLWorldMap::getInstance()->simInfoFromHandle(handle); if (siminfo == NULL) { siminfo = LLWorldMap::getInstance()->createSimInfoFromHandle(handle); } siminfo->setName( name ); siminfo->setAccess( accesscode ); siminfo->setRegionFlags( region_flags ); siminfo->setWaterHeight((F32) water_height); siminfo->setMapImageID( image_id, agent_flags ); siminfo->setSize( x_size, y_size ); #ifdef IMMEDIATE_IMAGE_LOAD if (use_web_map_tiles) { siminfo->mCurrentImage = loadObjectsTile((U32)x_regions, (U32)y_regions); } else { siminfo->mCurrentImage = LLViewerTextureManager::getFetchedTexture(siminfo->mMapImageID[LLWorldMap::getInstance()->mCurrentMap], MIPMAP_TRUE, FALSE); } gGL.getTexUnit(0)->bind(siminfo->mCurrentImage.get()); siminfo->mCurrentImage->setAddressMode(LLTexUnit::TAM_CLAMP); #endif if (siminfo->mMapImageID[2].notNull()) { #ifdef IMMEDIATE_IMAGE_LOAD siminfo->mOverlayImage = LLViewerTextureManager::getFetchedTextureURL(siminfo->mMapImageID[2]); #endif } else { siminfo->mOverlayImage = NULL; } if (LLWorldMap::getInstance()->mIsTrackingUnknownLocation && LLWorldMap::getInstance()->mUnknownLocation.mdV[0] >= x_meters && LLWorldMap::getInstance()->mUnknownLocation.mdV[0] < x_meters + 256 && LLWorldMap::getInstance()->mUnknownLocation.mdV[1] >= y_meters && LLWorldMap::getInstance()->mUnknownLocation.mdV[1] < y_meters + 256) { if (siminfo->isDown()) { // We were tracking this location, but it doesn't exist LLWorldMap::getInstance()->mInvalidLocation = true; } else { // We were tracking this location, and it does exist bool is_tracking_dbl = LLWorldMap::getInstance()->mIsTrackingDoubleClick == TRUE; gFloaterWorldMap->trackLocation(LLWorldMap::getInstance()->mUnknownLocation); if (is_tracking_dbl) { LLVector3d pos_global = LLTracker::getTrackedPositionGlobal(); gAgent.teleportViaLocation( pos_global ); } } } } if(LLWorldMap::getInstance()->mSLURLCallback != NULL) { // Server returns definitive capitalization, SLURL might not have that. if ((LLStringUtil::compareInsensitive(LLWorldMap::getInstance()->mSLURLRegionName, name)==0) || (LLWorldMap::getInstance()->mSLURLRegionHandle == handle)) { url_callback_t callback = LLWorldMap::getInstance()->mSLURLCallback; LLWorldMap::getInstance()->mSLURLCallback = NULL; LLWorldMap::getInstance()->mSLURLRegionName.clear(); LLWorldMap::getInstance()->mSLURLRegionHandle = 0; callback(handle, LLWorldMap::getInstance()->mSLURL, image_id, LLWorldMap::getInstance()->mSLURLTeleport); } } if( gAgent.mPendingLure && (U16)(gAgent.mPendingLure->mPosGlobal.mdV[0] / REGION_WIDTH_UNITS) == x_regions && (U16)(gAgent.mPendingLure->mPosGlobal.mdV[1] / REGION_WIDTH_UNITS) == y_regions ) { gAgent.onFoundLureDestination(); } } if(adjust) gFloaterWorldMap->adjustZoomSliderBounds(); gFloaterWorldMap->updateSims(found_null_sim); }
// public static void LLWorldMap::processMapBlockReply(LLMessageSystem* msg, void**) { U32 agent_flags; msg->getU32Fast(_PREHASH_AgentData, _PREHASH_Flags, agent_flags); if ((S32)agent_flags < 0 || agent_flags >= MAP_SIM_IMAGE_TYPES) { llwarns << "Invalid map image type returned! " << agent_flags << llendl; return; } S32 num_blocks = msg->getNumberOfBlocksFast(_PREHASH_Data); bool found_null_sim = false; #ifdef IMMEDIATE_IMAGE_LOAD bool use_web_map_tiles = useWebMapTiles(); #endif BOOL adjust = FALSE; for (S32 block=0; block<num_blocks; ++block) { U16 x_regions; U16 y_regions; std::string name; U8 accesscode; U32 region_flags; U8 water_height; U8 agents; LLUUID image_id; msg->getU16Fast(_PREHASH_Data, _PREHASH_X, x_regions, block); msg->getU16Fast(_PREHASH_Data, _PREHASH_Y, y_regions, block); msg->getStringFast(_PREHASH_Data, _PREHASH_Name, name, block); msg->getU8Fast(_PREHASH_Data, _PREHASH_Access, accesscode, block); msg->getU32Fast(_PREHASH_Data, _PREHASH_RegionFlags, region_flags, block); msg->getU8Fast(_PREHASH_Data, _PREHASH_WaterHeight, water_height, block); msg->getU8Fast(_PREHASH_Data, _PREHASH_Agents, agents, block); msg->getUUIDFast(_PREHASH_Data, _PREHASH_MapImageID, image_id, block); U32 x_meters = x_regions * REGION_WIDTH_UNITS; U32 y_meters = y_regions * REGION_WIDTH_UNITS; U64 handle = to_region_handle(x_meters, y_meters); if (accesscode == 255) { // This region doesn't exist if (LLWorldMap::getInstance()->mIsTrackingUnknownLocation && LLWorldMap::getInstance()->mUnknownLocation.mdV[0] >= x_meters && LLWorldMap::getInstance()->mUnknownLocation.mdV[0] < x_meters + 256 && LLWorldMap::getInstance()->mUnknownLocation.mdV[1] >= y_meters && LLWorldMap::getInstance()->mUnknownLocation.mdV[1] < y_meters + 256) { // We were tracking this location, but it doesn't exist LLWorldMap::getInstance()->mInvalidLocation = TRUE; } found_null_sim = true; } else { adjust = LLWorldMap::getInstance()->extendAABB(x_meters, y_meters, x_meters+REGION_WIDTH_UNITS, y_meters+REGION_WIDTH_UNITS) || adjust; // llinfos << "Map sim " << name << " image layer " << agent_flags << " ID " << image_id.getString() << llendl; LLSimInfo* siminfo = new LLSimInfo(); sim_info_map_t::iterator iter = LLWorldMap::getInstance()->mSimInfoMap.find(handle); if (iter != LLWorldMap::getInstance()->mSimInfoMap.end()) { LLSimInfo* oldinfo = iter->second; for (S32 image=0; image<MAP_SIM_IMAGE_TYPES; ++image) { siminfo->mMapImageID[image] = oldinfo->mMapImageID[image]; } delete oldinfo; } LLWorldMap::getInstance()->mSimInfoMap[handle] = siminfo; siminfo->mHandle = handle; siminfo->msizeX = 256; siminfo->msizeY = 256; siminfo->mName.assign( name ); siminfo->mAccess = accesscode; siminfo->mRegionFlags = region_flags; siminfo->mWaterHeight = (F32) water_height; siminfo->mMapImageID[agent_flags] = image_id; #ifdef IMMEDIATE_IMAGE_LOAD if (use_web_map_tiles) { siminfo->mCurrentImage = loadObjectsTile((U32)x_regions, (U32)y_regions); } else { siminfo->mCurrentImage = gImageList.getImage(siminfo->mMapImageID[LLWorldMap::getInstance()->mCurrentMap], MIPMAP_TRUE, FALSE); } gGL.getTexUnit(0)->bind(siminfo->mCurrentImage.get()); siminfo->mCurrentImage->setAddressMode(LLTexUnit::TAM_CLAMP); #endif if (siminfo->mMapImageID[2].notNull()) { #ifdef IMMEDIATE_IMAGE_LOAD siminfo->mOverlayImage = gImageList.getImage(siminfo->mMapImageID[2], MIPMAP_TRUE, FALSE); #endif } else { siminfo->mOverlayImage = NULL; } if (LLWorldMap::getInstance()->mIsTrackingUnknownLocation && LLWorldMap::getInstance()->mUnknownLocation.mdV[0] >= x_meters && LLWorldMap::getInstance()->mUnknownLocation.mdV[0] < x_meters + 256 && LLWorldMap::getInstance()->mUnknownLocation.mdV[1] >= y_meters && LLWorldMap::getInstance()->mUnknownLocation.mdV[1] < y_meters + 256) { if (siminfo->mAccess == SIM_ACCESS_DOWN) { // We were tracking this location, but it doesn't exist LLWorldMap::getInstance()->mInvalidLocation = true; } else { // We were tracking this location, and it does exist bool is_tracking_dbl = LLWorldMap::getInstance()->mIsTrackingDoubleClick == TRUE; gFloaterWorldMap->trackLocation(LLWorldMap::getInstance()->mUnknownLocation); if (is_tracking_dbl) { LLVector3d pos_global = LLTracker::getTrackedPositionGlobal(); gAgent.teleportViaLocation( pos_global ); } } } } if(LLWorldMap::getInstance()->mSLURLCallback != NULL) { // Server returns definitive capitalization, SLURL might not have that. if ((LLStringUtil::compareInsensitive(LLWorldMap::getInstance()->mSLURLRegionName, name)==0) || (LLWorldMap::getInstance()->mSLURLRegionHandle == handle)) { url_callback_t callback = LLWorldMap::getInstance()->mSLURLCallback; LLWorldMap::getInstance()->mSLURLCallback = NULL; LLWorldMap::getInstance()->mSLURLRegionName.clear(); LLWorldMap::getInstance()->mSLURLRegionHandle = 0; callback(handle, LLWorldMap::getInstance()->mSLURL, image_id, LLWorldMap::getInstance()->mSLURLTeleport); } } if(gAgent.mLureShow) { if((x_regions == gAgent.mLureGlobalX) && (y_regions == gAgent.mLureGlobalY)) { gAgent.onFoundLureDestination(); } } } if(adjust) gFloaterWorldMap->adjustZoomSliderBounds(); gFloaterWorldMap->updateSims(found_null_sim); }
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; // <edit> //this is a hack for opensims. if(LLViewerLogin::getInstance()->getGridChoice() < GRID_INFO_OTHER) img = loadObjectsTile(grid_x, grid_y, level); else { LLSimInfo* info = LLWorldMap::getInstance()->simInfoFromHandle(handle); if(info) { img = gImageList.getImage(info->getMapImageID(), MIPMAP_TRUE, FALSE); img->setBoostLevel(LLViewerImageBoostLevel::BOOST_MAP); } else return NULL; } // </edit> // 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; } }