diff --git a/code/source-c/main.c b/code/source-c/main.c index 2fbaf5a..baed84d 100644 --- a/code/source-c/main.c +++ b/code/source-c/main.c @@ -290,9 +290,6 @@ bool update() tc_update_world(tc_game_state_g.main_world); - // uint64_t current_ms = SDL_GetTicks64(); - // uint32_t ticks_between = current_ms - tc_last_update; - return true; } diff --git a/code/source-c/physics/aabb.c b/code/source-c/physics/aabb.c new file mode 100644 index 0000000..37d6584 --- /dev/null +++ b/code/source-c/physics/aabb.c @@ -0,0 +1,4 @@ +#include "primitives.h" + + + diff --git a/code/source-c/physics/obb.c b/code/source-c/physics/obb.c new file mode 100644 index 0000000..4b3e9c8 --- /dev/null +++ b/code/source-c/physics/obb.c @@ -0,0 +1,3 @@ +#include "primitives.h" + + diff --git a/code/source-c/physics/physics.c b/code/source-c/physics/physics.c new file mode 100644 index 0000000..fd605c5 --- /dev/null +++ b/code/source-c/physics/physics.c @@ -0,0 +1,42 @@ +#include "simulation.h" + +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) +{ + + + +} + + diff --git a/code/source-c/physics/plane.c b/code/source-c/physics/plane.c new file mode 100644 index 0000000..37d6584 --- /dev/null +++ b/code/source-c/physics/plane.c @@ -0,0 +1,4 @@ +#include "primitives.h" + + + diff --git a/code/source-c/physics/primitives.h b/code/source-c/physics/primitives.h new file mode 100644 index 0000000..b6364d4 --- /dev/null +++ b/code/source-c/physics/primitives.h @@ -0,0 +1,97 @@ + +#ifndef TC_PHYSICS_PRIMITIVES_H +#define TC_PHYSICS_PRIMITIVES_H + +#include +#include + +#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 + diff --git a/code/source-c/physics/raycast.c b/code/source-c/physics/raycast.c new file mode 100644 index 0000000..ce43caf --- /dev/null +++ b/code/source-c/physics/raycast.c @@ -0,0 +1,10 @@ +#include "primitives.h" + +tc_primitive_s * tc_cast_line(tc_physics_simulation_s *simulation, tc_line_s line) +{ + + + + +} + diff --git a/code/source-c/physics/simulation.h b/code/source-c/physics/simulation.h new file mode 100644 index 0000000..12a27ee --- /dev/null +++ b/code/source-c/physics/simulation.h @@ -0,0 +1,78 @@ + +#ifndef TC_PHYSICS_SIMULATION_H +#define TC_PHYSICS_SIMULATION_H + +#include + +#include +#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 +