66 lines
2.0 KiB
C
66 lines
2.0 KiB
C
#ifndef COLLIDER_H
|
|
#define COLLIDER_H
|
|
|
|
#if COLLIDER_DEBUG
|
|
extern u32 collider_debug_steps;
|
|
#endif
|
|
|
|
struct v2 collider_support_point(struct collider_shape *a, struct xform xf, struct v2 dir);
|
|
|
|
#if 0
|
|
/* Returns simple true or false indicating shape collision */
|
|
b32 collider_collision_boolean(struct collider_shape *shape0, struct collider_shape *shape1);
|
|
#endif
|
|
|
|
struct collider_menkowski_point {
|
|
struct v2 p; /* Menkowski difference point */
|
|
struct v2 s0; /* Support point of first shape in dir */
|
|
struct v2 s1; /* Support point of second shape in -dir */
|
|
};
|
|
|
|
struct collider_simplex {
|
|
u32 len;
|
|
struct collider_menkowski_point a, b, c;
|
|
};
|
|
|
|
struct collider_collision_point {
|
|
struct v2 point;
|
|
f32 separation;
|
|
u32 id; /* Based on polygon edge-to-edge */
|
|
};
|
|
|
|
struct collider_prototype { struct v2 points[64]; u32 len; };
|
|
struct collider_collision_points_result {
|
|
struct v2 normal;
|
|
struct collider_collision_point points[2];
|
|
u32 num_points;
|
|
|
|
/* For debugging */
|
|
b32 solved;
|
|
i32 path;
|
|
struct collider_simplex simplex;
|
|
struct collider_prototype prototype;
|
|
struct v2 a0, b0, a1, b1; /* Clipping faces */
|
|
};
|
|
|
|
struct collider_collision_points_result collider_collision_points(struct collider_shape *shape0, struct collider_shape *shape1, struct xform xf0, struct xform xf1);
|
|
|
|
struct collider_closest_points_result {
|
|
struct v2 normal;
|
|
struct v2 p0, p1;
|
|
b32 colliding;
|
|
|
|
/* For debugging */
|
|
b32 solved;
|
|
i32 path;
|
|
struct collider_simplex simplex;
|
|
struct collider_prototype prototype;
|
|
};
|
|
|
|
struct collider_closest_points_result collider_closest_points(struct collider_shape *shape0, struct collider_shape *shape1, struct xform xf0, struct xform xf1);
|
|
|
|
struct v2_array menkowski(struct arena *arena, struct collider_shape *shape0, struct collider_shape *shape1, struct xform xf0, struct xform xf1, u32 detail);
|
|
struct v2_array cloud(struct arena *arena, struct collider_shape *shape0, struct collider_shape *shape1, struct xform xf0, struct xform xf1);
|
|
|
|
#endif
|