1
0
Fork 0
mirror of https://git.coom.tech/drummyfish/small3dlib.git synced 2024-11-23 20:59:58 +01:00

Add macro

This commit is contained in:
Miloslav Číž 2019-05-10 18:50:47 +02:00
parent 01e523aff0
commit 1f0aa51429

31
s3l.h
View file

@ -116,7 +116,7 @@
#endif #endif
#ifndef S3L_PERSPECTIVE_CORRECTION #ifndef S3L_PERSPECTIVE_CORRECTION
#define S3L_PERSPECTIVE_CORRECTION 1 #define S3L_PERSPECTIVE_CORRECTION 0
#endif #endif
#define S3L_HALF_RESOLUTION_X (S3L_RESOLUTION_X >> 1) #define S3L_HALF_RESOLUTION_X (S3L_RESOLUTION_X >> 1)
@ -1013,18 +1013,18 @@ void _S3L_drawFilledTriangle(
{ {
if (currentY == splitY) // reached a vertical split of the triangle? if (currentY == splitY) // reached a vertical split of the triangle?
{ // then reinit one side { // then reinit one side
#define manageSplit(b0,b1,s)\
S3L_Unit *tmp = barycentric##b0;\
barycentric##b0 = barycentric##b1;\
barycentric##b1 = tmp;\
s##SideUnitPos =\
(S3L_FRACTIONS_PER_UNIT << S3L_LERP_QUALITY) - s##SideUnitPos;\
s##SideUnitStep *= -1;
if (splitOnLeft) if (splitOnLeft)
{ {
initSide(l,l,r,0); initSide(l,l,r,0);
manageSplit(0,2,r)
S3L_Unit *tmp = barycentric0;
barycentric0 = barycentric2;
barycentric2 = tmp;
rSideUnitPos = (S3L_FRACTIONS_PER_UNIT << S3L_LERP_QUALITY)
- rSideUnitPos;
rSideUnitStep *= -1;
#if S3L_PERSPECTIVE_CORRECTION == 1 #if S3L_PERSPECTIVE_CORRECTION == 1
initPC(l,r,l) initPC(l,r,l)
@ -1033,15 +1033,7 @@ void _S3L_drawFilledTriangle(
else else
{ {
initSide(r,r,l,0); initSide(r,r,l,0);
manageSplit(1,2,l)
S3L_Unit *tmp = barycentric1;
barycentric1 = barycentric2;
barycentric2 = tmp;
lSideUnitPos = (S3L_FRACTIONS_PER_UNIT << S3L_LERP_QUALITY)
- lSideUnitPos;
lSideUnitStep *= -1;
#if S3L_PERSPECTIVE_CORRECTION == 1 #if S3L_PERSPECTIVE_CORRECTION == 1
initPC(r,l,r) initPC(r,l,r)
@ -1114,6 +1106,7 @@ void _S3L_drawFilledTriangle(
++currentY; ++currentY;
} }
#undef manageSplit
#undef initPC #undef initPC
#undef initSide #undef initSide
#undef stepSide #undef stepSide