2023-10-15 08:21:36 +00:00
|
|
|
|
|
|
|
#ifndef TC_PHYSICS_PRIMITIVES_H
|
|
|
|
#define TC_PHYSICS_PRIMITIVES_H
|
|
|
|
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
|
2023-10-15 12:41:53 +00:00
|
|
|
#include <utility/math.h>
|
2023-10-15 08:21:36 +00:00
|
|
|
|
|
|
|
typedef struct tc_physics_mesh tc_physics_mesh_s;
|
|
|
|
|
|
|
|
typedef struct tc_aabb tc_aabb_s;
|
|
|
|
typedef struct tc_obb tc_obb_s;
|
|
|
|
typedef struct tc_plane tc_plane_s;
|
|
|
|
typedef struct tc_ellipsoid tc_ellipsoid_s;
|
|
|
|
typedef struct tc_ray tc_ray_s;
|
|
|
|
typedef struct tc_line tc_line_s;
|
|
|
|
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
TC_PRIMITIVE_AABB,
|
|
|
|
TC_PRIMITIVE_OBB,
|
|
|
|
TC_PRIMITIVE_PLANE,
|
|
|
|
TC_PRIMITIVE_ELLIPSOID,
|
|
|
|
TC_PRIMITIVE_RAY,
|
|
|
|
TC_PRIMITIVE_LINE
|
|
|
|
|
|
|
|
} tc_primitive_type_e;
|
|
|
|
|
|
|
|
struct tc_aabb
|
|
|
|
{
|
2023-10-15 12:41:53 +00:00
|
|
|
tc_vec3f_s start;
|
|
|
|
tc_vec3f_s size;
|
2023-10-15 08:21:36 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct tc_obb
|
|
|
|
{
|
2023-10-15 12:41:53 +00:00
|
|
|
tc_vec3f_s start;
|
|
|
|
tc_vec3f_s size;
|
|
|
|
tc_vec3f_s rotation;
|
2023-10-15 08:21:36 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct tc_plane
|
|
|
|
{
|
2023-10-15 12:41:53 +00:00
|
|
|
tc_vec3f_s center;
|
|
|
|
tc_vec3f_s rotation;
|
2023-10-15 08:21:36 +00:00
|
|
|
tc_vec2i_s size;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct tc_ellipsoid
|
|
|
|
{
|
2023-10-15 12:41:53 +00:00
|
|
|
tc_vec3f_s center;
|
|
|
|
tc_vec3f_s extent;
|
2023-10-15 08:21:36 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct tc_ray
|
|
|
|
{
|
2023-10-15 12:41:53 +00:00
|
|
|
tc_vec3f_s start;
|
|
|
|
tc_vec3f_s rotation;
|
2023-10-15 08:21:36 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct tc_line
|
|
|
|
{
|
2023-10-15 12:41:53 +00:00
|
|
|
tc_vec3f_s start;
|
|
|
|
tc_vec3f_s end;
|
2023-10-15 08:21:36 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
typedef union tc_primitive
|
|
|
|
{
|
|
|
|
tc_aabb_s aabb;
|
|
|
|
tc_obb_s obb;
|
|
|
|
tc_plane_s plane;
|
|
|
|
tc_ellipsoid_s sphere;
|
|
|
|
|
|
|
|
tc_line_s line;
|
|
|
|
tc_ray_s ray;
|
|
|
|
|
|
|
|
} tc_primitive_u;
|
|
|
|
|
2023-10-15 12:41:53 +00:00
|
|
|
typedef struct tc_primitive_container
|
2023-10-15 08:21:36 +00:00
|
|
|
{
|
|
|
|
tc_primitive_type_e type;
|
|
|
|
tc_primitive_u data;
|
|
|
|
|
|
|
|
} tc_primitive_s;
|
|
|
|
|
|
|
|
struct tc_physics_mesh
|
|
|
|
{
|
2023-10-15 12:41:53 +00:00
|
|
|
u32_t num_primitives;
|
2023-10-15 15:20:51 +00:00
|
|
|
union
|
|
|
|
{
|
|
|
|
struct complex
|
|
|
|
{
|
|
|
|
u32_t primitives_capacity;
|
|
|
|
tc_primitive_s *primitives;
|
|
|
|
} complex;
|
|
|
|
struct simple
|
|
|
|
{
|
|
|
|
tc_primitive_s primitive;
|
|
|
|
|
|
|
|
|
|
|
|
} simple;
|
|
|
|
} value;
|
2023-10-15 08:21:36 +00:00
|
|
|
};
|
|
|
|
|
2023-10-15 15:20:51 +00:00
|
|
|
tc_physics_mesh_s tc_wrap_aabb (tc_vec3f_s start, tc_vec3f_s size);
|
|
|
|
|
2023-10-15 08:21:36 +00:00
|
|
|
#endif // TC_PHYSICS_PRIMITIVES_H
|
|
|
|
|