2024-04-26 02:43:38 +00:00
|
|
|
#ifndef SEODISPARATE_COM_SEPARATING_AXIS_COLLISION_DETECTION_H_
|
|
|
|
#define SEODISPARATE_COM_SEPARATING_AXIS_COLLISION_DETECTION_H_
|
|
|
|
|
|
|
|
#define SC_SACD_PLATFORM_WINDOWS 1
|
|
|
|
#define SC_SACD_PLATFORM_OTHER 2
|
|
|
|
|
|
|
|
#if defined _WIN32
|
|
|
|
#define SC_SACD_PLATFORM SC_SACD_PLATFORM_WINDOWS
|
|
|
|
#else
|
|
|
|
#define SC_SACD_PLATFORM SC_SACD_PLATFORM_OTHER
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if SC_SACD_PLATFORM == SC_SACD_PLATFORM_WINDOWS
|
|
|
|
#define SC_SACD_EXPORT __declspec(dllexport)
|
|
|
|
#else
|
|
|
|
#define SC_SACD_EXPORT
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2024-04-26 03:28:12 +00:00
|
|
|
typedef struct SC_SACD_EXPORT SC_SACD_Vec3 {
|
|
|
|
float x, y, z;
|
|
|
|
} SC_SACD_Vec3;
|
|
|
|
|
2024-04-29 04:39:59 +00:00
|
|
|
typedef struct SC_SACD_EXPORT SC_SACD_Mat4 {
|
|
|
|
float x0, x1, x2, x3;
|
|
|
|
float y0, y1, y2, y3;
|
|
|
|
float z0, z1, z2, z3;
|
|
|
|
float w0, w1, w2, w3;
|
|
|
|
} SC_SACD_Mat4;
|
2024-04-26 03:28:12 +00:00
|
|
|
|
2024-04-26 02:43:38 +00:00
|
|
|
typedef struct SC_SACD_EXPORT SC_SACD_AABB_Box {
|
2024-04-26 04:13:59 +00:00
|
|
|
/// Coordinates are to center of box.
|
2024-04-26 02:43:38 +00:00
|
|
|
float x;
|
|
|
|
float y;
|
2024-04-26 03:28:12 +00:00
|
|
|
float z;
|
|
|
|
/// x-axis width.
|
2024-04-26 02:43:38 +00:00
|
|
|
float width;
|
2024-04-26 03:28:12 +00:00
|
|
|
/// y-axis height.
|
2024-04-26 02:43:38 +00:00
|
|
|
float height;
|
2024-04-26 03:28:12 +00:00
|
|
|
/// z-axis depth.
|
|
|
|
float depth;
|
2024-04-26 02:43:38 +00:00
|
|
|
} SC_SACD_AABB_Box;
|
|
|
|
|
|
|
|
typedef struct SC_SACD_EXPORT SC_SACD_Generic_Box {
|
2024-04-26 04:13:59 +00:00
|
|
|
/// Coordinates are to center of box.
|
2024-04-26 02:43:38 +00:00
|
|
|
float x;
|
|
|
|
float y;
|
2024-04-26 03:28:12 +00:00
|
|
|
float z;
|
|
|
|
/// x-axis width.
|
2024-04-26 02:43:38 +00:00
|
|
|
float width;
|
2024-04-26 03:28:12 +00:00
|
|
|
/// y-axis height.
|
2024-04-26 02:43:38 +00:00
|
|
|
float height;
|
2024-04-26 03:28:12 +00:00
|
|
|
/// z-axis depth.
|
|
|
|
float depth;
|
2024-04-30 05:00:32 +00:00
|
|
|
/// Local transform; expects center of box as origin.
|
|
|
|
SC_SACD_Mat4 transform;
|
2024-04-26 02:43:38 +00:00
|
|
|
} SC_SACD_Generic_Box;
|
|
|
|
|
2024-04-26 08:36:57 +00:00
|
|
|
typedef struct SC_SACD_EXPORT SC_SACD_Sphere {
|
|
|
|
float x;
|
|
|
|
float y;
|
|
|
|
float z;
|
|
|
|
float radius;
|
|
|
|
} SC_SACD_Sphere;
|
|
|
|
|
2024-04-26 02:43:38 +00:00
|
|
|
/// Returns non-zero if there is collision.
|
|
|
|
SC_SACD_EXPORT int SC_SACD_AABB_Box_Collision(const SC_SACD_AABB_Box *a,
|
|
|
|
const SC_SACD_AABB_Box *b);
|
|
|
|
|
|
|
|
/// Returns non-zero if there is collision.
|
|
|
|
SC_SACD_EXPORT int SC_SACD_Generic_Box_Collision(const SC_SACD_Generic_Box *a,
|
|
|
|
const SC_SACD_Generic_Box *b);
|
|
|
|
|
|
|
|
/// Returns non-zero if there is collision.
|
2024-04-26 03:28:12 +00:00
|
|
|
SC_SACD_EXPORT int SC_SACD_AABB_Generic_Box_Collision(
|
2024-04-26 02:43:38 +00:00
|
|
|
const SC_SACD_AABB_Box *a, const SC_SACD_Generic_Box *b);
|
|
|
|
|
2024-04-30 04:40:07 +00:00
|
|
|
/// Returns non-zero if there is collision.
|
2024-04-26 08:36:57 +00:00
|
|
|
SC_SACD_EXPORT int SC_SACD_Sphere_Collision(const SC_SACD_Sphere *a,
|
|
|
|
const SC_SACD_Sphere *b);
|
|
|
|
|
2024-04-30 04:40:07 +00:00
|
|
|
/// Returns non-zero if there is collision.
|
2024-04-26 08:36:57 +00:00
|
|
|
SC_SACD_EXPORT int SC_SACD_Sphere_AABB_Box_Collision(
|
|
|
|
const SC_SACD_Sphere *sphere, const SC_SACD_AABB_Box *box);
|
|
|
|
|
2024-04-30 04:40:07 +00:00
|
|
|
/// Returns non-zero if there is collision.
|
2024-04-26 08:36:57 +00:00
|
|
|
SC_SACD_EXPORT int SC_SACD_Sphere_Box_Collision(const SC_SACD_Sphere *sphere,
|
|
|
|
const SC_SACD_Generic_Box *box);
|
|
|
|
|
2024-04-26 03:28:12 +00:00
|
|
|
SC_SACD_EXPORT float SC_SACD_Dot_Product(const SC_SACD_Vec3 a,
|
|
|
|
const SC_SACD_Vec3 b);
|
|
|
|
|
|
|
|
SC_SACD_EXPORT SC_SACD_Vec3 SC_SACD_Cross_Product(const SC_SACD_Vec3 a,
|
|
|
|
const SC_SACD_Vec3 b);
|
|
|
|
|
2024-04-29 04:39:59 +00:00
|
|
|
SC_SACD_EXPORT SC_SACD_Mat4 SC_SACD_Mat4_Identity(void);
|
2024-04-27 10:11:36 +00:00
|
|
|
|
2024-04-29 04:39:59 +00:00
|
|
|
SC_SACD_EXPORT SC_SACD_Mat4 SC_SACD_Mat4_Mult(const SC_SACD_Mat4 *a,
|
|
|
|
const SC_SACD_Mat4 *b);
|
2024-04-27 10:11:36 +00:00
|
|
|
|
2024-04-29 04:39:59 +00:00
|
|
|
SC_SACD_EXPORT SC_SACD_Vec3 SC_SACD_Mat4_Vec3_Mult(const SC_SACD_Mat4 *mat,
|
2024-04-26 03:28:12 +00:00
|
|
|
const SC_SACD_Vec3 vec);
|
|
|
|
|
2024-04-30 05:00:32 +00:00
|
|
|
/// Rotates by x-axis first, then y-axis, then finally z-axis.
|
2024-04-26 03:28:12 +00:00
|
|
|
SC_SACD_EXPORT SC_SACD_Vec3 SC_SACD_Vec3_Rotate(const SC_SACD_Vec3 vec,
|
|
|
|
float x_axis, float y_axis,
|
|
|
|
float z_axis);
|
|
|
|
|
2024-04-29 04:39:59 +00:00
|
|
|
SC_SACD_EXPORT SC_SACD_Mat4 SC_SACD_Rotation_Mat4_XAxis(float x_radians);
|
|
|
|
SC_SACD_EXPORT SC_SACD_Mat4 SC_SACD_Rotation_Mat4_YAxis(float y_radians);
|
|
|
|
SC_SACD_EXPORT SC_SACD_Mat4 SC_SACD_Rotation_Mat4_ZAxis(float z_radians);
|
2024-04-27 10:11:36 +00:00
|
|
|
|
2024-04-29 05:09:49 +00:00
|
|
|
SC_SACD_EXPORT SC_SACD_Mat4 SC_SACD_Translate_Mat4(float x, float y, float z);
|
|
|
|
|
2024-04-26 08:36:57 +00:00
|
|
|
SC_SACD_EXPORT SC_SACD_Vec3 SC_SACD_Closest_Point_Dir_Normalized(
|
|
|
|
const SC_SACD_Vec3 *pos, const SC_SACD_Vec3 *dir,
|
|
|
|
const SC_SACD_Vec3 *point);
|
|
|
|
|
|
|
|
SC_SACD_EXPORT SC_SACD_Vec3 SC_SACD_Closest_Point(const SC_SACD_Vec3 *pos,
|
|
|
|
const SC_SACD_Vec3 *dir,
|
|
|
|
const SC_SACD_Vec3 *point);
|
|
|
|
|
2024-04-30 05:00:32 +00:00
|
|
|
SC_SACD_EXPORT float SC_SACD_Vec3_Length(const SC_SACD_Vec3 vec);
|
|
|
|
|
2024-04-26 02:43:38 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|