From d3a616122f46dc1100bf9ef751b8530a94aa3799 Mon Sep 17 00:00:00 2001 From: Cosmic Linden Date: Thu, 3 Mar 2022 09:58:25 -0800 Subject: SL-15232: Test to scroll mouse wheel to map position on main map/minimap --- indra/newview/llappviewer.cpp | 4 +- indra/newview/llfloaterworldmap.cpp | 58 ++++++++------------ indra/newview/llfloaterworldmap.h | 4 -- indra/newview/llworldmapview.cpp | 105 ++++++++++++++++++++++++++++++++++-- indra/newview/llworldmapview.h | 25 +++++++-- 5 files changed, 147 insertions(+), 49 deletions(-) diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index 254bf05d05..0428feddc1 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -589,7 +589,7 @@ static void settings_to_globals() gDebugWindowProc = gSavedSettings.getBOOL("DebugWindowProc"); gShowObjectUpdates = gSavedSettings.getBOOL("ShowObjectUpdates"); - LLWorldMapView::sMapScale = gSavedSettings.getF32("MapScale"); + LLWorldMapView::setScale(gSavedSettings.getF32("MapScale")); #if LL_DARWIN gHiDPISupport = gSavedSettings.getBOOL("RenderHiDPI"); @@ -3404,7 +3404,7 @@ void LLAppViewer::cleanupSavedSettings() } } - gSavedSettings.setF32("MapScale", LLWorldMapView::sMapScale ); + gSavedSettings.setF32("MapScale", LLWorldMapView::getScale()); // Some things are cached in LLAgent. if (gAgent.isInitialized()) diff --git a/indra/newview/llfloaterworldmap.cpp b/indra/newview/llfloaterworldmap.cpp index 27197f0b06..6e29a01dd1 100644 --- a/indra/newview/llfloaterworldmap.cpp +++ b/indra/newview/llfloaterworldmap.cpp @@ -79,7 +79,6 @@ //--------------------------------------------------------------------------- // Constants //--------------------------------------------------------------------------- -static const F32 MAP_ZOOM_TIME = 0.2f; // Merov: we switched from using the "world size" (which varies depending where the user went) to a fixed // width of 512 regions max visible at a time. This makes the zoom slider works in a consistent way across @@ -300,13 +299,11 @@ BOOL LLFloaterWorldMap::postBuild() landmark_combo->setTextChangedCallback( boost::bind(&LLFloaterWorldMap::onComboTextEntry, this) ); mListLandmarkCombo = dynamic_cast(landmark_combo); - mCurZoomVal = log(LLWorldMapView::sMapScale/256.f)/log(2.f); - getChild("zoom slider")->setValue(mCurZoomVal); + F32 slider_zoom = LLWorldMapView::getZoom(); + getChild("zoom slider")->setValue(slider_zoom); setDefaultBtn(NULL); - mZoomTimer.stop(); - onChangeMaturity(); return TRUE; @@ -406,18 +403,21 @@ BOOL LLFloaterWorldMap::handleHover(S32 x, S32 y, MASK mask) BOOL LLFloaterWorldMap::handleScrollWheel(S32 x, S32 y, S32 clicks) { - if (!isMinimized() && isFrontmost()) - { - if(mPanel->pointInView(x, y)) - { - F32 slider_value = (F32)getChild("zoom slider")->getValue().asReal(); - slider_value += ((F32)clicks * -0.3333f); - getChild("zoom slider")->setValue(LLSD(slider_value)); - return TRUE; - } - } - - return LLFloater::handleScrollWheel(x, y, clicks); + if (!isMinimized() && isFrontmost()) + { + if (mPanel->pointInView(x, y)) + { + F32 old_slider_zoom = (F32)getChild("zoom slider")->getValue().asReal(); + F32 slider_zoom = old_slider_zoom + ((F32)clicks * -0.3333f); + getChild("zoom slider")->setValue(LLSD(slider_zoom)); + S32 map_x = x - mPanel->getRect().mLeft; + S32 map_y = y - mPanel->getRect().mBottom; + LLWorldMapView::zoomWithPivot(slider_zoom, map_x, map_y); + return true; + } + } + + return LLFloater::handleScrollWheel(x, y, clicks); } @@ -496,21 +496,8 @@ void LLFloaterWorldMap::draw() setMouseOpaque(TRUE); getDragHandle()->setMouseOpaque(TRUE); - - //RN: snaps to zoom value because interpolation caused jitter in the text rendering - if (!mZoomTimer.getStarted() && mCurZoomVal != (F32)getChild("zoom slider")->getValue().asReal()) - { - mZoomTimer.start(); - } - F32 interp = mZoomTimer.getElapsedTimeF32() / MAP_ZOOM_TIME; - if (interp > 1.f) - { - interp = 1.f; - mZoomTimer.stop(); - } - mCurZoomVal = lerp(mCurZoomVal, (F32)getChild("zoom slider")->getValue().asReal(), interp); - F32 map_scale = 256.f*pow(2.f, mCurZoomVal); - LLWorldMapView::setScale( map_scale ); + + LLWorldMapView::zoom((F32)getChild("zoom slider")->getValue().asReal()); // Enable/disable checkboxes depending on the zoom level // If above threshold level (i.e. low res) -> Disable all checkboxes @@ -1338,9 +1325,10 @@ void LLFloaterWorldMap::centerOnTarget(BOOL animate) pos_global.clearVec(); } - LLWorldMapView::setPan( -llfloor((F32)(pos_global.mdV[VX] * (F64)LLWorldMapView::sMapScale / REGION_WIDTH_METERS)), - -llfloor((F32)(pos_global.mdV[VY] * (F64)LLWorldMapView::sMapScale / REGION_WIDTH_METERS)), - !animate); + F64 map_scale = (F64)LLWorldMapView::getScale(); + LLWorldMapView::setPan( -llfloor((F32)(pos_global.mdV[VX] * map_scale / REGION_WIDTH_METERS)), + -llfloor((F32)(pos_global.mdV[VY] * map_scale / REGION_WIDTH_METERS)), + !animate); mWaitingForTracker = FALSE; } diff --git a/indra/newview/llfloaterworldmap.h b/indra/newview/llfloaterworldmap.h index 97e99297cf..b7e2890906 100644 --- a/indra/newview/llfloaterworldmap.h +++ b/indra/newview/llfloaterworldmap.h @@ -156,10 +156,6 @@ protected: private: LLPanel* mPanel; // Panel displaying the map - // Ties to LLWorldMapView::sMapScale, in pixels per region - F32 mCurZoomVal; - LLFrameTimer mZoomTimer; - // update display of teleport destination coordinates - pos is in global coordinates void updateTeleportCoordsDisplay( const LLVector3d& pos ); diff --git a/indra/newview/llworldmapview.cpp b/indra/newview/llworldmapview.cpp index a6df079223..e6092c6192 100644 --- a/indra/newview/llworldmapview.cpp +++ b/indra/newview/llworldmapview.cpp @@ -58,9 +58,14 @@ #include "llglheaders.h" +// # Constants +static const F32 MAP_ITERP_TIME_CONSTANT = 0.75f; +static const F32 MAP_ZOOM_ACCELERATION_TIME = 0.3f; +static const F32 MAP_ZOOM_MAX_INTERP = 0.5f; +static const F32 MAP_SCALE_SNAP_THRESHOLD = 0.005f; + // Basically a C++ implementation of the OCEAN_COLOR defined in mapstitcher.py // Please ensure consistency between those 2 files (TODO: would be better to get that color from an asset source...) -// # Constants // OCEAN_COLOR = "#1D475F" const F32 OCEAN_RED = (F32)(0x1D)/255.f; const F32 OCEAN_GREEN = (F32)(0x47)/255.f; @@ -100,6 +105,13 @@ S32 LLWorldMapView::sTrackingArrowX = 0; S32 LLWorldMapView::sTrackingArrowY = 0; bool LLWorldMapView::sVisibleTilesLoaded = false; F32 LLWorldMapView::sMapScale = 128.f; +F32 LLWorldMapView::sTargetMapScale = LLWorldMapView::sMapScale; +LLVector2 LLWorldMapView::sZoomPivot = LLVector2(0.0f, 0.0f); +LLFrameTimer LLWorldMapView::sZoomTimer = LLFrameTimer(); +// *HACK: Borrowing some non-static values from the parent LLPanel implementation. Ideally this entire class should not rely on statics for zoom functionality, but I'm treading lightly for smallest delta - Cosmic +// TODO: Actually make this class non-static as discussed above, then test to make sure there are no adverse consequences to performance/stability - Cosmic +F32 LLWorldMapView::sWidthForZoom = 0.0f; +F32 LLWorldMapView::sHeightForZoom = 0.0f; std::map LLWorldMapView::sStringsMap; @@ -210,6 +222,8 @@ BOOL LLWorldMapView::postBuild() mTextBoxNorthEast ->reshapeToFitText(); mTextBoxSouthWest->reshapeToFitText(); mTextBoxNorthWest ->reshapeToFitText(); + + sZoomTimer.stop(); return true; } @@ -227,9 +241,36 @@ void LLWorldMapView::cleanupTextures() { } +// static +void LLWorldMapView::zoom(F32 zoom) +{ + sTargetMapScale = scaleFromZoom(zoom); + if (!sZoomTimer.getStarted() && sMapScale != sTargetMapScale) + { + sZoomPivot = LLVector2(0, 0); + sZoomTimer.start(); + } +} + +// static +void LLWorldMapView::zoomWithPivot(F32 zoom, S32 x, S32 y) +{ + sTargetMapScale = scaleFromZoom(zoom); + sZoomPivot = LLVector2(x, y); + if (!sZoomTimer.getStarted() && sMapScale != sTargetMapScale) + { + sZoomTimer.start(); + } +} + +// static +F32 LLWorldMapView::getZoom() +{ + return LLWorldMapView::zoomFromScale(sMapScale); +} // static -void LLWorldMapView::setScale( F32 scale ) +void LLWorldMapView::setScale(F32 scale, bool snap) { if (scale != sMapScale) { @@ -247,9 +288,32 @@ void LLWorldMapView::setScale( F32 scale ) sTargetPanX = sPanX; sTargetPanY = sPanY; sVisibleTilesLoaded = false; + + // If we are zooming relative to somewhere else rather than the center of the map, compensate for the difference in panning here + if (!sZoomPivot.isExactlyZero()) + { + LLVector2 relative_pivot; + relative_pivot.mV[VX] = sZoomPivot.mV[VX] - (sWidthForZoom / 2.0); + relative_pivot.mV[VY] = sZoomPivot.mV[VY] - (sHeightForZoom / 2.0); + LLVector2 zoom_pan_offset = relative_pivot - (relative_pivot * scale / old_scale); + sPanX += zoom_pan_offset.mV[VX]; + sPanY += zoom_pan_offset.mV[VY]; + sTargetPanX += zoom_pan_offset.mV[VX]; + sTargetPanY += zoom_pan_offset.mV[VY]; + } } + + if (snap) + { + sTargetMapScale = scale; + } } +// static +F32 LLWorldMapView::getScale() +{ + return sMapScale; +} // static void LLWorldMapView::translatePan( S32 delta_x, S32 delta_y ) @@ -301,11 +365,34 @@ void LLWorldMapView::draw() mVisibleRegions.clear(); // animate pan if necessary - sPanX = lerp(sPanX, sTargetPanX, LLSmoothInterpolation::getInterpolant(0.1f)); - sPanY = lerp(sPanY, sTargetPanY, LLSmoothInterpolation::getInterpolant(0.1f)); + sPanX = lerp(sPanX, sTargetPanX, LLSmoothInterpolation::getInterpolant(MAP_ITERP_TIME_CONSTANT)); + sPanY = lerp(sPanY, sTargetPanY, LLSmoothInterpolation::getInterpolant(MAP_ITERP_TIME_CONSTANT)); + + //RN: snaps to zoom value because interpolation caused jitter in the text rendering + if (!sZoomTimer.getStarted() && sMapScale != sTargetMapScale) + { + sZoomTimer.start(); + } + bool snap_scale = false; + F32 interp = llmin(MAP_ZOOM_MAX_INTERP, sZoomTimer.getElapsedTimeF32() / MAP_ZOOM_ACCELERATION_TIME); + F32 current_zoom_val = zoomFromScale(sMapScale); + F32 target_zoom_val = zoomFromScale(sTargetMapScale); + F32 new_zoom_val = lerp(current_zoom_val, target_zoom_val, interp); + if (abs(new_zoom_val - current_zoom_val) < MAP_SCALE_SNAP_THRESHOLD) + { + sZoomTimer.stop(); + snap_scale = true; + new_zoom_val = target_zoom_val; + } + F32 map_scale = scaleFromZoom(new_zoom_val); + setScale(map_scale, snap_scale); const S32 width = getRect().getWidth(); const S32 height = getRect().getHeight(); + // *HACK: Borrowing some non-static values from the parent LLPanel implementation. Ideally this entire class should not rely on statics for zoom functionality, but I'm treading lightly for smallest delta - Cosmic + // TODO: Actually make this class non-static as discussed above, then test to make sure there are no adverse consequences to performance/stability - Cosmic + sWidthForZoom = width; + sHeightForZoom = height; const F32 half_width = F32(width) / 2.0f; const F32 half_height = F32(height) / 2.0f; LLVector3d camera_global = gAgentCamera.getCameraPositionGlobal(); @@ -1792,4 +1879,14 @@ BOOL LLWorldMapView::handleDoubleClick( S32 x, S32 y, MASK mask ) return FALSE; } +// static +F32 LLWorldMapView::scaleFromZoom(F32 zoom) +{ + return exp2(zoom) * 256.0f; +} +// static +F32 LLWorldMapView::zoomFromScale(F32 scale) +{ + return log2(scale / 256.f); +} diff --git a/indra/newview/llworldmapview.h b/indra/newview/llworldmapview.h index a2a6dc53fb..9a549a443a 100644 --- a/indra/newview/llworldmapview.h +++ b/indra/newview/llworldmapview.h @@ -67,8 +67,16 @@ public: bool checkItemHit(S32 x, S32 y, LLItemInfo& item, LLUUID* id, bool track); void handleClick(S32 x, S32 y, MASK mask, S32* hit_type, LLUUID* id); - // Scale and pan are shared across all instances! (i.e. Terrain and Objects maps are always registered) - static void setScale( F32 scale ); + // Zoom, scale, and pan are shared across all instances! (i.e. Terrain and Objects maps are always registered) + // Scale and zoom are the same thing but with different units. + // Scale is for things defined in in-world coordinates. + // Zoom is used for UI and will interpolate the map scale over multiple frames. + // Pan is in pixels relative to the center of the map. + static void zoom(F32 zoom); + static void zoomWithPivot(F32 zoom, S32 x, S32 y); + static F32 getZoom(); + static void setScale(F32 scale, bool snap = true); + static F32 getScale(); static void translatePan( S32 delta_x, S32 delta_y ); static void setPan( S32 x, S32 y, BOOL snap = TRUE ); // Return true if the current scale level is above the threshold for accessing region info @@ -153,8 +161,6 @@ public: static LLUIImagePtr sForSaleImage; static LLUIImagePtr sForSaleAdultImage; - static F32 sMapScale; // scale = size of a region in pixels - BOOL mItemPicked; static F32 sPanX; // in pixels @@ -194,6 +200,17 @@ public: private: void drawTileOutline(S32 level, F32 top, F32 left, F32 bottom, F32 right); + + static F32 scaleFromZoom(F32 zoom); + static F32 zoomFromScale(F32 scale); + + static F32 sMapScale; + static F32 sTargetMapScale; + static LLVector2 sZoomPivot; + static LLFrameTimer sZoomTimer; + + static F32 sWidthForZoom; + static F32 sHeightForZoom; }; #endif -- cgit v1.2.3 From 288fbe23175d504359169ae6d8dda86529f8d046 Mon Sep 17 00:00:00 2001 From: Cosmic Linden Date: Wed, 9 Mar 2022 14:58:31 -0800 Subject: SL-15232: Fix top/right edges of main map not being scrollable --- indra/newview/llfloaterworldmap.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/indra/newview/llfloaterworldmap.cpp b/indra/newview/llfloaterworldmap.cpp index 6e29a01dd1..2947804b69 100644 --- a/indra/newview/llfloaterworldmap.cpp +++ b/indra/newview/llfloaterworldmap.cpp @@ -405,13 +405,13 @@ BOOL LLFloaterWorldMap::handleScrollWheel(S32 x, S32 y, S32 clicks) { if (!isMinimized() && isFrontmost()) { - if (mPanel->pointInView(x, y)) + S32 map_x = x - mPanel->getRect().mLeft; + S32 map_y = y - mPanel->getRect().mBottom; + if (mPanel->pointInView(map_x, map_y)) { F32 old_slider_zoom = (F32)getChild("zoom slider")->getValue().asReal(); F32 slider_zoom = old_slider_zoom + ((F32)clicks * -0.3333f); getChild("zoom slider")->setValue(LLSD(slider_zoom)); - S32 map_x = x - mPanel->getRect().mLeft; - S32 map_y = y - mPanel->getRect().mBottom; LLWorldMapView::zoomWithPivot(slider_zoom, map_x, map_y); return true; } -- cgit v1.2.3 From c6cba3a67d4a346d1d5cf0cc6e6a8fe8c640e13f Mon Sep 17 00:00:00 2001 From: Cosmic Linden Date: Thu, 10 Mar 2022 16:38:07 -0800 Subject: SL-15232: Clean up LLWorldMapView a bit. Avoid a static variable hack and convert a few related variables/methods to non-static as well --- indra/newview/llappviewer.cpp | 4 +- indra/newview/llfloaterworldmap.cpp | 41 ++++---- indra/newview/llfloaterworldmap.h | 3 +- indra/newview/llworldmapview.cpp | 198 ++++++++++++++++++------------------ indra/newview/llworldmapview.h | 41 ++++---- 5 files changed, 144 insertions(+), 143 deletions(-) diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index 0428feddc1..a06a9eb9fe 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -589,7 +589,7 @@ static void settings_to_globals() gDebugWindowProc = gSavedSettings.getBOOL("DebugWindowProc"); gShowObjectUpdates = gSavedSettings.getBOOL("ShowObjectUpdates"); - LLWorldMapView::setScale(gSavedSettings.getF32("MapScale")); + LLWorldMapView::setScaleSetting(gSavedSettings.getF32("MapScale")); #if LL_DARWIN gHiDPISupport = gSavedSettings.getBOOL("RenderHiDPI"); @@ -3404,7 +3404,7 @@ void LLAppViewer::cleanupSavedSettings() } } - gSavedSettings.setF32("MapScale", LLWorldMapView::getScale()); + gSavedSettings.setF32("MapScale", LLWorldMapView::getScaleSetting()); // Some things are cached in LLAgent. if (gAgent.isInitialized()) diff --git a/indra/newview/llfloaterworldmap.cpp b/indra/newview/llfloaterworldmap.cpp index 2947804b69..cf314c3e60 100644 --- a/indra/newview/llfloaterworldmap.cpp +++ b/indra/newview/llfloaterworldmap.cpp @@ -278,7 +278,7 @@ void* LLFloaterWorldMap::createWorldMapView(void* data) BOOL LLFloaterWorldMap::postBuild() { - mPanel = getChild("objects_mapview"); + mMapView = dynamic_cast(getChild("objects_mapview")); LLComboBox *avatar_combo = getChild("friend combo"); avatar_combo->selectFirstItem(); @@ -299,7 +299,7 @@ BOOL LLFloaterWorldMap::postBuild() landmark_combo->setTextChangedCallback( boost::bind(&LLFloaterWorldMap::onComboTextEntry, this) ); mListLandmarkCombo = dynamic_cast(landmark_combo); - F32 slider_zoom = LLWorldMapView::getZoom(); + F32 slider_zoom = mMapView->getZoom(); getChild("zoom slider")->setValue(slider_zoom); setDefaultBtn(NULL); @@ -313,7 +313,7 @@ BOOL LLFloaterWorldMap::postBuild() LLFloaterWorldMap::~LLFloaterWorldMap() { // All cleaned up by LLView destructor - mPanel = NULL; + mMapView = NULL; // Inventory deletes all observers on shutdown mInventory = NULL; @@ -345,17 +345,15 @@ void LLFloaterWorldMap::onOpen(const LLSD& key) mIsClosing = FALSE; - LLWorldMapView* map_panel; - map_panel = (LLWorldMapView*)gFloaterWorldMap->mPanel; - map_panel->clearLastClick(); + mMapView->clearLastClick(); { // reset pan on show, so it centers on you again if (!center_on_target) { - LLWorldMapView::setPan(0, 0, TRUE); + mMapView->setPan(0, 0, true); } - map_panel->updateVisibleBlocks(); + mMapView->updateVisibleBlocks(); // Reload items as they may have changed LLWorldMap::getInstance()->reloadItems(); @@ -405,14 +403,14 @@ BOOL LLFloaterWorldMap::handleScrollWheel(S32 x, S32 y, S32 clicks) { if (!isMinimized() && isFrontmost()) { - S32 map_x = x - mPanel->getRect().mLeft; - S32 map_y = y - mPanel->getRect().mBottom; - if (mPanel->pointInView(map_x, map_y)) + S32 map_x = x - mMapView->getRect().mLeft; + S32 map_y = y - mMapView->getRect().mBottom; + if (mMapView->pointInView(map_x, map_y)) { F32 old_slider_zoom = (F32)getChild("zoom slider")->getValue().asReal(); F32 slider_zoom = old_slider_zoom + ((F32)clicks * -0.3333f); getChild("zoom slider")->setValue(LLSD(slider_zoom)); - LLWorldMapView::zoomWithPivot(slider_zoom, map_x, map_y); + mMapView->zoomWithPivot(slider_zoom, map_x, map_y); return true; } } @@ -497,12 +495,12 @@ void LLFloaterWorldMap::draw() setMouseOpaque(TRUE); getDragHandle()->setMouseOpaque(TRUE); - LLWorldMapView::zoom((F32)getChild("zoom slider")->getValue().asReal()); + mMapView->zoom((F32)getChild("zoom slider")->getValue().asReal()); // Enable/disable checkboxes depending on the zoom level // If above threshold level (i.e. low res) -> Disable all checkboxes // If under threshold level (i.e. high res) -> Enable all checkboxes - bool enable = LLWorldMapView::showRegionInfo(); + bool enable = mMapView->showRegionInfo(); getChildView("people_chk")->setEnabled(enable); getChildView("infohub_chk")->setEnabled(enable); getChildView("telehub_chk")->setEnabled(enable); @@ -1001,9 +999,7 @@ void LLFloaterWorldMap::adjustZoomSliderBounds() S32 world_height_regions = MAX_VISIBLE_REGIONS; // Find how much space we have to display the world - LLWorldMapView* map_panel; - map_panel = (LLWorldMapView*)mPanel; - LLRect view_rect = map_panel->getRect(); + LLRect view_rect = mMapView->getRect(); // View size in pixels S32 view_width = view_rect.getWidth(); @@ -1271,9 +1267,9 @@ void LLFloaterWorldMap::onShowTargetBtn() void LLFloaterWorldMap::onShowAgentBtn() { - LLWorldMapView::setPan( 0, 0, FALSE); // FALSE == animate + mMapView->setPan(0, 0, false); // false == animate // Set flag so user's location will be displayed if not tracking anything else - mSetToUserPosition = TRUE; + mSetToUserPosition = true; } void LLFloaterWorldMap::onClickTeleportBtn() @@ -1325,8 +1321,8 @@ void LLFloaterWorldMap::centerOnTarget(BOOL animate) pos_global.clearVec(); } - F64 map_scale = (F64)LLWorldMapView::getScale(); - LLWorldMapView::setPan( -llfloor((F32)(pos_global.mdV[VX] * map_scale / REGION_WIDTH_METERS)), + F64 map_scale = (F64)mMapView->getScale(); + mMapView->setPan(-llfloor((F32)(pos_global.mdV[VX] * map_scale / REGION_WIDTH_METERS)), -llfloor((F32)(pos_global.mdV[VY] * map_scale / REGION_WIDTH_METERS)), !animate); mWaitingForTracker = FALSE; @@ -1627,6 +1623,5 @@ void LLFloaterWorldMap::onChangeMaturity() void LLFloaterWorldMap::onFocusLost() { gViewerWindow->showCursor(); - LLWorldMapView* map_panel = (LLWorldMapView*)gFloaterWorldMap->mPanel; - map_panel->mPanning = FALSE; + mMapView->mPanning = false; } diff --git a/indra/newview/llfloaterworldmap.h b/indra/newview/llfloaterworldmap.h index b7e2890906..c9724d37ac 100644 --- a/indra/newview/llfloaterworldmap.h +++ b/indra/newview/llfloaterworldmap.h @@ -44,6 +44,7 @@ class LLInventoryObserver; class LLItemInfo; class LLLineEditor; class LLTabContainer; +class LLWorldMapView; class LLFloaterWorldMap : public LLFloater { @@ -154,7 +155,7 @@ protected: void cacheLandmarkPosition(); private: - LLPanel* mPanel; // Panel displaying the map + LLWorldMapView* mMapView; // Panel displaying the map // update display of teleport destination coordinates - pos is in global coordinates void updateTeleportCoordsDisplay( const LLVector3d& pos ); diff --git a/indra/newview/llworldmapview.cpp b/indra/newview/llworldmapview.cpp index e6092c6192..cad655ea48 100644 --- a/indra/newview/llworldmapview.cpp +++ b/indra/newview/llworldmapview.cpp @@ -59,6 +59,7 @@ #include "llglheaders.h" // # Constants +static const F32 MAP_DEFAULT_SCALE = 128.f; static const F32 MAP_ITERP_TIME_CONSTANT = 0.75f; static const F32 MAP_ZOOM_ACCELERATION_TIME = 0.3f; static const F32 MAP_ZOOM_MAX_INTERP = 0.5f; @@ -97,21 +98,12 @@ LLUIImagePtr LLWorldMapView::sClassifiedsImage = NULL; LLUIImagePtr LLWorldMapView::sForSaleImage = NULL; LLUIImagePtr LLWorldMapView::sForSaleAdultImage = NULL; -F32 LLWorldMapView::sPanX = 0.f; -F32 LLWorldMapView::sPanY = 0.f; -F32 LLWorldMapView::sTargetPanX = 0.f; -F32 LLWorldMapView::sTargetPanY = 0.f; S32 LLWorldMapView::sTrackingArrowX = 0; S32 LLWorldMapView::sTrackingArrowY = 0; bool LLWorldMapView::sVisibleTilesLoaded = false; -F32 LLWorldMapView::sMapScale = 128.f; -F32 LLWorldMapView::sTargetMapScale = LLWorldMapView::sMapScale; +F32 LLWorldMapView::sMapScaleSetting = MAP_DEFAULT_SCALE; LLVector2 LLWorldMapView::sZoomPivot = LLVector2(0.0f, 0.0f); LLFrameTimer LLWorldMapView::sZoomTimer = LLFrameTimer(); -// *HACK: Borrowing some non-static values from the parent LLPanel implementation. Ideally this entire class should not rely on statics for zoom functionality, but I'm treading lightly for smallest delta - Cosmic -// TODO: Actually make this class non-static as discussed above, then test to make sure there are no adverse consequences to performance/stability - Cosmic -F32 LLWorldMapView::sWidthForZoom = 0.0f; -F32 LLWorldMapView::sHeightForZoom = 0.0f; std::map LLWorldMapView::sStringsMap; @@ -182,12 +174,18 @@ LLWorldMapView::LLWorldMapView() : LLPanel(), mBackgroundColor( LLColor4( OCEAN_RED, OCEAN_GREEN, OCEAN_BLUE, 1.f ) ), mItemPicked(FALSE), + mPanX(0.f), + mPanY(0.f), + mTargetPanX(0.f), + mTargetPanY(0.f), mPanning( FALSE ), mMouseDownPanX( 0 ), mMouseDownPanY( 0 ), mMouseDownX( 0 ), mMouseDownY( 0 ), - mSelectIDStart(0) + mSelectIDStart(0), + mMapScale(0.f), + mTargetMapScale(0.f) { //LL_INFOS("WorldMap") << "Creating the Map -> LLWorldMapView::LLWorldMapView()" << LL_ENDL; @@ -224,6 +222,7 @@ BOOL LLWorldMapView::postBuild() mTextBoxNorthWest ->reshapeToFitText(); sZoomTimer.stop(); + setScale(sMapScaleSetting, true); return true; } @@ -241,87 +240,96 @@ void LLWorldMapView::cleanupTextures() { } -// static void LLWorldMapView::zoom(F32 zoom) { - sTargetMapScale = scaleFromZoom(zoom); - if (!sZoomTimer.getStarted() && sMapScale != sTargetMapScale) + mTargetMapScale = scaleFromZoom(zoom); + if (!sZoomTimer.getStarted() && mMapScale != mTargetMapScale) { sZoomPivot = LLVector2(0, 0); sZoomTimer.start(); } } -// static void LLWorldMapView::zoomWithPivot(F32 zoom, S32 x, S32 y) { - sTargetMapScale = scaleFromZoom(zoom); + mTargetMapScale = scaleFromZoom(zoom); sZoomPivot = LLVector2(x, y); - if (!sZoomTimer.getStarted() && sMapScale != sTargetMapScale) + if (!sZoomTimer.getStarted() && mMapScale != mTargetMapScale) { sZoomTimer.start(); } } -// static F32 LLWorldMapView::getZoom() { - return LLWorldMapView::zoomFromScale(sMapScale); + return LLWorldMapView::zoomFromScale(mMapScale); +} + +F32 LLWorldMapView::getScale() +{ + return mMapScale; } // static +void LLWorldMapView::setScaleSetting(F32 scaleSetting) +{ + sMapScaleSetting = scaleSetting; +} + +// static +F32 LLWorldMapView::getScaleSetting() +{ + return sMapScaleSetting; +} + void LLWorldMapView::setScale(F32 scale, bool snap) { - if (scale != sMapScale) + if (scale != mMapScale) { - F32 old_scale = sMapScale; + F32 old_scale = mMapScale; - sMapScale = scale; - if (sMapScale <= 0.f) + mMapScale = scale; + // Set the scale used when saving the setting + sMapScaleSetting = scale; + if (mMapScale <= 0.f) { - sMapScale = 0.1f; + mMapScale = 0.1f; } F32 ratio = (scale / old_scale); - sPanX *= ratio; - sPanY *= ratio; - sTargetPanX = sPanX; - sTargetPanY = sPanY; + mPanX *= ratio; + mPanY *= ratio; + mTargetPanX = mPanX; + mTargetPanY = mPanY; sVisibleTilesLoaded = false; // If we are zooming relative to somewhere else rather than the center of the map, compensate for the difference in panning here if (!sZoomPivot.isExactlyZero()) { LLVector2 relative_pivot; - relative_pivot.mV[VX] = sZoomPivot.mV[VX] - (sWidthForZoom / 2.0); - relative_pivot.mV[VY] = sZoomPivot.mV[VY] - (sHeightForZoom / 2.0); + relative_pivot.mV[VX] = sZoomPivot.mV[VX] - (getRect().getWidth() / 2.0); + relative_pivot.mV[VY] = sZoomPivot.mV[VY] - (getRect().getHeight() / 2.0); LLVector2 zoom_pan_offset = relative_pivot - (relative_pivot * scale / old_scale); - sPanX += zoom_pan_offset.mV[VX]; - sPanY += zoom_pan_offset.mV[VY]; - sTargetPanX += zoom_pan_offset.mV[VX]; - sTargetPanY += zoom_pan_offset.mV[VY]; + mPanX += zoom_pan_offset.mV[VX]; + mPanY += zoom_pan_offset.mV[VY]; + mTargetPanX += zoom_pan_offset.mV[VX]; + mTargetPanY += zoom_pan_offset.mV[VY]; } } if (snap) { - sTargetMapScale = scale; - } + mTargetMapScale = scale; } - -// static -F32 LLWorldMapView::getScale() -{ - return sMapScale; } // static void LLWorldMapView::translatePan( S32 delta_x, S32 delta_y ) { - sPanX += delta_x; - sPanY += delta_y; - sTargetPanX = sPanX; - sTargetPanY = sPanY; + mPanX += delta_x; + mPanY += delta_y; + mTargetPanX = mPanX; + mTargetPanY = mPanY; sVisibleTilesLoaded = false; } @@ -329,19 +337,19 @@ void LLWorldMapView::translatePan( S32 delta_x, S32 delta_y ) // static void LLWorldMapView::setPan( S32 x, S32 y, BOOL snap ) { - sTargetPanX = (F32)x; - sTargetPanY = (F32)y; + mTargetPanX = (F32)x; + mTargetPanY = (F32)y; if (snap) { - sPanX = sTargetPanX; - sPanY = sTargetPanY; + mPanX = mTargetPanX; + mPanY = mTargetPanY; } sVisibleTilesLoaded = false; } bool LLWorldMapView::showRegionInfo() { - return (LLWorldMipmap::scaleToLevel(sMapScale) <= DRAW_SIMINFO_THRESHOLD ? true : false); + return (LLWorldMipmap::scaleToLevel(mMapScale) <= DRAW_SIMINFO_THRESHOLD ? true : false); } /////////////////////////////////////////////////////////////////////////////////// @@ -365,18 +373,18 @@ void LLWorldMapView::draw() mVisibleRegions.clear(); // animate pan if necessary - sPanX = lerp(sPanX, sTargetPanX, LLSmoothInterpolation::getInterpolant(MAP_ITERP_TIME_CONSTANT)); - sPanY = lerp(sPanY, sTargetPanY, LLSmoothInterpolation::getInterpolant(MAP_ITERP_TIME_CONSTANT)); + mPanX = lerp(mPanX, mTargetPanX, LLSmoothInterpolation::getInterpolant(MAP_ITERP_TIME_CONSTANT)); + mPanY = lerp(mPanY, mTargetPanY, LLSmoothInterpolation::getInterpolant(MAP_ITERP_TIME_CONSTANT)); //RN: snaps to zoom value because interpolation caused jitter in the text rendering - if (!sZoomTimer.getStarted() && sMapScale != sTargetMapScale) + if (!sZoomTimer.getStarted() && mMapScale != mTargetMapScale) { sZoomTimer.start(); } bool snap_scale = false; F32 interp = llmin(MAP_ZOOM_MAX_INTERP, sZoomTimer.getElapsedTimeF32() / MAP_ZOOM_ACCELERATION_TIME); - F32 current_zoom_val = zoomFromScale(sMapScale); - F32 target_zoom_val = zoomFromScale(sTargetMapScale); + F32 current_zoom_val = zoomFromScale(mMapScale); + F32 target_zoom_val = zoomFromScale(mTargetMapScale); F32 new_zoom_val = lerp(current_zoom_val, target_zoom_val, interp); if (abs(new_zoom_val - current_zoom_val) < MAP_SCALE_SNAP_THRESHOLD) { @@ -389,15 +397,11 @@ void LLWorldMapView::draw() const S32 width = getRect().getWidth(); const S32 height = getRect().getHeight(); - // *HACK: Borrowing some non-static values from the parent LLPanel implementation. Ideally this entire class should not rely on statics for zoom functionality, but I'm treading lightly for smallest delta - Cosmic - // TODO: Actually make this class non-static as discussed above, then test to make sure there are no adverse consequences to performance/stability - Cosmic - sWidthForZoom = width; - sHeightForZoom = height; const F32 half_width = F32(width) / 2.0f; const F32 half_height = F32(height) / 2.0f; LLVector3d camera_global = gAgentCamera.getCameraPositionGlobal(); - S32 level = LLWorldMipmap::scaleToLevel(sMapScale); + S32 level = LLWorldMipmap::scaleToLevel(mMapScale); LLLocalClipRect clip(getLocalRect()); { @@ -437,15 +441,15 @@ void LLWorldMapView::draw() // Find x and y position relative to camera's center. LLVector3d rel_region_pos = origin_global - camera_global; - F32 relative_x = (rel_region_pos.mdV[0] / REGION_WIDTH_METERS) * sMapScale; - F32 relative_y = (rel_region_pos.mdV[1] / REGION_WIDTH_METERS) * sMapScale; + F32 relative_x = (rel_region_pos.mdV[0] / REGION_WIDTH_METERS) * mMapScale; + F32 relative_y = (rel_region_pos.mdV[1] / REGION_WIDTH_METERS) * mMapScale; // Coordinates of the sim in pixels in the UI panel // When the view isn't panned, 0,0 = center of rectangle - F32 bottom = sPanY + half_height + relative_y; - F32 left = sPanX + half_width + relative_x; - F32 top = bottom + sMapScale ; - F32 right = left + sMapScale ; + F32 bottom = mPanY + half_height + relative_y; + F32 left = mPanX + half_width + relative_x; + F32 top = bottom + mMapScale ; + F32 right = left + mMapScale ; // Discard if region is outside the screen rectangle (not visible on screen) if ((top < 0.f) || (bottom > height) || @@ -506,7 +510,7 @@ void LLWorldMapView::draw() if (overlayimage) { // Inform the fetch mechanism of the size we need - S32 draw_size = ll_round(sMapScale); + S32 draw_size = ll_round(mMapScale); overlayimage->setKnownDrawSize(ll_round(draw_size * LLUI::getScaleFactor().mV[VX]), ll_round(draw_size * LLUI::getScaleFactor().mV[VY])); // Draw something whenever we have enough info if (overlayimage->hasGLTexture()) @@ -534,7 +538,7 @@ void LLWorldMapView::draw() } // Draw the region name in the lower left corner - if (sMapScale >= DRAW_TEXT_THRESHOLD) + if (mMapScale >= DRAW_TEXT_THRESHOLD) { LLFontGL* font = LLFontGL::getFont(LLFontDescriptor("SansSerif", "Small", LLFontGL::BOLD)); std::string mesg; @@ -554,7 +558,7 @@ void LLWorldMapView::draw() LLColor4::white, LLFontGL::LEFT, LLFontGL::BASELINE, LLFontGL::NORMAL, LLFontGL::DROP_SHADOW, S32_MAX, //max_chars - sMapScale, //max_pixels + mMapScale, //max_pixels NULL, TRUE); //use ellipses } @@ -681,7 +685,7 @@ void LLWorldMapView::setVisible(BOOL visible) void LLWorldMapView::drawMipmap(S32 width, S32 height) { // Compute the level of the mipmap to use for the current scale level - S32 level = LLWorldMipmap::scaleToLevel(sMapScale); + S32 level = LLWorldMipmap::scaleToLevel(mMapScale); // Set the tile boost level so that unused tiles get to 0 LLWorldMap::getInstance()->equalizeBoostLevels(); @@ -964,7 +968,7 @@ void LLWorldMapView::drawAgents() void LLWorldMapView::drawFrustum() { // Draw frustum - F32 meters_to_pixels = sMapScale/ REGION_WIDTH_METERS; + F32 meters_to_pixels = mMapScale/ REGION_WIDTH_METERS; F32 horiz_fov = LLViewerCamera::getInstance()->getView() * LLViewerCamera::getInstance()->getAspect(); F32 far_clip_meters = LLViewerCamera::getInstance()->getFar(); @@ -974,8 +978,8 @@ void LLWorldMapView::drawFrustum() F32 half_width_pixels = half_width_meters * meters_to_pixels; // Compute the frustum coordinates. Take the UI scale into account. - F32 ctr_x = ((getLocalRect().getWidth() * 0.5f + sPanX) * LLUI::getScaleFactor().mV[VX]); - F32 ctr_y = ((getLocalRect().getHeight() * 0.5f + sPanY) * LLUI::getScaleFactor().mV[VY]); + F32 ctr_x = ((getLocalRect().getWidth() * 0.5f + mPanX) * LLUI::getScaleFactor().mV[VX]); + F32 ctr_y = ((getLocalRect().getHeight() * 0.5f + mPanY) * LLUI::getScaleFactor().mV[VY]); gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); @@ -1032,13 +1036,13 @@ LLVector3 LLWorldMapView::globalPosToView( const LLVector3d& global_pos ) LLVector3 pos_local; pos_local.setVec(relative_pos_global); // convert to floats from doubles - pos_local.mV[VX] *= sMapScale / REGION_WIDTH_METERS; - pos_local.mV[VY] *= sMapScale / REGION_WIDTH_METERS; + pos_local.mV[VX] *= mMapScale / REGION_WIDTH_METERS; + pos_local.mV[VY] *= mMapScale / REGION_WIDTH_METERS; // leave Z component in meters - pos_local.mV[VX] += getRect().getWidth() / 2 + sPanX; - pos_local.mV[VY] += getRect().getHeight() / 2 + sPanY; + pos_local.mV[VX] += getRect().getWidth() / 2 + mPanX; + pos_local.mV[VY] += getRect().getHeight() / 2 + mPanY; return pos_local; } @@ -1109,12 +1113,12 @@ void LLWorldMapView::drawTracking(const LLVector3d& pos_global, const LLColor4& // If you change this, then you need to change LLTracker::getTrackedPositionGlobal() as well LLVector3d LLWorldMapView::viewPosToGlobal( S32 x, S32 y ) { - x -= llfloor((getRect().getWidth() / 2 + sPanX)); - y -= llfloor((getRect().getHeight() / 2 + sPanY)); + x -= llfloor((getRect().getWidth() / 2 + mPanX)); + y -= llfloor((getRect().getHeight() / 2 + mPanY)); LLVector3 pos_local( (F32)x, (F32)y, 0.f ); - pos_local *= ( REGION_WIDTH_METERS / sMapScale ); + pos_local *= ( REGION_WIDTH_METERS / mMapScale ); LLVector3d pos_global; pos_global.setVec( pos_local ); @@ -1571,7 +1575,7 @@ void LLWorldMapView::handleClick(S32 x, S32 y, MASK mask, LLWorldMap::getInstance()->cancelTracking(); - S32 level = LLWorldMipmap::scaleToLevel(sMapScale); + S32 level = LLWorldMipmap::scaleToLevel(mMapScale); // If the zoom level is not too far out already, test hits if (level <= DRAW_SIMINFO_THRESHOLD) { @@ -1688,8 +1692,8 @@ BOOL LLWorldMapView::handleMouseDown( S32 x, S32 y, MASK mask ) { gFocusMgr.setMouseCapture( this ); - mMouseDownPanX = ll_round(sPanX); - mMouseDownPanY = ll_round(sPanY); + mMouseDownPanX = ll_round(mPanX); + mMouseDownPanY = ll_round(mPanY); mMouseDownX = x; mMouseDownY = y; sHandledLastClick = TRUE; @@ -1704,8 +1708,8 @@ BOOL LLWorldMapView::handleMouseUp( S32 x, S32 y, MASK mask ) { // restore mouse cursor S32 local_x, local_y; - local_x = mMouseDownX + llfloor(sPanX - mMouseDownPanX); - local_y = mMouseDownY + llfloor(sPanY - mMouseDownPanY); + local_x = mMouseDownX + llfloor(mPanX - mMouseDownPanX); + local_y = mMouseDownY + llfloor(mPanY - mMouseDownPanY); LLRect clip_rect = getRect(); clip_rect.stretch(-8); clip_rect.clipPointToRect(mMouseDownX, mMouseDownY, local_x, local_y); @@ -1733,7 +1737,7 @@ BOOL LLWorldMapView::handleMouseUp( S32 x, S32 y, MASK mask ) void LLWorldMapView::updateVisibleBlocks() { - if (LLWorldMipmap::scaleToLevel(sMapScale) > DRAW_SIMINFO_THRESHOLD) + if (LLWorldMipmap::scaleToLevel(mMapScale) > DRAW_SIMINFO_THRESHOLD) { // If we're zoomed out too much, we just don't load all those sim info: too much! return; @@ -1749,16 +1753,16 @@ void LLWorldMapView::updateVisibleBlocks() const F32 half_height = F32(height) / 2.0f; // Compute center into sim grid coordinates - S32 world_center_x = S32((-sPanX / sMapScale) + (camera_global.mdV[0] / REGION_WIDTH_METERS)); - S32 world_center_y = S32((-sPanY / sMapScale) + (camera_global.mdV[1] / REGION_WIDTH_METERS)); + S32 world_center_x = S32((-mPanX / mMapScale) + (camera_global.mdV[0] / REGION_WIDTH_METERS)); + S32 world_center_y = S32((-mPanY / mMapScale) + (camera_global.mdV[1] / REGION_WIDTH_METERS)); // Compute the boundaries into sim grid coordinates - S32 world_left = world_center_x - S32(half_width / sMapScale) - 1; - S32 world_right = world_center_x + S32(half_width / sMapScale) + 1; - S32 world_bottom = world_center_y - S32(half_height / sMapScale) - 1; - S32 world_top = world_center_y + S32(half_height / sMapScale) + 1; + S32 world_left = world_center_x - S32(half_width / mMapScale) - 1; + S32 world_right = world_center_x + S32(half_width / mMapScale) + 1; + S32 world_bottom = world_center_y - S32(half_height / mMapScale) - 1; + S32 world_top = world_center_y + S32(half_height / mMapScale) + 1; - //LL_INFOS("WorldMap") << "LLWorldMapView::updateVisibleBlocks() : sMapScale = " << sMapScale << ", left = " << world_left << ", right = " << world_right << ", bottom = " << world_bottom << ", top = " << world_top << LL_ENDL; + //LL_INFOS("WorldMap") << "LLWorldMapView::updateVisibleBlocks() : mMapScale = " << mMapScale << ", left = " << world_left << ", right = " << world_right << ", bottom = " << world_bottom << ", top = " << world_top << LL_ENDL; LLWorldMap::getInstance()->updateRegions(world_left, world_bottom, world_right, world_top); } @@ -1779,10 +1783,10 @@ BOOL LLWorldMapView::handleHover( S32 x, S32 y, MASK mask ) F32 delta_y = (F32)(gViewerWindow->getCurrentMouseDY()); // Set pan to value at start of drag + offset - sPanX += delta_x; - sPanY += delta_y; - sTargetPanX = sPanX; - sTargetPanY = sPanY; + mPanX += delta_x; + mPanY += delta_y; + mTargetPanX = mPanX; + mTargetPanY = mPanY; gViewerWindow->moveCursorToCenter(); } diff --git a/indra/newview/llworldmapview.h b/indra/newview/llworldmapview.h index 9a549a443a..edbdded120 100644 --- a/indra/newview/llworldmapview.h +++ b/indra/newview/llworldmapview.h @@ -67,20 +67,21 @@ public: bool checkItemHit(S32 x, S32 y, LLItemInfo& item, LLUUID* id, bool track); void handleClick(S32 x, S32 y, MASK mask, S32* hit_type, LLUUID* id); - // Zoom, scale, and pan are shared across all instances! (i.e. Terrain and Objects maps are always registered) - // Scale and zoom are the same thing but with different units. - // Scale is for things defined in in-world coordinates. + // Scale, aka zoom, is shared across all instances! (i.e. Terrain and Objects maps are always registered) // Zoom is used for UI and will interpolate the map scale over multiple frames. + void zoom(F32 zoom); + void zoomWithPivot(F32 zoom, S32 x, S32 y); + F32 getZoom(); + // Scale is a linear scaling factor of in-world coordinates + F32 getScale(); + // setScaleSetting/getScaleSetting are for the default map setting on login + static void setScaleSetting(F32 scaleSetting); + static F32 getScaleSetting(); // Pan is in pixels relative to the center of the map. - static void zoom(F32 zoom); - static void zoomWithPivot(F32 zoom, S32 x, S32 y); - static F32 getZoom(); - static void setScale(F32 scale, bool snap = true); - static F32 getScale(); - static void translatePan( S32 delta_x, S32 delta_y ); - static void setPan( S32 x, S32 y, BOOL snap = TRUE ); + void translatePan( S32 delta_x, S32 delta_y ); + void setPan( S32 x, S32 y, BOOL snap = TRUE ); // Return true if the current scale level is above the threshold for accessing region info - static bool showRegionInfo(); + bool showRegionInfo(); LLVector3 globalPosToView(const LLVector3d& global_pos); LLVector3d viewPosToGlobal(S32 x,S32 y); @@ -163,10 +164,10 @@ public: BOOL mItemPicked; - static F32 sPanX; // in pixels - static F32 sPanY; // in pixels - static F32 sTargetPanX; // in pixels - static F32 sTargetPanY; // in pixels + F32 mPanX; // in pixels + F32 mPanY; // in pixels + F32 mTargetPanX; // in pixels + F32 mTargetPanY; // in pixels static S32 sTrackingArrowX; static S32 sTrackingArrowY; static bool sVisibleTilesLoaded; @@ -201,16 +202,16 @@ public: private: void drawTileOutline(S32 level, F32 top, F32 left, F32 bottom, F32 right); + void setScale(F32 scale, bool snap = true); + static F32 scaleFromZoom(F32 zoom); static F32 zoomFromScale(F32 scale); - static F32 sMapScale; - static F32 sTargetMapScale; + F32 mMapScale; + F32 mTargetMapScale; + static F32 sMapScaleSetting; static LLVector2 sZoomPivot; static LLFrameTimer sZoomTimer; - - static F32 sWidthForZoom; - static F32 sHeightForZoom; }; #endif -- cgit v1.2.3 From 9bca1aa8fb69c2163866dd7e5ce3b60fb62676b3 Mon Sep 17 00:00:00 2001 From: Cosmic Linden Date: Thu, 10 Mar 2022 16:52:29 -0800 Subject: SL-15232: Clang format --- indra/newview/llfloaterworldmap.cpp | 12 ++-- indra/newview/llworldmapview.cpp | 127 +++++++++++++++--------------------- 2 files changed, 59 insertions(+), 80 deletions(-) mode change 100644 => 100755 indra/newview/llfloaterworldmap.cpp mode change 100644 => 100755 indra/newview/llworldmapview.cpp diff --git a/indra/newview/llfloaterworldmap.cpp b/indra/newview/llfloaterworldmap.cpp old mode 100644 new mode 100755 index cf314c3e60..e54e042006 --- a/indra/newview/llfloaterworldmap.cpp +++ b/indra/newview/llfloaterworldmap.cpp @@ -407,14 +407,14 @@ BOOL LLFloaterWorldMap::handleScrollWheel(S32 x, S32 y, S32 clicks) S32 map_y = y - mMapView->getRect().mBottom; if (mMapView->pointInView(map_x, map_y)) { - F32 old_slider_zoom = (F32)getChild("zoom slider")->getValue().asReal(); - F32 slider_zoom = old_slider_zoom + ((F32)clicks * -0.3333f); + F32 old_slider_zoom = (F32) getChild("zoom slider")->getValue().asReal(); + F32 slider_zoom = old_slider_zoom + ((F32) clicks * -0.3333f); getChild("zoom slider")->setValue(LLSD(slider_zoom)); mMapView->zoomWithPivot(slider_zoom, map_x, map_y); return true; } } - + return LLFloater::handleScrollWheel(x, y, clicks); } @@ -1267,8 +1267,8 @@ void LLFloaterWorldMap::onShowTargetBtn() void LLFloaterWorldMap::onShowAgentBtn() { - mMapView->setPan(0, 0, false); // false == animate - // Set flag so user's location will be displayed if not tracking anything else + mMapView->setPan(0, 0, false); // false == animate + // Set flag so user's location will be displayed if not tracking anything else mSetToUserPosition = true; } @@ -1622,6 +1622,6 @@ void LLFloaterWorldMap::onChangeMaturity() void LLFloaterWorldMap::onFocusLost() { - gViewerWindow->showCursor(); + gViewerWindow->showCursor(); mMapView->mPanning = false; } diff --git a/indra/newview/llworldmapview.cpp b/indra/newview/llworldmapview.cpp old mode 100644 new mode 100755 index cad655ea48..57292f98a0 --- a/indra/newview/llworldmapview.cpp +++ b/indra/newview/llworldmapview.cpp @@ -170,26 +170,26 @@ void LLWorldMapView::cleanupClass() sForSaleAdultImage = NULL; } -LLWorldMapView::LLWorldMapView() -: LLPanel(), - mBackgroundColor( LLColor4( OCEAN_RED, OCEAN_GREEN, OCEAN_BLUE, 1.f ) ), - mItemPicked(FALSE), +LLWorldMapView::LLWorldMapView() : + LLPanel(), + mBackgroundColor(LLColor4(OCEAN_RED, OCEAN_GREEN, OCEAN_BLUE, 1.f)), + mItemPicked(FALSE), mPanX(0.f), mPanY(0.f), mTargetPanX(0.f), mTargetPanY(0.f), - mPanning( FALSE ), - mMouseDownPanX( 0 ), - mMouseDownPanY( 0 ), - mMouseDownX( 0 ), - mMouseDownY( 0 ), + mPanning(FALSE), + mMouseDownPanX(0), + mMouseDownPanY(0), + mMouseDownX(0), + mMouseDownY(0), mSelectIDStart(0), mMapScale(0.f), mTargetMapScale(0.f) { - //LL_INFOS("WorldMap") << "Creating the Map -> LLWorldMapView::LLWorldMapView()" << LL_ENDL; + // LL_INFOS("WorldMap") << "Creating the Map -> LLWorldMapView::LLWorldMapView()" << LL_ENDL; - clearLastClick(); + clearLastClick(); } BOOL LLWorldMapView::postBuild() @@ -253,104 +253,89 @@ void LLWorldMapView::zoom(F32 zoom) void LLWorldMapView::zoomWithPivot(F32 zoom, S32 x, S32 y) { mTargetMapScale = scaleFromZoom(zoom); - sZoomPivot = LLVector2(x, y); + sZoomPivot = LLVector2(x, y); if (!sZoomTimer.getStarted() && mMapScale != mTargetMapScale) { sZoomTimer.start(); } } -F32 LLWorldMapView::getZoom() -{ - return LLWorldMapView::zoomFromScale(mMapScale); -} +F32 LLWorldMapView::getZoom() { return LLWorldMapView::zoomFromScale(mMapScale); } -F32 LLWorldMapView::getScale() -{ - return mMapScale; -} +F32 LLWorldMapView::getScale() { return mMapScale; } // static -void LLWorldMapView::setScaleSetting(F32 scaleSetting) -{ - sMapScaleSetting = scaleSetting; -} +void LLWorldMapView::setScaleSetting(F32 scaleSetting) { sMapScaleSetting = scaleSetting; } // static -F32 LLWorldMapView::getScaleSetting() -{ - return sMapScaleSetting; -} +F32 LLWorldMapView::getScaleSetting() { return sMapScaleSetting; } void LLWorldMapView::setScale(F32 scale, bool snap) { - if (scale != mMapScale) - { - F32 old_scale = mMapScale; + if (scale != mMapScale) + { + F32 old_scale = mMapScale; - mMapScale = scale; + mMapScale = scale; // Set the scale used when saving the setting sMapScaleSetting = scale; - if (mMapScale <= 0.f) - { - mMapScale = 0.1f; - } + if (mMapScale <= 0.f) + { + mMapScale = 0.1f; + } + + F32 ratio = (scale / old_scale); + mPanX *= ratio; + mPanY *= ratio; + mTargetPanX = mPanX; + mTargetPanY = mPanY; + sVisibleTilesLoaded = false; - F32 ratio = (scale / old_scale); - mPanX *= ratio; - mPanY *= ratio; - mTargetPanX = mPanX; - mTargetPanY = mPanY; - sVisibleTilesLoaded = false; - // If we are zooming relative to somewhere else rather than the center of the map, compensate for the difference in panning here if (!sZoomPivot.isExactlyZero()) { LLVector2 relative_pivot; - relative_pivot.mV[VX] = sZoomPivot.mV[VX] - (getRect().getWidth() / 2.0); - relative_pivot.mV[VY] = sZoomPivot.mV[VY] - (getRect().getHeight() / 2.0); + relative_pivot.mV[VX] = sZoomPivot.mV[VX] - (getRect().getWidth() / 2.0); + relative_pivot.mV[VY] = sZoomPivot.mV[VY] - (getRect().getHeight() / 2.0); LLVector2 zoom_pan_offset = relative_pivot - (relative_pivot * scale / old_scale); mPanX += zoom_pan_offset.mV[VX]; mPanY += zoom_pan_offset.mV[VY]; mTargetPanX += zoom_pan_offset.mV[VX]; mTargetPanY += zoom_pan_offset.mV[VY]; } - } + } if (snap) { mTargetMapScale = scale; -} + } } // static -void LLWorldMapView::translatePan( S32 delta_x, S32 delta_y ) +void LLWorldMapView::translatePan(S32 delta_x, S32 delta_y) { - mPanX += delta_x; - mPanY += delta_y; - mTargetPanX = mPanX; - mTargetPanY = mPanY; - sVisibleTilesLoaded = false; + mPanX += delta_x; + mPanY += delta_y; + mTargetPanX = mPanX; + mTargetPanY = mPanY; + sVisibleTilesLoaded = false; } // static -void LLWorldMapView::setPan( S32 x, S32 y, BOOL snap ) +void LLWorldMapView::setPan(S32 x, S32 y, BOOL snap) { - mTargetPanX = (F32)x; - mTargetPanY = (F32)y; - if (snap) - { - mPanX = mTargetPanX; - mPanY = mTargetPanY; - } - sVisibleTilesLoaded = false; + mTargetPanX = (F32) x; + mTargetPanY = (F32) y; + if (snap) + { + mPanX = mTargetPanX; + mPanY = mTargetPanY; + } + sVisibleTilesLoaded = false; } -bool LLWorldMapView::showRegionInfo() -{ - return (LLWorldMipmap::scaleToLevel(mMapScale) <= DRAW_SIMINFO_THRESHOLD ? true : false); -} +bool LLWorldMapView::showRegionInfo() { return (LLWorldMipmap::scaleToLevel(mMapScale) <= DRAW_SIMINFO_THRESHOLD ? true : false); } /////////////////////////////////////////////////////////////////////////////////// // HELPERS @@ -1884,13 +1869,7 @@ BOOL LLWorldMapView::handleDoubleClick( S32 x, S32 y, MASK mask ) } // static -F32 LLWorldMapView::scaleFromZoom(F32 zoom) -{ - return exp2(zoom) * 256.0f; -} +F32 LLWorldMapView::scaleFromZoom(F32 zoom) { return exp2(zoom) * 256.0f; } // static -F32 LLWorldMapView::zoomFromScale(F32 scale) -{ - return log2(scale / 256.f); -} +F32 LLWorldMapView::zoomFromScale(F32 scale) { return log2(scale / 256.f); } -- cgit v1.2.3