From b77fbb38b2b16d563bdf658b923cefd8aa67ee24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miloslav=20=C4=8C=C3=AD=C5=BE?= Date: Sat, 4 May 2019 00:24:05 +0200 Subject: [PATCH] Remove discontinity conditions --- s3l.h | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/s3l.h b/s3l.h index 7b95579..cd8628d 100644 --- a/s3l.h +++ b/s3l.h @@ -813,10 +813,6 @@ void S3L_drawTriangle( initSide(r,t,r,1) initSide(l,t,l,1) - S3L_Unit xFrom_prev = tPointX; // helper vars, hold previous values of xFrom - S3L_Unit xTo_prev = tPointX; // and xTo (declared later) to prevent - // discontinuities - while (currentY <= endY) // draw the triangle from top to bottom { if (currentY == splitY) // reached a vertical split of the triangle? @@ -849,18 +845,13 @@ void S3L_drawTriangle( // draw the horizontal line - S3L_Unit xFrom = lX < (xTo_prev + 1) ? lX : (xTo_prev + 1); - S3L_Unit xTo = rX > (xFrom_prev - 1) ? rX : (xFrom_prev - 1); - /* ^ these conditions prevent discontinuities when drawing - "long" triangles (thinner than 1 px) */ - - S3L_Unit tMax = xTo - xFrom; + S3L_Unit tMax = rX - lX; tMax = S3L_NONZERO(tMax); // prevent division by zero S3L_Unit t1 = 0; S3L_Unit t2 = tMax; - for (S3L_ScreenCoord x = xFrom; x <= xTo; ++x) + for (S3L_ScreenCoord x = lX; x <= rX; ++x) { *barycentric0 = S3L_interpolateFrom0(rSideUnitPos,t1,tMax); *barycentric1 = S3L_interpolateFrom0(lSideUnitPos,t2,tMax); @@ -879,9 +870,6 @@ void S3L_drawTriangle( lSideUnitPos += lSideUnitStep; rSideUnitPos += rSideUnitStep; - xFrom_prev = xFrom; - xTo_prev = xTo; - ++currentY; }