Techneck/code/source-c/physics/primitives.h

98 lines
1.9 KiB
C

#ifndef TC_PHYSICS_PRIMITIVES_H
#define TC_PHYSICS_PRIMITIVES_H
#include <stdbool.h>
#include <stdint.h>
#include "../utility.h"
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
{
tc_vec3_s start;
tc_vec3_s size;
};
struct tc_obb
{
tc_vec3_s start;
tc_vec3_s size;
tc_vec3_s rotation;
};
struct tc_plane
{
tc_vec3_s center;
tc_vec3_s rotation;
tc_vec2i_s size;
};
struct tc_ellipsoid
{
tc_vec3_s center;
tc_vec3_s extent;
};
struct tc_ray
{
tc_vec3_s start;
tc_vec3_s rotation;
};
struct tc_line
{
tc_vec3_s start;
tc_vec3_s end;
};
typedef union tc_primitive
{
tc_aabb_s aabb;
tc_obb_s obb;
tc_plane_s plane;
tc_ellipsoid_s sphere;
tc_plane_s plane;
tc_line_s line;
tc_ray_s ray;
} tc_primitive_u;
typedef struct tc_primitive
{
tc_primitive_type_e type;
tc_primitive_u data;
} tc_primitive_s;
struct tc_physics_mesh
{
uint32_t primitives_capacity;
uint32_t num_primitives;
tc_primitive_s *primitives;
};
#endif // TC_PHYSICS_PRIMITIVES_H