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:
parent
52951d29b5
commit
fa9794000c
2 changed files with 9 additions and 13 deletions
|
@ -14,7 +14,7 @@
|
||||||
#define S3L_STRICT_NEAR_CULLING 0
|
#define S3L_STRICT_NEAR_CULLING 0
|
||||||
#define S3L_PERSPECTIVE_CORRECTION 2
|
#define S3L_PERSPECTIVE_CORRECTION 2
|
||||||
#define S3L_SORT 0
|
#define S3L_SORT 0
|
||||||
#define S3L_Z_BUFFER 1
|
#define S3L_Z_BUFFER 2
|
||||||
|
|
||||||
#define S3L_PIXEL_FUNCTION drawPixel
|
#define S3L_PIXEL_FUNCTION drawPixel
|
||||||
|
|
||||||
|
|
16
small3dlib.h
16
small3dlib.h
|
@ -1085,8 +1085,6 @@ void S3L_vec4Xmat4(S3L_Vec4 *v, S3L_Mat4 *m)
|
||||||
vBackup.z = v->z;
|
vBackup.z = v->z;
|
||||||
vBackup.w = v->w;
|
vBackup.w = v->w;
|
||||||
|
|
||||||
// TODO: try alternative operation orders to optimize
|
|
||||||
|
|
||||||
#define dotCol(col)\
|
#define dotCol(col)\
|
||||||
((vBackup.x * (*m)[col][0]) +\
|
((vBackup.x * (*m)[col][0]) +\
|
||||||
(vBackup.y * (*m)[col][1]) +\
|
(vBackup.y * (*m)[col][1]) +\
|
||||||
|
@ -1571,8 +1569,8 @@ void S3L_rotationToDirections(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void S3L_initPixelInfo(S3L_PixelInfo *p) // TODO: maybe non-pointer for p
|
void S3L_initPixelInfo(S3L_PixelInfo *p)
|
||||||
{ // could be faster?
|
{
|
||||||
p->x = 0;
|
p->x = 0;
|
||||||
p->y = 0;
|
p->y = 0;
|
||||||
p->barycentric[0] = S3L_FRACTIONS_PER_UNIT;
|
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
|
if (currentY >= 0) /* clipping of pixels whose y < 0 (can't be easily done
|
||||||
outside the loop) */
|
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;
|
p.y = currentY;
|
||||||
|
|
||||||
// draw the horizontal line
|
// draw the horizontal line
|
||||||
|
@ -2083,8 +2079,6 @@ void S3L_drawTriangle(
|
||||||
loop */
|
loop */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// draw the row -- inner loop:
|
|
||||||
|
|
||||||
#if S3L_PERSPECTIVE_CORRECTION == 2
|
#if S3L_PERSPECTIVE_CORRECTION == 2
|
||||||
S3L_FastLerpState depthPC, b0PC, b1PC;
|
S3L_FastLerpState depthPC, b0PC, b1PC;
|
||||||
|
|
||||||
|
@ -2108,6 +2102,8 @@ void S3L_drawTriangle(
|
||||||
int8_t rowCount = S3L_PC_APPROX_LENGTH;
|
int8_t rowCount = S3L_PC_APPROX_LENGTH;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// draw the row -- inner loop:
|
||||||
|
|
||||||
for (S3L_ScreenCoord x = lXClipped; x < rXClipped; ++x)
|
for (S3L_ScreenCoord x = lXClipped; x < rXClipped; ++x)
|
||||||
{
|
{
|
||||||
int8_t testsPassed = 1;
|
int8_t testsPassed = 1;
|
||||||
|
@ -2234,7 +2230,7 @@ void S3L_drawTriangle(
|
||||||
S3L_FRACTIONS_PER_UNIT - *barycentric0 - *barycentric1;
|
S3L_FRACTIONS_PER_UNIT - *barycentric0 - *barycentric1;
|
||||||
#endif
|
#endif
|
||||||
S3L_PIXEL_FUNCTION(&p);
|
S3L_PIXEL_FUNCTION(&p);
|
||||||
}
|
} // tests passed
|
||||||
|
|
||||||
#if !S3L_FLAT
|
#if !S3L_FLAT
|
||||||
#if S3L_PERSPECTIVE_CORRECTION
|
#if S3L_PERSPECTIVE_CORRECTION
|
||||||
|
|
Loading…
Reference in a new issue