Skip to content

Commit

Permalink
Automap|Fixed: Manual panning
Browse files Browse the repository at this point in the history
The camera origin animation was incorrectly being applied
when the camera was being panned manually. Instead, manual
panning should just be instantly applied to the camera position.
Fixed panning speed to be resolution independent (approx.
140 VGA pixels per second).
  • Loading branch information
skyjake committed Feb 15, 2012
1 parent f6e8870 commit 5857faa
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 14 deletions.
6 changes: 4 additions & 2 deletions doomsday/plugins/common/include/hu_automap.h
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,10 @@ void UIAutomap_SetWorldBounds(uiwidget_t* obj, float lowX, float hiX, float lowY
void UIAutomap_SetMinScale(uiwidget_t* obj, const float scale);

void UIAutomap_CameraOrigin(uiwidget_t* obj, float* x, float* y);
boolean UIAutomap_SetCameraOrigin(uiwidget_t* obj, float x, float y);
boolean UIAutomap_TranslateCameraOrigin(uiwidget_t* obj, float x, float y);
boolean UIAutomap_SetCameraOrigin(uiwidget_t* obj, float x, float y /*, boolean forceInstantly=false*/);
boolean UIAutomap_SetCameraOrigin2(uiwidget_t* obj, float x, float y, boolean forceInstantly);
boolean UIAutomap_TranslateCameraOrigin(uiwidget_t* obj, float x, float y /*, boolean forceInstantly=false*/);
boolean UIAutomap_TranslateCameraOrigin2(uiwidget_t* obj, float x, float y, boolean forceInstantly);

/**
* @param max Maximum view position delta in world units.
Expand Down
37 changes: 25 additions & 12 deletions doomsday/plugins/common/src/hu_automap.c
Original file line number Diff line number Diff line change
Expand Up @@ -1659,23 +1659,26 @@ void UIAutomap_Ticker(uiwidget_t* obj, timespan_t ticLength)
UIAutomap_SetScale(obj, am->viewScale / zoomSpeed);
}

// Map camera paning control.
// Map camera panning control.
if(am->pan || NULL == mo)
{
float panUnitsPerTic, xy[2] = { 0, 0 }; // deltas
float panUnitsPerSecond, xy[2] = { 0, 0 }; // deltas

// DOOM.EXE pans the automap at 140 fixed pixels per second.
panUnitsPerTic = (UIAutomap_FrameToMap(obj, 140) / TICSPERSEC) * (2 * cfg.automapPanSpeed) * TICRATE;
if(panUnitsPerTic < 8)
panUnitsPerTic = 8;
// DOOM.EXE pans the automap at 140 fixed pixels per second (VGA: 200 pixels tall).
/// @todo This needs resolution-independent units. (The "frame" units are screen pixels.)
panUnitsPerSecond = UIAutomap_FrameToMap(obj, 140 * Rect_Height(UIWidget_Geometry(obj))/200.f) * (2 * cfg.automapPanSpeed);
if(panUnitsPerSecond < 8)
panUnitsPerSecond = 8;

xy[VX] = panX[0] * panUnitsPerTic * ticLength + panX[1];
xy[VY] = panY[0] * panUnitsPerTic * ticLength + panY[1];
/// @todo Fix sensitivity for relative axes.

xy[VX] = panX[0] * panUnitsPerSecond * ticLength + panX[1];
xy[VY] = panY[0] * panUnitsPerSecond * ticLength + panY[1];
V2_Rotate(xy, am->angle / 360 * 2 * PI);

if(xy[VX] || xy[VY])
{
UIAutomap_TranslateCameraOrigin(obj, xy[VX], xy[VY]);
UIAutomap_TranslateCameraOrigin2(obj, xy[VX], xy[VY], true /*instant change*/);
}
}
else
Expand Down Expand Up @@ -1897,16 +1900,21 @@ void UIAutomap_CameraOrigin(uiwidget_t* obj, float* x, float* y)
}

boolean UIAutomap_SetCameraOrigin(uiwidget_t* obj, float x, float y)
{
return UIAutomap_SetCameraOrigin2(obj, x, y, false);
}

boolean UIAutomap_SetCameraOrigin2(uiwidget_t* obj, float x, float y, boolean forceInstantly)
{
guidata_automap_t* am = (guidata_automap_t*)obj->typedata;
boolean instantChange = false;
boolean instantChange = forceInstantly;
assert(obj->type == GUI_AUTOMAP);

// Already at this target?
if(x == am->targetViewX && y == am->targetViewY)
return false;

if(am->maxViewPositionDelta > 0)
if(!forceInstantly && am->maxViewPositionDelta > 0)
{
float dx, dy, dist;

Expand Down Expand Up @@ -1938,11 +1946,16 @@ boolean UIAutomap_SetCameraOrigin(uiwidget_t* obj, float x, float y)
}

boolean UIAutomap_TranslateCameraOrigin(uiwidget_t* obj, float x, float y)
{
return UIAutomap_TranslateCameraOrigin2(obj, x, y, false);
}

boolean UIAutomap_TranslateCameraOrigin2(uiwidget_t* obj, float x, float y, boolean forceInstantly)
{
guidata_automap_t* am = (guidata_automap_t*)obj->typedata;
assert(obj->type == GUI_AUTOMAP);

return UIAutomap_SetCameraOrigin(obj, am->viewX + x, am->viewY + y);
return UIAutomap_SetCameraOrigin2(obj, am->viewX + x, am->viewY + y, forceInstantly);
}

void UIAutomap_ParallaxLayerOrigin(uiwidget_t* obj, float* x, float* y)
Expand Down

0 comments on commit 5857faa

Please sign in to comment.