This commit is contained in:
2026-01-17 10:03:46 -05:00
parent d6fe969ce8
commit bb1981c5f6

View File

@@ -1,6 +1,7 @@
#include "include/gen.h" #include "include/gen.h"
#include "include/geom.h" #include "include/geom.h"
#include <raylib.h>
#include <stddef.h> #include <stddef.h>
#include <stdlib.h> #include <stdlib.h>
#include <time.h> #include <time.h>
@@ -106,22 +107,28 @@ void gen_lith() {
Pt* plhulls[NPLATES]; // The convex hulls of each plate. Pt* plhulls[NPLATES]; // The convex hulls of each plate.
size_t plhulls_count[NPLATES]; // The number of points in each hull. 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; size_t count;
plhulls[i] = cvx_hull(plareas[i], plareas_count[i], &count); plhulls[i] = cvx_hull(plareas[i], plareas_count[i], &count);
plhulls_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); Tri* tris = malloc(plhulls_count[i] / 3 + 2);
tris[0] = (Tri){plhulls[i][0], plhulls[i][1], plhulls[i][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}); lith[0] = pls[0];
Tri* tri2 = tri_init((Pt){7, 0}, (Pt){0, 7}, (Pt){7, 7}); lith[1] = pls[1];
lith[0] = (Plate){.col = BLUE, .ntris = 1, .tris = tri1};
lith[1] = (Plate){.col = GREEN, .ntris = 1, .tris = tri2};
} }