Rounding error corrections in display lists; Also minor #ifdef OLD_ZOOM fixes to make it actually work
git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@1539 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
+29
-28
@@ -275,7 +275,7 @@ CalcReduction (SIZE dx, SIZE dy)
|
|||||||
#ifdef OLD_ZOOM
|
#ifdef OLD_ZOOM
|
||||||
static VIEW_STATE
|
static VIEW_STATE
|
||||||
CalcView (PPOINT pNewScrollPt, BYTE next_reduction,
|
CalcView (PPOINT pNewScrollPt, BYTE next_reduction,
|
||||||
PSIZE pdx, PSIZE pdy)
|
PSIZE pdx, PSIZE pdy, COUNT ships_alive)
|
||||||
#else
|
#else
|
||||||
static VIEW_STATE
|
static VIEW_STATE
|
||||||
CalcView (PPOINT pNewScrollPt, SIZE next_reduction,
|
CalcView (PPOINT pNewScrollPt, SIZE next_reduction,
|
||||||
@@ -808,6 +808,25 @@ InsertPrim (PRIM_LINKS *pLinks, COUNT primIndex, COUNT iPI)
|
|||||||
|
|
||||||
PRIM_LINKS DisplayLinks;
|
PRIM_LINKS DisplayLinks;
|
||||||
|
|
||||||
|
#ifdef OLD_ZOOM
|
||||||
|
/* old fixed-step zoom style */
|
||||||
|
static inline COORD
|
||||||
|
CalcDisplayCoord (COORD c, COORD orgc, BYTE reduction)
|
||||||
|
{
|
||||||
|
return (c - orgc) >> reduction;
|
||||||
|
}
|
||||||
|
|
||||||
|
#else /* OLD_ZOOM */
|
||||||
|
|
||||||
|
/* new continuous zoom style */
|
||||||
|
static inline COORD
|
||||||
|
CalcDisplayCoord (COORD c, COORD orgc, SIZE reduction)
|
||||||
|
{
|
||||||
|
/* correcting rounding error here */
|
||||||
|
return (((c - orgc) << ZOOM_SHIFT) + (reduction >> 1)) / reduction;
|
||||||
|
}
|
||||||
|
#endif /* OLD_ZOOM */
|
||||||
|
|
||||||
static void
|
static void
|
||||||
PostProcessQueue (VIEW_STATE view_state, SIZE scroll_x,
|
PostProcessQueue (VIEW_STATE view_state, SIZE scroll_x,
|
||||||
SIZE scroll_y)
|
SIZE scroll_y)
|
||||||
@@ -912,46 +931,26 @@ PostProcessQueue (VIEW_STATE view_state, SIZE scroll_x,
|
|||||||
|
|
||||||
next.x = WRAP_X (ElementPtr->current.location.x + delta.x);
|
next.x = WRAP_X (ElementPtr->current.location.x + delta.x);
|
||||||
next.y = WRAP_Y (ElementPtr->current.location.y + delta.y);
|
next.y = WRAP_Y (ElementPtr->current.location.y + delta.y);
|
||||||
#ifdef OLD_ZOOM
|
|
||||||
DisplayArray[ElementPtr->PrimIndex].Object.Line.first.x =
|
DisplayArray[ElementPtr->PrimIndex].Object.Line.first.x =
|
||||||
(next.x - SpaceOrg.x) >> reduction;
|
CalcDisplayCoord (next.x, SpaceOrg.x, reduction);
|
||||||
DisplayArray[ElementPtr->PrimIndex].Object.Line.first.y =
|
DisplayArray[ElementPtr->PrimIndex].Object.Line.first.y =
|
||||||
(next.y - SpaceOrg.y) >> reduction;
|
CalcDisplayCoord (next.y, SpaceOrg.y, reduction);
|
||||||
#else
|
|
||||||
DisplayArray[ElementPtr->PrimIndex].Object.Line.first.x =
|
|
||||||
((next.x - SpaceOrg.x) << ZOOM_SHIFT) / reduction;
|
|
||||||
DisplayArray[ElementPtr->PrimIndex].Object.Line.first.y =
|
|
||||||
((next.y - SpaceOrg.y) << ZOOM_SHIFT) / reduction;
|
|
||||||
#endif
|
|
||||||
next.x += dx;
|
next.x += dx;
|
||||||
next.y += dy;
|
next.y += dy;
|
||||||
#ifdef OLD_ZOOM
|
|
||||||
DisplayArray[ElementPtr->PrimIndex].Object.Line.second.x =
|
DisplayArray[ElementPtr->PrimIndex].Object.Line.second.x =
|
||||||
(next.x - SpaceOrg.x) >> reduction;
|
CalcDisplayCoord (next.x, SpaceOrg.x, reduction);
|
||||||
DisplayArray[ElementPtr->PrimIndex].Object.Line.second.y =
|
DisplayArray[ElementPtr->PrimIndex].Object.Line.second.y =
|
||||||
(next.y - SpaceOrg.y) >> reduction;
|
CalcDisplayCoord (next.y, SpaceOrg.y, reduction);
|
||||||
#else
|
|
||||||
DisplayArray[ElementPtr->PrimIndex].Object.Line.second.x =
|
|
||||||
((next.x - SpaceOrg.x) << ZOOM_SHIFT) / reduction;
|
|
||||||
DisplayArray[ElementPtr->PrimIndex].Object.Line.second.y =
|
|
||||||
((next.y - SpaceOrg.y) << ZOOM_SHIFT) / reduction;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
next.x = WRAP_X (ElementPtr->next.location.x + delta.x);
|
next.x = WRAP_X (ElementPtr->next.location.x + delta.x);
|
||||||
next.y = WRAP_Y (ElementPtr->next.location.y + delta.y);
|
next.y = WRAP_Y (ElementPtr->next.location.y + delta.y);
|
||||||
#ifdef OLD_ZOOM
|
|
||||||
DisplayArray[ElementPtr->PrimIndex].Object.Point.x =
|
DisplayArray[ElementPtr->PrimIndex].Object.Point.x =
|
||||||
(next.x - SpaceOrg.x) >> reduction;
|
CalcDisplayCoord (next.x, SpaceOrg.x, reduction);
|
||||||
DisplayArray[ElementPtr->PrimIndex].Object.Point.y =
|
DisplayArray[ElementPtr->PrimIndex].Object.Point.y =
|
||||||
(next.y - SpaceOrg.y) >> reduction;
|
CalcDisplayCoord (next.y, SpaceOrg.y, reduction);
|
||||||
#else
|
|
||||||
DisplayArray[ElementPtr->PrimIndex].Object.Point.x =
|
|
||||||
((next.x - SpaceOrg.x) << ZOOM_SHIFT) / reduction;
|
|
||||||
DisplayArray[ElementPtr->PrimIndex].Object.Point.y =
|
|
||||||
((next.y - SpaceOrg.y) << ZOOM_SHIFT) / reduction;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (ObjType == STAMP_PRIM
|
if (ObjType == STAMP_PRIM
|
||||||
|| ObjType == STAMPFILL_PRIM)
|
|| ObjType == STAMPFILL_PRIM)
|
||||||
@@ -1085,12 +1084,14 @@ RedrawQueue (BOOLEAN clear)
|
|||||||
nth_frame += skip_frames;
|
nth_frame += skip_frames;
|
||||||
if (clear)
|
if (clear)
|
||||||
ClearDrawable (); // this is for BATCH_BUILD_PAGE effect, but not scaled by SetGraphicScale
|
ClearDrawable (); // this is for BATCH_BUILD_PAGE effect, but not scaled by SetGraphicScale
|
||||||
|
#ifndef OLD_ZOOM
|
||||||
{
|
{
|
||||||
COUNT index, scale;
|
COUNT index, scale;
|
||||||
|
|
||||||
CALC_ZOOM_STUFF (&index, &scale);
|
CALC_ZOOM_STUFF (&index, &scale);
|
||||||
SetGraphicScale (scale);
|
SetGraphicScale (scale);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
DrawBatch (DisplayArray, DisplayLinks, 0);//BATCH_BUILD_PAGE);
|
DrawBatch (DisplayArray, DisplayLinks, 0);//BATCH_BUILD_PAGE);
|
||||||
SetGraphicScale (0);
|
SetGraphicScale (0);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user