35 static inline void plane_copy(
struct plane *dst,
const struct plane *p)
37 vec3_copy(&dst->
dir, &p->
dir);
41 static inline void plane_set(
struct plane *dst,
const struct vec3 *dir,
44 vec3_copy(&dst->
dir, dir);
48 static inline void plane_setf(
struct plane *dst,
float a,
float b,
float c,
51 vec3_set(&dst->
dir, a, b, c);
56 const struct vec3 *v2,
const struct vec3 *v3);
64 const struct vec3 *orig,
65 const struct vec3 *dir,
float *t);
67 const struct vec3 *v1,
68 const struct vec3 *v2,
float *t);
71 const struct vec3 *v2,
const struct vec3 *v3,
75 const struct vec3 *v2,
float precision);
77 static inline bool plane_close(
const struct plane *p1,
const struct plane *p2,
80 return vec3_close(&p1->
dir, &p2->
dir, precision) &&
81 close_float(p1->
dist, p2->
dist, precision);
84 static inline bool plane_coplanar(
const struct plane *p1,
85 const struct plane *p2,
float precision)
87 float cos_angle = vec3_dot(&p1->
dir, &p2->
dir);
89 if (close_float(cos_angle, 1.0f, precision))
90 return close_float(p1->
dist, p2->
dist, precision);
91 else if (close_float(cos_angle, -1.0f, precision))
92 return close_float(-p1->
dist, p2->
dist, precision);
EXPORT bool plane_intersection_line(const struct plane *p, const struct vec3 *v1, const struct vec3 *v2, float *t)
EXPORT bool plane_tri_inside(const struct plane *p, const struct vec3 *v1, const struct vec3 *v2, const struct vec3 *v3, float precision)
EXPORT void plane_transform(struct plane *dst, const struct plane *p, const struct matrix4 *m)
struct vec3 dir
Definition: plane.h:31
#define EXPORT
Definition: c99defs.h:49
float dist
Definition: plane.h:32
EXPORT void plane_from_tri(struct plane *dst, const struct vec3 *v1, const struct vec3 *v2, const struct vec3 *v3)
__m128 m
Definition: vec3.h:39
EXPORT bool plane_intersection_ray(const struct plane *p, const struct vec3 *orig, const struct vec3 *dir, float *t)
EXPORT void plane_transform3x4(struct plane *dst, const struct plane *p, const struct matrix3 *m)
EXPORT bool plane_line_inside(const struct plane *p, const struct vec3 *v1, const struct vec3 *v2, float precision)