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

Optimize inner loop

This commit is contained in:
Miloslav Číž 2019-05-18 19:20:47 +02:00
parent c0e5c383a8
commit b1c1650864

24
s3l.h
View file

@ -460,6 +460,15 @@ static inline S3L_Unit S3L_interpolateByUnitFrom0(S3L_Unit v2, S3L_Unit t)
return (v2 * t) / S3L_FRACTIONS_PER_UNIT;
}
/**
Same as S3L_interpolate but with v1 = 0. Should be faster.
*/
static inline S3L_Unit S3L_interpolateFrom0(S3L_Unit v2, S3L_Unit t,
S3L_Unit tMax)
{
return (v2 * t) / tMax;
}
/**
Multiplies two matrices with normalization by S3L_FRACTIONS_PER_UNIT. Result
is stored in the first matrix.
@ -795,14 +804,6 @@ static inline S3L_Unit S3L_interpolateBarycentric(
) / S3L_FRACTIONS_PER_UNIT;
}
/**
Same as S3L_interpolate but with v1 = 0. Should be faster.
*/
static inline int16_t S3L_interpolateFrom0(int16_t v2, int16_t t, int16_t tMax)
{
return (v2 * t) / tMax;
}
void S3L_bresenhamInit(S3L_BresenhamState *state, int16_t x0, int16_t y0,
int16_t x1, int16_t y1)
{
@ -1174,8 +1175,11 @@ void _S3L_drawFilledTriangle(
S3L_correctPerspective(S3L_interpolateFrom0(S3L_FRACTIONS_PER_UNIT,
x - lX,rowLength),&rowPC);
*barycentric0 = S3L_interpolateByUnitFrom0(rT,rowT);
*barycentric1 = S3L_interpolateByUnit(lT,0,rowT);
*barycentric0 =
S3L_interpolateByUnitFrom0(rT,rowT);
*barycentric1 =
S3L_interpolateByUnitFrom0(lT,S3L_FRACTIONS_PER_UNIT - rowT);
#else
*barycentric0 = b0 >> S3L_FAST_LERP_QUALITY;
*barycentric1 = b1 >> S3L_FAST_LERP_QUALITY;