Added bounds checking for triangles.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user