refactor: decouple sim from framework, remove voxel geometry
This commit is contained in:
parent
c538641ec8
commit
5a565844dd
41 changed files with 477 additions and 2407 deletions
|
|
@ -73,6 +73,7 @@ static const char* pxl8_ffi_cdefs =
|
|||
"bool pxl8_key_down(const pxl8_input_state* input, const char* key_name);\n"
|
||||
"bool pxl8_key_pressed(const pxl8_input_state* input, const char* key_name);\n"
|
||||
"bool pxl8_key_released(const pxl8_input_state* input, const char* key_name);\n"
|
||||
"void pxl8_set_key_down(pxl8_input_state* input, const char* key_name, bool down);\n"
|
||||
"bool pxl8_mouse_pressed(const pxl8_input_state* input, i32 button);\n"
|
||||
"bool pxl8_mouse_released(const pxl8_input_state* input, i32 button);\n"
|
||||
"int pxl8_mouse_wheel_x(const pxl8_input_state* input);\n"
|
||||
|
|
@ -397,23 +398,15 @@ static const char* pxl8_ffi_cdefs =
|
|||
"void pxl8_graph_eval_texture(const pxl8_graph* graph, u8* buffer, i32 width, i32 height);\n"
|
||||
"\n"
|
||||
"typedef struct pxl8_bsp pxl8_bsp;\n"
|
||||
"typedef struct pxl8_vxl_chunk pxl8_vxl_chunk;\n"
|
||||
"\n"
|
||||
"u32 pxl8_bsp_face_count(const pxl8_bsp* bsp);\n"
|
||||
"pxl8_vec3 pxl8_bsp_face_normal(const pxl8_bsp* bsp, u32 face_id);\n"
|
||||
"u8 pxl8_bsp_light_at(const pxl8_bsp* bsp, f32 x, f32 y, f32 z, u8 ambient);\n"
|
||||
"\n"
|
||||
"typedef enum { PXL8_WORLD_CHUNK_VXL = 0, PXL8_WORLD_CHUNK_BSP = 1 } pxl8_world_chunk_type;\n"
|
||||
"\n"
|
||||
"typedef struct pxl8_world_chunk {\n"
|
||||
" pxl8_world_chunk_type type;\n"
|
||||
" u32 id;\n"
|
||||
" u32 version;\n"
|
||||
" i32 cx, cy, cz;\n"
|
||||
" union {\n"
|
||||
" pxl8_bsp* bsp;\n"
|
||||
" pxl8_vxl_chunk* voxels;\n"
|
||||
" };\n"
|
||||
" pxl8_bsp* bsp;\n"
|
||||
"} pxl8_world_chunk;\n"
|
||||
"\n"
|
||||
"typedef struct pxl8_world pxl8_world;\n"
|
||||
|
|
@ -432,10 +425,6 @@ static const char* pxl8_ffi_cdefs =
|
|||
"pxl8_ray pxl8_world_sweep(const pxl8_world* world, pxl8_vec3 from, pxl8_vec3 to, float radius);\n"
|
||||
"void pxl8_world_render(pxl8_world* world, pxl8_gfx* gfx, pxl8_vec3 camera_pos);\n"
|
||||
"void pxl8_world_set_bsp_material(pxl8_world* world, u16 material_id, const pxl8_gfx_material* material);\n"
|
||||
"i32 pxl8_world_get_render_distance(const pxl8_world* world);\n"
|
||||
"void pxl8_world_set_render_distance(pxl8_world* world, i32 distance);\n"
|
||||
"i32 pxl8_world_get_sim_distance(const pxl8_world* world);\n"
|
||||
"void pxl8_world_set_sim_distance(pxl8_world* world, i32 distance);\n"
|
||||
"\n"
|
||||
"typedef struct pxl8_sim_entity {\n"
|
||||
" pxl8_vec3 pos;\n"
|
||||
|
|
@ -463,6 +452,7 @@ static const char* pxl8_ffi_cdefs =
|
|||
"bool pxl8_gui_slider_int(pxl8_gui_state* state, pxl8_gfx* gfx, u32 id, i32 x, i32 y, i32 w, i32 h, i32* value, i32 min_val, i32 max_val);\n"
|
||||
"void pxl8_gui_window(pxl8_gfx* gfx, i32 x, i32 y, i32 w, i32 h, const char* title);\n"
|
||||
"void pxl8_gui_label(pxl8_gfx* gfx, i32 x, i32 y, const char* text, u8 color);\n"
|
||||
"u8 pxl8_gui_color(pxl8_gfx* gfx, u8 index);\n"
|
||||
"bool pxl8_gui_is_hovering(const pxl8_gui_state* state);\n"
|
||||
"void pxl8_gui_get_cursor_pos(const pxl8_gui_state* state, i32* x, i32* y);\n"
|
||||
"\n"
|
||||
|
|
@ -524,7 +514,7 @@ static const char* pxl8_ffi_cdefs =
|
|||
"\n"
|
||||
"typedef struct pxl8_net pxl8_net;\n"
|
||||
"typedef struct pxl8_net_config { const char* address; u16 port; } pxl8_net_config;\n"
|
||||
"typedef enum pxl8_cmd_type { PXL8_CMD_NONE = 0, PXL8_CMD_SPAWN_ENTITY, PXL8_CMD_EXIT_CHUNK, PXL8_CMD_ENTER_CHUNK } pxl8_cmd_type;\n"
|
||||
"typedef enum pxl8_cmd_type { PXL8_CMD_NONE = 0, PXL8_CMD_SPAWN_ENTITY, PXL8_CMD_ENTER_SCENE } pxl8_cmd_type;\n"
|
||||
"\n"
|
||||
"typedef struct pxl8_command_msg {\n"
|
||||
" u16 cmd_type;\n"
|
||||
|
|
@ -544,6 +534,32 @@ static const char* pxl8_ffi_cdefs =
|
|||
" u64 timestamp;\n"
|
||||
"} pxl8_input_msg;\n"
|
||||
"\n"
|
||||
"typedef struct pxl8_sim_config {\n"
|
||||
" f32 move_speed;\n"
|
||||
" f32 ground_accel;\n"
|
||||
" f32 air_accel;\n"
|
||||
" f32 stop_speed;\n"
|
||||
" f32 friction;\n"
|
||||
" f32 gravity;\n"
|
||||
" f32 jump_velocity;\n"
|
||||
" f32 player_radius;\n"
|
||||
" f32 player_height;\n"
|
||||
" f32 max_pitch;\n"
|
||||
"} pxl8_sim_config;\n"
|
||||
"\n"
|
||||
"typedef struct pxl8_sim_world {\n"
|
||||
" const pxl8_bsp* bsp;\n"
|
||||
"} pxl8_sim_world;\n"
|
||||
"\n"
|
||||
"void pxl8_sim_move_player(pxl8_sim_entity* ent, const pxl8_input_msg* input, const pxl8_sim_world* world, const pxl8_sim_config* cfg, f32 dt);\n"
|
||||
"void pxl8_sim_integrate(pxl8_sim_entity* ent, const pxl8_sim_world* world, const pxl8_sim_config* cfg, f32 dt);\n"
|
||||
"pxl8_vec3 pxl8_sim_trace(const pxl8_sim_world* world, pxl8_vec3 from, pxl8_vec3 to, f32 radius, f32 height);\n"
|
||||
"bool pxl8_sim_check_ground(const pxl8_sim_world* world, pxl8_vec3 pos, f32 radius);\n"
|
||||
"\n"
|
||||
"pxl8_sim_world pxl8_world_sim_world(const pxl8_world* world, pxl8_vec3 pos);\n"
|
||||
"void pxl8_world_set_sim_config(pxl8_world* world, const pxl8_sim_config* config);\n"
|
||||
"void pxl8_world_push_input(pxl8_world* world, const pxl8_input_msg* input);\n"
|
||||
"\n"
|
||||
"typedef struct pxl8_entity_state {\n"
|
||||
" u64 entity_id;\n"
|
||||
" u8 userdata[56];\n"
|
||||
|
|
@ -578,10 +594,8 @@ static const char* pxl8_ffi_cdefs =
|
|||
"void pxl8_net_predicted_tick_set(pxl8_net* net, u64 tick);\n"
|
||||
"i32 pxl8_net_send_command(pxl8_net* net, const pxl8_command_msg* cmd);\n"
|
||||
"i32 pxl8_net_send_input(pxl8_net* net, const pxl8_input_msg* input);\n"
|
||||
"i32 pxl8_net_send_chunk_settings(pxl8_net* net, i32 render_distance, i32 sim_distance);\n"
|
||||
"i32 pxl8_net_spawn(pxl8_net* net, f32 x, f32 y, f32 z, f32 yaw, f32 pitch);\n"
|
||||
"i32 pxl8_net_exit_chunk(pxl8_net* net, f32 x, f32 y, f32 z);\n"
|
||||
"i32 pxl8_net_enter_chunk(pxl8_net* net, u32 chunk_id);\n"
|
||||
"i32 pxl8_net_enter_scene(pxl8_net* net, u8 chunk_type, u32 chunk_id, f32 x, f32 y, f32 z);\n"
|
||||
"const pxl8_snapshot_header* pxl8_net_snapshot(const pxl8_net* net);\n"
|
||||
"u64 pxl8_net_tick(const pxl8_net* net);\n"
|
||||
"void pxl8_net_update(pxl8_net* net, f32 dt);\n"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue