From bb1981c5f6f32898e453521b1def766b4b164f44 Mon Sep 17 00:00:00 2001 From: Jacob Date: Sat, 17 Jan 2026 10:03:46 -0500 Subject: [PATCH] Why. --- src/gen.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/src/gen.c b/src/gen.c index 9e4118d..1933fff 100644 --- a/src/gen.c +++ b/src/gen.c @@ -1,6 +1,7 @@ #include "include/gen.h" #include "include/geom.h" +#include #include #include #include @@ -106,22 +107,28 @@ void gen_lith() { Pt* plhulls[NPLATES]; // The convex hulls of each plate. size_t plhulls_count[NPLATES]; // The number of points in each hull. - for (int i = 0; i < NPLATES; i++) { + for (int i = 0; i < NPLATES; i++) { // Generate convex hulls. size_t count; plhulls[i] = cvx_hull(plareas[i], plareas_count[i], &count); plhulls_count[i] = count; } - Plate pls[NPLATES]; + Plate pls[NPLATES]; // The plates. - for (int i = 0; i < NPLATES; i++) { + for (int i = 0; i < NPLATES; + i++) { // Generate plate triangle lists from convex hulls. Tri* tris = malloc(plhulls_count[i] / 3 + 2); tris[0] = (Tri){plhulls[i][0], plhulls[i][1], plhulls[i][2]}; + for (int j = 2; j < plhulls_count[i] - 2; j++) { + tris[j] = + (Tri){plhulls[i][0], plhulls[i][j + 1], plhulls[i][j + 2]}; + } + + pls[i] = (Plate){.ntris = 1, + .tris = tris, + .col = ColorFromHSV(((float)rand()) / 100, 1, 1)}; } - Tri* tri1 = tri_init((Pt){0, 0}, (Pt){0, 7}, (Pt){7, 0}); - Tri* tri2 = tri_init((Pt){7, 0}, (Pt){0, 7}, (Pt){7, 7}); - - lith[0] = (Plate){.col = BLUE, .ntris = 1, .tris = tri1}; - lith[1] = (Plate){.col = GREEN, .ntris = 1, .tris = tri2}; + lith[0] = pls[0]; + lith[1] = pls[1]; }