automap panning interpolation from PrBoom+ (#659)

* automap panning and zooming interpolation from PrBoom+

* fix mousewheel zoom

* restore old M_ZOOMIN M_ZOOMOUT

* remove zoom interpolation
This commit is contained in:
Roman Fomin 2022-07-14 15:27:33 +07:00 committed by GitHub
parent b8b37b7817
commit c8390d535a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -264,6 +264,7 @@ static fixed_t ftom_zoommul; // how far the window zooms each tic (fb coords)
static int64_t m_x, m_y; // LL x,y window location on the map (map coords)
static int64_t m_x2, m_y2; // UR x,y window location on the map (map coords)
static int64_t prev_m_x, prev_m_y;
//
// width/height of window on map (map coords)
@ -292,9 +293,6 @@ static fixed_t max_scale_mtof; // used to tell when to stop zooming in
static int64_t old_m_w, old_m_h;
static int64_t old_m_x, old_m_y;
// old location used by the Follower routine
static mpoint_t f_oldloc;
// used by MTOF to scale from map-to-frame-buffer coords
static fixed_t scale_mtof = INITSCALEMTOF;
// used by FTOM to scale from frame-buffer-to-map coords (=1/scale_mtof)
@ -510,17 +508,25 @@ void AM_changeWindowLoc(void)
if (m_paninc.x || m_paninc.y)
{
followplayer = 0;
f_oldloc.x = D_MAXINT;
}
incx = m_paninc.x;
incy = m_paninc.y;
if (uncapped && leveltime > oldleveltime)
{
incx = FixedMul(m_paninc.x, fractionaltic);
incy = FixedMul(m_paninc.y, fractionaltic);
}
else
{
incx = m_paninc.x;
incy = m_paninc.y;
}
if (automaprotate)
{
AM_rotate(&incx, &incy, ANGLE_MAX - mapangle);
}
m_x += incx;
m_y += incy;
m_x = prev_m_x + incx;
m_y = prev_m_y + incy;
if (m_x + m_w/2 > max_x)
m_x = max_x - m_w/2;
@ -554,7 +560,6 @@ void AM_initVariables(void)
automapactive = true;
fb = screens[0];
f_oldloc.x = D_MAXINT;
amclock = 0;
lightlev = 0;
@ -575,6 +580,7 @@ void AM_initVariables(void)
plr = &players[pnum];
m_x = (plr->mo->x >> FRACTOMAPBITS) - m_w/2;
m_y = (plr->mo->y >> FRACTOMAPBITS) - m_h/2;
AM_Ticker(); // initialize variables for interpolation
AM_changeWindowLoc();
// for saving & restoring
@ -864,7 +870,6 @@ boolean AM_Responder
else if (M_InputActivated(input_map_follow))
{
followplayer = !followplayer;
f_oldloc.x = D_MAXINT;
// Ty 03/27/98 - externalized
plr->message = followplayer ? s_AMSTR_FOLLOWON : s_AMSTR_FOLLOWOFF;
}
@ -985,17 +990,10 @@ void AM_changeWindowScale(void)
//
void AM_doFollowPlayer(void)
{
if (f_oldloc.x != plr->mo->x || f_oldloc.y != plr->mo->y)
{
// [JN] Prevent player arrow from jittering
// by not using FTOM->MTOF conversion.
m_x = (plr->mo->x >> FRACTOMAPBITS) - m_w/2;
m_y = (plr->mo->y >> FRACTOMAPBITS) - m_h/2;
m_x2 = m_x + m_w;
m_y2 = m_y + m_h;
f_oldloc.x = plr->mo->x;
f_oldloc.y = plr->mo->y;
}
m_x = (viewx >> FRACTOMAPBITS) - m_w/2;
m_y = (viewy >> FRACTOMAPBITS) - m_h/2;
m_x2 = m_x + m_w;
m_y2 = m_y + m_h;
}
//
@ -1025,18 +1023,14 @@ void AM_Ticker (void)
amclock++;
if (followplayer)
AM_doFollowPlayer();
// Change the zoom if necessary
// Change the zoom if necessary.
if (ftom_zoommul != FRACUNIT)
AM_changeWindowScale();
// Change x,y location
if (m_paninc.x || m_paninc.y)
{
AM_changeWindowLoc();
AM_changeWindowScale();
}
prev_m_x = m_x;
prev_m_y = m_y;
}
@ -1780,8 +1774,8 @@ void AM_drawPlayers(void)
if (!netgame)
{
// [crispy] interpolate player arrow in non-follow mode
if (!followplayer && leveltime > oldleveltime)
// interpolate player arrow
if (uncapped && leveltime > oldleveltime)
{
pt.x = viewx >> FRACTOMAPBITS;
pt.y = viewy >> FRACTOMAPBITS;
@ -2082,6 +2076,20 @@ void AM_Drawer (void)
{
if (!automapactive) return;
// move AM_doFollowPlayer and AM_changeWindowLoc from AM_Ticker for
// interpolation
if (followplayer)
{
AM_doFollowPlayer();
}
// Change X and Y location.
if (m_paninc.x || m_paninc.y)
{
AM_changeWindowLoc();
}
// [crispy] required for AM_rotatePoint()
if (automaprotate)
{