1
0
Fork 0
mirror of https://git.coom.tech/drummyfish/small3dlib.git synced 2024-11-24 21:09:57 +01:00

Use triangle winding function in draw

This commit is contained in:
Miloslav Číž 2019-06-12 23:35:57 +02:00
parent fd7d957a64
commit a2283732f0

View file

@ -1652,11 +1652,7 @@ void S3L_drawTriangle(
tPointSy = y##t;\ tPointSy = y##t;\
tPointPP = &point##t;\ tPointPP = &point##t;\
barycentric2 = &(p.barycentric[t]);\ barycentric2 = &(p.barycentric[t]);\
int32_t aDx = x##a - x##t;\ if (S3L_triangleWinding(x##t,y##t,x##a,y##a,x##b,y##b) >= 0)\
int32_t bDx = x##b - x##t;\
int32_t aDy = S3L_nonZero(y##a - y##t);\
int32_t bDy = S3L_nonZero(y##b - y##t);\
if ((aDx << 8) / aDy < (bDx << 8) / bDy)\
{\ {\
lPointSx = x##a; lPointSy = y##a;\ lPointSx = x##a; lPointSy = y##a;\
rPointSx = x##b; rPointSy = y##b;\ rPointSx = x##b; rPointSy = y##b;\
@ -1948,6 +1944,8 @@ void S3L_drawTriangle(
if (rXClipped < lXClipped && if (rXClipped < lXClipped &&
lXClipped < S3L_RESOLUTION_X && rXClipped >= 0) lXClipped < S3L_RESOLUTION_X && rXClipped >= 0)
{ {
// TODO: After the change to computing the L/R, is this needed anymore?
/* This can sometimes happen because of numerical errors in sorting /* This can sometimes happen because of numerical errors in sorting
left vs right triangle point, which are compared based on SLOPE, not left vs right triangle point, which are compared based on SLOPE, not
x coordinates. Here we swap the values to prevents not drawing the x coordinates. Here we swap the values to prevents not drawing the