2023-10-15 12:41:53 +00:00
|
|
|
#include <world.h>
|
|
|
|
#include <stddef.h> // For NULL
|
2023-10-15 15:20:51 +00:00
|
|
|
#include <stdio.h>
|
2023-10-15 12:41:53 +00:00
|
|
|
|
2023-10-15 15:20:51 +00:00
|
|
|
void tc_initialize_chunk_physics(tc_entity_s *chunk_entity, void *userdata)
|
2023-10-15 12:41:53 +00:00
|
|
|
{
|
2023-10-17 12:39:20 +00:00
|
|
|
/*
|
2023-10-15 15:20:51 +00:00
|
|
|
tc_chunk_s *chunk = chunk_entity->specific;
|
2023-10-17 11:25:02 +00:00
|
|
|
tc_world_s *world = chunk->location.world;
|
2023-10-15 15:20:51 +00:00
|
|
|
tc_physics_simulation_s *simulation = world->physics;
|
2023-10-15 12:41:53 +00:00
|
|
|
|
2023-10-15 15:20:51 +00:00
|
|
|
tc_physics_entity_s *chunk_body = tc_new_physics_group(simulation);
|
|
|
|
|
|
|
|
tc_vec3f_s block_start;
|
|
|
|
block_start.x = -0.5f;
|
|
|
|
block_start.y = -0.5f;
|
|
|
|
block_start.z = -0.5f;
|
|
|
|
|
|
|
|
tc_vec3f_s block_size;
|
|
|
|
block_size.x = 1.0f;
|
|
|
|
block_size.y = 1.0f;
|
|
|
|
block_size.z = 1.0f;
|
|
|
|
|
|
|
|
tc_physics_mesh_s block_mesh = tc_wrap_aabb(block_start, block_size);
|
|
|
|
|
|
|
|
for(u32_t x = 0; x < 32; ++x)
|
|
|
|
for(u32_t y = 0; y < 32; ++y)
|
|
|
|
for(u32_t z = 0; z < 32; ++z)
|
|
|
|
{
|
|
|
|
tc_physics_entity_s *block_entity = tc_new_physics_entity(simulation);
|
|
|
|
block_entity->relative_position.x = x;
|
|
|
|
block_entity->relative_position.y = y;
|
|
|
|
block_entity->relative_position.z = z;
|
|
|
|
block_entity->type = TC_PHYSICS_ENTITY;
|
|
|
|
block_entity->value.entity.mesh = block_mesh;
|
|
|
|
|
|
|
|
tc_add_physics_object_to(chunk_body, block_entity);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
tc_add_physics_object(world->physics, chunk_body);
|
|
|
|
tc_set_pointer_for_entity(chunk_entity, "physics_body", chunk_body);
|
2023-10-17 12:39:20 +00:00
|
|
|
*/
|
2023-10-15 12:41:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void tc_create_world_physics(tc_world_s *world, void *userdata)
|
|
|
|
{
|
|
|
|
world->physics = tc_new_physics_simulation();
|
2023-10-17 11:25:02 +00:00
|
|
|
tc_add_to_hooklist(&world->on_chunk_create, (tc_fn_hook) tc_initialize_chunk_physics, NULL);
|
|
|
|
tc_add_to_hooklist(&world->on_chunk_update, (tc_fn_hook) tc_initialize_chunk_physics, NULL);
|
2023-10-15 12:41:53 +00:00
|
|
|
}
|
|
|
|
|