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

Fix triangle flicker

This commit is contained in:
Miloslav Číž 2019-05-11 19:52:40 +02:00
parent d9ed6e322e
commit 85cadda3b3
2 changed files with 7 additions and 7 deletions

4
s3l.h
View file

@ -876,7 +876,7 @@ void _S3L_drawFilledTriangle(
int16_t bDx = x##b - x##t;\ int16_t bDx = x##b - x##t;\
int16_t aDy = S3L_nonZero(y##a - y##t);\ int16_t aDy = S3L_nonZero(y##a - y##t);\
int16_t bDy = S3L_nonZero(y##b - y##t);\ int16_t bDy = S3L_nonZero(y##b - y##t);\
if ((aDx << 4) / aDy < (bDx << 4) / bDy)\ if ((aDx << 5) / aDy < (bDx << 5) / bDy)\
{\ {\
lPointSx = x##a; lPointSy = y##a;\ lPointSx = x##a; lPointSy = y##a;\
rPointSx = x##b; rPointSy = y##b;\ rPointSx = x##b; rPointSy = y##b;\
@ -1175,10 +1175,8 @@ void S3L_drawTriangle(S3L_Vec4 point0, S3L_Vec4 point1, S3L_Vec4 point2,
const S3L_DrawConfig *config, const S3L_Camera *camera, const S3L_DrawConfig *config, const S3L_Camera *camera,
S3L_Index triangleID) S3L_Index triangleID)
{ {
if (config->backfaceCulling != S3L_BACKFACE_CULLING_NONE) if (config->backfaceCulling != S3L_BACKFACE_CULLING_NONE)
{ {
int32_t winding = // determines CW or CCW int32_t winding = // determines CW or CCW
( (
(point1.y - point0.y) * (point2.x - point1.x) - (point1.y - point0.y) * (point2.x - point1.x) -

View file

@ -129,11 +129,13 @@ void draw()
clearScreen(); clearScreen();
modelTransform.rotation.z = frame * 0.1; uint32_t f = frame;
modelTransform.rotation.x = frame * 0.3;
modelTransform.translation.x = sin(frame >> 7) * 700; modelTransform.rotation.z = f * 0.1;
modelTransform.translation.y = sin(frame >> 8) * 600; modelTransform.rotation.x = f * 0.3;
modelTransform.translation.x = sin(f >> 7) * 700;
modelTransform.translation.y = sin(f >> 8) * 600;
S3L_drawModelIndexed(ver,tri,12,modelTransform,&camera,&conf); S3L_drawModelIndexed(ver,tri,12,modelTransform,&camera,&conf);