Skip to content

Commit

Permalink
Automap border size is now fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
danij-deng committed Jan 28, 2012
1 parent 90dddc3 commit f2291f0
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 27 deletions.
11 changes: 7 additions & 4 deletions doomsday/plugins/common/include/hu_automap.h
Expand Up @@ -44,13 +44,19 @@ extern boolean freezeMapRLs;
* of the current map with navigational interface.
*/

// Automap flags:
#define UIAUTOMAP_BORDER 4 ///< In fixed 320x200 pixels.

/**
* @defgroup uiautomapFlags UIAutomap Flags
*/
///@{
#define AMF_REND_THINGS 0x01
#define AMF_REND_KEYS 0x02
#define AMF_REND_ALLLINES 0x04
#define AMF_REND_SPECIALLINES 0x08
#define AMF_REND_VERTEXES 0x10
#define AMF_REND_LINE_NORMALS 0x20
///@}

// Mapped point of interest.
typedef struct {
Expand Down Expand Up @@ -91,9 +97,6 @@ typedef struct {
float alpha, targetAlpha, oldAlpha;
float alphaTimer;

// Automap window border (in screen space):
float border;

// Viewer location on the map:
float viewTimer;
float viewX, viewY; // Current.
Expand Down
46 changes: 23 additions & 23 deletions doomsday/plugins/common/src/hu_automap.c
Expand Up @@ -1284,14 +1284,14 @@ static void setupGLStateForMap(uiwidget_t* obj)
// Setup the scissor clipper.
/// @todo Do this in the UI module.
{
const int border = .5f + UIAUTOMAP_BORDER * aspectScale;
RectRaw clipRegion;
Size2Raw portSize;

R_ViewPortSize(obj->player, &portSize);
clipRegion.origin.x = .5f + FIXXTOSCREENX(geometry.origin.x + am->border);
clipRegion.origin.y = .5f + FIXYTOSCREENY(geometry.origin.y + am->border);
clipRegion.size.width = .5f + FIXXTOSCREENX(geometry.size.width - am->border*2);
clipRegion.size.height = .5f + FIXYTOSCREENY(geometry.size.height - am->border*2);
Rect_Raw(UIWidget_Geometry(obj), &clipRegion);
clipRegion.origin.x += border;
clipRegion.origin.y += border;
clipRegion.size.width -= 2 * border;
clipRegion.size.height -= 2 * border;

DGL_SetScissor(&clipRegion);
DGL_Enable(DGL_SCISSOR_TEST);
Expand Down Expand Up @@ -1447,6 +1447,8 @@ DGL_End();

if(amMaskTexture)
{
const int border = .5f + UIAUTOMAP_BORDER * aspectScale;

DGL_Bind(amMaskTexture);
DGL_Enable(DGL_TEXTURE_2D);

Expand All @@ -1456,10 +1458,10 @@ DGL_End();
DGL_LoadIdentity();

DGL_PushMatrix();
DGL_Scalef(1.f / (geometry.size.width - am->border*2),
1.f / (geometry.size.height - am->border*2), 1);
DGL_Translatef(geometry.size.width /2 - am->border,
geometry.size.height /2 - am->border, 0);
DGL_Scalef(1.f / (geometry.size.width - border*2),
1.f / (geometry.size.height - border*2), 1);
DGL_Translatef(geometry.size.width /2 - border,
geometry.size.height /2 - border, 0);
DGL_Rotatef(-angle, 0, 0, 1);
DGL_Scalef(am->scaleMTOF, am->scaleMTOF, 1);
DGL_Translatef(-vx, -vy, 0);
Expand Down Expand Up @@ -1738,36 +1740,34 @@ void UIAutomap_Ticker(uiwidget_t* obj, timespan_t ticLength)
am->scaleMTOF = scale;
am->scaleFTOM = 1.0f / am->scaleMTOF;

// Calculate border (viewport coordinate space).
am->border = 4;

/**
* Calculate the am coordinates of the rotated view window.
* Calculate the coordinates of the rotated view window.
*/
// Determine fixed to screen space scaling factors.
{
float viewPoint[2], rads, viewWidth, viewHeight;
const int border = .5f + UIAUTOMAP_BORDER * aspectScale;

// Determine the dimensions of the view window in am coordinates.
viewWidth = UIAutomap_FrameToMap(obj, Rect_Width(obj->geometry) - (am->border*2));
viewHeight = UIAutomap_FrameToMap(obj, Rect_Height(obj->geometry) - (am->border*2));
viewWidth = UIAutomap_FrameToMap(obj, Rect_Width(obj->geometry) - border*2);
viewHeight = UIAutomap_FrameToMap(obj, Rect_Height(obj->geometry) - border*2);
am->topLeft[0] = am->bottomLeft[0] = -viewWidth/2;
am->topLeft[1] = am->topRight[1] = viewHeight/2;
am->bottomRight[0] = am->topRight[0] = viewWidth/2;
am->bottomRight[1] = am->bottomLeft[1] = -viewHeight/2;

// Apply am rotation.
// Apply rotation.
rads = (float)(am->angle / 360 * 2 * PI);
V2_Rotate(am->topLeft, rads);
V2_Rotate(am->bottomRight, rads);
V2_Rotate(am->bottomLeft, rads);
V2_Rotate(am->topRight, rads);

// Translate to the viewpoint.
// Translate to the view point.
UIAutomap_CameraOrigin(obj, &viewPoint[0], &viewPoint[1]);
am->topLeft[0] += viewPoint[0]; am->topLeft[1] += viewPoint[1];
am->bottomRight[0] += viewPoint[0]; am->bottomRight[1] += viewPoint[1];
am->bottomLeft[0] += viewPoint[0]; am->bottomLeft[1] += viewPoint[1];
am->topRight[0] += viewPoint[0]; am->topRight[1] += viewPoint[1];
V2_Sum(am->topLeft, am->topLeft, viewPoint);
V2_Sum(am->bottomRight, am->bottomRight, viewPoint);
V2_Sum(am->bottomLeft, am->bottomLeft, viewPoint);
V2_Sum(am->topRight, am->topRight, viewPoint);
}

width = UIAutomap_FrameToMap(obj, Rect_Width(obj->geometry));
Expand Down

0 comments on commit f2291f0

Please sign in to comment.