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

Remove unused parameter

This commit is contained in:
Miloslav Číž 2019-05-05 20:13:07 +02:00
parent 9c60d2584b
commit 193f29c6ef
2 changed files with 13 additions and 16 deletions

23
s3l.h
View file

@ -734,9 +734,8 @@ void S3L_drawTriangle(
specifics of this algorithm are among others: specifics of this algorithm are among others:
- drawing possibly a NON-CONTINUOUS line - drawing possibly a NON-CONTINUOUS line
- NOT tracing the line exactly, but rather rasterizing either on the - NOT tracing the line exactly, but rather rasterizing on one (right)
left or right side of it (depending on what's chosen), according to side of it, according to the pixel CENTERS
the pixel CENTERS
The principle is this: The principle is this:
@ -747,9 +746,7 @@ void S3L_drawTriangle(
- To make this INTEGER ONLY, scale the case so that distance between - To make this INTEGER ONLY, scale the case so that distance between
pixels is equal to dy (instead of 1). This way the error becomes pixels is equal to dy (instead of 1). This way the error becomes
dx/dy * dy == dx, and we're comparing the error to (and potentially dx/dy * dy == dx, and we're comparing the error to (and potentially
substracting) 1 * dy == dy. substracting) 1 * dy == dy. */
- The inital error is set to either 0 or dy (effectively shifting the
line) dependin on whether we want to rasterize on right or left. */
int16_t int16_t
/* triangle side: /* triangle side:
@ -771,9 +768,9 @@ void S3L_drawTriangle(
p1 - point from (t, l or r) p1 - point from (t, l or r)
p2 - point to (t, l or r) p2 - point to (t, l or r)
down - whether the side coordinate goes top-down or vice versa down - whether the side coordinate goes top-down or vice versa
left - whether to rasterize on left of the line or vice versa */ */
#define initSide(s,p1,p2,down,left)\ #define initSide(s,p1,p2,down)\
s##X = p1##PointX;\ s##X = p1##PointX;\
s##Dx = p2##PointX - p1##PointX;\ s##Dx = p2##PointX - p1##PointX;\
s##Dy = p2##PointY - p1##PointY;\ s##Dy = p2##PointY - p1##PointY;\
@ -785,7 +782,7 @@ void S3L_drawTriangle(
s##SideUnitStep *= -1;\ s##SideUnitStep *= -1;\
}\ }\
s##Inc = s##Dx >= 0 ? 1 : -1;\ s##Inc = s##Dx >= 0 ? 1 : -1;\
s##Err = left != (s##Dx < 0) ? 0 : s##Dy;\ s##Err = (s##Dx < 0) ? 0 : s##Dy;\
s##ErrAdd = S3L_abs(s##Dx);\ s##ErrAdd = S3L_abs(s##Dx);\
s##ErrSub = s##Dy != 0 ? s##Dy : 1; /* don't allow 0, could lead to an s##ErrSub = s##Dy != 0 ? s##Dy : 1; /* don't allow 0, could lead to an
infinite substracting loop */ infinite substracting loop */
@ -798,8 +795,8 @@ void S3L_drawTriangle(
}\ }\
s##Err += s##ErrAdd; s##Err += s##ErrAdd;
initSide(r,t,r,1,0) initSide(r,t,r,1)
initSide(l,t,l,1,0) initSide(l,t,l,1)
while (currentY < endY) /* draw the triangle from top to bottom -- the while (currentY < endY) /* draw the triangle from top to bottom -- the
bottom-most row is left out because, following bottom-most row is left out because, following
@ -810,7 +807,7 @@ void S3L_drawTriangle(
{ // then reinit one side { // then reinit one side
if (splitOnLeft) if (splitOnLeft)
{ {
initSide(l,l,r,0,0); initSide(l,l,r,0);
S3L_Unit *tmp = barycentric0; S3L_Unit *tmp = barycentric0;
barycentric0 = barycentric2; barycentric0 = barycentric2;
@ -821,7 +818,7 @@ void S3L_drawTriangle(
} }
else else
{ {
initSide(r,r,l,0,0); initSide(r,r,l,0);
S3L_Unit *tmp = barycentric1; S3L_Unit *tmp = barycentric1;
barycentric1 = barycentric2; barycentric1 = barycentric2;

6
test.c
View file

@ -80,7 +80,7 @@ uint16_t testRasterization()
numErrors += testTriangleRasterization(5,3, 3,3, 9,3, pixelsEmpty); numErrors += testTriangleRasterization(5,3, 3,3, 9,3, pixelsEmpty);
numErrors += testTriangleRasterization(9,4, 9,0, 9,9, pixelsEmpty); numErrors += testTriangleRasterization(9,4, 9,0, 9,9, pixelsEmpty);
numErrors += testTriangleRasterization(3,3, 6,6, 7,7, pixelsEmpty); numErrors += testTriangleRasterization(3,3, 6,6, 9,9, pixelsEmpty);
numErrors += testTriangleRasterization(7,0, 3,3, 0,7, pixelsEmpty); numErrors += testTriangleRasterization(7,0, 3,3, 0,7, pixelsEmpty);
numErrors += testTriangleRasterization(7,7, 7,7, 7,7, pixelsEmpty); numErrors += testTriangleRasterization(7,7, 7,7, 7,7, pixelsEmpty);
@ -297,8 +297,8 @@ uint16_t testRasterization()
uint16_t numErrors2 = 0; uint16_t numErrors2 = 0;
for (uint8_t y = 0; y < TEST_BUFFER_H - 1; ++y) for (uint8_t y = 0; y < TEST_BUFFER_H - 1; ++y)
{ { // ^ complete left and bottom aren't
printf(" "); printf(" "); // supposed to be rasterized
for (uint8_t x = 0; x < TEST_BUFFER_W - 1; ++x) for (uint8_t x = 0; x < TEST_BUFFER_W - 1; ++x)
{ {