rename SIM_ENT_PROP -> SEPROP

This commit is contained in:
jacob 2025-05-15 04:07:35 -05:00
parent f7c994678d
commit 50713144f6
6 changed files with 199 additions and 199 deletions

View File

@ -55,7 +55,7 @@ struct phys_collision_data_array phys_create_and_update_contacts(struct arena *a
for (u64 check0_index = 0; check0_index < ss->num_ents_reserved; ++check0_index) { for (u64 check0_index = 0; check0_index < ss->num_ents_reserved; ++check0_index) {
struct sim_ent *check0 = &ss->ents[check0_index]; struct sim_ent *check0 = &ss->ents[check0_index];
if (!sim_ent_is_valid_and_active(check0)) continue; if (!sim_ent_is_valid_and_active(check0)) continue;
if (!(sim_ent_has_prop(check0, SIM_ENT_PROP_PHYSICAL_DYNAMIC) || sim_ent_has_prop(check0, SIM_ENT_PROP_PHYSICAL_KINEMATIC))) continue; if (!(sim_ent_has_prop(check0, SEPROP_PHYSICAL_DYNAMIC) || sim_ent_has_prop(check0, SEPROP_PHYSICAL_KINEMATIC))) continue;
if (check0->local_collider.count <= 0) continue; if (check0->local_collider.count <= 0) continue;
struct xform check0_xf = sim_ent_get_xform(check0); struct xform check0_xf = sim_ent_get_xform(check0);
@ -68,7 +68,7 @@ struct phys_collision_data_array phys_create_and_update_contacts(struct arena *a
struct sim_ent *check1 = sim_ent_from_id(ss, space_entry->ent); struct sim_ent *check1 = sim_ent_from_id(ss, space_entry->ent);
if (check1 == check0) continue; if (check1 == check0) continue;
if (!sim_ent_is_valid_and_active(check1)) continue; if (!sim_ent_is_valid_and_active(check1)) continue;
if (!(sim_ent_has_prop(check1, SIM_ENT_PROP_PHYSICAL_DYNAMIC) || sim_ent_has_prop(check1, SIM_ENT_PROP_PHYSICAL_KINEMATIC))) continue; if (!(sim_ent_has_prop(check1, SEPROP_PHYSICAL_DYNAMIC) || sim_ent_has_prop(check1, SEPROP_PHYSICAL_KINEMATIC))) continue;
if (check1->local_collider.count <= 0) continue; if (check1->local_collider.count <= 0) continue;
/* Deterministic order based on entity id */ /* Deterministic order based on entity id */
@ -121,12 +121,12 @@ struct phys_collision_data_array phys_create_and_update_contacts(struct arena *a
constraint_ent = sim_ent_alloc_local_with_id(root, constraint_id); constraint_ent = sim_ent_alloc_local_with_id(root, constraint_id);
constraint_ent->contact_constraint_data.e0 = e0->id; constraint_ent->contact_constraint_data.e0 = e0->id;
constraint_ent->contact_constraint_data.e1 = e1->id; constraint_ent->contact_constraint_data.e1 = e1->id;
constraint_ent->contact_constraint_data.skip_solve = sim_ent_has_prop(e0, SIM_ENT_PROP_SENSOR) || sim_ent_has_prop(e1, SIM_ENT_PROP_SENSOR) constraint_ent->contact_constraint_data.skip_solve = sim_ent_has_prop(e0, SEPROP_SENSOR) || sim_ent_has_prop(e1, SEPROP_SENSOR)
|| !(sim_ent_has_prop(e0, SIM_ENT_PROP_PHYSICAL_DYNAMIC) || sim_ent_has_prop(e1, SIM_ENT_PROP_PHYSICAL_DYNAMIC)); || !(sim_ent_has_prop(e0, SEPROP_PHYSICAL_DYNAMIC) || sim_ent_has_prop(e1, SEPROP_PHYSICAL_DYNAMIC));
sim_ent_enable_prop(constraint_ent, SIM_ENT_PROP_ACTIVE); sim_ent_enable_prop(constraint_ent, SEPROP_ACTIVE);
/* TODO: Should we recalculate normal as more contact points are added? */ /* TODO: Should we recalculate normal as more contact points are added? */
sim_ent_enable_prop(constraint_ent, SIM_ENT_PROP_CONTACT_CONSTRAINT); sim_ent_enable_prop(constraint_ent, SEPROP_CONTACT_CONSTRAINT);
sim_ent_activate(constraint_ent, tick); sim_ent_activate(constraint_ent, tick);
} }
@ -234,7 +234,7 @@ struct phys_collision_data_array phys_create_and_update_contacts(struct arena *a
if (!dbg_ent->valid) { if (!dbg_ent->valid) {
/* FIXME: Entity never released */ /* FIXME: Entity never released */
dbg_ent = sim_ent_alloc_local(root); dbg_ent = sim_ent_alloc_local(root);
sim_ent_enable_prop(dbg_ent, SIM_ENT_PROP_COLLISION_DEBUG); sim_ent_enable_prop(dbg_ent, SEPROP_COLLISION_DEBUG);
sim_lookup_set(debug_lookup, key, dbg_ent->handle); sim_lookup_set(debug_lookup, key, dbg_ent->handle);
} }
@ -276,7 +276,7 @@ void phys_prepare_contacts(struct phys_step_ctx *ctx, u64 phys_iteration)
for (u64 sim_ent_index = 0; sim_ent_index < ss->num_ents_reserved; ++sim_ent_index) { for (u64 sim_ent_index = 0; sim_ent_index < ss->num_ents_reserved; ++sim_ent_index) {
struct sim_ent *constraint_ent = &ss->ents[sim_ent_index]; struct sim_ent *constraint_ent = &ss->ents[sim_ent_index];
if (!sim_ent_should_simulate(constraint_ent)) continue; if (!sim_ent_should_simulate(constraint_ent)) continue;
if (!sim_ent_has_prop(constraint_ent, SIM_ENT_PROP_CONTACT_CONSTRAINT)) continue; if (!sim_ent_has_prop(constraint_ent, SEPROP_CONTACT_CONSTRAINT)) continue;
struct phys_contact_constraint *constraint = &constraint_ent->contact_constraint_data; struct phys_contact_constraint *constraint = &constraint_ent->contact_constraint_data;
@ -323,11 +323,11 @@ void phys_prepare_contacts(struct phys_step_ctx *ctx, u64 phys_iteration)
constraint->inv_i0 = inv_i0; constraint->inv_i0 = inv_i0;
constraint->inv_i1 = inv_i1; constraint->inv_i1 = inv_i1;
if (sim_ent_has_prop(e0, SIM_ENT_PROP_PHYSICAL_KINEMATIC)) { if (sim_ent_has_prop(e0, SEPROP_PHYSICAL_KINEMATIC)) {
constraint->inv_m0 = 0; constraint->inv_m0 = 0;
constraint->inv_i0 = 0; constraint->inv_i0 = 0;
} }
if (sim_ent_has_prop(e1, SIM_ENT_PROP_PHYSICAL_KINEMATIC)) { if (sim_ent_has_prop(e1, SEPROP_PHYSICAL_KINEMATIC)) {
constraint->inv_m1 = 0; constraint->inv_m1 = 0;
constraint->inv_i1 = 0; constraint->inv_i1 = 0;
} }
@ -363,8 +363,8 @@ void phys_prepare_contacts(struct phys_step_ctx *ctx, u64 phys_iteration)
} else { } else {
/* Mark constraint for removal */ /* Mark constraint for removal */
constraint_ent->contact_constraint_data.num_points = 0; constraint_ent->contact_constraint_data.num_points = 0;
sim_ent_disable_prop(constraint_ent, SIM_ENT_PROP_ACTIVE); sim_ent_disable_prop(constraint_ent, SEPROP_ACTIVE);
sim_ent_enable_prop(constraint_ent, SIM_ENT_PROP_RELEASE); sim_ent_enable_prop(constraint_ent, SEPROP_RELEASE);
} }
} }
@ -373,7 +373,7 @@ void phys_prepare_contacts(struct phys_step_ctx *ctx, u64 phys_iteration)
for (u64 sim_ent_index = 0; sim_ent_index < ss->num_ents_reserved; ++sim_ent_index) { for (u64 sim_ent_index = 0; sim_ent_index < ss->num_ents_reserved; ++sim_ent_index) {
struct sim_ent *dbg_ent = &ss->ents[sim_ent_index]; struct sim_ent *dbg_ent = &ss->ents[sim_ent_index];
if (!sim_ent_should_simulate(dbg_ent)) continue; if (!sim_ent_should_simulate(dbg_ent)) continue;
if (!sim_ent_has_prop(dbg_ent, SIM_ENT_PROP_COLLISION_DEBUG)) continue; if (!sim_ent_has_prop(dbg_ent, SEPROP_COLLISION_DEBUG)) continue;
struct phys_collision_debug *dbg = &dbg_ent->collision_debug_data; struct phys_collision_debug *dbg = &dbg_ent->collision_debug_data;
struct sim_ent *e0 = sim_ent_from_id(ss, dbg->e0); struct sim_ent *e0 = sim_ent_from_id(ss, dbg->e0);
@ -381,11 +381,11 @@ void phys_prepare_contacts(struct phys_step_ctx *ctx, u64 phys_iteration)
if (!sim_ent_should_simulate(e0) || !sim_ent_should_simulate(e1) if (!sim_ent_should_simulate(e0) || !sim_ent_should_simulate(e1)
|| !(sim_ent_has_prop(e0, SIM_ENT_PROP_PHYSICAL_DYNAMIC) || sim_ent_has_prop(e0, SIM_ENT_PROP_PHYSICAL_KINEMATIC)) || !(sim_ent_has_prop(e0, SEPROP_PHYSICAL_DYNAMIC) || sim_ent_has_prop(e0, SEPROP_PHYSICAL_KINEMATIC))
|| !(sim_ent_has_prop(e1, SIM_ENT_PROP_PHYSICAL_DYNAMIC) || sim_ent_has_prop(e1, SIM_ENT_PROP_PHYSICAL_KINEMATIC))) { || !(sim_ent_has_prop(e1, SEPROP_PHYSICAL_DYNAMIC) || sim_ent_has_prop(e1, SEPROP_PHYSICAL_KINEMATIC))) {
/* Mark dbg ent for removal */ /* Mark dbg ent for removal */
sim_ent_disable_prop(dbg_ent, SIM_ENT_PROP_ACTIVE); sim_ent_disable_prop(dbg_ent, SEPROP_ACTIVE);
sim_ent_enable_prop(dbg_ent, SIM_ENT_PROP_RELEASE); sim_ent_enable_prop(dbg_ent, SEPROP_RELEASE);
/* Remove from lookup */ /* Remove from lookup */
struct sim_lookup_key key = sim_lookup_key_from_two_handles(dbg->e0, dbg->e1); struct sim_lookup_key key = sim_lookup_key_from_two_handles(dbg->e0, dbg->e1);
@ -408,7 +408,7 @@ void phys_warm_start_contacts(struct phys_step_ctx *ctx)
for (u64 sim_ent_index = 0; sim_ent_index < ss->num_ents_reserved; ++sim_ent_index) { for (u64 sim_ent_index = 0; sim_ent_index < ss->num_ents_reserved; ++sim_ent_index) {
struct sim_ent *constraint_ent = &ss->ents[sim_ent_index]; struct sim_ent *constraint_ent = &ss->ents[sim_ent_index];
if (!sim_ent_should_simulate(constraint_ent)) continue; if (!sim_ent_should_simulate(constraint_ent)) continue;
if (!sim_ent_has_prop(constraint_ent, SIM_ENT_PROP_CONTACT_CONSTRAINT)) continue; if (!sim_ent_has_prop(constraint_ent, SEPROP_CONTACT_CONSTRAINT)) continue;
struct phys_contact_constraint *constraint = &constraint_ent->contact_constraint_data; struct phys_contact_constraint *constraint = &constraint_ent->contact_constraint_data;
@ -463,7 +463,7 @@ void phys_solve_contacts(struct phys_step_ctx *ctx, f32 dt, b32 apply_bias)
for (u64 sim_ent_index = 0; sim_ent_index < ss->num_ents_reserved; ++sim_ent_index) { for (u64 sim_ent_index = 0; sim_ent_index < ss->num_ents_reserved; ++sim_ent_index) {
struct sim_ent *constraint_ent = &ss->ents[sim_ent_index]; struct sim_ent *constraint_ent = &ss->ents[sim_ent_index];
if (!sim_ent_should_simulate(constraint_ent)) continue; if (!sim_ent_should_simulate(constraint_ent)) continue;
if (!sim_ent_has_prop(constraint_ent, SIM_ENT_PROP_CONTACT_CONSTRAINT)) continue; if (!sim_ent_has_prop(constraint_ent, SEPROP_CONTACT_CONSTRAINT)) continue;
struct phys_contact_constraint *constraint = &constraint_ent->contact_constraint_data; struct phys_contact_constraint *constraint = &constraint_ent->contact_constraint_data;
@ -594,7 +594,7 @@ void phys_prepare_motor_joints(struct phys_step_ctx *ctx)
for (u64 sim_ent_index = 0; sim_ent_index < ss->num_ents_reserved; ++sim_ent_index) { for (u64 sim_ent_index = 0; sim_ent_index < ss->num_ents_reserved; ++sim_ent_index) {
struct sim_ent *joint_ent = &ss->ents[sim_ent_index]; struct sim_ent *joint_ent = &ss->ents[sim_ent_index];
if (!sim_ent_should_simulate(joint_ent)) continue; if (!sim_ent_should_simulate(joint_ent)) continue;
if (!sim_ent_has_prop(joint_ent, SIM_ENT_PROP_MOTOR_JOINT)) continue; if (!sim_ent_has_prop(joint_ent, SEPROP_MOTOR_JOINT)) continue;
struct phys_motor_joint *joint = &joint_ent->motor_joint_data; struct phys_motor_joint *joint = &joint_ent->motor_joint_data;
@ -645,8 +645,8 @@ void phys_prepare_motor_joints(struct phys_step_ctx *ctx)
#endif #endif
} else { } else {
/* Mark joint for removal */ /* Mark joint for removal */
sim_ent_disable_prop(joint_ent, SIM_ENT_PROP_ACTIVE); sim_ent_disable_prop(joint_ent, SEPROP_ACTIVE);
sim_ent_enable_prop(joint_ent, SIM_ENT_PROP_RELEASE); sim_ent_enable_prop(joint_ent, SEPROP_RELEASE);
} }
} }
} }
@ -658,7 +658,7 @@ void phys_warm_start_motor_joints(struct phys_step_ctx *ctx)
for (u64 sim_ent_index = 0; sim_ent_index < ss->num_ents_reserved; ++sim_ent_index) { for (u64 sim_ent_index = 0; sim_ent_index < ss->num_ents_reserved; ++sim_ent_index) {
struct sim_ent *joint_ent = &ss->ents[sim_ent_index]; struct sim_ent *joint_ent = &ss->ents[sim_ent_index];
if (!sim_ent_should_simulate(joint_ent)) continue; if (!sim_ent_should_simulate(joint_ent)) continue;
if (!sim_ent_has_prop(joint_ent, SIM_ENT_PROP_MOTOR_JOINT)) continue; if (!sim_ent_has_prop(joint_ent, SEPROP_MOTOR_JOINT)) continue;
struct phys_motor_joint *joint = &joint_ent->motor_joint_data; struct phys_motor_joint *joint = &joint_ent->motor_joint_data;
@ -690,7 +690,7 @@ void phys_solve_motor_joints(struct phys_step_ctx *ctx, f32 dt)
for (u64 sim_ent_index = 0; sim_ent_index < ss->num_ents_reserved; ++sim_ent_index) { for (u64 sim_ent_index = 0; sim_ent_index < ss->num_ents_reserved; ++sim_ent_index) {
struct sim_ent *joint_ent = &ss->ents[sim_ent_index]; struct sim_ent *joint_ent = &ss->ents[sim_ent_index];
if (!sim_ent_should_simulate(joint_ent)) continue; if (!sim_ent_should_simulate(joint_ent)) continue;
if (!sim_ent_has_prop(joint_ent, SIM_ENT_PROP_MOTOR_JOINT)) continue; if (!sim_ent_has_prop(joint_ent, SEPROP_MOTOR_JOINT)) continue;
struct phys_motor_joint *joint = &joint_ent->motor_joint_data; struct phys_motor_joint *joint = &joint_ent->motor_joint_data;
@ -783,7 +783,7 @@ void phys_prepare_mouse_joints(struct phys_step_ctx *ctx)
for (u64 sim_ent_index = 0; sim_ent_index < ss->num_ents_reserved; ++sim_ent_index) { for (u64 sim_ent_index = 0; sim_ent_index < ss->num_ents_reserved; ++sim_ent_index) {
struct sim_ent *joint_ent = &ss->ents[sim_ent_index]; struct sim_ent *joint_ent = &ss->ents[sim_ent_index];
if (!sim_ent_should_simulate(joint_ent)) continue; if (!sim_ent_should_simulate(joint_ent)) continue;
if (!sim_ent_has_prop(joint_ent, SIM_ENT_PROP_MOUSE_JOINT)) continue; if (!sim_ent_has_prop(joint_ent, SEPROP_MOUSE_JOINT)) continue;
struct phys_mouse_joint *joint = &joint_ent->mouse_joint_data; struct phys_mouse_joint *joint = &joint_ent->mouse_joint_data;
struct sim_ent *ent = sim_ent_from_id(ss, joint->target); struct sim_ent *ent = sim_ent_from_id(ss, joint->target);
@ -817,8 +817,8 @@ void phys_prepare_mouse_joints(struct phys_step_ctx *ctx)
#endif #endif
} else { } else {
/* Mark joint for removal */ /* Mark joint for removal */
sim_ent_disable_prop(joint_ent, SIM_ENT_PROP_ACTIVE); sim_ent_disable_prop(joint_ent, SEPROP_ACTIVE);
sim_ent_enable_prop(joint_ent, SIM_ENT_PROP_RELEASE); sim_ent_enable_prop(joint_ent, SEPROP_RELEASE);
} }
} }
} }
@ -830,7 +830,7 @@ void phys_warm_start_mouse_joints(struct phys_step_ctx *ctx)
for (u64 sim_ent_index = 0; sim_ent_index < ss->num_ents_reserved; ++sim_ent_index) { for (u64 sim_ent_index = 0; sim_ent_index < ss->num_ents_reserved; ++sim_ent_index) {
struct sim_ent *joint_ent = &ss->ents[sim_ent_index]; struct sim_ent *joint_ent = &ss->ents[sim_ent_index];
if (!sim_ent_should_simulate(joint_ent)) continue; if (!sim_ent_should_simulate(joint_ent)) continue;
if (!sim_ent_has_prop(joint_ent, SIM_ENT_PROP_MOUSE_JOINT)) continue; if (!sim_ent_has_prop(joint_ent, SEPROP_MOUSE_JOINT)) continue;
struct phys_mouse_joint *joint = &joint_ent->mouse_joint_data; struct phys_mouse_joint *joint = &joint_ent->mouse_joint_data;
struct sim_ent *ent = sim_ent_from_id(ss, joint->target); struct sim_ent *ent = sim_ent_from_id(ss, joint->target);
@ -852,7 +852,7 @@ void phys_solve_mouse_joints(struct phys_step_ctx *ctx, f32 dt)
for (u64 sim_ent_index = 0; sim_ent_index < ss->num_ents_reserved; ++sim_ent_index) { for (u64 sim_ent_index = 0; sim_ent_index < ss->num_ents_reserved; ++sim_ent_index) {
struct sim_ent *joint_ent = &ss->ents[sim_ent_index]; struct sim_ent *joint_ent = &ss->ents[sim_ent_index];
if (!sim_ent_should_simulate(joint_ent)) continue; if (!sim_ent_should_simulate(joint_ent)) continue;
if (!sim_ent_has_prop(joint_ent, SIM_ENT_PROP_MOUSE_JOINT)) continue; if (!sim_ent_has_prop(joint_ent, SEPROP_MOUSE_JOINT)) continue;
struct phys_mouse_joint *joint = &joint_ent->mouse_joint_data; struct phys_mouse_joint *joint = &joint_ent->mouse_joint_data;
struct sim_ent *ent = sim_ent_from_id(ss, joint->target); struct sim_ent *ent = sim_ent_from_id(ss, joint->target);
@ -940,8 +940,8 @@ void phys_integrate_forces(struct phys_step_ctx *ctx, f32 dt)
struct sim_ent *ent = &ss->ents[sim_ent_index]; struct sim_ent *ent = &ss->ents[sim_ent_index];
if (!sim_ent_should_simulate(ent)) continue; if (!sim_ent_should_simulate(ent)) continue;
b32 is_dynamic = sim_ent_has_prop(ent, SIM_ENT_PROP_PHYSICAL_DYNAMIC); b32 is_dynamic = sim_ent_has_prop(ent, SEPROP_PHYSICAL_DYNAMIC);
b32 is_kinematic = sim_ent_has_prop(ent, SIM_ENT_PROP_PHYSICAL_KINEMATIC); b32 is_kinematic = sim_ent_has_prop(ent, SEPROP_PHYSICAL_KINEMATIC);
if (is_dynamic || is_kinematic) { if (is_dynamic || is_kinematic) {
struct v2 linear_velocity = ent->linear_velocity; struct v2 linear_velocity = ent->linear_velocity;
f32 angular_velocity = ent->angular_velocity; f32 angular_velocity = ent->angular_velocity;
@ -981,7 +981,7 @@ void phys_integrate_velocities(struct phys_step_ctx *ctx, f32 dt)
for (u64 sim_ent_index = 0; sim_ent_index < ss->num_ents_reserved; ++sim_ent_index) { for (u64 sim_ent_index = 0; sim_ent_index < ss->num_ents_reserved; ++sim_ent_index) {
struct sim_ent *ent = &ss->ents[sim_ent_index]; struct sim_ent *ent = &ss->ents[sim_ent_index];
if (!sim_ent_should_simulate(ent)) continue; if (!sim_ent_should_simulate(ent)) continue;
if (!sim_ent_has_prop(ent, SIM_ENT_PROP_PHYSICAL_DYNAMIC) && !sim_ent_has_prop(ent, SIM_ENT_PROP_PHYSICAL_KINEMATIC)) continue; if (!sim_ent_has_prop(ent, SEPROP_PHYSICAL_DYNAMIC) && !sim_ent_has_prop(ent, SEPROP_PHYSICAL_KINEMATIC)) continue;
struct xform xf = get_derived_xform(ent, dt); struct xform xf = get_derived_xform(ent, dt);
sim_ent_set_xform(ent, xf); sim_ent_set_xform(ent, xf);
@ -1002,8 +1002,8 @@ f32 phys_determine_earliest_toi_for_bullets(struct phys_step_ctx *ctx, f32 step_
for (u64 e0_index = 0; e0_index < ss->num_ents_reserved; ++e0_index) { for (u64 e0_index = 0; e0_index < ss->num_ents_reserved; ++e0_index) {
struct sim_ent *e0 = &ss->ents[e0_index]; struct sim_ent *e0 = &ss->ents[e0_index];
if (!sim_ent_should_simulate(e0)) continue; if (!sim_ent_should_simulate(e0)) continue;
if (!(sim_ent_has_prop(e0, SIM_ENT_PROP_PHYSICAL_DYNAMIC) || sim_ent_has_prop(e0, SIM_ENT_PROP_PHYSICAL_KINEMATIC))) continue; if (!(sim_ent_has_prop(e0, SEPROP_PHYSICAL_DYNAMIC) || sim_ent_has_prop(e0, SEPROP_PHYSICAL_KINEMATIC))) continue;
if (!sim_ent_has_prop(e0, SIM_ENT_PROP_BULLET)) continue; if (!sim_ent_has_prop(e0, SEPROP_BULLET)) continue;
if (e0->local_collider.count <= 0) continue; if (e0->local_collider.count <= 0) continue;
struct collider_shape e0_collider = e0->local_collider; struct collider_shape e0_collider = e0->local_collider;
@ -1021,7 +1021,7 @@ f32 phys_determine_earliest_toi_for_bullets(struct phys_step_ctx *ctx, f32 step_
struct sim_ent *e1 = sim_ent_from_id(ss, entry->ent); struct sim_ent *e1 = sim_ent_from_id(ss, entry->ent);
if (e1 == e0) continue; if (e1 == e0) continue;
if (!sim_ent_should_simulate(e1)) continue; if (!sim_ent_should_simulate(e1)) continue;
if (!(sim_ent_has_prop(e1, SIM_ENT_PROP_PHYSICAL_DYNAMIC) || sim_ent_has_prop(e1, SIM_ENT_PROP_PHYSICAL_KINEMATIC))) continue; if (!(sim_ent_has_prop(e1, SEPROP_PHYSICAL_DYNAMIC) || sim_ent_has_prop(e1, SEPROP_PHYSICAL_KINEMATIC))) continue;
if (e1->local_collider.count <= 0) continue; if (e1->local_collider.count <= 0) continue;
struct collider_shape e1_collider = e1->local_collider; struct collider_shape e1_collider = e1->local_collider;

View File

@ -618,7 +618,7 @@ void sim_snapshot_sync_ents(struct sim_snapshot *local_ss, struct sim_snapshot *
/* Sync ents with remote, skipping index 0 (nil) & index 1 (root) */ /* Sync ents with remote, skipping index 0 (nil) & index 1 (root) */
for (u64 i = 2; i < local_ss->num_ents_reserved; ++i) { for (u64 i = 2; i < local_ss->num_ents_reserved; ++i) {
struct sim_ent *local_ent = &local_ss->ents[i]; struct sim_ent *local_ent = &local_ss->ents[i];
if (local_ent->valid && sim_ent_has_prop(local_ent, SIM_ENT_PROP_SYNC_DST)) { if (local_ent->valid && sim_ent_has_prop(local_ent, SEPROP_SYNC_DST)) {
b32 should_sync = sim_ent_id_eq(local_ent->owner, remote_player) || sim_ent_id_is_nil(remote_player); b32 should_sync = sim_ent_id_eq(local_ent->owner, remote_player) || sim_ent_id_is_nil(remote_player);
if ((sync_flags & SIM_SYNC_FLAG_NOSYNC_PREDICTABLES) && sim_ent_id_eq(local_ent->predictor, local_ss->local_player)) { if ((sync_flags & SIM_SYNC_FLAG_NOSYNC_PREDICTABLES) && sim_ent_id_eq(local_ent->predictor, local_ss->local_player)) {
should_sync = false; should_sync = false;
@ -630,13 +630,13 @@ void sim_snapshot_sync_ents(struct sim_snapshot *local_ss, struct sim_snapshot *
sim_ent_sync(local_ent, remote_ent); sim_ent_sync(local_ent, remote_ent);
} else { } else {
/* Remote ent is no longer valid / networked, release it */ /* Remote ent is no longer valid / networked, release it */
sim_ent_enable_prop(local_ent, SIM_ENT_PROP_RELEASE); sim_ent_enable_prop(local_ent, SEPROP_RELEASE);
sim_ent_disable_prop(local_ent, SIM_ENT_PROP_SYNC_DST); sim_ent_disable_prop(local_ent, SEPROP_SYNC_DST);
} }
} }
} }
} }
sim_ent_release_all_with_prop(local_ss, SIM_ENT_PROP_RELEASE); sim_ent_release_all_with_prop(local_ss, SEPROP_RELEASE);
} }
@ -922,7 +922,7 @@ void sim_snapshot_decode(struct bitbuff_reader *br, struct sim_snapshot *ss)
struct sim_ent *e = sim_ent_from_index(ss, e); struct sim_ent *e = sim_ent_from_index(ss, e);
ASSERT(e->valid); /* An entity that we don't have allocated should never have been marked for release */ ASSERT(e->valid); /* An entity that we don't have allocated should never have been marked for release */
if (e->valid) { if (e->valid) {
sim_ent_enable_prop(e, SIM_ENT_PROP_RELEASE); sim_ent_enable_prop(e, SEPROP_RELEASE);
} }
} else { } else {
alloc_parent_index = br_read_uv(); alloc_parent_index = br_read_uv();
@ -1008,7 +1008,7 @@ void sim_snapshot_decode(struct bitbuff_reader *br, struct sim_snapshot *ss)
if (br_read_bit(br)) { if (br_read_bit(br)) {
struct sim_ent_decode_node *n = arena_push_zero(scratch.arena, struct sim_ent_decode_node) struct sim_ent_decode_node *n = arena_push_zero(scratch.arena, struct sim_ent_decode_node)
} else { } else {
sim_ent_enable_prop(e, SIM_ENT_PROP_RELEASE); sim_ent_enable_prop(e, SEPROP_RELEASE);
} }
} }
} }
@ -1027,13 +1027,13 @@ void sim_snapshot_decode(struct bitbuff_reader *br, struct sim_snapshot *ss)
/* Why is an already released ent being marked as released? */ /* Why is an already released ent being marked as released? */
ASSERT(e->valid); ASSERT(e->valid);
if (e->valid) { if (e->valid) {
sim_ent_enable_prop(e, SIM_ENT_PROP_RELEASE); sim_ent_enable_prop(e, SEPROP_RELEASE);
} }
} else { } else {
sim_ent_decode(br, e); sim_ent_decode(br, e);
} }
} }
sim_ent_release_all_with_prop(ss, SIM_ENT_PROP_RELEASE); sim_ent_release_all_with_prop(ss, SEPROP_RELEASE);
#endif #endif
scratch_end(scratch); scratch_end(scratch);

View File

@ -77,7 +77,7 @@ struct sim_ent *sim_ent_alloc_sync_src(struct sim_ent *parent)
{ {
struct sim_snapshot *ss = parent->ss; struct sim_snapshot *ss = parent->ss;
struct sim_ent *e = sim_ent_alloc_raw(ss, parent, sim_ent_random_id()); struct sim_ent *e = sim_ent_alloc_raw(ss, parent, sim_ent_random_id());
sim_ent_enable_prop(e, SIM_ENT_PROP_SYNC_SRC); sim_ent_enable_prop(e, SEPROP_SYNC_SRC);
e->owner = ss->local_player; e->owner = ss->local_player;
return e; return e;
} }
@ -86,7 +86,7 @@ struct sim_ent *sim_ent_alloc_sync_src_with_id(struct sim_ent *parent, struct si
{ {
struct sim_snapshot *ss = parent->ss; struct sim_snapshot *ss = parent->ss;
struct sim_ent *e = sim_ent_alloc_raw(ss, parent, id); struct sim_ent *e = sim_ent_alloc_raw(ss, parent, id);
sim_ent_enable_prop(e, SIM_ENT_PROP_SYNC_SRC); sim_ent_enable_prop(e, SEPROP_SYNC_SRC);
e->owner = ss->local_player; e->owner = ss->local_player;
return e; return e;
} }
@ -96,7 +96,7 @@ struct sim_ent *sim_ent_alloc_sync_dst(struct sim_ent *parent, struct sim_ent_id
{ {
struct sim_snapshot *ss = parent->ss; struct sim_snapshot *ss = parent->ss;
struct sim_ent *e = sim_ent_alloc_raw(ss, parent, ent_id); struct sim_ent *e = sim_ent_alloc_raw(ss, parent, ent_id);
sim_ent_enable_prop(e, SIM_ENT_PROP_SYNC_DST); sim_ent_enable_prop(e, SEPROP_SYNC_DST);
e->owner = owner_id; e->owner = owner_id;
return e; return e;
} }
@ -151,7 +151,7 @@ void sim_ent_release_all_with_prop(struct sim_snapshot *ss, enum sim_ent_prop pr
* child entities will be released along with parent anyway) */ * child entities will be released along with parent anyway) */
for (u64 i = 0; i < ents_to_release_count; ++i) { for (u64 i = 0; i < ents_to_release_count; ++i) {
struct sim_ent *ent = ents_to_release[i]; struct sim_ent *ent = ents_to_release[i];
if (ent->valid && !ent->is_root && !sim_ent_has_prop(ent, SIM_ENT_PROP_CMD) && !sim_ent_has_prop(ent, SIM_ENT_PROP_PLAYER)) { if (ent->valid && !ent->is_root && !sim_ent_has_prop(ent, SEPROP_CMD) && !sim_ent_has_prop(ent, SEPROP_PLAYER)) {
sim_ent_release(ent); sim_ent_release(ent);
} }
} }
@ -165,7 +165,7 @@ void sim_ent_release_all_with_prop(struct sim_snapshot *ss, enum sim_ent_prop pr
void sim_ent_activate(struct sim_ent *ent, u64 current_tick) void sim_ent_activate(struct sim_ent *ent, u64 current_tick)
{ {
sim_ent_enable_prop(ent, SIM_ENT_PROP_ACTIVE); sim_ent_enable_prop(ent, SEPROP_ACTIVE);
ent->activation_tick = current_tick; ent->activation_tick = current_tick;
++ent->continuity_gen; ++ent->continuity_gen;
} }
@ -592,7 +592,7 @@ void sim_ent_lerp(struct sim_ent *e, struct sim_ent *e0, struct sim_ent *e1, f64
void sim_ent_sync_alloc_tree(struct sim_ent *local_parent, struct sim_ent *remote, struct sim_ent_id remote_player) void sim_ent_sync_alloc_tree(struct sim_ent *local_parent, struct sim_ent *remote, struct sim_ent_id remote_player)
{ {
__prof; __prof;
if (sim_ent_has_prop(remote, SIM_ENT_PROP_SYNC_SRC)) { if (sim_ent_has_prop(remote, SEPROP_SYNC_SRC)) {
struct sim_snapshot *local_ss = local_parent->ss; struct sim_snapshot *local_ss = local_parent->ss;
struct sim_snapshot *remote_ss = remote->ss; struct sim_snapshot *remote_ss = remote->ss;
@ -633,8 +633,8 @@ void sim_ent_sync(struct sim_ent *local, struct sim_ent *remote)
local->prev_in_id_bin = old.prev_in_id_bin; local->prev_in_id_bin = old.prev_in_id_bin;
local->next_free = old.next_free; local->next_free = old.next_free;
sim_ent_disable_prop(local, SIM_ENT_PROP_SYNC_SRC); sim_ent_disable_prop(local, SEPROP_SYNC_SRC);
sim_ent_enable_prop(local, SIM_ENT_PROP_SYNC_DST); sim_ent_enable_prop(local, SEPROP_SYNC_DST);
} }

View File

@ -13,51 +13,51 @@ struct bitbuff_writer;
struct bitbuff_reader; struct bitbuff_reader;
enum sim_ent_prop { enum sim_ent_prop {
SIM_ENT_PROP_ACTIVE, SEPROP_ACTIVE,
SIM_ENT_PROP_RELEASE, SEPROP_RELEASE,
SIM_ENT_PROP_SYNC_SRC, /* This entity should be networked to other clients */ SEPROP_SYNC_SRC, /* This entity should be networked to other clients */
SIM_ENT_PROP_SYNC_DST, /* This entity is not locally created, and should sync with incoming net src ents */ SEPROP_SYNC_DST, /* This entity is not locally created, and should sync with incoming net src ents */
SIM_ENT_PROP_PLAYER, SEPROP_PLAYER,
SIM_ENT_PROP_PLAYER_IS_MASTER, SEPROP_PLAYER_IS_MASTER,
SIM_ENT_PROP_CMD, SEPROP_CMD,
SIM_ENT_PROP_TILE_CHUNK, SEPROP_TILE_CHUNK,
SIM_ENT_PROP_PHYSICAL_DYNAMIC, SEPROP_PHYSICAL_DYNAMIC,
SIM_ENT_PROP_PHYSICAL_KINEMATIC, SEPROP_PHYSICAL_KINEMATIC,
SIM_ENT_PROP_CONTROLLED, SEPROP_CONTROLLED,
SIM_ENT_PROP_COLLISION_DEBUG, SEPROP_COLLISION_DEBUG,
SIM_ENT_PROP_CONTACT_CONSTRAINT, SEPROP_CONTACT_CONSTRAINT,
SIM_ENT_PROP_MOTOR_JOINT, SEPROP_MOTOR_JOINT,
SIM_ENT_PROP_MOUSE_JOINT, SEPROP_MOUSE_JOINT,
SIM_ENT_PROP_SENSOR, SEPROP_SENSOR,
SIM_ENT_PROP_CAMERA, SEPROP_CAMERA,
SIM_ENT_PROP_CAMERA_ACTIVE, SEPROP_CAMERA_ACTIVE,
SIM_ENT_PROP_WEAPON, SEPROP_WEAPON_BULLETS,
SIM_ENT_PROP_TRIGGERING_EQUIPPED, SEPROP_TRIGGERING_EQUIPPED,
SIM_ENT_PROP_TRIGGERED_THIS_TICK, SEPROP_TRIGGERED_THIS_TICK,
SIM_ENT_PROP_TRIGGER_NEXT_TICK, SEPROP_TRIGGER_NEXT_TICK,
SIM_ENT_PROP_BULLET, SEPROP_BULLET,
SIM_ENT_PROP_TRACER, SEPROP_TRACER,
SIM_ENT_PROP_QUAKE, SEPROP_QUAKE,
SIM_ENT_PROP_ATTACHED, SEPROP_ATTACHED,
/* Test props */ /* Test props */
SIM_ENT_PROP_TEST, SEPROP_TEST,
SIM_ENT_PROP_TEST_SOUND_EMITTER, SEPROP_TEST_SOUND_EMITTER,
SIM_ENT_PROP_COUNT SEPROP_COUNT
}; };
struct sim_ent { struct sim_ent {
@ -68,7 +68,7 @@ struct sim_ent {
b32 valid; /* Is this ent allocated in memory that can be written to (can always be read) */ b32 valid; /* Is this ent allocated in memory that can be written to (can always be read) */
struct sim_ent_id id; struct sim_ent_id id;
u64 props[(SIM_ENT_PROP_COUNT + 63) / 64]; u64 props[(SEPROP_COUNT + 63) / 64];
u64 continuity_gen; u64 continuity_gen;
/* Is this the root ent */ /* Is this the root ent */
@ -95,8 +95,8 @@ struct sim_ent {
/* ====================================================================== */ /* ====================================================================== */
/* Sync */ /* Sync */
/* SIM_ENT_PROP_SYNC_SRC */ /* SEPROP_SYNC_SRC */
/* SIM_ENT_PROP_SYNC_DST */ /* SEPROP_SYNC_DST */
/* Id of the player that owns simulation for this entity */ /* Id of the player that owns simulation for this entity */
struct sim_ent_id owner; struct sim_ent_id owner;
@ -127,7 +127,7 @@ struct sim_ent {
/* ====================================================================== */ /* ====================================================================== */
/* Cmd */ /* Cmd */
/* SIM_ENT_PROP_CMD */ /* SEPROP_CMD */
enum sim_cmd_kind cmd_kind; enum sim_cmd_kind cmd_kind;
struct sim_ent_id cmd_player; struct sim_ent_id cmd_player;
@ -144,7 +144,7 @@ struct sim_ent {
/* ====================================================================== */ /* ====================================================================== */
/* Chat */ /* Chat */
/* SIM_ENT_PROP_CHAT */ /* SEPROP_CHAT */
struct sim_ent_id chat_player; struct sim_ent_id chat_player;
//struct string chat_msg; //struct string chat_msg;
@ -152,7 +152,7 @@ struct sim_ent {
/* ====================================================================== */ /* ====================================================================== */
/* Client */ /* Client */
/* SIM_ENT_PROP_PLAYER */ /* SEPROP_PLAYER */
/* FIXME: Lerp */ /* FIXME: Lerp */
@ -187,25 +187,25 @@ struct sim_ent {
/* ====================================================================== */ /* ====================================================================== */
/* Contact constraint */ /* Contact constraint */
/* SIM_ENT_PROP_CONSTRAINT_CONTACT */ /* SEPROP_CONSTRAINT_CONTACT */
struct phys_contact_constraint contact_constraint_data; struct phys_contact_constraint contact_constraint_data;
/* ====================================================================== */ /* ====================================================================== */
/* Motor joint */ /* Motor joint */
/* SIM_ENT_PROP_MOTOR_JOINT */ /* SEPROP_MOTOR_JOINT */
struct phys_motor_joint motor_joint_data; struct phys_motor_joint motor_joint_data;
/* ====================================================================== */ /* ====================================================================== */
/* Mouse joint */ /* Mouse joint */
/* SIM_ENT_PROP_MOUSE_JOINT */ /* SEPROP_MOUSE_JOINT */
struct phys_mouse_joint mouse_joint_data; struct phys_mouse_joint mouse_joint_data;
/* ====================================================================== */ /* ====================================================================== */
/* Control */ /* Control */
/* SIM_ENT_PROP_CONTROLLED */ /* SEPROP_CONTROLLED */
struct sim_ent_id controlling_client; struct sim_ent_id controlling_client;
@ -222,7 +222,7 @@ struct sim_ent {
/* ====================================================================== */ /* ====================================================================== */
/* Physics */ /* Physics */
/* SIM_ENT_PROP_PHYSICAL_DYNAMIC */ /* SEPROP_PHYSICAL_DYNAMIC */
//f32 density; /* Density in kg/m^2 */ //f32 density; /* Density in kg/m^2 */
@ -259,14 +259,14 @@ struct sim_ent {
/* ====================================================================== */ /* ====================================================================== */
/* Animation */ /* Animation */
/* SIM_ENT_PROP_ANIMATING */ /* SEPROP_ANIMATING */
i64 animation_last_frame_change_time_ns; i64 animation_last_frame_change_time_ns;
u32 animation_frame; u32 animation_frame;
/* ====================================================================== */ /* ====================================================================== */
/* Attachment */ /* Attachment */
/* SIM_ENT_PROP_ATTACHED */ /* SEPROP_ATTACHED */
/* Slice name on the parent ent's sprite to attach to */ /* Slice name on the parent ent's sprite to attach to */
struct string attach_slice; struct string attach_slice;
@ -278,7 +278,7 @@ struct sim_ent {
/* ====================================================================== */ /* ====================================================================== */
/* Triggers */ /* Triggers */
/* SIM_ENT_PROP_TRIGGERED_THIS_TICK */ /* SEPROP_TRIGGERED_THIS_TICK */
f32 trigger_delay; /* Minimum time between triggers */ f32 trigger_delay; /* Minimum time between triggers */
i64 last_triggered_ns; i64 last_triggered_ns;
@ -296,7 +296,7 @@ struct sim_ent {
/* ====================================================================== */ /* ====================================================================== */
/* Tracer */ /* Tracer */
/* SIM_ENT_PROP_TRACER */ /* SEPROP_TRACER */
struct v2 tracer_start; struct v2 tracer_start;
struct v2 tracer_start_velocity; struct v2 tracer_start_velocity;
@ -309,7 +309,7 @@ struct sim_ent {
/* ====================================================================== */ /* ====================================================================== */
/* Quake */ /* Quake */
/* SIM_ENT_PROP_QUAKE */ /* SEPROP_QUAKE */
f32 quake_intensity; f32 quake_intensity;
f32 quake_frequency; f32 quake_frequency;
@ -318,12 +318,12 @@ struct sim_ent {
/* ====================================================================== */ /* ====================================================================== */
/* Testing */ /* Testing */
/* SIM_ENT_PROP_TEST */ /* SEPROP_TEST */
b32 test_initialized; b32 test_initialized;
struct xform test_start_local_xform; struct xform test_start_local_xform;
struct xform test_start_sprite_xform; struct xform test_start_sprite_xform;
/* SIM_ENT_PROP_TEST_SOUND_EMITTER */ /* SEPROP_TEST_SOUND_EMITTER */
struct string sound_name; struct string sound_name;
struct mixer_desc sound_desc; struct mixer_desc sound_desc;
struct mixer_track_handle sound_handle; struct mixer_track_handle sound_handle;
@ -331,7 +331,7 @@ struct sim_ent {
/* ====================================================================== */ /* ====================================================================== */
/* Camera */ /* Camera */
/* SIM_ENT_PROP_CAMERA */ /* SEPROP_CAMERA */
struct sim_ent_id camera_follow; struct sim_ent_id camera_follow;
struct xform camera_quad_xform; struct xform camera_quad_xform;
f32 camera_lerp; /* Rate at which camera xform approaches target xform */ f32 camera_lerp; /* Rate at which camera xform approaches target xform */
@ -409,7 +409,7 @@ INLINE b32 sim_ent_has_prop(struct sim_ent *ent, enum sim_ent_prop prop)
INLINE b32 sim_ent_is_valid_and_active(struct sim_ent *ent) INLINE b32 sim_ent_is_valid_and_active(struct sim_ent *ent)
{ {
return ent->valid && sim_ent_has_prop(ent, SIM_ENT_PROP_ACTIVE); return ent->valid && sim_ent_has_prop(ent, SEPROP_ACTIVE);
} }
INLINE b32 sim_ent_should_predict(struct sim_ent *ent) INLINE b32 sim_ent_should_predict(struct sim_ent *ent)
@ -427,7 +427,7 @@ INLINE b32 sim_ent_should_simulate(struct sim_ent *ent)
b32 res = false; b32 res = false;
if (sim_ent_is_valid_and_active(ent)) { if (sim_ent_is_valid_and_active(ent)) {
res = true; res = true;
if (sim_ent_has_prop(ent, SIM_ENT_PROP_SYNC_DST)) { if (sim_ent_has_prop(ent, SEPROP_SYNC_DST)) {
struct sim_ent_id local_player = ent->ss->local_player; struct sim_ent_id local_player = ent->ss->local_player;
res = sim_ent_id_eq(local_player, ent->owner) || sim_ent_id_eq(local_player, ent->predictor); res = sim_ent_id_eq(local_player, ent->owner) || sim_ent_id_eq(local_player, ent->predictor);
} }

View File

@ -73,7 +73,7 @@ INTERNAL struct sim_ent *spawn_test_employee(struct sim_step_ctx *ctx)
f32 r = 0; f32 r = 0;
{ {
sim_ent_enable_prop(e, SIM_ENT_PROP_TEST); sim_ent_enable_prop(e, SEPROP_TEST);
e->sprite = sprite_tag_from_path(LIT("res/graphics/tim.ase")); e->sprite = sprite_tag_from_path(LIT("res/graphics/tim.ase"));
e->mass_unscaled = 10; e->mass_unscaled = 10;
e->inertia_unscaled = 5; e->inertia_unscaled = 5;
@ -106,7 +106,7 @@ INTERNAL struct sim_ent *spawn_test_employee(struct sim_step_ctx *ctx)
//e->control_torque = 5000; //e->control_torque = 5000;
e->control_torque = F32_INFINITY; e->control_torque = F32_INFINITY;
sim_ent_enable_prop(e, SIM_ENT_PROP_PHYSICAL_DYNAMIC); sim_ent_enable_prop(e, SEPROP_PHYSICAL_DYNAMIC);
employee = e; employee = e;
} }
@ -116,11 +116,11 @@ INTERNAL struct sim_ent *spawn_test_employee(struct sim_step_ctx *ctx)
struct sim_ent *e = sim_ent_alloc_sync_src(employee); struct sim_ent *e = sim_ent_alloc_sync_src(employee);
e->sprite = sprite_tag_from_path(LIT("res/graphics/gun.ase")); e->sprite = sprite_tag_from_path(LIT("res/graphics/gun.ase"));
sim_ent_enable_prop(e, SIM_ENT_PROP_ATTACHED); sim_ent_enable_prop(e, SEPROP_ATTACHED);
e->attach_slice = LIT("attach.wep"); e->attach_slice = LIT("attach.wep");
e->layer = SIM_LAYER_RELATIVE_WEAPON; e->layer = SIM_LAYER_RELATIVE_WEAPON;
sim_ent_enable_prop(e, SIM_ENT_PROP_WEAPON); sim_ent_enable_prop(e, SEPROP_WEAPON_BULLETS);
e->trigger_delay = 1.0f / 10.0f; e->trigger_delay = 1.0f / 10.0f;
//e->trigger_delay = 1.0f / 100.0f; //e->trigger_delay = 1.0f / 100.0f;
@ -139,8 +139,8 @@ INTERNAL struct sim_ent *spawn_test_camera(struct sim_snapshot *world, struct si
camera_ent = sim_ent_alloc_sync_src(root); camera_ent = sim_ent_alloc_sync_src(root);
sim_ent_set_xform(camera_ent, XFORM_IDENT); sim_ent_set_xform(camera_ent, XFORM_IDENT);
sim_ent_enable_prop(camera_ent, SIM_ENT_PROP_CAMERA); sim_ent_enable_prop(camera_ent, SEPROP_CAMERA);
sim_ent_enable_prop(camera_ent, SIM_ENT_PROP_CAMERA_ACTIVE); sim_ent_enable_prop(camera_ent, SEPROP_CAMERA_ACTIVE);
camera_ent->camera_follow = follow->id; camera_ent->camera_follow = follow->id;
f32 width = (f32)DEFAULT_CAMERA_WIDTH; f32 width = (f32)DEFAULT_CAMERA_WIDTH;
@ -176,7 +176,7 @@ INTERNAL void spawn_test_entities(struct sim_step_ctx *ctx, struct v2 offset)
e->sprite_collider_slice = LIT("shape"); e->sprite_collider_slice = LIT("shape");
e->layer = SIM_LAYER_SHOULDERS; e->layer = SIM_LAYER_SHOULDERS;
sim_ent_enable_prop(e, SIM_ENT_PROP_PHYSICAL_DYNAMIC); sim_ent_enable_prop(e, SEPROP_PHYSICAL_DYNAMIC);
e->mass_unscaled = 100; e->mass_unscaled = 100;
e->inertia_unscaled = 10; e->inertia_unscaled = 10;
e->linear_ground_friction = 250; e->linear_ground_friction = 250;
@ -206,7 +206,7 @@ INTERNAL void spawn_test_entities(struct sim_step_ctx *ctx, struct v2 offset)
e->sprite_collider_slice = LIT("shape"); e->sprite_collider_slice = LIT("shape");
e->layer = SIM_LAYER_SHOULDERS; e->layer = SIM_LAYER_SHOULDERS;
sim_ent_enable_prop(e, SIM_ENT_PROP_PHYSICAL_DYNAMIC); sim_ent_enable_prop(e, SEPROP_PHYSICAL_DYNAMIC);
e->mass_unscaled = 100; e->mass_unscaled = 100;
e->inertia_unscaled = 50; e->inertia_unscaled = 50;
e->linear_ground_friction = 100; e->linear_ground_friction = 100;
@ -230,7 +230,7 @@ INTERNAL void spawn_test_entities(struct sim_step_ctx *ctx, struct v2 offset)
e->sprite_collider_slice = LIT("shape"); e->sprite_collider_slice = LIT("shape");
e->layer = SIM_LAYER_SHOULDERS; e->layer = SIM_LAYER_SHOULDERS;
sim_ent_enable_prop(e, SIM_ENT_PROP_PHYSICAL_DYNAMIC); sim_ent_enable_prop(e, SEPROP_PHYSICAL_DYNAMIC);
e->mass_unscaled = 0.5; e->mass_unscaled = 0.5;
e->inertia_unscaled = 1000; e->inertia_unscaled = 1000;
e->linear_ground_friction = 0.001; e->linear_ground_friction = 0.001;
@ -244,7 +244,7 @@ INTERNAL void test_clear_level(struct sim_step_ctx *ctx)
for (u64 j = 0; j < world->num_ents_reserved; ++j) { for (u64 j = 0; j < world->num_ents_reserved; ++j) {
struct sim_ent *ent = &world->ents[j]; struct sim_ent *ent = &world->ents[j];
if (ent->valid) { if (ent->valid) {
sim_ent_enable_prop(ent, SIM_ENT_PROP_RELEASE); sim_ent_enable_prop(ent, SEPROP_RELEASE);
} }
} }
} }
@ -267,13 +267,13 @@ INTERNAL PHYS_COLLISION_CALLBACK_FUNC_DEF(on_collision, collision_data_array, st
if (sim_ent_should_simulate(e0) && sim_ent_should_simulate(e1)) { if (sim_ent_should_simulate(e0) && sim_ent_should_simulate(e1)) {
/* Bullet hit entity */ /* Bullet hit entity */
if (sim_ent_has_prop(e0, SIM_ENT_PROP_BULLET) || sim_ent_has_prop(e1, SIM_ENT_PROP_BULLET)) { if (sim_ent_has_prop(e0, SEPROP_BULLET) || sim_ent_has_prop(e1, SEPROP_BULLET)) {
struct v2 normal = data->normal; /* Impact normal */ struct v2 normal = data->normal; /* Impact normal */
struct v2 vrel = v2_neg(data->vrel); /* Impact velocity */ struct v2 vrel = v2_neg(data->vrel); /* Impact velocity */
struct sim_ent *target = e0; struct sim_ent *target = e0;
struct sim_ent *bullet = e1; struct sim_ent *bullet = e1;
if (sim_ent_has_prop(e0, SIM_ENT_PROP_BULLET)) { if (sim_ent_has_prop(e0, SEPROP_BULLET)) {
target = e1; target = e1;
bullet = e0; bullet = e0;
normal = v2_neg(normal); normal = v2_neg(normal);
@ -291,7 +291,7 @@ INTERNAL PHYS_COLLISION_CALLBACK_FUNC_DEF(on_collision, collision_data_array, st
/* Update bullet */ /* Update bullet */
bullet->bullet_has_hit = true; bullet->bullet_has_hit = true;
sim_ent_enable_prop(bullet, SIM_ENT_PROP_RELEASE); sim_ent_enable_prop(bullet, SEPROP_RELEASE);
/* Update tracer */ /* Update tracer */
struct sim_ent *tracer = sim_ent_from_id(world, bullet->bullet_tracer); struct sim_ent *tracer = sim_ent_from_id(world, bullet->bullet_tracer);
@ -323,7 +323,7 @@ INTERNAL PHYS_COLLISION_CALLBACK_FUNC_DEF(on_collision, collision_data_array, st
f32 angular_velocity_range = 5; f32 angular_velocity_range = 5;
f32 angular_velocity = rand_f64_from_seed(&step_ctx->rand, -angular_velocity_range, angular_velocity_range); f32 angular_velocity = rand_f64_from_seed(&step_ctx->rand, -angular_velocity_range, angular_velocity_range);
sim_ent_enable_prop(decal, SIM_ENT_PROP_PHYSICAL_KINEMATIC); sim_ent_enable_prop(decal, SEPROP_PHYSICAL_KINEMATIC);
sim_ent_set_linear_velocity(decal, linear_velocity); sim_ent_set_linear_velocity(decal, linear_velocity);
sim_ent_set_angular_velocity(decal, angular_velocity); sim_ent_set_angular_velocity(decal, angular_velocity);
@ -385,18 +385,18 @@ void sim_step(struct sim_step_ctx *ctx)
/* FIXME: Player never released upon disconnect */ /* FIXME: Player never released upon disconnect */
player = sim_ent_alloc_sync_src(root); player = sim_ent_alloc_sync_src(root);
player->player_client_handle = client->handle; player->player_client_handle = client->handle;
sim_ent_enable_prop(player, SIM_ENT_PROP_PLAYER); sim_ent_enable_prop(player, SEPROP_PLAYER);
player->predictor = player->id; player->predictor = player->id;
sim_ent_enable_prop(player, SIM_ENT_PROP_ACTIVE); sim_ent_enable_prop(player, SEPROP_ACTIVE);
client->player_id = player->id; client->player_id = player->id;
if (client == user_input_client) { if (client == user_input_client) {
user_input_client->player_id = player->id; user_input_client->player_id = player->id;
world_client->player_id = player->id; world_client->player_id = player->id;
world->local_player = player->id; world->local_player = player->id;
player->owner = player->id; player->owner = player->id;
sim_ent_enable_prop(player, SIM_ENT_PROP_PLAYER_IS_MASTER); sim_ent_enable_prop(player, SEPROP_PLAYER_IS_MASTER);
} }
logf_info("Created player with id %F for sim client %F. is_master: %F", FMT_UID(player->id.uid), FMT_HANDLE(client->handle), FMT_UINT(sim_ent_has_prop(player, SIM_ENT_PROP_PLAYER_IS_MASTER))); logf_info("Created player with id %F for sim client %F. is_master: %F", FMT_UID(player->id.uid), FMT_HANDLE(client->handle), FMT_UINT(sim_ent_has_prop(player, SEPROP_PLAYER_IS_MASTER)));
} }
/* Update rtt */ /* Update rtt */
@ -419,16 +419,16 @@ void sim_step(struct sim_step_ctx *ctx)
/* Mark all incoming ents as sync dsts */ /* Mark all incoming ents as sync dsts */
for (u64 i = 0; i < world->num_ents_reserved; ++i) { for (u64 i = 0; i < world->num_ents_reserved; ++i) {
struct sim_ent *ent = &world->ents[i]; struct sim_ent *ent = &world->ents[i];
if (ent->valid && sim_ent_has_prop(ent, SIM_ENT_PROP_SYNC_SRC) && !sim_ent_id_eq(ent->owner, world_client->player_id)) { if (ent->valid && sim_ent_has_prop(ent, SEPROP_SYNC_SRC) && !sim_ent_id_eq(ent->owner, world_client->player_id)) {
sim_ent_disable_prop(ent, SIM_ENT_PROP_SYNC_SRC); sim_ent_disable_prop(ent, SEPROP_SYNC_SRC);
sim_ent_enable_prop(ent, SIM_ENT_PROP_SYNC_DST); sim_ent_enable_prop(ent, SEPROP_SYNC_DST);
} }
} }
/* Mark incoming cmds with correct client */ /* Mark incoming cmds with correct client */
for (u64 i = 0; i < world->num_ents_reserved; ++i) { for (u64 i = 0; i < world->num_ents_reserved; ++i) {
struct sim_ent *ent = &world->ents[i]; struct sim_ent *ent = &world->ents[i];
if (ent->valid && sim_ent_has_prop(ent, SIM_ENT_PROP_CMD) && sim_ent_has_prop(ent, SIM_ENT_PROP_SYNC_DST)) { if (ent->valid && sim_ent_has_prop(ent, SEPROP_CMD) && sim_ent_has_prop(ent, SEPROP_SYNC_DST)) {
ent->cmd_player = ent->owner; ent->cmd_player = ent->owner;
} }
} }
@ -437,9 +437,9 @@ void sim_step(struct sim_step_ctx *ctx)
if (!is_master) { if (!is_master) {
for (u64 i = 0; i < world->num_ents_reserved; ++i) { for (u64 i = 0; i < world->num_ents_reserved; ++i) {
struct sim_ent *ent = &world->ents[i]; struct sim_ent *ent = &world->ents[i];
if (sim_ent_is_valid_and_active(ent) && sim_ent_has_prop(ent, SIM_ENT_PROP_CMD)) { if (sim_ent_is_valid_and_active(ent) && sim_ent_has_prop(ent, SEPROP_CMD)) {
if (!sim_ent_id_is_nil(ent->cmd_player) && sim_ent_id_eq(ent->cmd_player, world->local_player)) { if (!sim_ent_id_is_nil(ent->cmd_player) && sim_ent_id_eq(ent->cmd_player, world->local_player)) {
sim_ent_enable_prop(ent, SIM_ENT_PROP_SYNC_SRC); sim_ent_enable_prop(ent, SEPROP_SYNC_SRC);
} }
} }
} }
@ -450,7 +450,7 @@ void sim_step(struct sim_step_ctx *ctx)
* Release entities at beginning of frame * Release entities at beginning of frame
* ========================== */ * ========================== */
sim_ent_release_all_with_prop(world, SIM_ENT_PROP_RELEASE); sim_ent_release_all_with_prop(world, SEPROP_RELEASE);
sim_accel_reset(world, ctx->accel); sim_accel_reset(world, ctx->accel);
/* ========================== * /* ========================== *
@ -460,9 +460,9 @@ void sim_step(struct sim_step_ctx *ctx)
for (u64 ent_index = 0; ent_index < world->num_ents_reserved; ++ent_index) { for (u64 ent_index = 0; ent_index < world->num_ents_reserved; ++ent_index) {
struct sim_ent *ent = &world->ents[ent_index]; struct sim_ent *ent = &world->ents[ent_index];
if (!ent->valid) continue; if (!ent->valid) continue;
if (sim_ent_has_prop(ent, SIM_ENT_PROP_SYNC_DST) && !sim_ent_is_owner(ent) && !sim_ent_should_predict(ent)) continue; if (sim_ent_has_prop(ent, SEPROP_SYNC_DST) && !sim_ent_is_owner(ent) && !sim_ent_should_predict(ent)) continue;
if (!sim_ent_has_prop(ent, SIM_ENT_PROP_ACTIVE)) { if (!sim_ent_has_prop(ent, SEPROP_ACTIVE)) {
u64 atick = ent->activation_tick; u64 atick = ent->activation_tick;
if (atick != 0 || world->tick >= atick) { if (atick != 0 || world->tick >= atick) {
sim_ent_activate(ent, world->tick); sim_ent_activate(ent, world->tick);
@ -478,11 +478,11 @@ void sim_step(struct sim_step_ctx *ctx)
struct sim_ent *ent = &world->ents[ent_index]; struct sim_ent *ent = &world->ents[ent_index];
if (!sim_ent_should_simulate(ent)) continue; if (!sim_ent_should_simulate(ent)) continue;
if (sim_ent_has_prop(ent, SIM_ENT_PROP_TRIGGER_NEXT_TICK)) { if (sim_ent_has_prop(ent, SEPROP_TRIGGER_NEXT_TICK)) {
sim_ent_disable_prop(ent, SIM_ENT_PROP_TRIGGER_NEXT_TICK); sim_ent_disable_prop(ent, SEPROP_TRIGGER_NEXT_TICK);
sim_ent_enable_prop(ent, SIM_ENT_PROP_TRIGGERED_THIS_TICK); sim_ent_enable_prop(ent, SEPROP_TRIGGERED_THIS_TICK);
} else if (sim_ent_has_prop(ent, SIM_ENT_PROP_TRIGGERED_THIS_TICK)) { } else if (sim_ent_has_prop(ent, SEPROP_TRIGGERED_THIS_TICK)) {
sim_ent_disable_prop(ent, SIM_ENT_PROP_TRIGGERED_THIS_TICK); sim_ent_disable_prop(ent, SEPROP_TRIGGERED_THIS_TICK);
} }
} }
@ -494,7 +494,7 @@ void sim_step(struct sim_step_ctx *ctx)
struct sim_ent *cmd_ent = &world->ents[ent_index]; struct sim_ent *cmd_ent = &world->ents[ent_index];
if (!is_master && !sim_ent_should_simulate(cmd_ent)) continue; if (!is_master && !sim_ent_should_simulate(cmd_ent)) continue;
if (sim_ent_has_prop(cmd_ent, SIM_ENT_PROP_CMD)) { if (sim_ent_has_prop(cmd_ent, SEPROP_CMD)) {
struct sim_ent *player = sim_ent_from_id(world, cmd_ent->cmd_player); struct sim_ent *player = sim_ent_from_id(world, cmd_ent->cmd_player);
if (sim_ent_should_simulate(player)) { if (sim_ent_should_simulate(player)) {
b32 persist_cmd = false; b32 persist_cmd = false;
@ -573,7 +573,7 @@ void sim_step(struct sim_step_ctx *ctx)
struct sim_ent *chunk_ent = sim_ent_from_id(world, chunk_id); struct sim_ent *chunk_ent = sim_ent_from_id(world, chunk_id);
if (!chunk_ent->valid) { if (!chunk_ent->valid) {
chunk_ent = sim_ent_alloc_sync_src_with_id(root, chunk_id); chunk_ent = sim_ent_alloc_sync_src_with_id(root, chunk_id);
sim_ent_enable_prop(chunk_ent, SIM_ENT_PROP_TILE_CHUNK); sim_ent_enable_prop(chunk_ent, SEPROP_TILE_CHUNK);
} }
struct string old_data = sim_ent_get_tile_chunk_data(chunk_ent); struct string old_data = sim_ent_get_tile_chunk_data(chunk_ent);
@ -601,7 +601,7 @@ void sim_step(struct sim_step_ctx *ctx)
struct string msg = sim_data_from_key(sim_data_store, msg_key); struct string msg = sim_data_from_key(sim_data_store, msg_key);
if (msg.len > 0) { if (msg.len > 0) {
struct sim_ent *chat_ent = sim_ent_alloc_sync_src(root); struct sim_ent *chat_ent = sim_ent_alloc_sync_src(root);
sim_ent_enable_prop(chat_ent, SIM_ENT_PROP_CHAT); sim_ent_enable_prop(chat_ent, SEPROP_CHAT);
chat_ent->chat_player = player->id; chat_ent->chat_player = player->id;
chat_ent->chat_msg = msg_key; chat_ent->chat_msg = msg_key;
} }
@ -617,7 +617,7 @@ void sim_step(struct sim_step_ctx *ctx)
/* Release cmd */ /* Release cmd */
if (!persist_cmd) { if (!persist_cmd) {
sim_ent_enable_prop(cmd_ent, SIM_ENT_PROP_RELEASE); sim_ent_enable_prop(cmd_ent, SEPROP_RELEASE);
} }
} }
} }
@ -631,13 +631,13 @@ void sim_step(struct sim_step_ctx *ctx)
for (u64 i = 0; i < world->num_ents_reserved; ++i) { for (u64 i = 0; i < world->num_ents_reserved; ++i) {
struct sim_ent *ent = &world->ents[i]; struct sim_ent *ent = &world->ents[i];
if (!sim_ent_should_simulate(ent)) continue; if (!sim_ent_should_simulate(ent)) continue;
if (sim_ent_has_prop(ent, SIM_ENT_PROP_PLAYER)) { if (sim_ent_has_prop(ent, SEPROP_PLAYER)) {
/* FIXME: Ents never released when client disconnects */ /* FIXME: Ents never released when client disconnects */
struct sim_ent *control_ent = sim_ent_from_id(world, ent->player_control_ent); struct sim_ent *control_ent = sim_ent_from_id(world, ent->player_control_ent);
if (!control_ent->valid) { if (!control_ent->valid) {
control_ent = spawn_test_employee(ctx); control_ent = spawn_test_employee(ctx);
control_ent->predictor = ent->id; control_ent->predictor = ent->id;
sim_ent_enable_prop(control_ent, SIM_ENT_PROP_CONTROLLED); sim_ent_enable_prop(control_ent, SEPROP_CONTROLLED);
ent->player_control_ent = control_ent->id; ent->player_control_ent = control_ent->id;
control_ent->controlling_client = ent->id; control_ent->controlling_client = ent->id;
} }
@ -659,15 +659,15 @@ void sim_step(struct sim_step_ctx *ctx)
struct sim_ent *ent = &world->ents[ent_index]; struct sim_ent *ent = &world->ents[ent_index];
if (!sim_ent_should_simulate(ent)) continue; if (!sim_ent_should_simulate(ent)) continue;
if (sim_ent_has_prop(ent, SIM_ENT_PROP_CONTROLLED)) { if (sim_ent_has_prop(ent, SEPROP_CONTROLLED)) {
struct sim_ent *player = sim_ent_from_id(world, ent->controlling_client); struct sim_ent *player = sim_ent_from_id(world, ent->controlling_client);
if (player->valid) { if (player->valid) {
ent->control = player->player_control; ent->control = player->player_control;
/* TODO: Move this */ /* TODO: Move this */
if (ent->control.flags & SIM_CONTROL_FLAG_FIRE) { if (ent->control.flags & SIM_CONTROL_FLAG_FIRE) {
sim_ent_enable_prop(ent, SIM_ENT_PROP_TRIGGERING_EQUIPPED); sim_ent_enable_prop(ent, SEPROP_TRIGGERING_EQUIPPED);
} else { } else {
sim_ent_disable_prop(ent, SIM_ENT_PROP_TRIGGERING_EQUIPPED); sim_ent_disable_prop(ent, SEPROP_TRIGGERING_EQUIPPED);
} }
} }
} }
@ -739,7 +739,7 @@ void sim_step(struct sim_step_ctx *ctx)
/* Test collider */ /* Test collider */
#if 0 #if 0
if (sim_ent_has_prop(ent, SIM_ENT_PROP_TEST)) { if (sim_ent_has_prop(ent, SEPROP_TEST)) {
//if ((true)) { //if ((true)) {
#if 0 #if 0
ent->local_collider.points[0] = V2(0, 0); ent->local_collider.points[0] = V2(0, 0);
@ -780,7 +780,7 @@ void sim_step(struct sim_step_ctx *ctx)
for (u64 ent_index = 0; ent_index < world->num_ents_reserved; ++ent_index) { for (u64 ent_index = 0; ent_index < world->num_ents_reserved; ++ent_index) {
struct sim_ent *ent = &world->ents[ent_index]; struct sim_ent *ent = &world->ents[ent_index];
if (!sim_ent_should_simulate(ent)) continue; if (!sim_ent_should_simulate(ent)) continue;
if (!sim_ent_has_prop(ent, SIM_ENT_PROP_ATTACHED)) continue; if (!sim_ent_has_prop(ent, SEPROP_ATTACHED)) continue;
struct sim_ent *parent = sim_ent_from_id(world, ent->parent); struct sim_ent *parent = sim_ent_from_id(world, ent->parent);
struct sprite_tag parent_sprite = parent->sprite; struct sprite_tag parent_sprite = parent->sprite;
@ -806,7 +806,7 @@ void sim_step(struct sim_step_ctx *ctx)
for (u64 ent_index = 0; ent_index < ss_blended->num_ents_reserved; ++ent_index) { for (u64 ent_index = 0; ent_index < ss_blended->num_ents_reserved; ++ent_index) {
struct sim_ent *ent = &ss_blended->ents[ent_index]; struct sim_ent *ent = &ss_blended->ents[ent_index];
if (!sim_ent_is_valid_and_active(ent)) continue; if (!sim_ent_is_valid_and_active(ent)) continue;
if (!sim_ent_has_prop(ent, SIM_ENT_PROP_TEST)) continue; if (!sim_ent_has_prop(ent, SEPROP_TEST)) continue;
#if 0 #if 0
if (!ent->test_initialized) { if (!ent->test_initialized) {
@ -857,10 +857,10 @@ void sim_step(struct sim_step_ctx *ctx)
struct sim_ent *ent = &world->ents[ent_index]; struct sim_ent *ent = &world->ents[ent_index];
if (!sim_ent_should_simulate(ent)) continue; if (!sim_ent_should_simulate(ent)) continue;
if (sim_ent_has_prop(ent, SIM_ENT_PROP_TRIGGERING_EQUIPPED)) { if (sim_ent_has_prop(ent, SEPROP_TRIGGERING_EQUIPPED)) {
struct sim_ent *eq = sim_ent_from_id(world, ent->equipped); struct sim_ent *eq = sim_ent_from_id(world, ent->equipped);
if (sim_ent_should_simulate(eq)) { if (sim_ent_should_simulate(eq)) {
sim_ent_enable_prop(eq, SIM_ENT_PROP_TRIGGERED_THIS_TICK); sim_ent_enable_prop(eq, SEPROP_TRIGGERED_THIS_TICK);
} }
} }
} }
@ -872,13 +872,13 @@ void sim_step(struct sim_step_ctx *ctx)
for (u64 ent_index = 0; ent_index < world->num_ents_reserved; ++ent_index) { for (u64 ent_index = 0; ent_index < world->num_ents_reserved; ++ent_index) {
struct sim_ent *ent = &world->ents[ent_index]; struct sim_ent *ent = &world->ents[ent_index];
if (!sim_ent_should_simulate(ent)) continue; if (!sim_ent_should_simulate(ent)) continue;
if (!sim_ent_has_prop(ent, SIM_ENT_PROP_TRIGGERED_THIS_TICK)) continue; if (!sim_ent_has_prop(ent, SEPROP_TRIGGERED_THIS_TICK)) continue;
if ((world->sim_time_ns - ent->last_triggered_ns < NS_FROM_SECONDS(ent->trigger_delay)) && ent->last_triggered_ns != 0) continue; if ((world->sim_time_ns - ent->last_triggered_ns < NS_FROM_SECONDS(ent->trigger_delay)) && ent->last_triggered_ns != 0) continue;
ent->last_triggered_ns = world->sim_time_ns; ent->last_triggered_ns = world->sim_time_ns;
/* Fire weapon */ /* Fire weapon */
if (sim_ent_has_prop(ent, SIM_ENT_PROP_WEAPON)) { if (sim_ent_has_prop(ent, SEPROP_WEAPON_BULLETS)) {
struct sprite_tag sprite = ent->sprite; struct sprite_tag sprite = ent->sprite;
u32 animation_frame = ent->animation_frame; u32 animation_frame = ent->animation_frame;
struct sprite_sheet *sheet = sprite_sheet_from_tag_await(sprite_frame_scope, sprite); struct sprite_sheet *sheet = sprite_sheet_from_tag_await(sprite_frame_scope, sprite);
@ -913,8 +913,8 @@ void sim_step(struct sim_step_ctx *ctx)
bullet->sprite_collider_slice = LIT("shape"); bullet->sprite_collider_slice = LIT("shape");
#endif #endif
sim_ent_enable_prop(bullet, SIM_ENT_PROP_BULLET); sim_ent_enable_prop(bullet, SEPROP_BULLET);
sim_ent_enable_prop(bullet, SIM_ENT_PROP_SENSOR); sim_ent_enable_prop(bullet, SEPROP_SENSOR);
} }
/* Spawn tracer */ /* Spawn tracer */
@ -922,7 +922,7 @@ void sim_step(struct sim_step_ctx *ctx)
struct sim_ent *tracer = sim_ent_alloc_sync_src(root); struct sim_ent *tracer = sim_ent_alloc_sync_src(root);
tracer->tracer_fade_duration = 0.025f; tracer->tracer_fade_duration = 0.025f;
tracer->layer = SIM_LAYER_TRACERS; tracer->layer = SIM_LAYER_TRACERS;
sim_ent_enable_prop(tracer, SIM_ENT_PROP_TRACER); sim_ent_enable_prop(tracer, SEPROP_TRACER);
bullet->bullet_tracer = tracer->id; bullet->bullet_tracer = tracer->id;
} }
@ -937,15 +937,15 @@ void sim_step(struct sim_step_ctx *ctx)
struct sim_ent *ent = &world->ents[ent_index]; struct sim_ent *ent = &world->ents[ent_index];
if (!sim_ent_should_simulate(ent)) continue; if (!sim_ent_should_simulate(ent)) continue;
if (sim_ent_has_prop(ent, SIM_ENT_PROP_CONTROLLED)) { if (sim_ent_has_prop(ent, SEPROP_CONTROLLED)) {
struct sim_ent *joint_ent = sim_ent_from_id(world, ent->move_joint); struct sim_ent *joint_ent = sim_ent_from_id(world, ent->move_joint);
if (is_master && !sim_ent_is_valid_and_active(joint_ent)) { if (is_master && !sim_ent_is_valid_and_active(joint_ent)) {
joint_ent = sim_ent_alloc_sync_src(root); joint_ent = sim_ent_alloc_sync_src(root);
joint_ent->predictor = ent->predictor; joint_ent->predictor = ent->predictor;
joint_ent->mass_unscaled = F32_INFINITY; joint_ent->mass_unscaled = F32_INFINITY;
joint_ent->inertia_unscaled = F32_INFINITY; joint_ent->inertia_unscaled = F32_INFINITY;
sim_ent_enable_prop(joint_ent, SIM_ENT_PROP_MOTOR_JOINT); sim_ent_enable_prop(joint_ent, SEPROP_MOTOR_JOINT);
sim_ent_enable_prop(joint_ent, SIM_ENT_PROP_ACTIVE); sim_ent_enable_prop(joint_ent, SEPROP_ACTIVE);
ent->move_joint = joint_ent->id; ent->move_joint = joint_ent->id;
struct phys_motor_joint_def def = ZI; struct phys_motor_joint_def def = ZI;
@ -973,7 +973,7 @@ void sim_step(struct sim_step_ctx *ctx)
struct sim_ent *ent = &world->ents[ent_index]; struct sim_ent *ent = &world->ents[ent_index];
if (!sim_ent_should_simulate(ent)) continue; if (!sim_ent_should_simulate(ent)) continue;
if (sim_ent_has_prop(ent, SIM_ENT_PROP_CONTROLLED)) { if (sim_ent_has_prop(ent, SEPROP_CONTROLLED)) {
struct xform xf = sim_ent_get_xform(ent); struct xform xf = sim_ent_get_xform(ent);
struct xform sprite_xf = xform_mul(xf, ent->sprite_local_xform); struct xform sprite_xf = xform_mul(xf, ent->sprite_local_xform);
@ -984,9 +984,9 @@ void sim_step(struct sim_step_ctx *ctx)
joint_ent->predictor = ent->predictor; joint_ent->predictor = ent->predictor;
joint_ent->mass_unscaled = F32_INFINITY; joint_ent->mass_unscaled = F32_INFINITY;
joint_ent->inertia_unscaled = F32_INFINITY; joint_ent->inertia_unscaled = F32_INFINITY;
sim_ent_enable_prop(joint_ent, SIM_ENT_PROP_PHYSICAL_KINEMATIC); /* Since we'll be setting velocity manually */ sim_ent_enable_prop(joint_ent, SEPROP_PHYSICAL_KINEMATIC); /* Since we'll be setting velocity manually */
sim_ent_enable_prop(joint_ent, SIM_ENT_PROP_MOTOR_JOINT); sim_ent_enable_prop(joint_ent, SEPROP_MOTOR_JOINT);
sim_ent_enable_prop(joint_ent, SIM_ENT_PROP_ACTIVE); sim_ent_enable_prop(joint_ent, SEPROP_ACTIVE);
ent->aim_joint = joint_ent->id; ent->aim_joint = joint_ent->id;
struct phys_motor_joint_def def = ZI; struct phys_motor_joint_def def = ZI;
@ -1070,7 +1070,7 @@ void sim_step(struct sim_step_ctx *ctx)
for (u64 ent_index = 0; ent_index < world->num_ents_reserved; ++ent_index) { for (u64 ent_index = 0; ent_index < world->num_ents_reserved; ++ent_index) {
struct sim_ent *ent = &world->ents[ent_index]; struct sim_ent *ent = &world->ents[ent_index];
if (!sim_ent_should_simulate(ent)) continue; if (!sim_ent_should_simulate(ent)) continue;
if (!sim_ent_has_prop(ent, SIM_ENT_PROP_PHYSICAL_DYNAMIC)) continue; if (!sim_ent_has_prop(ent, SEPROP_PHYSICAL_DYNAMIC)) continue;
struct sim_ent *joint_ent = sim_ent_from_id(world, ent->ground_friction_joint); struct sim_ent *joint_ent = sim_ent_from_id(world, ent->ground_friction_joint);
@ -1084,8 +1084,8 @@ void sim_step(struct sim_step_ctx *ctx)
if (is_master && !sim_ent_is_valid_and_active(joint_ent)) { if (is_master && !sim_ent_is_valid_and_active(joint_ent)) {
joint_ent = sim_ent_alloc_sync_src(root); joint_ent = sim_ent_alloc_sync_src(root);
joint_ent->predictor = ent->predictor; joint_ent->predictor = ent->predictor;
sim_ent_enable_prop(joint_ent, SIM_ENT_PROP_MOTOR_JOINT); sim_ent_enable_prop(joint_ent, SEPROP_MOTOR_JOINT);
sim_ent_enable_prop(joint_ent, SIM_ENT_PROP_ACTIVE); sim_ent_enable_prop(joint_ent, SEPROP_ACTIVE);
joint_ent->motor_joint_data = phys_motor_joint_from_def(def); joint_ent->motor_joint_data = phys_motor_joint_from_def(def);
ent->ground_friction_joint = joint_ent->id; ent->ground_friction_joint = joint_ent->id;
} }
@ -1101,7 +1101,7 @@ void sim_step(struct sim_step_ctx *ctx)
for (u64 i = 0; i < world->num_ents_reserved; ++i) { for (u64 i = 0; i < world->num_ents_reserved; ++i) {
struct sim_ent *player = &world->ents[i]; struct sim_ent *player = &world->ents[i];
if (!sim_ent_should_simulate(player)) continue; if (!sim_ent_should_simulate(player)) continue;
if (!sim_ent_has_prop(player, SIM_ENT_PROP_PLAYER)) continue; if (!sim_ent_has_prop(player, SEPROP_PLAYER)) continue;
struct v2 cursor = player->player_cursor_pos; struct v2 cursor = player->player_cursor_pos;
b32 start_dragging = player->player_dbg_drag_start; b32 start_dragging = player->player_dbg_drag_start;
@ -1123,8 +1123,8 @@ void sim_step(struct sim_step_ctx *ctx)
joint_ent->mass_unscaled = F32_INFINITY; joint_ent->mass_unscaled = F32_INFINITY;
joint_ent->inertia_unscaled = F32_INFINITY; joint_ent->inertia_unscaled = F32_INFINITY;
player->player_dbg_drag_joint_ent = joint_ent->id; player->player_dbg_drag_joint_ent = joint_ent->id;
sim_ent_enable_prop(joint_ent, SIM_ENT_PROP_MOUSE_JOINT); sim_ent_enable_prop(joint_ent, SEPROP_MOUSE_JOINT);
sim_ent_enable_prop(joint_ent, SIM_ENT_PROP_ACTIVE); sim_ent_enable_prop(joint_ent, SEPROP_ACTIVE);
} }
struct xform xf = sim_ent_get_xform(target_ent); struct xform xf = sim_ent_get_xform(target_ent);
f32 mass = target_ent->mass_unscaled * math_fabs(xform_get_determinant(xf)); f32 mass = target_ent->mass_unscaled * math_fabs(xform_get_determinant(xf));
@ -1163,7 +1163,7 @@ void sim_step(struct sim_step_ctx *ctx)
for (u64 ent_index = 0; ent_index < world->num_ents_reserved; ++ent_index) { for (u64 ent_index = 0; ent_index < world->num_ents_reserved; ++ent_index) {
struct sim_ent *ent = &world->ents[ent_index]; struct sim_ent *ent = &world->ents[ent_index];
if (!sim_ent_should_simulate(ent)) continue; if (!sim_ent_should_simulate(ent)) continue;
if (!sim_ent_has_prop(ent, SIM_ENT_PROP_TRACER)) continue; if (!sim_ent_has_prop(ent, SEPROP_TRACER)) continue;
struct v2 end = sim_ent_get_xform(ent).og; struct v2 end = sim_ent_get_xform(ent).og;
@ -1173,7 +1173,7 @@ void sim_step(struct sim_step_ctx *ctx)
if (v2_dot(tick_velocity, v2_sub(gradient_start, end)) > 0) { if (v2_dot(tick_velocity, v2_sub(gradient_start, end)) > 0) {
/* Tracer has disappeared */ /* Tracer has disappeared */
sim_ent_enable_prop(ent, SIM_ENT_PROP_RELEASE); sim_ent_enable_prop(ent, SEPROP_RELEASE);
} }
ent->tracer_gradient_start = gradient_start; ent->tracer_gradient_start = gradient_start;
@ -1187,7 +1187,7 @@ void sim_step(struct sim_step_ctx *ctx)
for (u64 ent_index = 0; ent_index < world->num_ents_reserved; ++ent_index) { for (u64 ent_index = 0; ent_index < world->num_ents_reserved; ++ent_index) {
struct sim_ent *ent = &world->ents[ent_index]; struct sim_ent *ent = &world->ents[ent_index];
if (!sim_ent_should_simulate(ent)) continue; if (!sim_ent_should_simulate(ent)) continue;
if (!sim_ent_has_prop(ent, SIM_ENT_PROP_BULLET)) continue; if (!sim_ent_has_prop(ent, SEPROP_BULLET)) continue;
if (ent->activation_tick == world->tick) { if (ent->activation_tick == world->tick) {
struct sim_ent *src = sim_ent_from_id(world, ent->bullet_src); struct sim_ent *src = sim_ent_from_id(world, ent->bullet_src);
@ -1208,7 +1208,7 @@ void sim_step(struct sim_step_ctx *ctx)
struct xform xf = XFORM_TRS(.t = pos, .r = v2_angle(impulse) + PI / 2); struct xform xf = XFORM_TRS(.t = pos, .r = v2_angle(impulse) + PI / 2);
sim_ent_set_xform(ent, xf); sim_ent_set_xform(ent, xf);
sim_ent_enable_prop(ent, SIM_ENT_PROP_PHYSICAL_KINEMATIC); sim_ent_enable_prop(ent, SEPROP_PHYSICAL_KINEMATIC);
sim_ent_apply_linear_impulse_to_center(ent, impulse); sim_ent_apply_linear_impulse_to_center(ent, impulse);
@ -1216,7 +1216,7 @@ void sim_step(struct sim_step_ctx *ctx)
struct sim_ent *tracer = sim_ent_from_id(world, ent->bullet_tracer); struct sim_ent *tracer = sim_ent_from_id(world, ent->bullet_tracer);
if (sim_ent_should_simulate(tracer)) { if (sim_ent_should_simulate(tracer)) {
sim_ent_set_xform(tracer, xf); sim_ent_set_xform(tracer, xf);
sim_ent_enable_prop(tracer, SIM_ENT_PROP_PHYSICAL_KINEMATIC); sim_ent_enable_prop(tracer, SEPROP_PHYSICAL_KINEMATIC);
sim_ent_set_linear_velocity(tracer, ent->linear_velocity); sim_ent_set_linear_velocity(tracer, ent->linear_velocity);
tracer->tracer_start = pos; tracer->tracer_start = pos;
tracer->tracer_start_velocity = ent->linear_velocity; tracer->tracer_start_velocity = ent->linear_velocity;
@ -1230,7 +1230,7 @@ void sim_step(struct sim_step_ctx *ctx)
sim_ent_set_xform(quake, XFORM_POS(pos)); sim_ent_set_xform(quake, XFORM_POS(pos));
quake->quake_intensity = 0.2f; quake->quake_intensity = 0.2f;
quake->quake_fade = quake->quake_intensity / 0.1f; quake->quake_fade = quake->quake_intensity / 0.1f;
sim_ent_enable_prop(quake, SIM_ENT_PROP_QUAKE); sim_ent_enable_prop(quake, SEPROP_QUAKE);
} }
} }
} }
@ -1242,7 +1242,7 @@ void sim_step(struct sim_step_ctx *ctx)
for (u64 ent_index = 0; ent_index < world->num_ents_reserved; ++ent_index) { for (u64 ent_index = 0; ent_index < world->num_ents_reserved; ++ent_index) {
struct sim_ent *ent = &world->ents[ent_index]; struct sim_ent *ent = &world->ents[ent_index];
if (!sim_ent_should_simulate(ent)) continue; if (!sim_ent_should_simulate(ent)) continue;
if (!sim_ent_has_prop(ent, SIM_ENT_PROP_CAMERA)) continue; if (!sim_ent_has_prop(ent, SEPROP_CAMERA)) continue;
struct xform xf = sim_ent_get_xform(ent); struct xform xf = sim_ent_get_xform(ent);
@ -1283,7 +1283,7 @@ void sim_step(struct sim_step_ctx *ctx)
for (u64 quake_ent_index = 0; quake_ent_index < world->num_ents_reserved; ++quake_ent_index) { for (u64 quake_ent_index = 0; quake_ent_index < world->num_ents_reserved; ++quake_ent_index) {
struct sim_ent *quake = &world->ents[quake_ent_index]; struct sim_ent *quake = &world->ents[quake_ent_index];
if (!sim_ent_should_simulate(quake)) continue; if (!sim_ent_should_simulate(quake)) continue;
if (!sim_ent_has_prop(quake, SIM_ENT_PROP_QUAKE)) continue; if (!sim_ent_has_prop(quake, SEPROP_QUAKE)) continue;
ent->shake += quake->quake_intensity; ent->shake += quake->quake_intensity;
} }
} }
@ -1298,11 +1298,11 @@ void sim_step(struct sim_step_ctx *ctx)
for (u64 ent_index = 0; ent_index < world->num_ents_reserved; ++ent_index) { for (u64 ent_index = 0; ent_index < world->num_ents_reserved; ++ent_index) {
struct sim_ent *ent = &world->ents[ent_index]; struct sim_ent *ent = &world->ents[ent_index];
if (!sim_ent_should_simulate(ent)) continue; if (!sim_ent_should_simulate(ent)) continue;
if (!sim_ent_has_prop(ent, SIM_ENT_PROP_QUAKE)) continue; if (!sim_ent_has_prop(ent, SEPROP_QUAKE)) continue;
ent->quake_intensity = max_f32(0, ent->quake_intensity - (ent->quake_fade * sim_dt)); ent->quake_intensity = max_f32(0, ent->quake_intensity - (ent->quake_fade * sim_dt));
if (ent->quake_intensity <= 0) { if (ent->quake_intensity <= 0) {
sim_ent_enable_prop(ent, SIM_ENT_PROP_RELEASE); sim_ent_enable_prop(ent, SEPROP_RELEASE);
} }
} }
@ -1339,7 +1339,7 @@ void sim_step(struct sim_step_ctx *ctx)
* Release entities at end of frame * Release entities at end of frame
* ========================== */ * ========================== */
sim_ent_release_all_with_prop(world, SIM_ENT_PROP_RELEASE); sim_ent_release_all_with_prop(world, SEPROP_RELEASE);
/* ========================== * /* ========================== *
* Sync to publish client * Sync to publish client
@ -1356,8 +1356,8 @@ void sim_step(struct sim_step_ctx *ctx)
for (u64 ent_index = 2; ent_index < pub_world->num_ents_reserved; ++ent_index) { for (u64 ent_index = 2; ent_index < pub_world->num_ents_reserved; ++ent_index) {
struct sim_ent *ent = &pub_world->ents[ent_index]; struct sim_ent *ent = &pub_world->ents[ent_index];
if (ent->valid) { if (ent->valid) {
sim_ent_enable_prop(ent, SIM_ENT_PROP_SYNC_DST); sim_ent_enable_prop(ent, SEPROP_SYNC_DST);
sim_ent_enable_prop(ent, SIM_ENT_PROP_SYNC_SRC); sim_ent_enable_prop(ent, SEPROP_SYNC_SRC);
} }
} }

View File

@ -350,8 +350,8 @@ INTERNAL struct string get_ent_debug_text(struct arena *arena, struct sim_ent *e
res.len += string_format(arena, LIT("[%F]"), FMT_UID(ent->id.uid)).len; res.len += string_format(arena, LIT("[%F]"), FMT_UID(ent->id.uid)).len;
{ {
b32 transmitting = sim_ent_has_prop(ent, SIM_ENT_PROP_SYNC_SRC); b32 transmitting = sim_ent_has_prop(ent, SEPROP_SYNC_SRC);
b32 receiving = sim_ent_has_prop(ent, SIM_ENT_PROP_SYNC_DST); b32 receiving = sim_ent_has_prop(ent, SEPROP_SYNC_DST);
if (transmitting & receiving) { if (transmitting & receiving) {
res.len += string_copy(arena, LIT(" networked (sending & receiving)")).len; res.len += string_copy(arena, LIT(" networked (sending & receiving)")).len;
} else if (transmitting) { } else if (transmitting) {
@ -373,7 +373,7 @@ INTERNAL struct string get_ent_debug_text(struct arena *arena, struct sim_ent *e
for (u64 chunk_index = ARRAY_COUNT(ent->props); chunk_index-- > 0;) { for (u64 chunk_index = ARRAY_COUNT(ent->props); chunk_index-- > 0;) {
u64 chunk = ent->props[chunk_index]; u64 chunk = ent->props[chunk_index];
for (u64 part_index = 8; part_index-- > 0;) { for (u64 part_index = 8; part_index-- > 0;) {
if ((chunk_index != (ARRAY_COUNT(ent->props) - 1)) || ((chunk_index * 64) + (part_index * 8)) <= SIM_ENT_PROP_COUNT) { if ((chunk_index != (ARRAY_COUNT(ent->props) - 1)) || ((chunk_index * 64) + (part_index * 8)) <= SEPROP_COUNT) {
u8 part = (chunk >> (part_index * 8)) & 0xFF; u8 part = (chunk >> (part_index * 8)) & 0xFF;
string_from_char(arena, hex[(part >> 4) & 0x0F]); string_from_char(arena, hex[(part >> 4) & 0x0F]);
string_from_char(arena, hex[(part >> 0) & 0x0F]); string_from_char(arena, hex[(part >> 0) & 0x0F]);
@ -895,7 +895,7 @@ INTERNAL void user_update(void)
for (u64 ent_index = 0; ent_index < G.ss_blended->num_ents_reserved; ++ent_index) { for (u64 ent_index = 0; ent_index < G.ss_blended->num_ents_reserved; ++ent_index) {
struct sim_ent *chunk_ent = &G.ss_blended->ents[ent_index]; struct sim_ent *chunk_ent = &G.ss_blended->ents[ent_index];
if (sim_ent_is_valid_and_active(chunk_ent) && sim_ent_has_prop(chunk_ent, SIM_ENT_PROP_TILE_CHUNK)) { if (sim_ent_is_valid_and_active(chunk_ent) && sim_ent_has_prop(chunk_ent, SEPROP_TILE_CHUNK)) {
struct user_tile_cache_entry *entry = user_tile_cache_entry_from_chunk_pos(chunk_ent->tile_chunk_pos); struct user_tile_cache_entry *entry = user_tile_cache_entry_from_chunk_pos(chunk_ent->tile_chunk_pos);
if (!entry->valid) { if (!entry->valid) {
entry = user_tile_cache_entry_alloc(chunk_ent->tile_chunk_pos); entry = user_tile_cache_entry_alloc(chunk_ent->tile_chunk_pos);
@ -1026,13 +1026,13 @@ INTERNAL void user_update(void)
struct xform parent_xf = sim_ent_get_xform(parent); struct xform parent_xf = sim_ent_get_xform(parent);
b32 skip_debug_draw = !G.debug_camera && ent == local_camera; b32 skip_debug_draw = !G.debug_camera && ent == local_camera;
b32 skip_debug_draw_transform = sim_ent_has_prop(ent, SIM_ENT_PROP_CAMERA); b32 skip_debug_draw_transform = sim_ent_has_prop(ent, SEPROP_CAMERA);
skip_debug_draw_transform = true; skip_debug_draw_transform = true;
struct xform sprite_xform = xf; struct xform sprite_xform = xf;
/* Draw tracer */ /* Draw tracer */
if (sim_ent_has_prop(ent, SIM_ENT_PROP_TRACER)) { if (sim_ent_has_prop(ent, SEPROP_TRACER)) {
struct v2 velocity = ent->tracer_start_velocity; struct v2 velocity = ent->tracer_start_velocity;
struct v2 a = ent->tracer_start; struct v2 a = ent->tracer_start;
@ -1093,7 +1093,7 @@ INTERNAL void user_update(void)
if (G.debug_draw && !skip_debug_draw) { if (G.debug_draw && !skip_debug_draw) {
struct temp_arena temp = arena_temp_begin(scratch.arena); struct temp_arena temp = arena_temp_begin(scratch.arena);
if (sim_ent_has_prop(ent, SIM_ENT_PROP_PHYSICAL_DYNAMIC) || sim_ent_has_prop(ent, SIM_ENT_PROP_PHYSICAL_KINEMATIC)) { if (sim_ent_has_prop(ent, SEPROP_PHYSICAL_DYNAMIC) || sim_ent_has_prop(ent, SEPROP_PHYSICAL_KINEMATIC)) {
debug_draw_movement(ent); debug_draw_movement(ent);
} }
@ -1169,7 +1169,7 @@ INTERNAL void user_update(void)
#endif #endif
/* Draw collider */ /* Draw collider */
if (sim_ent_has_prop(ent, SIM_ENT_PROP_PHYSICAL_DYNAMIC)) { if (sim_ent_has_prop(ent, SEPROP_PHYSICAL_DYNAMIC)) {
struct collider_shape collider = ent->local_collider; struct collider_shape collider = ent->local_collider;
u32 color = RGBA_32_F(1, 1, 0, 0.5); u32 color = RGBA_32_F(1, 1, 0, 0.5);
f32 thickness = 2; f32 thickness = 2;
@ -1204,7 +1204,7 @@ INTERNAL void user_update(void)
} }
/* Draw contact constraint */ /* Draw contact constraint */
if (sim_ent_has_prop(ent, SIM_ENT_PROP_CONTACT_CONSTRAINT)) { if (sim_ent_has_prop(ent, SEPROP_CONTACT_CONSTRAINT)) {
struct phys_contact_constraint *data = &ent->contact_constraint_data; struct phys_contact_constraint *data = &ent->contact_constraint_data;
struct sim_ent *e0 = sim_ent_from_id(G.ss_blended, data->e0); struct sim_ent *e0 = sim_ent_from_id(G.ss_blended, data->e0);
struct sim_ent *e1 = sim_ent_from_id(G.ss_blended, data->e1); struct sim_ent *e1 = sim_ent_from_id(G.ss_blended, data->e1);
@ -1277,7 +1277,7 @@ INTERNAL void user_update(void)
/* Draw collision debug */ /* Draw collision debug */
#if COLLIDER_DEBUG #if COLLIDER_DEBUG
if (sim_ent_has_prop(ent, SIM_ENT_PROP_COLLISION_DEBUG)) { if (sim_ent_has_prop(ent, SEPROP_COLLISION_DEBUG)) {
struct phys_collision_debug *data = &ent->collision_debug_data; struct phys_collision_debug *data = &ent->collision_debug_data;
struct collider_collision_points_result collider_res = data->res; struct collider_collision_points_result collider_res = data->res;
struct sim_ent *e0 = sim_ent_from_id(G.ss_blended, data->e0); struct sim_ent *e0 = sim_ent_from_id(G.ss_blended, data->e0);
@ -1468,7 +1468,7 @@ INTERNAL void user_update(void)
#endif #endif
/* Draw hierarchy */ /* Draw hierarchy */
if (sim_ent_has_prop(parent, SIM_ENT_PROP_ACTIVE) && !parent->is_root) { if (sim_ent_has_prop(parent, SEPROP_ACTIVE) && !parent->is_root) {
u32 color = RGBA_32_F(0.6, 0.6, 1, 0.75); u32 color = RGBA_32_F(0.6, 0.6, 1, 0.75);
f32 thickness = 2; f32 thickness = 2;
f32 arrow_height = 15; f32 arrow_height = 15;
@ -1479,7 +1479,7 @@ INTERNAL void user_update(void)
} }
/* Draw camera rect */ /* Draw camera rect */
if (sim_ent_has_prop(ent, SIM_ENT_PROP_CAMERA)) { if (sim_ent_has_prop(ent, SEPROP_CAMERA)) {
u32 color = ent == local_camera ? RGBA_32_F(1, 1, 1, 0.5) : RGBA_32_F(0, 0.75, 0, 0.5); u32 color = ent == local_camera ? RGBA_32_F(1, 1, 1, 0.5) : RGBA_32_F(0, 0.75, 0, 0.5);
f32 thickness = 3; f32 thickness = 3;
@ -1781,15 +1781,15 @@ INTERNAL void user_update(void)
draw_text(G.ui_cmd_buffer, font, pos, string_format(temp.arena, LIT("debug_camera: %F"), FMT_STR(G.debug_camera ? LIT("true") : LIT("false")))); draw_text(G.ui_cmd_buffer, font, pos, string_format(temp.arena, LIT("debug_camera: %F"), FMT_STR(G.debug_camera ? LIT("true") : LIT("false"))));
pos.y += spacing; pos.y += spacing;
struct v2 player_linear_vel = sim_ent_find_first_match_one(store, SIM_ENT_PROP_PLAYER_CONTROLLED)->linear_velocity; struct v2 player_linear_vel = sim_ent_find_first_match_one(store, SEPROP_PLAYER_CONTROLLED)->linear_velocity;
draw_text(G.ui_cmd_buffer, font, pos, string_format(temp.arena, LIT("player linear velocity: (%F, %F)"), FMT_FLOAT_P((f64)player_linear_vel.x, 12), FMT_FLOAT_P((f64)player_linear_vel.y, 12))); draw_text(G.ui_cmd_buffer, font, pos, string_format(temp.arena, LIT("player linear velocity: (%F, %F)"), FMT_FLOAT_P((f64)player_linear_vel.x, 12), FMT_FLOAT_P((f64)player_linear_vel.y, 12)));
pos.y += spacing; pos.y += spacing;
f32 player_angular_vel = sim_ent_find_first_match_one(store, SIM_ENT_PROP_PLAYER_CONTROLLED)->angular_velocity; f32 player_angular_vel = sim_ent_find_first_match_one(store, SEPROP_PLAYER_CONTROLLED)->angular_velocity;
draw_text(G.ui_cmd_buffer, font, pos, string_format(temp.arena, LIT("player angular velocity: %F"), FMT_FLOAT_P((f64)player_angular_vel, 12))); draw_text(G.ui_cmd_buffer, font, pos, string_format(temp.arena, LIT("player angular velocity: %F"), FMT_FLOAT_P((f64)player_angular_vel, 12)));
pos.y += spacing; pos.y += spacing;
struct v2 player_pos = sim_ent_get_xform(sim_ent_find_first_match_one(store, SIM_ENT_PROP_PLAYER_CONTROLLED)).og; struct v2 player_pos = sim_ent_get_xform(sim_ent_find_first_match_one(store, SEPROP_PLAYER_CONTROLLED)).og;
draw_text(G.ui_cmd_buffer, font, pos, string_format(temp.arena, LIT("player pos: (%F, %F)"), FMT_FLOAT_P((f64)player_pos.x, 12), FMT_FLOAT_P((f64)player_pos.y, 12))); draw_text(G.ui_cmd_buffer, font, pos, string_format(temp.arena, LIT("player pos: (%F, %F)"), FMT_FLOAT_P((f64)player_pos.x, 12), FMT_FLOAT_P((f64)player_pos.y, 12)));
pos.y += spacing; pos.y += spacing;
#endif #endif
@ -1946,12 +1946,12 @@ INTERNAL void generate_user_input_cmds(struct sim_client *user_input_client, u64
struct sim_snapshot *user_input_ss = sim_snapshot_alloc(user_input_client, prev_user_input_ss, tick); struct sim_snapshot *user_input_ss = sim_snapshot_alloc(user_input_client, prev_user_input_ss, tick);
struct sim_ent *user_input_root = sim_ent_from_id(user_input_ss, SIM_ENT_ROOT_ID); struct sim_ent *user_input_root = sim_ent_from_id(user_input_ss, SIM_ENT_ROOT_ID);
/* Find / create local control cmd ent */ /* Find / create local control cmd ent */
struct sim_ent *control_cmd = sim_ent_find_first_match_one(user_input_ss, SIM_ENT_PROP_CMD); struct sim_ent *control_cmd = sim_ent_find_first_match_one(user_input_ss, SEPROP_CMD);
if (!control_cmd->valid) { if (!control_cmd->valid) {
control_cmd = sim_ent_alloc_sync_src(user_input_root); control_cmd = sim_ent_alloc_sync_src(user_input_root);
control_cmd->cmd_kind = SIM_CMD_KIND_CONTROL; control_cmd->cmd_kind = SIM_CMD_KIND_CONTROL;
control_cmd->predictor = user_input_client->player_id; control_cmd->predictor = user_input_client->player_id;
sim_ent_enable_prop(control_cmd, SIM_ENT_PROP_CMD); sim_ent_enable_prop(control_cmd, SEPROP_CMD);
sim_ent_activate(control_cmd, user_input_ss->tick); sim_ent_activate(control_cmd, user_input_ss->tick);
} }
{ {
@ -2229,9 +2229,9 @@ INTERNAL SYS_THREAD_ENTRY_POINT_FUNC_DEF(user_local_sim_thread_entry_point, arg)
/* Assume all incoming ents want to be sync srcs */ /* Assume all incoming ents want to be sync srcs */
for (u64 i = 0; i < ss->num_ents_reserved; ++i) { for (u64 i = 0; i < ss->num_ents_reserved; ++i) {
struct sim_ent *ent = &ss->ents[i]; struct sim_ent *ent = &ss->ents[i];
if (ent->valid && sim_ent_has_prop(ent, SIM_ENT_PROP_SYNC_DST)) { if (ent->valid && sim_ent_has_prop(ent, SEPROP_SYNC_DST)) {
sim_ent_disable_prop(ent, SIM_ENT_PROP_SYNC_DST); sim_ent_disable_prop(ent, SEPROP_SYNC_DST);
sim_ent_enable_prop(ent, SIM_ENT_PROP_SYNC_SRC); sim_ent_enable_prop(ent, SEPROP_SYNC_SRC);
} }
} }
} else { } else {
@ -2418,7 +2418,7 @@ INTERNAL SYS_THREAD_ENTRY_POINT_FUNC_DEF(user_local_sim_thread_entry_point, arg)
} }
if (master_ss->valid) { if (master_ss->valid) {
struct sim_ent *master_player = sim_ent_find_first_match_one(master_ss, SIM_ENT_PROP_PLAYER_IS_MASTER); struct sim_ent *master_player = sim_ent_find_first_match_one(master_ss, SEPROP_PLAYER_IS_MASTER);
/* Update ent id from master */ /* Update ent id from master */
{ {