pxl8/src/sim/pxl8_sim.h

54 lines
1.4 KiB
C
Raw Normal View History

2026-01-31 09:31:17 -06:00
#pragma once
#include "pxl8_bsp.h"
#include "pxl8_math.h"
#include "pxl8_protocol.h"
#include "pxl8_types.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)
typedef struct pxl8_sim_config {
f32 move_speed;
f32 ground_accel;
f32 air_accel;
f32 stop_speed;
f32 friction;
f32 gravity;
f32 jump_velocity;
f32 player_radius;
f32 player_height;
f32 max_pitch;
} pxl8_sim_config;
2026-01-31 09:31:17 -06:00
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;
} 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);
pxl8_vec3 pxl8_sim_trace(const pxl8_sim_world* world, pxl8_vec3 from, pxl8_vec3 to, f32 radius, f32 height);
2026-01-31 09:31:17 -06:00
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, const pxl8_sim_config* cfg, f32 dt);
void pxl8_sim_integrate(pxl8_sim_entity* ent, const pxl8_sim_world* world, const pxl8_sim_config* cfg, f32 dt);
2026-01-31 09:31:17 -06:00
#ifdef __cplusplus
}
#endif