mirror of
https://git.coom.tech/drummyfish/small3dlib.git
synced 2024-11-21 20:39:57 +01:00
Remove discontinity conditions
This commit is contained in:
parent
e0aa1e6661
commit
b77fbb38b2
1 changed files with 2 additions and 14 deletions
16
s3l.h
16
s3l.h
|
@ -813,10 +813,6 @@ void S3L_drawTriangle(
|
||||||
initSide(r,t,r,1)
|
initSide(r,t,r,1)
|
||||||
initSide(l,t,l,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
|
while (currentY <= endY) // draw the triangle from top to bottom
|
||||||
{
|
{
|
||||||
if (currentY == splitY) // reached a vertical split of the triangle?
|
if (currentY == splitY) // reached a vertical split of the triangle?
|
||||||
|
@ -849,18 +845,13 @@ void S3L_drawTriangle(
|
||||||
|
|
||||||
// draw the horizontal line
|
// draw the horizontal line
|
||||||
|
|
||||||
S3L_Unit xFrom = lX < (xTo_prev + 1) ? lX : (xTo_prev + 1);
|
S3L_Unit tMax = rX - lX;
|
||||||
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;
|
|
||||||
tMax = S3L_NONZERO(tMax); // prevent division by zero
|
tMax = S3L_NONZERO(tMax); // prevent division by zero
|
||||||
|
|
||||||
S3L_Unit t1 = 0;
|
S3L_Unit t1 = 0;
|
||||||
S3L_Unit t2 = tMax;
|
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);
|
*barycentric0 = S3L_interpolateFrom0(rSideUnitPos,t1,tMax);
|
||||||
*barycentric1 = S3L_interpolateFrom0(lSideUnitPos,t2,tMax);
|
*barycentric1 = S3L_interpolateFrom0(lSideUnitPos,t2,tMax);
|
||||||
|
@ -879,9 +870,6 @@ void S3L_drawTriangle(
|
||||||
lSideUnitPos += lSideUnitStep;
|
lSideUnitPos += lSideUnitStep;
|
||||||
rSideUnitPos += rSideUnitStep;
|
rSideUnitPos += rSideUnitStep;
|
||||||
|
|
||||||
xFrom_prev = xFrom;
|
|
||||||
xTo_prev = xTo;
|
|
||||||
|
|
||||||
++currentY;
|
++currentY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue