more utility functions in geom
[meshfrac] / src / geom.h
index fa492f0..14faa82 100644 (file)
@@ -7,8 +7,23 @@ struct plane {
        cgm_vec3 pt, norm;
 };
 
+struct vertex {
+       cgm_vec3 pos, norm;
+       cgm_vec2 uv;
+};
+
+struct poly {
+       struct vertex *verts;   /* dynarr */
+};
+
 float plane_dist(const struct plane *p, const cgm_vec3 *pt);
 float plane_sdist(const struct plane *p, const cgm_vec3 *pt);
 void midplane(struct plane *p, const cgm_vec3 *a, const cgm_vec3 *b);
 
+void poly_plane(const struct poly *poly, struct plane *plane);
+
+/* returns negative if there's no intersection, parametric distance if there is */
+float ray_plane(const cgm_ray *ray, const struct plane *plane);
+float ray_poly(const cgm_ray *ray, const struct poly *poly);
+
 #endif /* GEOM_H_ */