@@ -1653,32 +1653,36 @@ void W3DView::setSnapMode( CameraLockType lockType, Real lockDist )
16531653}
16541654
16551655// -------------------------------------------------------------------------------------------------
1656- /* * Scroll the view by the given delta in SCREEN COORDINATES, this interface
1657- * assumes we will be scrolling along the X,Y plane */
1656+ // Scroll the view by the given delta in SCREEN COORDINATES, this interface
1657+ // assumes we will be scrolling along the X,Y plane
1658+ //
1659+ // TheSuperHackers @bugfix Now rotates the view plane on the Z axis only to properly discard the
1660+ // camera pitch. The aspect ratio also no longer modifies the vertical scroll speed.
16581661// -------------------------------------------------------------------------------------------------
16591662void W3DView::scrollBy ( Coord2D *delta )
16601663{
16611664 // if we haven't moved, ignore
16621665 if ( delta && (delta->x != 0 || delta->y != 0 ) )
16631666 {
1664- const Real SCROLL_RESOLUTION = 250 .0f ;
1667+ CONSTEXPR const Real SCROLL_RESOLUTION = 250 .0f ;
16651668
16661669 Vector3 world, worldStart, worldEnd;
1667- Vector2 screen, start, end;
1670+ Vector2 start, end;
16681671
16691672 m_scrollAmount = *delta;
16701673
1671- screen.X = delta->x ;
1672- screen.Y = delta->y ;
1673-
16741674 start.X = getWidth ();
16751675 start.Y = getHeight ();
1676- Real aspect = getHeight () == 0 ? 1 : getWidth ()/ getHeight ();
1676+
16771677 end.X = start.X + delta->x * SCROLL_RESOLUTION;
1678- end.Y = start.Y + delta->y * SCROLL_RESOLUTION*aspect;
1678+ end.Y = start.Y + delta->y * SCROLL_RESOLUTION;
1679+
1680+ m_3DCamera->Device_To_View_Space ( start, &worldStart );
1681+ m_3DCamera->Device_To_View_Space ( end, &worldEnd );
16791682
1680- m_3DCamera->Device_To_World_Space ( start, &worldStart );
1681- m_3DCamera->Device_To_World_Space ( end, &worldEnd );
1683+ const Real zRotation = m_3DCamera->Get_Transform ().Get_Z_Rotation ();
1684+ worldStart.Rotate_Z (zRotation);
1685+ worldEnd.Rotate_Z (zRotation);
16821686
16831687 world.X = worldEnd.X - worldStart.X ;
16841688 world.Y = worldEnd.Y - worldStart.Y ;
0 commit comments