pxl8/demo3d/client/world/demo3d_world.h

72 lines
2.5 KiB
C
Raw Normal View History

#pragma once
#include "demo3d_entity.h"
#include "pxl8_gfx.h"
#include "pxl8_gfx3d.h"
#include "pxl8_math.h"
#include "demo3d_net.h"
#include "demo3d_sim.h"
#include "pxl8_types.h"
#include "demo3d_chunk.h"
#include "demo3d_chunk_cache.h"
#include "demo3d_bsp_render.h"
#ifdef __cplusplus
extern "C" {
#endif
#define DEMO3D_WORLD_MAX_LOADED_CHUNKS 64
typedef struct {
u16 leafs[16];
u8 count;
} demo3d_edge_leafs;
typedef struct demo3d_loaded_chunk {
demo3d_chunk* chunk;
demo3d_bsp_render_state* render_state;
demo3d_edge_leafs edges[4];
i32 cx;
i32 cz;
bool active;
} demo3d_loaded_chunk;
typedef struct demo3d_world demo3d_world;
demo3d_world* demo3d_world_create(void);
void demo3d_world_destroy(demo3d_world* world);
demo3d_chunk_cache* demo3d_world_get_chunk_cache(demo3d_world* world);
demo3d_chunk* demo3d_world_active_chunk(demo3d_world* world);
bool demo3d_world_point_solid(const demo3d_world* world, f32 x, f32 y, f32 z);
pxl8_ray demo3d_world_ray(const demo3d_world* world, pxl8_vec3 from, pxl8_vec3 to);
pxl8_ray demo3d_world_sweep(const demo3d_world* world, pxl8_vec3 from, pxl8_vec3 to, f32 radius);
void demo3d_world_update(demo3d_world* world, f32 dt);
void demo3d_world_render(demo3d_world* world, pxl8_gfx* gfx, pxl8_vec3 camera_pos);
void demo3d_world_sync(demo3d_world* world, demo3d_net* net);
void demo3d_world_set_bsp_material(demo3d_world* world, u16 material_id, const pxl8_gfx_material* material);
void demo3d_world_set_sim_config(demo3d_world* world, const demo3d_sim_config* config);
void demo3d_world_init_local_player(demo3d_world* world, f32 x, f32 y, f32 z);
void demo3d_world_set_look(demo3d_world* world, f32 yaw, f32 pitch);
demo3d_sim_entity* demo3d_world_local_player(demo3d_world* world);
demo3d_sim_world demo3d_world_sim_world(const demo3d_world* world, pxl8_vec3 pos);
void demo3d_world_predict(demo3d_world* world, demo3d_net* net, const demo3d_input_msg* input, f32 dt);
void demo3d_world_reconcile(demo3d_world* world, demo3d_net* net, f32 dt);
#ifdef PXL8_ASYNC_THREADS
void demo3d_world_start_sim_thread(demo3d_world* world, demo3d_net* net);
void demo3d_world_stop_sim_thread(demo3d_world* world);
void demo3d_world_pause_sim(demo3d_world* world, bool paused);
void demo3d_world_push_input(demo3d_world* world, const demo3d_input_msg* input);
const demo3d_sim_entity* demo3d_world_get_render_state(const demo3d_world* world);
f32 demo3d_world_get_interp_alpha(const demo3d_world* world);
#endif
#ifdef __cplusplus
}
#endif