2023-10-15 08:21:36 +00:00
|
|
|
|
|
|
|
#ifndef TC_PHYSICS_SIMULATION_H
|
|
|
|
#define TC_PHYSICS_SIMULATION_H
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
2023-10-15 12:41:53 +00:00
|
|
|
#include <physics/primitives.h>
|
2023-10-15 08:21:36 +00:00
|
|
|
#include <utility/utility.h>
|
2023-10-15 12:41:53 +00:00
|
|
|
#include <entity.h>
|
2023-10-15 08:21:36 +00:00
|
|
|
|
|
|
|
typedef struct tc_physics_entity tc_physics_entity_s;
|
2023-10-15 12:41:53 +00:00
|
|
|
typedef struct tc_entity_physics_attributes tc_entity_physics_attributes_s;
|
2023-10-15 08:21:36 +00:00
|
|
|
|
|
|
|
struct tc_entity_physics_attributes
|
|
|
|
{
|
2023-10-15 12:41:53 +00:00
|
|
|
bool_t has_gravity;
|
2023-10-15 08:21:36 +00:00
|
|
|
|
2023-10-15 12:41:53 +00:00
|
|
|
bool_t raw_movement;
|
|
|
|
bool_t raw_rotation;
|
2023-10-15 08:21:36 +00:00
|
|
|
|
2023-10-15 12:41:53 +00:00
|
|
|
tc_vec3f_s acceleration;
|
|
|
|
tc_vec3f_s spin;
|
2023-10-15 08:21:36 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
TC_PHYSICS_ENTITY,
|
|
|
|
TC_PHYSICS_ENTITY_GROUP
|
|
|
|
|
|
|
|
} tc_physics_entity_type_e;
|
|
|
|
|
|
|
|
struct tc_physics_entity
|
|
|
|
{
|
2023-10-15 12:41:53 +00:00
|
|
|
tc_physics_entity_s *super;
|
2023-10-15 08:21:36 +00:00
|
|
|
|
|
|
|
// relative_position: The position of this physics entity relative to its super-entity
|
2023-10-15 12:41:53 +00:00
|
|
|
tc_vec3f_s relative_position;
|
2023-10-15 08:21:36 +00:00
|
|
|
|
2023-10-15 12:41:53 +00:00
|
|
|
tc_physics_entity_type_e type;
|
2023-10-15 08:21:36 +00:00
|
|
|
union specific
|
|
|
|
{
|
|
|
|
struct entity
|
|
|
|
{
|
2023-10-15 12:41:53 +00:00
|
|
|
char *name;
|
2023-10-15 08:21:36 +00:00
|
|
|
tc_entity_s *entity;
|
|
|
|
|
|
|
|
} entity;
|
|
|
|
|
|
|
|
struct subentity_group
|
|
|
|
{
|
2023-10-15 12:41:53 +00:00
|
|
|
u32_t num_entities;
|
2023-10-15 08:21:36 +00:00
|
|
|
tc_physics_entity_s *entities;
|
|
|
|
|
|
|
|
} group;
|
|
|
|
|
|
|
|
} value;
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct tc_physics_simulation
|
|
|
|
{
|
|
|
|
tc_physics_entity_s world_root;
|
|
|
|
|
|
|
|
} tc_physics_simulation_s;
|
|
|
|
|
|
|
|
tc_physics_simulation_s tc_new_physics_simulation ();
|
2023-10-15 12:41:53 +00:00
|
|
|
void tc_add_physics_object (tc_physics_simulation_s *simulation, tc_physics_entity_s object);
|
2023-10-15 08:21:36 +00:00
|
|
|
void tc_add_physics_object_to (tc_physics_entity_s *container, tc_physics_entity_s object);
|
|
|
|
|
2023-10-15 12:41:53 +00:00
|
|
|
tc_physics_entity_s tc_new_physics_entity ();
|
2023-10-15 08:21:36 +00:00
|
|
|
|
2023-10-15 12:41:53 +00:00
|
|
|
void tc_tick_physics (tc_physics_simulation_s *simulation, f32_t delta);
|
2023-10-15 08:21:36 +00:00
|
|
|
|
2023-10-15 12:41:53 +00:00
|
|
|
tc_primitive_s * tc_cast_line (tc_physics_simulation_s *simulation, tc_line_s line);
|
2023-10-15 08:21:36 +00:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|