New geometry data structures.

This commit is contained in:
2025-12-13 11:13:20 -05:00
parent 4d372ff3d1
commit 903820d635
3 changed files with 29 additions and 56 deletions

View File

@@ -3,12 +3,18 @@
#include <raylib.h>
#include <stdio.h>
#include <stdlib.h>
Vector2 PointToVector2(Pt p) {
Vector2 v;
v.x = (float)(p.x * 100) + 50;
v.y = (float)(p.y * 100) + 50;
v.x = (float)(p.x * 100) + 50.;
v.y = (float)(p.y * 100) + 50.;
return v;
}
Vector2 PointpToVector2(Pt* p) {
Vector2 v;
v.x = (float)(p->x * 100) + 50;
v.y = (float)(p->y * 100) + 50;
return v;
}
@@ -16,23 +22,13 @@ void render() {
for (int i = 0; i < NPLATES; i++) {
Plate plate = lith[i];
// Skip plates with less than 3 vertices (can't form a polygon).
if (plate.nverts < 3) continue;
// Convert the vertices from world coordinates (Pt) to screen
// coordinates (Vector2).
Vector2 screen_verts[10];
for (int j = 0; j < plate.nverts; j++) {
screen_verts[j] = PointToVector2(plate.verts[j]);
}
for (int j = 0; j < plate.nverts; j++) {
Vector2 p1 = screen_verts[j];
Vector2 p2 =
screen_verts[(j + 1) % plate.nverts]; // Loop back to the first
// point
DrawLineV(p1, p2, WHITE);
}
DrawTriangleLines(
PointToVector2(plate.tris[0].a), PointToVector2(plate.tris[0].b),
PointToVector2(plate.tris[0].c), RED
);
printf(
">>>>>>>>>>>>>>>>>>%i %i\n", plate.tris[0].a.x, plate.tris[0].a.y
);
}
for (int x = 0; x < WORLD_SZ; x++) {