Skip to content

Commit

Permalink
[MZ] Some polygon filling optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
TheFakeMontyOnTheRun committed May 20, 2024
1 parent 2e999a1 commit e9f1a94
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions mz_frontend/Engine3D/Engine3D.c
Original file line number Diff line number Diff line change
Expand Up @@ -358,12 +358,6 @@ void drawSquare(int16_t x0, int16_t y0, int16_t z0, int16_t dX, int16_t dY, uint
/* Draw the horizontal outlines of z0 and z1 */
/* Ceiling is lower than camera */
if (drawContour) {
for (x = px0z0; x <= px1z0; ++x) {
if (IN_RANGE(0, XRESMINUSONE, x)) {
vLine(x, py0z0, py1z0, shouldStippleFill);
}
}

if (elementMask & 2) {
if ((elementMask != 255) && IN_RANGE(0, XRESMINUSONE, px0z0)) {
vLine(px0z0, py0z0, py1z0, shouldStippleBorder);
Expand All @@ -373,6 +367,18 @@ void drawSquare(int16_t x0, int16_t y0, int16_t z0, int16_t dX, int16_t dY, uint
vLine(px1z0, py0z0, py1z0, shouldStippleBorder);
}
}

for (x = px0z0; x < px1z0; ++x) {
if ( x < 0 ) {
continue;
}

if (x >= XRES ) {
return;
}

vLine(x, py0z0, py1z0, shouldStippleFill);
}
}
}

Expand Down Expand Up @@ -747,6 +753,10 @@ void drawFloorAt(int16_t x0, int16_t y0, int16_t z0, int16_t dX, int16_t dZ) {
return;
}

if (rightX1 < 0) {
return;
}

if (IN_RANGE(0, XRESMINUSONE, leftX0) || IN_RANGE(0, XRESMINUSONE, rightX0)) {
hLine(leftX0, rightX0, currentY0, shouldStipple);
}
Expand Down

0 comments on commit e9f1a94

Please sign in to comment.