power_play/src/sim/sim_step.h
2025-07-28 15:58:03 -05:00

38 lines
1.3 KiB
C

struct space;
struct sim_snapshot;
struct sim_snapshot_list;
/* ========================== *
* Sim accel
* ========================== */
/* Structure used to accelerate up entity lookup (rebuilt every step) */
/* TODO: Remove this and do something better. Just a hack to de-couple old sim ctx from step. */
struct sim_accel {
struct space *space;
};
struct sim_accel sim_accel_alloc(void);
void sim_accel_release(struct sim_accel *accel);
void sim_accel_reset(struct sim_snapshot *ss, struct sim_accel *accel);
/* ========================== *
* Sim step
* ========================== */
struct sim_step_ctx {
b32 is_master;
struct sim_accel *accel;
struct rand_state rand; /* TODO: Replace with per-sim rand for deterministic rng */
struct sim_snapshot *world; /* The world to simulate */
i64 sim_dt_ns; /* How much sim time should progress */
struct sim_client *user_input_client; /* The client that contains input from the user thread */
struct sim_client *master_client; /* The master client to read snapshots from (nil if world is master) */
struct sim_client *publish_client; /* The publish client to write syncable state to (nil if skipping publish) */
};
void sim_step(struct sim_step_ctx *ctx);