mirror of
https://git.coom.tech/drummyfish/small3dlib.git
synced 2024-11-21 20:39:57 +01:00
Revert
This commit is contained in:
parent
6e6bdf0c77
commit
4c042bd5fa
1 changed files with 14 additions and 15 deletions
29
small3dlib.h
29
small3dlib.h
|
@ -145,8 +145,6 @@ BE REDEFINED, so rather don't do it (otherwise things may overflow etc.). */
|
||||||
|
|
||||||
#define S3L_FRACTIONS_PER_UNIT 512
|
#define S3L_FRACTIONS_PER_UNIT 512
|
||||||
|
|
||||||
#define S3L_UNIT_MINUS_ONE (S3L_FRACTIONS_PER_UNIT - 1)
|
|
||||||
|
|
||||||
typedef int16_t S3L_ScreenCoord;
|
typedef int16_t S3L_ScreenCoord;
|
||||||
typedef uint16_t S3L_Index;
|
typedef uint16_t S3L_Index;
|
||||||
|
|
||||||
|
@ -449,9 +447,10 @@ typedef struct
|
||||||
vertices. These serve to locate the pixel on a
|
vertices. These serve to locate the pixel on a
|
||||||
triangle and interpolate values between it's
|
triangle and interpolate values between it's
|
||||||
three points. Each one goes from 0 to
|
three points. Each one goes from 0 to
|
||||||
S3L_UNIT_MINUS_ONE (inclidung) and the sum of the
|
S3L_FRACTIONS_PER_UNIT (inclidung), but due to
|
||||||
three coordinates will always be exactly
|
rounding error may fall outside this range. The
|
||||||
S3L_UNIT_MINUS_ONE. */
|
sum of the three coordinates will always be
|
||||||
|
exactly S3L_FRACTIONS_PER_UNIT. */
|
||||||
S3L_Index triangleIndex; ///< Triangle index.
|
S3L_Index triangleIndex; ///< Triangle index.
|
||||||
S3L_Index modelIndex;
|
S3L_Index modelIndex;
|
||||||
S3L_Unit depth; ///< Depth (only if depth is turned on).
|
S3L_Unit depth; ///< Depth (only if depth is turned on).
|
||||||
|
@ -1655,9 +1654,9 @@ void S3L_drawTriangle(
|
||||||
|
|
||||||
#if S3L_FLAT
|
#if S3L_FLAT
|
||||||
p.depth = (tPointPP->z + lPointPP->z + rPointPP->z) / 3;
|
p.depth = (tPointPP->z + lPointPP->z + rPointPP->z) / 3;
|
||||||
*barycentric0 = S3L_UNIT_MINUS_ONE / 3;
|
*barycentric0 = S3L_FRACTIONS_PER_UNIT / 3;
|
||||||
*barycentric1 = S3L_UNIT_MINUS_ONE / 3;
|
*barycentric1 = S3L_FRACTIONS_PER_UNIT / 3;
|
||||||
*barycentric2 = S3L_UNIT_MINUS_ONE - 2 * (S3L_UNIT_MINUS_ONE / 3);
|
*barycentric2 = S3L_FRACTIONS_PER_UNIT - 2 * (S3L_FRACTIONS_PER_UNIT / 3);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
p.triangleSize[0] = rPointSx - lPointSx;
|
p.triangleSize[0] = rPointSx - lPointSx;
|
||||||
|
@ -1739,12 +1738,12 @@ void S3L_drawTriangle(
|
||||||
s##Dx = p2##PointSx - p1##PointSx;\
|
s##Dx = p2##PointSx - p1##PointSx;\
|
||||||
s##Dy = p2##PointSy - p1##PointSy;\
|
s##Dy = p2##PointSy - p1##PointSy;\
|
||||||
initDepthFLS(s,p1,p2)\
|
initDepthFLS(s,p1,p2)\
|
||||||
s##SideFLS.stepScaled = (S3L_UNIT_MINUS_ONE << S3L_FAST_LERP_QUALITY)\
|
s##SideFLS.stepScaled = (S3L_FRACTIONS_PER_UNIT << S3L_FAST_LERP_QUALITY)\
|
||||||
/ (s##Dy != 0 ? s##Dy : 1);\
|
/ (s##Dy != 0 ? s##Dy : 1);\
|
||||||
s##SideFLS.valueScaled = 0;\
|
s##SideFLS.valueScaled = 0;\
|
||||||
if (!down)\
|
if (!down)\
|
||||||
{\
|
{\
|
||||||
s##SideFLS.valueScaled = S3L_UNIT_MINUS_ONE << S3L_FAST_LERP_QUALITY;\
|
s##SideFLS.valueScaled = S3L_FRACTIONS_PER_UNIT << S3L_FAST_LERP_QUALITY;\
|
||||||
s##SideFLS.stepScaled *= -1;\
|
s##SideFLS.stepScaled *= -1;\
|
||||||
}\
|
}\
|
||||||
s##Inc = s##Dx >= 0 ? 1 : -1;\
|
s##Inc = s##Dx >= 0 ? 1 : -1;\
|
||||||
|
@ -1819,7 +1818,7 @@ void S3L_drawTriangle(
|
||||||
S3L_Unit *tmp = barycentric##b0;\
|
S3L_Unit *tmp = barycentric##b0;\
|
||||||
barycentric##b0 = barycentric##b1;\
|
barycentric##b0 = barycentric##b1;\
|
||||||
barycentric##b1 = tmp;\
|
barycentric##b1 = tmp;\
|
||||||
s0##SideFLS.valueScaled = (S3L_UNIT_MINUS_ONE\
|
s0##SideFLS.valueScaled = (S3L_FRACTIONS_PER_UNIT\
|
||||||
<< S3L_FAST_LERP_QUALITY) - s0##SideFLS.valueScaled;\
|
<< S3L_FAST_LERP_QUALITY) - s0##SideFLS.valueScaled;\
|
||||||
s0##SideFLS.stepScaled *= -1;\
|
s0##SideFLS.stepScaled *= -1;\
|
||||||
manageSplitPerspective(s0,s1)
|
manageSplitPerspective(s0,s1)
|
||||||
|
@ -1926,7 +1925,7 @@ void S3L_drawTriangle(
|
||||||
S3L_FastLerpState depthPC, b0PC, b1PC;
|
S3L_FastLerpState depthPC, b0PC, b1PC;
|
||||||
|
|
||||||
depthPC.valueScaled =
|
depthPC.valueScaled =
|
||||||
((S3L_UNIT_MINUS_ONE * S3L_FRACTIONS_PER_UNIT) /
|
((S3L_FRACTIONS_PER_UNIT * S3L_FRACTIONS_PER_UNIT) /
|
||||||
S3L_nonZero(S3L_interpolate(lRecipZ,rRecipZ,i,rowLength)))
|
S3L_nonZero(S3L_interpolate(lRecipZ,rRecipZ,i,rowLength)))
|
||||||
<< S3L_FAST_LERP_QUALITY;
|
<< S3L_FAST_LERP_QUALITY;
|
||||||
|
|
||||||
|
@ -1957,7 +1956,7 @@ void S3L_drawTriangle(
|
||||||
|
|
||||||
#if S3L_COMPUTE_DEPTH
|
#if S3L_COMPUTE_DEPTH
|
||||||
#if S3L_PERSPECTIVE_CORRECTION == 1
|
#if S3L_PERSPECTIVE_CORRECTION == 1
|
||||||
p.depth = (S3L_UNIT_MINUS_ONE * S3L_FRACTIONS_PER_UNIT) /
|
p.depth = (S3L_FRACTIONS_PER_UNIT * S3L_FRACTIONS_PER_UNIT) /
|
||||||
S3L_nonZero(S3L_interpolate(lRecipZ,rRecipZ,i,rowLength));
|
S3L_nonZero(S3L_interpolate(lRecipZ,rRecipZ,i,rowLength));
|
||||||
#elif S3L_PERSPECTIVE_CORRECTION == 2
|
#elif S3L_PERSPECTIVE_CORRECTION == 2
|
||||||
if (rowCount >= S3L_PC_APPROX_LENGTH)
|
if (rowCount >= S3L_PC_APPROX_LENGTH)
|
||||||
|
@ -1968,7 +1967,7 @@ void S3L_drawTriangle(
|
||||||
|
|
||||||
S3L_Unit nextDepth =
|
S3L_Unit nextDepth =
|
||||||
(
|
(
|
||||||
(S3L_UNIT_MINUS_ONE * S3L_FRACTIONS_PER_UNIT) /
|
(S3L_FRACTIONS_PER_UNIT * S3L_FRACTIONS_PER_UNIT) /
|
||||||
S3L_nonZero(S3L_interpolate(lRecipZ,rRecipZ,nextI,rowLength))
|
S3L_nonZero(S3L_interpolate(lRecipZ,rRecipZ,nextI,rowLength))
|
||||||
) << S3L_FAST_LERP_QUALITY;
|
) << S3L_FAST_LERP_QUALITY;
|
||||||
|
|
||||||
|
@ -2032,7 +2031,7 @@ void S3L_drawTriangle(
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
*barycentric2 =
|
*barycentric2 =
|
||||||
S3L_UNIT_MINUS_ONE - *barycentric0 - *barycentric1;
|
S3L_FRACTIONS_PER_UNIT - *barycentric0 - *barycentric1;
|
||||||
#endif
|
#endif
|
||||||
S3L_PIXEL_FUNCTION(&p);
|
S3L_PIXEL_FUNCTION(&p);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue