57 lines
1.7 KiB
C
57 lines
1.7 KiB
C
|
|
#pragma once
|
||
|
|
|
||
|
|
#include "pxl8_bsp.h"
|
||
|
|
#include "pxl8_math.h"
|
||
|
|
#include "pxl8_protocol.h"
|
||
|
|
#include "pxl8_types.h"
|
||
|
|
#include "pxl8_vxl.h"
|
||
|
|
|
||
|
|
#ifdef __cplusplus
|
||
|
|
extern "C" {
|
||
|
|
#endif
|
||
|
|
|
||
|
|
#define PXL8_SIM_FLAG_ALIVE (1 << 0)
|
||
|
|
#define PXL8_SIM_FLAG_PLAYER (1 << 1)
|
||
|
|
#define PXL8_SIM_FLAG_GROUNDED (1 << 2)
|
||
|
|
|
||
|
|
#define PXL8_SIM_MOVE_SPEED 180.0f
|
||
|
|
#define PXL8_SIM_GROUND_ACCEL 10.0f
|
||
|
|
#define PXL8_SIM_AIR_ACCEL 1.0f
|
||
|
|
#define PXL8_SIM_STOP_SPEED 100.0f
|
||
|
|
#define PXL8_SIM_FRICTION 6.0f
|
||
|
|
#define PXL8_SIM_GRAVITY 800.0f
|
||
|
|
#define PXL8_SIM_JUMP_VELOCITY 200.0f
|
||
|
|
#define PXL8_SIM_PLAYER_RADIUS 16.0f
|
||
|
|
#define PXL8_SIM_MAX_PITCH 1.5f
|
||
|
|
|
||
|
|
typedef struct pxl8_sim_entity {
|
||
|
|
pxl8_vec3 pos;
|
||
|
|
pxl8_vec3 vel;
|
||
|
|
f32 yaw;
|
||
|
|
f32 pitch;
|
||
|
|
u32 flags;
|
||
|
|
u16 kind;
|
||
|
|
u16 _pad;
|
||
|
|
} pxl8_sim_entity;
|
||
|
|
|
||
|
|
typedef struct pxl8_sim_world {
|
||
|
|
const pxl8_bsp* bsp;
|
||
|
|
const pxl8_vxl_chunk* vxl;
|
||
|
|
i32 vxl_cx, vxl_cy, vxl_cz;
|
||
|
|
} pxl8_sim_world;
|
||
|
|
|
||
|
|
bool pxl8_bsp_point_solid(const pxl8_bsp* bsp, pxl8_vec3 pos);
|
||
|
|
pxl8_vec3 pxl8_bsp_trace(const pxl8_bsp* bsp, pxl8_vec3 from, pxl8_vec3 to, f32 radius);
|
||
|
|
|
||
|
|
bool pxl8_vxl_point_solid(const pxl8_vxl_chunk* chunk, i32 cx, i32 cy, i32 cz, f32 x, f32 y, f32 z);
|
||
|
|
pxl8_vec3 pxl8_vxl_trace(const pxl8_vxl_chunk* chunk, i32 cx, i32 cy, i32 cz, pxl8_vec3 from, pxl8_vec3 to, f32 radius);
|
||
|
|
|
||
|
|
pxl8_vec3 pxl8_sim_trace(const pxl8_sim_world* world, pxl8_vec3 from, pxl8_vec3 to, f32 radius);
|
||
|
|
bool pxl8_sim_check_ground(const pxl8_sim_world* world, pxl8_vec3 pos, f32 radius);
|
||
|
|
void pxl8_sim_move_player(pxl8_sim_entity* ent, const pxl8_input_msg* input, const pxl8_sim_world* world, f32 dt);
|
||
|
|
void pxl8_sim_integrate(pxl8_sim_entity* ent, const pxl8_sim_world* world, f32 dt);
|
||
|
|
|
||
|
|
#ifdef __cplusplus
|
||
|
|
}
|
||
|
|
#endif
|