From bb394e37caa8ffc337e8d5b85d30dac567b764a1 Mon Sep 17 00:00:00 2001 From: Max Vetrov Date: Thu, 6 Aug 2020 23:01:00 +0200 Subject: [PATCH] Update mini3d.c Little bit shorter. --- mini3d.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/mini3d.c b/mini3d.c index 736d1fd..6b898e9 100644 --- a/mini3d.c +++ b/mini3d.c @@ -400,24 +400,21 @@ int trapezoid_init_triangle(trapezoid_t *trap, const vertex_t *p1, k = (p3->pos.y - p1->pos.y) / (p2->pos.y - p1->pos.y); x = p1->pos.x + (p2->pos.x - p1->pos.x) * k; + trap[0].left.v1 = *p1; + trap[0].right.v1 = *p1; + trap[1].right.v2 = *p3; + trap[1].left.v2 = *p3; + if (x <= p3->pos.x) { // triangle left - trap[0].left.v1 = *p1; trap[0].left.v2 = *p2; - trap[0].right.v1 = *p1; trap[0].right.v2 = *p3; trap[1].left.v1 = *p2; - trap[1].left.v2 = *p3; trap[1].right.v1 = *p1; - trap[1].right.v2 = *p3; } else { // triangle right - trap[0].left.v1 = *p1; trap[0].left.v2 = *p3; - trap[0].right.v1 = *p1; trap[0].right.v2 = *p2; trap[1].left.v1 = *p1; - trap[1].left.v2 = *p3; trap[1].right.v1 = *p2; - trap[1].right.v2 = *p3; } return 2;