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/llworldmapview.cpp | 105 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 101 insertions(+), 4 deletions(-) (limited to 'indra/newview/llworldmapview.cpp') 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); +} -- 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/llworldmapview.cpp | 198 ++++++++++++++++++++------------------- 1 file changed, 101 insertions(+), 97 deletions(-) (limited to 'indra/newview/llworldmapview.cpp') 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(); } -- 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/llworldmapview.cpp | 127 ++++++++++++++++----------------------- 1 file changed, 53 insertions(+), 74 deletions(-) mode change 100644 => 100755 indra/newview/llworldmapview.cpp (limited to 'indra/newview/llworldmapview.cpp') 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 From 38cc06e43a92a10d73ab149944b3cff19b8da8ad Mon Sep 17 00:00:00 2001 From: Mnikolenko Productengine Date: Mon, 18 Jul 2022 16:53:43 +0300 Subject: SL-17785 FIXED World Map scrolls too slowly when searching for a region. --- indra/newview/llworldmapview.cpp | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'indra/newview/llworldmapview.cpp') diff --git a/indra/newview/llworldmapview.cpp b/indra/newview/llworldmapview.cpp index 2ac4b30d2e..6e994b4e68 100755 --- a/indra/newview/llworldmapview.cpp +++ b/indra/newview/llworldmapview.cpp @@ -185,7 +185,8 @@ LLWorldMapView::LLWorldMapView() : mMouseDownY(0), mSelectIDStart(0), mMapScale(0.f), - mTargetMapScale(0.f) + mTargetMapScale(0.f), + mMapIterpTime(MAP_ITERP_TIME_CONSTANT) { // LL_INFOS("WorldMap") << "Creating the Map -> LLWorldMapView::LLWorldMapView()" << LL_ENDL; @@ -283,7 +284,7 @@ void LLWorldMapView::setScale(F32 scale, bool snap) { mMapScale = 0.1f; } - + mMapIterpTime = MAP_ITERP_TIME_CONSTANT; F32 ratio = (scale / old_scale); mPanX *= ratio; mPanY *= ratio; @@ -325,6 +326,7 @@ void LLWorldMapView::translatePan(S32 delta_x, S32 delta_y) // static void LLWorldMapView::setPan(S32 x, S32 y, BOOL snap) { + mMapIterpTime = MAP_ITERP_TIME_CONSTANT; mTargetPanX = (F32) x; mTargetPanY = (F32) y; if (snap) @@ -335,6 +337,13 @@ void LLWorldMapView::setPan(S32 x, S32 y, BOOL snap) sVisibleTilesLoaded = false; } +// static +void LLWorldMapView::setPanWithInterpTime(S32 x, S32 y, BOOL snap, F32 interp_time) +{ + setPan(x, y, snap); + mMapIterpTime = interp_time; +} + bool LLWorldMapView::showRegionInfo() { return (LLWorldMipmap::scaleToLevel(mMapScale) <= DRAW_SIMINFO_THRESHOLD ? true : false); } /////////////////////////////////////////////////////////////////////////////////// @@ -357,9 +366,9 @@ void LLWorldMapView::draw() mVisibleRegions.clear(); - // animate pan if necessary - mPanX = lerp(mPanX, mTargetPanX, LLSmoothInterpolation::getInterpolant(MAP_ITERP_TIME_CONSTANT)); - mPanY = lerp(mPanY, mTargetPanY, LLSmoothInterpolation::getInterpolant(MAP_ITERP_TIME_CONSTANT)); + // animate pan if necessary + mPanX = lerp(mPanX, mTargetPanX, LLSmoothInterpolation::getInterpolant(mMapIterpTime)); + mPanY = lerp(mPanY, mTargetPanY, LLSmoothInterpolation::getInterpolant(mMapIterpTime)); //RN: snaps to zoom value because interpolation caused jitter in the text rendering if (!sZoomTimer.getStarted() && mMapScale != mTargetMapScale) -- cgit v1.2.3