Added bounds checking for triangles.

This commit is contained in:
2025-12-20 10:33:12 -05:00
parent cffc64f3e9
commit 3bf2a7b429
10 changed files with 126 additions and 116 deletions

View File

@@ -1,6 +1,10 @@
#ifndef GEOM_H
#define GEOM_H
#include <stdlib.h>
#include <stdbool.h>
#include <raylib.h>
// The maximum number of Tris in a Plate.
#define NTRI 4
@@ -19,8 +23,19 @@ typedef struct {
Pt c;
} Tri;
extern Tri* alltris[512];
extern size_t allsize;
Tri* tri_init(Pt a, Pt b, Pt c);
void tri_destroy(Tri* tri);
// Check if a point is within the triangle. Uses barycentric coordinate system.
bool tri_within(Pt pt, Tri* tri);
typedef struct {
Tri tris[NTRI];
Color col;
size_t ntris;
Tri* tris;
} Plate;
#endif