From 85f48c1d799278a528011a908f6241940bf644bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miloslav=20=C4=8C=C3=AD=C5=BE?= Date: Sun, 18 Nov 2018 09:33:15 +0100 Subject: [PATCH] Advance barycentric --- s3l.h | 7 +++++-- testSDL.c | 9 +++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/s3l.h b/s3l.h index c24670c..759958a 100644 --- a/s3l.h +++ b/s3l.h @@ -273,7 +273,6 @@ void S3L_drawTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2 initSide(l,l,r,0); barycentric1 = &p.barycentricC; - barycentric2 = &p.barycentricB; barycentric3 = &p.barycentricA; rSideUnitPos = S3L_FRACTIONS_PER_UNIT - rSideUnitPos; @@ -283,7 +282,11 @@ void S3L_drawTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2 { initSide(r,r,l,0); - // TODO + barycentric2 = &p.barycentricC; + barycentric3 = &p.barycentricB; + + lSideUnitPos = S3L_FRACTIONS_PER_UNIT - lSideUnitPos; + lSideUnitStep *= -1; } } diff --git a/testSDL.c b/testSDL.c index 17877b3..c4ccdbd 100644 --- a/testSDL.c +++ b/testSDL.c @@ -48,16 +48,17 @@ const int16_t test_coords[] = 100,100, 99,101, 101,101, // 0, small triangle 190,50, 200,10, 400,80, // 1, arbitrary 40,80, 20,50, 100,30, // 2, arbitrary - 150,300, 290,400, 450,400, // 3, regular - 105,300, 120,300, 201,300, // 4, horizontal line - 400,300, 400,320, 400,400 // 5, vertical line + 350,270, 440,200, 490,220, // 3, arbitrary + 150,300, 290,400, 450,400, // 4, regular + 105,200, 120,200, 201,200, // 5, horizontal line + 300,200, 300,250, 300,220 // 6, vertical line }; void draw() { clearScreen(); - for (int c = 0; c < 4; ++c) + for (int c = 0; c < 7; ++c) { int x0 = test_coords[6 * c],