79 lines
1.9 KiB
C
79 lines
1.9 KiB
C
|
|
||
|
#ifndef TC_PHYSICS_SIMULATION_H
|
||
|
#define TC_PHYSICS_SIMULATION_H
|
||
|
|
||
|
#include <stdint.h>
|
||
|
|
||
|
#include <utility/utility.h>
|
||
|
#include <../entity.h>
|
||
|
|
||
|
typedef struct tc_physics_entity tc_physics_entity_s;
|
||
|
typedef struct tc_entity_physics_attributes tc_entity_physics_attributes;
|
||
|
|
||
|
struct tc_entity_physics_attributes
|
||
|
{
|
||
|
bool has_gravity;
|
||
|
|
||
|
bool raw_movement;
|
||
|
bool raw_rotation;
|
||
|
|
||
|
tc_vec3_s acceleration;
|
||
|
tc_vec3_s spin;
|
||
|
};
|
||
|
|
||
|
typedef enum
|
||
|
{
|
||
|
TC_PHYSICS_ENTITY,
|
||
|
TC_PHYSICS_ENTITY_GROUP
|
||
|
|
||
|
} tc_physics_entity_type_e;
|
||
|
|
||
|
struct tc_physics_entity
|
||
|
{
|
||
|
tc_physics_entity *super;
|
||
|
|
||
|
// relative_position: The position of this physics entity relative to its super-entity
|
||
|
tc_vec3_s relative_position;
|
||
|
|
||
|
tc_physics_entity_e type;
|
||
|
union specific
|
||
|
{
|
||
|
struct entity
|
||
|
{
|
||
|
tc_entity_s *entity;
|
||
|
|
||
|
} entity;
|
||
|
|
||
|
struct subentity_group
|
||
|
{
|
||
|
uint32_t num_entities;
|
||
|
tc_physics_entity_s *entities;
|
||
|
|
||
|
} group;
|
||
|
|
||
|
} value;
|
||
|
};
|
||
|
|
||
|
typedef struct tc_physics_simulation
|
||
|
{
|
||
|
tc_vec3_s limits;
|
||
|
|
||
|
tc_physics_entity_s world_root;
|
||
|
|
||
|
} tc_physics_simulation_s;
|
||
|
|
||
|
tc_physics_simulation_s tc_new_physics_simulation ();
|
||
|
void tc_add_physics_object (tc_physics_simulation_s *simulation, tc_physics_entity object);
|
||
|
void tc_add_physics_object_to (tc_physics_entity_s *container, tc_physics_entity_s object);
|
||
|
|
||
|
tc_phyiscs_entity_s tc_new_physics_entity ();
|
||
|
|
||
|
void tc_tick_physics (tc_physics_simulation_s *simulation, float delta);
|
||
|
|
||
|
|
||
|
|
||
|
tc_primitive_s tc_cast_line (tc_physics_simulation_s *simulation, tc_line_s line);
|
||
|
|
||
|
#endif
|
||
|
|