First cut of pulling the TT_SIDE bit out of the tile database

and forcing it to be passed as an argument to all the callback
functions for the search routines that require it.  Magic now
compiles and runs with the new code, but there are a number of
known issues that need to be fixed up.  Committing now so that
I can rebase on the last update to the master branch.
This commit is contained in:
R. Timothy Edwards
2026-01-09 12:05:03 -05:00
parent d24d52e403
commit 516c9d7635
106 changed files with 1463 additions and 875 deletions
+2 -1
View File
@@ -362,8 +362,9 @@ plotGremlinRect(rect, lineStyle)
*/
int
plotGremlinPaint(tile, cxp)
plotGremlinPaint(tile, dinfo, cxp)
Tile *tile; /* Tile that's of type to be output. */
TileType dinfo; /* Split tile information (unused) */
TreeContext *cxp; /* Describes search in progress. */
{
Rect tileArea, edge, rootArea;
+10 -8
View File
@@ -311,8 +311,9 @@ pnmRenderRegion(scale, scale_over_2, normal, temp, func, arg)
*/
int
pnmBBOX (tile,cxp)
pnmBBOX (tile, dinfo, cxp)
Tile *tile;
TileType dinfo;
TreeContext *cxp;
{
Rect targetRect, sourceRect;
@@ -368,8 +369,9 @@ pnmBBOX (tile,cxp)
*/
int
pnmTile (tile, cxp)
pnmTile (tile, dinfo, cxp)
Tile *tile;
TileType dinfo;
TreeContext *cxp;
{
SearchContext *scx = cxp->tc_scx;
@@ -397,11 +399,11 @@ pnmTile (tile, cxp)
/* Handle non-Manhattan geometry */
if (IsSplit(tile))
{
TileType dinfo;
TileType newdinfo;
int w, h, llx, lly, urx, ury;
Rect scaledClip;
type = (SplitSide(tile)) ? SplitRightType(tile) : SplitLeftType(tile);
type = (dinfo & TT_SIDE) ? SplitRightType(tile) : SplitLeftType(tile);
if (type == TT_SPACE) return 0;
else if (PaintStyles[type].wmask == 0) return 0;
@@ -430,15 +432,15 @@ pnmTile (tile, cxp)
/* The following structures could be much better */
/* written for considerable speedup. . . */
dinfo = DBTransformDiagonal(TiGetTypeExact(tile), &scx->scx_trans);
if (((dinfo & TT_SIDE) >> 1) != (dinfo & TT_DIRECTION))
newdinfo = DBTransformDiagonal(TiGetTypeExact(tile) | dinfo, &scx->scx_trans);
if (((newdinfo & TT_SIDE) >> 1) != (newdinfo & TT_DIRECTION))
{
/* work top to bottom */
for (y = ury - 1; y >= lly; y--)
{
if (y >= scaledClip.r_ytop) continue;
else if (y < scaledClip.r_ybot) break;
if (dinfo & TT_SIDE) /* work right to left */
if (newdinfo & TT_SIDE) /* work right to left */
{
for (x = urx - 1; x >= llx; x--)
{
@@ -468,7 +470,7 @@ pnmTile (tile, cxp)
{
if (y < scaledClip.r_ybot) continue;
else if (y >= scaledClip.r_ytop) break;
if (dinfo & TT_SIDE) /* work right to left */
if (newdinfo & TT_SIDE) /* work right to left */
{
for (x = urx; x >= llx; x--)
{
+9 -8
View File
@@ -513,8 +513,9 @@ plotPSRect(rect, style)
*/
int
plotPSPaint(tile, cxp)
plotPSPaint(tile, dinfo, cxp)
Tile *tile; /* Tile that's of type to be output. */
TileType dinfo; /* Split tile information */
TreeContext *cxp; /* Describes search in progress. */
{
Rect tileArea, edge, rootArea;
@@ -554,7 +555,7 @@ plotPSPaint(tile, cxp)
if (IsSplit(tile))
{
int np, i, j;
TileType dinfo;
TileType newdinfo;
Point polyp[5];
plotPSFlushRect(curStyle->grs_stipple);
@@ -563,12 +564,12 @@ plotPSPaint(tile, cxp)
/* Side and direction are altered by geometric transformations */
dinfo = DBTransformDiagonal(TiGetTypeExact(tile), &scx->scx_trans);
newdinfo = DBTransformDiagonal(TiGetTypeExact(tile) | dinfo, &scx->scx_trans);
/* Use GrClipTriangle() routine to get the n-sided polygon that */
/* results from clipping a triangle to the clip region. */
GrClipTriangle(&rootArea, &bbox, TRUE, dinfo, polyp, &np);
GrClipTriangle(&rootArea, &bbox, TRUE, newdinfo, polyp, &np);
for (i = 0; i < np; i++)
{
polyp[i].p_x -= bbox.r_xbot;
@@ -651,7 +652,7 @@ plotPSPaint(tile, cxp)
* (This code is essentially a duplicate of selRedisplayFunc())
*/
if (IsSplit(tile) && (!(SplitSide(tile) ^ SplitDirection(tile))))
if (IsSplit(tile) && (!((dinfo & TT_SIDE) ? 1 : 0) ^ SplitDirection(tile)))
goto searchleft; /* nothing on bottom of split */
if (tileArea.r_ybot > TiPlaneRect.r_ybot)
@@ -676,7 +677,7 @@ plotPSPaint(tile, cxp)
*/
searchleft:
if (IsSplit(tile) && SplitSide(tile))
if (IsSplit(tile) && (dinfo & TT_SIDE))
goto searchtop; /* Nothing on left side of tile */
if (tileArea.r_xbot > TiPlaneRect.r_xbot)
@@ -699,7 +700,7 @@ searchleft:
/* Same thing for the tile's top border. */
searchtop:
if (IsSplit(tile) && (SplitSide(tile) ^ SplitDirection(tile)))
if (IsSplit(tile) && (((dinfo & TT_SIDE) ? 1 : 0) ^ SplitDirection(tile)))
goto searchright; /* Nothing on top side of tile */
if (tileArea.r_ytop < TiPlaneRect.r_ytop)
@@ -722,7 +723,7 @@ searchtop:
/* Finally, the right border. */
searchright:
if (IsSplit(tile) && !SplitSide(tile))
if (IsSplit(tile) && !(dinfo & TT_SIDE))
return 0; /* Nothing on right side of tile */
if (tileArea.r_xtop < TiPlaneRect.r_xtop)
+3 -2
View File
@@ -525,8 +525,9 @@ plotPixRect(area, widen, style)
*/
int
plotPixTile(tile, cxp)
Tile *tile; /* Tile that's of type to be output. */
plotPixTile(tile, dinfo, cxp)
Tile *tile; /* Tile that's of type to be output. */
TileType dinfo; /* Split tile information (unhandled) */
TreeContext *cxp; /* Describes search in progress. */
{
Rect tileArea, rootArea, swathArea;
+12 -10
View File
@@ -664,8 +664,9 @@ plotVersRect(area, widen, raster)
*/
int
plotVersTile(tile, cxp)
Tile *tile; /* Tile that's of type to be output. */
plotVersTile(tile, dinfo, cxp)
Tile *tile; /* Tile that's of type to be output. */
TileType dinfo; /* Split tile information */
TreeContext *cxp; /* Describes search in progress. */
{
Rect tileArea, rootArea, swathArea, edge;
@@ -701,18 +702,19 @@ plotVersTile(tile, cxp)
if (IsSplit(tile))
{
int i, j;
TileType dinfo;
TileType newdinfo;
Rect r;
dinfo = DBTransformDiagonal(TiGetTypeExact(tile), &cxp->tc_scx->scx_trans);
newdinfo = DBTransformDiagonal(TiGetTypeExact(tile) | dinfo,
&cxp->tc_scx->scx_trans);
if (!(curStyle->vs_flags & VS_BORDER) && !(curStyle->vs_flags & VS_CROSS))
PlotPolyRaster(raster, &swathArea, &swathClip, dinfo,
PlotPolyRaster(raster, &swathArea, &swathClip, newdinfo,
curStyle->vs_stipple);
/* Diagonal is always drawn (clipping handled in plotVersLine) */
r = rootArea;
if (dinfo & TT_DIRECTION)
if (newdinfo & TT_DIRECTION)
{
/* swap X to make diagonal go the other way */
r.r_xbot = r.r_xtop;
@@ -740,7 +742,7 @@ plotVersTile(tile, cxp)
* (unless it is at infinity).
*/
if (IsSplit(tile) && (!(SplitSide(tile) ^ SplitDirection(tile))))
if (IsSplit(tile) && (!((dinfo & TT_SIDE) ? 1 : 0) ^ SplitDirection(tile)))
goto searchleft; /* nothing on bottom of split */
if (tileArea.r_ybot > TiPlaneRect.r_ybot)
@@ -761,7 +763,7 @@ plotVersTile(tile, cxp)
}
searchleft:
if (IsSplit(tile) && (SplitSide(tile)))
if (IsSplit(tile) && (dinfo & TT_SIDE))
goto searchtop; /* Nothing on left side of split */
/* Now go along the tile's left border, doing the same thing. Ignore
@@ -788,7 +790,7 @@ searchleft:
/* Same thing for the tile's top border. */
searchtop:
if (IsSplit(tile) && (SplitSide(tile) ^ SplitDirection(tile)))
if (IsSplit(tile) && (((dinfo & TT_SIDE) ? 1 : 0) ^ SplitDirection(tile)))
goto searchright; /* Nothing on top side of tile */
if (tileArea.r_ytop < TiPlaneRect.r_ytop)
@@ -811,7 +813,7 @@ searchtop:
/* Finally, the right border. */
searchright:
if (IsSplit(tile) && !(SplitSide(tile)))
if (IsSplit(tile) && !(dinfo & TT_SIDE))
return 0; /* Nothing on right side of tile */
if (tileArea.r_xtop < TiPlaneRect.r_xtop)