1
0
Fork 0
mirror of https://git.coom.tech/drummyfish/small3dlib.git synced 2024-12-23 01:26:19 +01:00

Refactor a bit

This commit is contained in:
Miloslav Číž 2019-06-22 19:29:08 +02:00
parent 52951d29b5
commit fa9794000c
2 changed files with 9 additions and 13 deletions

View file

@ -14,7 +14,7 @@
#define S3L_STRICT_NEAR_CULLING 0
#define S3L_PERSPECTIVE_CORRECTION 2
#define S3L_SORT 0
#define S3L_Z_BUFFER 1
#define S3L_Z_BUFFER 2
#define S3L_PIXEL_FUNCTION drawPixel

View file

@ -1085,8 +1085,6 @@ void S3L_vec4Xmat4(S3L_Vec4 *v, S3L_Mat4 *m)
vBackup.z = v->z;
vBackup.w = v->w;
// TODO: try alternative operation orders to optimize
#define dotCol(col)\
((vBackup.x * (*m)[col][0]) +\
(vBackup.y * (*m)[col][1]) +\
@ -1571,8 +1569,8 @@ void S3L_rotationToDirections(
}
}
void S3L_initPixelInfo(S3L_PixelInfo *p) // TODO: maybe non-pointer for p
{ // could be faster?
void S3L_initPixelInfo(S3L_PixelInfo *p)
{
p->x = 0;
p->y = 0;
p->barycentric[0] = S3L_FRACTIONS_PER_UNIT;
@ -2017,9 +2015,7 @@ void S3L_drawTriangle(
if (currentY >= 0) /* clipping of pixels whose y < 0 (can't be easily done
outside the loop) */
{ /* TODO: ^ This is bad though, a single large
triangle outside he top of the screen will trigger
a long loop. Try to FIX THIS! */
{
p.y = currentY;
// draw the horizontal line
@ -2083,8 +2079,6 @@ void S3L_drawTriangle(
loop */
#endif
// draw the row -- inner loop:
#if S3L_PERSPECTIVE_CORRECTION == 2
S3L_FastLerpState depthPC, b0PC, b1PC;
@ -2108,6 +2102,8 @@ void S3L_drawTriangle(
int8_t rowCount = S3L_PC_APPROX_LENGTH;
#endif
// draw the row -- inner loop:
for (S3L_ScreenCoord x = lXClipped; x < rXClipped; ++x)
{
int8_t testsPassed = 1;
@ -2234,7 +2230,7 @@ void S3L_drawTriangle(
S3L_FRACTIONS_PER_UNIT - *barycentric0 - *barycentric1;
#endif
S3L_PIXEL_FUNCTION(&p);
}
} // tests passed
#if !S3L_FLAT
#if S3L_PERSPECTIVE_CORRECTION