diff --git a/src/pp/pp.c b/src/pp/pp.c index 733790aa..97a1812f 100644 --- a/src/pp/pp.c +++ b/src/pp/pp.c @@ -199,7 +199,7 @@ String PP_DebugStringFromEnt(Arena *arena, PP_Ent *ent) String result = ZI; result.text = PushDry(arena, u8); - //result.len += StringF(arena, "[%F]", FmtUid(ent->id.uid)).len; + //result.len += StringF(arena, "[%F]", FmtUid(ent->key.uid)).len; { b32 transmitting = PP_HasProp(ent, PP_Prop_SyncSrc); b32 receiving = PP_HasProp(ent, PP_Prop_SyncDst); @@ -862,7 +862,7 @@ void PP_UpdateUser(void) { if (PP_IsNilEntKey(g->debug_following)) { - g->debug_following = hovered_ent->id; + g->debug_following = hovered_ent->key; } else { @@ -905,7 +905,7 @@ void PP_UpdateUser(void) f32 shake = ent->shake; if (shake > 0) { - u64 angle_seed0 = ent->id.uid.lo + (u64)(g->ss_blended->sim_time_ns / frequency_ns); + u64 angle_seed0 = ent->key.uid.lo + (u64)(g->ss_blended->sim_time_ns / frequency_ns); u64 angle_seed1 = angle_seed0 + 1; f32 angle0 = RandF64FromSeed(angle_seed0, 0, Tau); f32 angle1 = RandF64FromSeed(angle_seed1, 0, Tau); @@ -1406,7 +1406,7 @@ void PP_UpdateUser(void) } /* Draw focus arrow */ - if (ent == local_control || PP_EqEntKey(ent->id, g->debug_following)) + if (ent == local_control || PP_EqEntKey(ent->key, g->debug_following)) { S_Sheet *sheet = S_SheetFromResourceAsync(ent->sprite); S_Slice slice = S_SliceFromNameIndex(sheet, Lit("attach.wep"), ent->animation_frame); @@ -1584,7 +1584,7 @@ void PP_UpdateUser(void) String fmt = Lit( "e0 index: %F\n" "e1 index: %F\n" - "id: 0x%F\n" + "key: 0x%F\n" "impulse (n): %F\n" "impulse (t): %F\n" "separation: %F\n" @@ -1592,9 +1592,9 @@ void PP_UpdateUser(void) "num contacts: %F" ); String text = StringF(temp.arena, fmt, - FmtUint(e0->handle.idx), - FmtUint(e1->handle.idx), - FmtHex(point.id), + FmtUint(e0->key.idx), + FmtUint(e1->key.idx), + FmtHex(point.key), FmtFloat(point.normal_impulse), FmtFloat(point.tangent_impulse), FmtFloatP(point.starting_separation, 6), @@ -2039,7 +2039,7 @@ void PP_UpdateUser(void) u32 old_flags = g->user_sim_cmd_control.flags; g->user_sim_cmd_control = control; g->user_sim_cmd_control.flags |= old_flags; - g->user_hovered_ent = hovered_ent->id; + g->user_hovered_ent = hovered_ent->key; Unlock(&lock); } } @@ -2146,7 +2146,7 @@ void PP_UpdateUser(void) UI_BuildLabelF("render time: %F", FmtFloat(SecondsFromNs(g->render_time_ns))); - UI_BuildLabelF("local player: [%F]", FmtUid(local_player->id.uid)); + UI_BuildLabelF("local player: [%F]", FmtUid(local_player->key.uid)); UI_BuildSpacer(UI_EM(1.5, 0)); Vec2 world_cursor = g->world_cursor; @@ -2451,7 +2451,7 @@ void PP_UpdateUser(void) //////////////////////////////////////////////////////////// //~ User update job -JobDef(PP_UpdateUserOrSleep, UNUSED sig, UNUSED id) +JobDef(PP_UpdateUserOrSleep, UNUSED sig, UNUSED key) { PP_SharedUserState *g = &PP_shared_user_state; i64 time_ns = TimeNs(); @@ -2511,7 +2511,7 @@ void PP_GenerateuserInputCmds(PP_Client *user_input_client, u64 tick) //////////////////////////////////////////////////////////// //~ Sim update -JobDef(PP_UpdateSim, UNUSED sig, UNUSED id) +JobDef(PP_UpdateSim, UNUSED sig, UNUSED key) { PP_SharedUserState *g = &PP_shared_user_state; #if 0 @@ -3014,7 +3014,7 @@ JobDef(PP_UpdateSim, UNUSED sig, UNUSED id) { PP_Ent *master_player = PP_FirstWithProp(master_ss, PP_Prop_IsMaster); - /* Update ent id from master */ + /* Update ent key from master */ { user_input_client->player_id = master_ss->local_player; local_client->player_id = master_ss->local_player; @@ -3083,7 +3083,7 @@ JobDef(PP_UpdateSim, UNUSED sig, UNUSED id) { if (base_ss->valid) { - PP_SyncSnapshotEnts(base_ss, master_ss, master_player->id, 0); + PP_SyncSnapshotEnts(base_ss, master_ss, master_player->key, 0); } else { @@ -3112,7 +3112,7 @@ JobDef(PP_UpdateSim, UNUSED sig, UNUSED id) ctx.world = PP_AcquireSnapshot(local_client, prev_ss, step_tick); if (!mispredicted_tick && step_tick == step_end_tick) { - PP_SyncSnapshotEnts(ctx.world, master_ss, master_player->id, PP_SyncFlag_NoSyncPredictables); + PP_SyncSnapshotEnts(ctx.world, master_ss, master_player->key, PP_SyncFlag_NoSyncPredictables); } PP_StepSim(&ctx); prev_ss = ctx.world; diff --git a/src/pp/pp_ent.c b/src/pp/pp_ent.c index 5e9e59c8..db0b68f0 100644 --- a/src/pp/pp_ent.c +++ b/src/pp/pp_ent.c @@ -1,7 +1,7 @@ //////////////////////////////////////////////////////////// //~ Acquire -PP_Ent *PP_AcquireRawEnt(PP_Snapshot *ss, PP_Ent *parent, PP_EntKey id) +PP_Ent *PP_AcquireRawEnt(PP_Snapshot *ss, PP_Ent *parent, PP_EntKey key) { Assert(parent->valid); Assert(ss->valid); @@ -26,7 +26,7 @@ PP_Ent *PP_AcquireRawEnt(PP_Snapshot *ss, PP_Ent *parent, PP_EntKey id) ent->_is_xform_dirty = 1; ++ss->num_ents_allocated; - PP_SetEntKey(ent, id); + PP_SetEntKey(ent, key); PP_Link(ent, parent); return ent; @@ -41,10 +41,10 @@ PP_Ent *PP_AcquireLocalEnt(PP_Ent *parent) return e; } -PP_Ent *PP_AcquireLocalEntWithKey(PP_Ent *parent, PP_EntKey id) +PP_Ent *PP_AcquireLocalEntWithKey(PP_Ent *parent, PP_EntKey key) { PP_Snapshot *ss = parent->ss; - PP_Ent *e = PP_AcquireRawEnt(ss, parent, id); + PP_Ent *e = PP_AcquireRawEnt(ss, parent, key); e->owner = ss->local_player; return e; } @@ -59,16 +59,16 @@ PP_Ent *PP_AcquireSyncSrcEnt(PP_Ent *parent) return e; } -PP_Ent *PP_AcquireSyncSrcEntWithKey(PP_Ent *parent, PP_EntKey id) +PP_Ent *PP_AcquireSyncSrcEntWithKey(PP_Ent *parent, PP_EntKey key) { PP_Snapshot *ss = parent->ss; - PP_Ent *e = PP_AcquireRawEnt(ss, parent, id); + PP_Ent *e = PP_AcquireRawEnt(ss, parent, key); PP_EnableProp(e, PP_Prop_SyncSrc); e->owner = ss->local_player; return e; } -/* Acquires a new entity that will sync with incoming net src ents containing id, and coming from the specified owner */ +/* Acquires a new entity that will sync with incoming net src ents containing key, and coming from the specified owner */ PP_Ent *PP_AcquireSyncDstEnt(PP_Ent *parent, PP_EntKey ent_id, PP_EntKey owner_id) { PP_Snapshot *ss = parent->ss; @@ -156,7 +156,7 @@ void PP_ActivateEnt(PP_Ent *ent, u64 current_tick) } //////////////////////////////////////////////////////////// -//~ Ent id +//~ Ent key u32 PP_IndexFromEnt(PP_Snapshot *ss, PP_Ent *ent) { @@ -175,17 +175,17 @@ PP_Ent *PP_EntFromIndex(PP_Snapshot *ss, u32 index) } } -PP_EntBin *PP_EntBinFromKey(PP_Snapshot *ss, PP_EntKey id) +PP_EntBin *PP_EntBinFromKey(PP_Snapshot *ss, PP_EntKey key) { - return &ss->id_bins[id.uid.lo % ss->num_id_bins]; + return &ss->key_bins[key.uid.lo % ss->num_key_bins]; } -/* NOTE: This should only really happen during ent allocation (it doesn't make sense for an allocated ent's id to change) */ -void PP_SetEntKey(PP_Ent *ent, PP_EntKey id) +/* NOTE: This should only really happen during ent allocation (it doesn't make sense for an allocated ent's key to change) */ +void PP_SetEntKey(PP_Ent *ent, PP_EntKey key) { PP_Snapshot *ss = ent->ss; - PP_EntKey old_id = ent->id; - if (!PP_EqEntKey(old_id, id)) + PP_EntKey old_id = ent->key; + if (!PP_EqEntKey(old_id, key)) { /* Release old from lookup */ if (!PP_IsNilEntKey(old_id)) @@ -201,7 +201,7 @@ void PP_SetEntKey(PP_Ent *ent, PP_EntKey id) { next_index = search->next_in_id_bin; next = PP_EntFromIndex(ss, next_index); - if (PP_EqEntKey(search->id, old_id)) + if (PP_EqEntKey(search->key, old_id)) { break; } @@ -211,7 +211,7 @@ void PP_SetEntKey(PP_Ent *ent, PP_EntKey id) search = next; } - /* Old id not in bin, this should be impossible. */ + /* Old key not in bin, this should be impossible. */ Assert(search->valid); if (prev->valid) @@ -233,18 +233,18 @@ void PP_SetEntKey(PP_Ent *ent, PP_EntKey id) } } - /* Insert new id into lookup */ - if (!PP_IsNilEntKey(id)) + /* Insert new key into lookup */ + if (!PP_IsNilEntKey(key)) { #if RtcIsEnabled { - PP_Ent *existing = PP_EntFromKey(ss, id); + PP_Ent *existing = PP_EntFromKey(ss, key); /* Collision should be extremely unlikely under normal circumstances, there's probably a logic error somewhere. */ Assert(!existing->valid); } #endif - PP_EntBin *bin = PP_EntBinFromKey(ss, id); + PP_EntBin *bin = PP_EntBinFromKey(ss, key); u32 ent_index = PP_IndexFromEnt(ss, ent); PP_Ent *last = PP_EntFromIndex(ss, bin->last); if (last->valid) @@ -260,20 +260,20 @@ void PP_SetEntKey(PP_Ent *ent, PP_EntKey id) bin->last = ent_index; } - ent->id = id; + ent->key = key; } } -PP_Ent *PP_EntFromKey(PP_Snapshot *ss, PP_EntKey id) +PP_Ent *PP_EntFromKey(PP_Snapshot *ss, PP_EntKey key) { PP_Ent *result = PP_NilEnt(); - if (!PP_IsNilEntKey(id) && ss->valid) + if (!PP_IsNilEntKey(key) && ss->valid) { - PP_EntBin *bin = PP_EntBinFromKey(ss, id); + PP_EntBin *bin = PP_EntBinFromKey(ss, key); for (PP_Ent *e = PP_EntFromIndex(ss, bin->first); e->valid; e = PP_EntFromIndex(ss, e->next_in_id_bin)) { - if (PP_EqEntKey(e->id, id)) + if (PP_EqEntKey(e->key, key)) { result = e; break; @@ -290,7 +290,7 @@ PP_EntKey PP_RandomKey(void) return result; } -/* Returns the deterministic id of the contact constraint ent id that should be produced from e0 & e1 colliding */ +/* Returns the deterministic key of the contact constraint ent key that should be produced from e0 & e1 colliding */ PP_EntKey PP_ContactConstraintKeyFromContactingKeys(PP_EntKey player_id, PP_EntKey id0, PP_EntKey id1) { PP_EntKey result = ZI; @@ -301,7 +301,7 @@ PP_EntKey PP_ContactConstraintKeyFromContactingKeys(PP_EntKey player_id, PP_EntK return result; } -/* Returns the deterministic id of the debug contact constraint ent id that should be produced from e0 & e1 colliding */ +/* Returns the deterministic key of the debug contact constraint ent key that should be produced from e0 & e1 colliding */ PP_EntKey PP_CollisionDebugKeyFromKeys(PP_EntKey player_id, PP_EntKey id0, PP_EntKey id1) { PP_EntKey result = ZI; @@ -312,7 +312,7 @@ PP_EntKey PP_CollisionDebugKeyFromKeys(PP_EntKey player_id, PP_EntKey id0, PP_En return result; } -/* Returns the deterministic id of the tile chunk that should be produced at chunk pos */ +/* Returns the deterministic key of the tile chunk that should be produced at chunk pos */ PP_EntKey PP_TileChunkKeyFromIndex(Vec2I32 chunk_index) { PP_EntKey result = ZI; @@ -380,7 +380,7 @@ void PP_Link(PP_Ent *ent, PP_Ent *parent) PP_Unlink(ent); } - PP_EntKey ent_id = ent->id; + PP_EntKey ent_id = ent->key; PP_EntKey last_child_id = parent->last; PP_Ent *last_child = PP_EntFromKey(ss, last_child_id); if (last_child->valid) @@ -404,7 +404,7 @@ void PP_Link(PP_Ent *ent, PP_Ent *parent) ent->top = parent->top; } - ent->parent = parent->id; + ent->parent = parent->key; } /* NOTE: PP_Ent will be dangling after calling this, should re-link to root ent. */ @@ -420,19 +420,19 @@ void PP_Unlink(PP_Ent *ent) /* Unlink from parent & siblings */ if (prev->valid) { - prev->next = next->id; + prev->next = next->key; } else { - parent->first = next->id; + parent->first = next->key; } if (next->valid) { - next->prev = prev->id; + next->prev = prev->key; } else { - parent->last = prev->id; + parent->last = prev->key; } ent->prev = PP_NilEntKey; ent->next = PP_NilEntKey; @@ -652,7 +652,7 @@ PP_TileKind PP_TileKindFromChunk(PP_Ent *chunk_ent, Vec2I32 local_tile_index) void PP_LerpEnt(PP_Ent *e, PP_Ent *e0, PP_Ent *e1, f64 blend) { if (PP_IsValidAndActive(e0) && PP_IsValidAndActive(e1) - && PP_EqEntKey(e0->id, e1->id) + && PP_EqEntKey(e0->key, e1->key) && e0->continuity_gen == e1->continuity_gen) { e->_local_xform = LerpXform(e0->_local_xform, e1->_local_xform, blend); @@ -699,11 +699,11 @@ void PP_CreateMissingEntsFromSnapshots(PP_Ent *local_parent, PP_Ent *remote, PP_ PP_Snapshot *local_ss = local_parent->ss; PP_Snapshot *remote_ss = remote->ss; - PP_EntKey id = remote->id; - PP_Ent *local_ent = PP_EntFromKey(local_ss, id); + PP_EntKey key = remote->key; + PP_Ent *local_ent = PP_EntFromKey(local_ss, key); if (!local_ent->valid) { - local_ent = PP_AcquireSyncDstEnt(local_parent, id, remote_player); + local_ent = PP_AcquireSyncDstEnt(local_parent, key, remote_player); } for (PP_Ent *remote_child = PP_EntFromKey(remote_ss, remote->first); remote_child->valid; remote_child = PP_EntFromKey(remote_ss, remote_child->next)) { @@ -719,10 +719,10 @@ void PP_SyncEnt(PP_Ent *local, PP_Ent *remote) CopyStruct(local, remote); /* Why would 2 ents w/ different uids ever be synced? */ - Assert(PP_EqEntKey(local->id, old.id)); + Assert(PP_EqEntKey(local->key, old.key)); local->ss = old.ss; - local->id = old.id; + local->key = old.key; /* Keep local tree */ local->parent = old.parent; @@ -807,7 +807,7 @@ void PP_EncodeEnt(BB_Writer *bw, PP_Ent *e0, PP_Ent *e1) /* FIXME: Things like xforms need to be retreived manually rather than memcopied. - * This will also be true for things like ent handles once uids are implemented. */ + * This will also be true for things like ent keys once uids are implemented. */ /* TODO: Granular delta encoding */ @@ -856,10 +856,10 @@ void PP_DecodeEnt(BB_Reader *br, PP_Ent *e) } decoded.ss = e->ss; - PP_EntKey old_id = e->id; - PP_EntKey new_id = decoded.id; + PP_EntKey old_id = e->key; + PP_EntKey new_id = decoded.key; CopyStruct(e, &decoded); - e->id = old_id; + e->key = old_id; if (!PP_EqEntKey(old_id, new_id)) { PP_SetEntKey(e, new_id); diff --git a/src/pp/pp_ent.h b/src/pp/pp_ent.h index 1076a6a4..e3c9e8ce 100644 --- a/src/pp/pp_ent.h +++ b/src/pp/pp_ent.h @@ -71,7 +71,7 @@ Struct(PP_Ent) //- Metadata b32 valid; /* Is this ent allocated in memory that can be written to (can always be read) */ - PP_EntKey id; + PP_EntKey key; u64 props[(PP_Prop_Count + 63) / 64]; u64 continuity_gen; @@ -81,7 +81,7 @@ Struct(PP_Ent) /* Is ent a child of the root ent */ b32 is_top; - /* The id of the top level parent of the ent tree (if ent is top then this point to itself) */ + /* The key of the top level parent of the ent tree (if ent is top then this point to itself) */ PP_EntKey top; /* Tree */ @@ -101,10 +101,10 @@ Struct(PP_Ent) /* PP_Prop_SyncSrc */ /* PP_Prop_SyncDst */ - /* Id of the player that owns simulation for this entity */ + /* Key of the player that owns simulation for this entity */ PP_EntKey owner; - /* Id of the player that should predict simulation of this this entity locally */ + /* Key of the player that should predict simulation of this this entity locally */ PP_EntKey predictor; //- Position @@ -162,7 +162,7 @@ Struct(PP_Ent) /* FIXME: Lerp */ - PP_ClientKey player_client_handle; /* The client key on the master sim's machine */ + PP_ClientKey player_client_key; /* The client key on the master sim's machine */ PP_ControlData player_control; Vec2 player_cursor_pos; @@ -188,7 +188,7 @@ Struct(PP_Ent) ContactDebugData collision_debug_data; #endif - PP_SpaceEntryKey space_handle; + PP_SpaceEntryKey space_key; //- Constraints / joints @@ -394,27 +394,27 @@ Inline PP_Ent *PP_NilEnt(void) } //////////////////////////////////////////////////////////// -//~ Id types +//~ Key types #define PP_NilEntKey ((PP_EntKey) { UID(0, 0) }) #define PP_RootEntKey ((PP_EntKey) { UID(0xaaaaaaaaaaaaaaaa, 0xaaaaaaaaaaaaaaaa) }) -/* Id magic number constants (to be used in conjunction with ent ids in deterministic id combinations) */ +/* Key magic number constants (to be used in conjunction with ent ids in deterministic key combinations) */ #define PP_TileChunkBasisUid (UID(0x3ce42de071dd226b, 0x9b566f7df30c813a)) #define PP_ContactBasisUid (UID(0x6a2a5d2dbecf534f, 0x0a8ca7c372a015af)) #define PP_CollisionDebugBasisUid (UID(0x302c01182013bb02, 0x570bd270399d11a5)) //////////////////////////////////////////////////////////// -//~ Id helpers +//~ Key helpers Inline b32 PP_EqEntKey(PP_EntKey a, PP_EntKey b) { return EqUid(a.uid, b.uid); } -Inline b32 PP_IsNilEntKey(PP_EntKey id) +Inline b32 PP_IsNilEntKey(PP_EntKey key) { - return EqUid(id.uid, PP_NilEntKey.uid); + return EqUid(key.uid, PP_NilEntKey.uid); } //////////////////////////////////////////////////////////// @@ -474,11 +474,11 @@ Inline b32 PP_ShouldSimulate(PP_Ent *ent) //////////////////////////////////////////////////////////// //~ Acquire operations -PP_Ent *PP_AcquireRawEnt(PP_Snapshot *ss, PP_Ent *parent, PP_EntKey id); +PP_Ent *PP_AcquireRawEnt(PP_Snapshot *ss, PP_Ent *parent, PP_EntKey key); PP_Ent *PP_AcquireLocalEnt(PP_Ent *parent); -PP_Ent *PP_AcquireLocalEntWithKey(PP_Ent *parent, PP_EntKey id); +PP_Ent *PP_AcquireLocalEntWithKey(PP_Ent *parent, PP_EntKey key); PP_Ent *PP_AcquireSyncSrcEnt(PP_Ent *parent); -PP_Ent *PP_AcquireSyncSrcEntWithKey(PP_Ent *parent, PP_EntKey id); +PP_Ent *PP_AcquireSyncSrcEntWithKey(PP_Ent *parent, PP_EntKey key); PP_Ent *PP_AcquireSyncDstEnt(PP_Ent *parent, PP_EntKey ent_id, PP_EntKey owner_id); //////////////////////////////////////////////////////////// @@ -494,13 +494,13 @@ void PP_ReleaseAllWithProp(PP_Snapshot *ss, PP_Prop prop); void PP_ActivateEnt(PP_Ent *ent, u64 current_tick); //////////////////////////////////////////////////////////// -//~ Id operations +//~ Key operations u32 PP_IndexFromEnt(PP_Snapshot *ss, PP_Ent *ent); PP_Ent *PP_EntFromIndex(PP_Snapshot *ss, u32 index); -PP_EntBin *PP_EntBinFromKey(PP_Snapshot *ss, PP_EntKey id); -void PP_SetEntKey(PP_Ent *ent, PP_EntKey id); -PP_Ent *PP_EntFromKey(PP_Snapshot *ss, PP_EntKey id); +PP_EntBin *PP_EntBinFromKey(PP_Snapshot *ss, PP_EntKey key); +void PP_SetEntKey(PP_Ent *ent, PP_EntKey key); +PP_Ent *PP_EntFromKey(PP_Snapshot *ss, PP_EntKey key); PP_EntKey PP_RandomKey(void); PP_EntKey PP_ContactConstraintKeyFromContactingKeys(PP_EntKey player_id, PP_EntKey id0, PP_EntKey id1); PP_EntKey PP_CollisionDebugKeyFromKeys(PP_EntKey player_id, PP_EntKey id0, PP_EntKey id1); diff --git a/src/pp/pp_phys.c b/src/pp/pp_phys.c index b0611e84..b9369b5b 100644 --- a/src/pp/pp_phys.c +++ b/src/pp/pp_phys.c @@ -43,14 +43,14 @@ void PP_CreateAndUpdateContacts(PP_PhysStepCtx *ctx, f32 elapsed_dt, u64 phys_it if (check1->local_collider.count <= 0) continue; if (!PP_CanEntsContact(check0, check1)) continue; - /* Deterministic order based on entity id */ + /* Deterministic order based on entity key */ PP_Ent *e0; PP_Ent *e1; Xform e0_xf; Xform e1_xf; CLD_Shape e0_collider; CLD_Shape e1_collider; - if (check0->id.uid.hi < check1->id.uid.hi) + if (check0->key.uid.hi < check1->key.uid.hi) { e0 = check0; e1 = check1; @@ -69,7 +69,7 @@ void PP_CreateAndUpdateContacts(PP_PhysStepCtx *ctx, f32 elapsed_dt, u64 phys_it e1_collider = check0_collider; } - PP_EntKey constraint_id = PP_ContactConstraintKeyFromContactingKeys(local_player, e0->id, e1->id); + PP_EntKey constraint_id = PP_ContactConstraintKeyFromContactingKeys(local_player, e0->key, e1->key); PP_Ent *constraint_ent = PP_EntFromKey(ss, constraint_id); if (constraint_ent->valid) @@ -101,8 +101,8 @@ void PP_CreateAndUpdateContacts(PP_PhysStepCtx *ctx, f32 elapsed_dt, u64 phys_it is_start = 1; /* Create constraint */ constraint_ent = PP_AcquireLocalEntWithKey(root, constraint_id); - constraint_ent->contact_constraint_data.e0 = e0->id; - constraint_ent->contact_constraint_data.e1 = e1->id; + constraint_ent->contact_constraint_data.e0 = e0->key; + constraint_ent->contact_constraint_data.e1 = e1->key; /* Both entities must be solid and one must be dynamic for a solve to be necessary. */ constraint_ent->contact_constraint_data.skip_solve = !PP_HasProp(e0, PP_Prop_Solid) || !PP_HasProp(e1, PP_Prop_Solid) || !(PP_HasProp(e0, PP_Prop_Dynamic) || PP_HasProp(e1, PP_Prop_Dynamic)); @@ -197,8 +197,8 @@ void PP_CreateAndUpdateContacts(PP_PhysStepCtx *ctx, f32 elapsed_dt, u64 phys_it if (collision_callback) { PP_CollisionData data = ZI; - data.e0 = e0->id; - data.e1 = e1->id; + data.e0 = e0->key; + data.e1 = e1->key; data.normal = collision_result.normal; data.is_start = is_start; data.dt = elapsed_dt; @@ -250,7 +250,7 @@ void PP_CreateAndUpdateContacts(PP_PhysStepCtx *ctx, f32 elapsed_dt, u64 phys_it /* TODO: Remove this (debugging) */ #if COLLIDER_DEBUG && COLLIDER_DEBUG_DETAILED { - PP_EntKey dbg_ent_id = PP_CollisionDebugKeyFromKeys(local_player, e0->id, e1->id); + PP_EntKey dbg_ent_id = PP_CollisionDebugKeyFromKeys(local_player, e0->key, e1->key); PP_Ent *dbg_ent = PP_EntFromKey(ss, dbg_ent_id); if (!dbg_ent->valid) { @@ -261,8 +261,8 @@ void PP_CreateAndUpdateContacts(PP_PhysStepCtx *ctx, f32 elapsed_dt, u64 phys_it ContactDebugData *dbg = &dbg_ent->collision_debug_data; - dbg->e0 = e0->id; - dbg->e1 = e1->id; + dbg->e0 = e0->key; + dbg->e1 = e1->key; dbg->collision_result = collision_result; if (constraint) @@ -1290,11 +1290,11 @@ void PP_UpdateAabbs(PP_PhysStepCtx *ctx) if (ent->local_collider.count > 0) { Xform xf = PP_XformFromEnt(ent); - PP_SpaceEntry *space_entry = PP_SpaceEntryFromKey(space, ent->space_handle); + PP_SpaceEntry *space_entry = PP_SpaceEntryFromKey(space, ent->space_key); if (!space_entry->valid) { - space_entry = PP_AcquireSpaceEntry(space, ent->id); - ent->space_handle = space_entry->handle; + space_entry = PP_AcquireSpaceEntry(space, ent->key); + ent->space_key = space_entry->key; } Aabb aabb = CLD_AabbFromShape(&ent->local_collider, xf); PP_UpdateSpaceEntryAabb(space_entry, aabb); diff --git a/src/pp/pp_sim.c b/src/pp/pp_sim.c index aab2ee26..6cc1d8ea 100644 --- a/src/pp/pp_sim.c +++ b/src/pp/pp_sim.c @@ -2,26 +2,26 @@ * * PP_Client store -> clients -> snapshots -> ents * - * A client store holds clients, which can be retrieved by client handle or by a host channel id (if one is assigned). + * A client store holds clients, which can be retrieved by client key or by a host channel id (if one is assigned). * * A client holds snapshots, which can be retrieved by tick number. * - The snapshots stored in clients & the contents of those snapshots are determined from data transmitted by the client. * - Different kinds of clients will transmit different subsets of snapshot data (e.g. a master client will transmit most ent state, while slave clients may just transmit 1 or more command ents) * - A client will never hold more than one snapshot for the same tick (e.g. a client will never have 2 snapshots at tick 5) * - * A snapshot holds the ent tree for a particular tick, in which ents can be retrieved by ent id. + * A snapshot holds the ent tree for a particular tick, in which ents can be retrieved by ent key. * - A tick is the quantized time step that all clients implicitly conform to. * * An ent is the smallest unit of simulation state. * - It is assigned a 128 bit unique identifer generated at allocation time. - * - This id is used to refer to other ents in the tree and to sync ents accross clients. - * - This id is usually random, but can be deterministic under certain conditions. + * - This key is used to refer to other ents in the tree and to sync ents accross clients. + * - This key is usually random, but can be deterministic under certain conditions. * - For example, instead of storing a contact constraint lookup table, contact constraints are - * retrieved by searching for the ent with the id resulting from combining the ent ids of the - * two contacting entities (plus a unique 'basis' ent id used for all contact constraints). + * retrieved by searching for the ent with the key resulting from combining the ent keys of the + * two contacting entities (plus a unique 'basis' ent key used for all contact constraints). * - The ent also implicitly has a 32 bit index, which is just its offset from the start of the entity array in the local snapshot. * - Since index is based on offset which remains stable regardless of snapshot memory location, it - * is used when working in contexts where id is irrelevant. + * is used when working in contexts where key is irrelevant. */ //////////////////////////////////////////////////////////// @@ -57,7 +57,7 @@ void PP_StartupSim(void) g->nil_ent = PushStruct(g->nil_arena, PP_Ent); g->nil_ent->ss = PP_NilSnapshot(); g->nil_ent->valid = 0; - g->nil_ent->id = PP_NilEntKey; + g->nil_ent->key = PP_NilEntKey; g->nil_ent->_local_xform = XformIdentity; g->nil_ent->_xform = XformIdentity; g->nil_ent->_is_xform_dirty = 0; @@ -111,27 +111,27 @@ void PP_ReleaseClientStore(PP_ClientStore *store) PP_Client *PP_AcquireClient(PP_ClientStore *store) { - PP_ClientKey handle = ZI; + PP_ClientKey key = ZI; PP_Client *client = PP_ClientFromKey(store, store->first_free_client); if (client->valid) { store->first_free_client = client->next_free; - handle = client->handle; - ++handle.gen; + key = client->key; + ++key.gen; } else { client = PushStructNoZero(store->clients_arena, PP_Client); - handle.gen = 1; - handle.idx = store->num_clients_reserved; + key.gen = 1; + key.idx = store->num_clients_reserved; ++store->num_clients_reserved; } ++store->num_clients_allocated; *client = *PP_NilClient(); client->store = store; client->valid = 1; - client->handle = handle; + client->key = key; client->snapshots_arena = AcquireArena(Gibi(8)); client->num_snapshot_lookup_bins = PP_TickLookupBinsCount; @@ -163,9 +163,9 @@ void PP_ReleaseClient(PP_Client *client) PP_ClientStore *store = client->store; client->valid = 0; client->next_free = store->first_free_client; - store->first_free_client = client->handle; + store->first_free_client = client->key; --store->num_clients_allocated; - ++client->handle.gen; + ++client->key.gen; ReleaseArena(client->snapshots_arena); } @@ -191,19 +191,19 @@ void PP_SetClientChannelId(PP_Client *client, N_ChannelId channel_id) PP_Client *next = PP_ClientFromKey(store, client->next_in_bin); if (prev->valid) { - prev->next_in_bin = next->handle; + prev->next_in_bin = next->key; } else { - bin->first = next->handle; + bin->first = next->key; } if (next->valid) { - next->prev_in_bin = prev->handle; + next->prev_in_bin = prev->key; } else { - bin->last = prev->handle; + bin->last = prev->key; } } @@ -220,14 +220,14 @@ void PP_SetClientChannelId(PP_Client *client, N_ChannelId channel_id) PP_Client *prev_in_bin = PP_ClientFromKey(store, bin->last); if (prev_in_bin->valid) { - prev_in_bin->next_in_bin = client->handle; - client->prev_in_bin = prev_in_bin->handle; + prev_in_bin->next_in_bin = client->key; + client->prev_in_bin = prev_in_bin->key; } else { - bin->first = client->handle; + bin->first = client->key; } - bin->last = client->handle; + bin->last = client->key; } } } @@ -249,12 +249,12 @@ PP_Client *PP_ClientFromChannelId(PP_ClientStore *store, N_ChannelId channel_id) return result; } -PP_Client *PP_ClientFromKey(PP_ClientStore *store, PP_ClientKey handle) +PP_Client *PP_ClientFromKey(PP_ClientStore *store, PP_ClientKey key) { - if (handle.gen != 0 && handle.idx < store->num_clients_reserved) + if (key.gen != 0 && key.idx < store->num_clients_reserved) { - PP_Client *client = &store->clients[handle.idx]; - if (client->handle.gen == handle.gen) + PP_Client *client = &store->clients[key.idx]; + if (client->key.gen == key.gen) { return client; } @@ -313,19 +313,19 @@ PP_Snapshot *PP_AcquireSnapshot(PP_Client *client, PP_Snapshot *src, u64 tick) ss->local_player = src->local_player; ss->phys_iteration = src->phys_iteration; - /* Copy id lookup bins */ - ss->num_id_bins = src->num_id_bins > 0 ? src->num_id_bins : PP_IdLookupBinsCount; - ss->id_bins = PushStructsNoZero(ss->arena, PP_EntBin, ss->num_id_bins); - if (src->num_id_bins > 0) + /* Copy key lookup bins */ + ss->num_key_bins = src->num_key_bins > 0 ? src->num_key_bins : PP_KeyLookupBinsCount; + ss->key_bins = PushStructsNoZero(ss->arena, PP_EntBin, ss->num_key_bins); + if (src->num_key_bins > 0) { - for (u64 i = 0; i < src->num_id_bins; ++i) + for (u64 i = 0; i < src->num_key_bins; ++i) { - ss->id_bins[i] = src->id_bins[i]; + ss->key_bins[i] = src->key_bins[i]; } } else { - ZeroBytes(ss->id_bins, sizeof(*ss->id_bins) * ss->num_id_bins); + ZeroBytes(ss->key_bins, sizeof(*ss->key_bins) * ss->num_key_bins); } /* Copy entities */ @@ -344,7 +344,7 @@ PP_Snapshot *PP_AcquireSnapshot(PP_Client *client, PP_Snapshot *src, u64 tick) ++ss->num_ents_reserved; } - /* Push root ent with constant id */ + /* Push root ent with constant key */ { PP_Ent *root = PushStructNoZero(ss->ents_arena, PP_Ent); *root = *PP_NilEnt(); @@ -750,7 +750,7 @@ void PP_SyncSnapshotEnts(PP_Snapshot *local_ss, PP_Snapshot *remote_ss, PP_EntKe } if (should_sync) { - PP_Ent *remote_ent = PP_EntFromKey(remote_ss, local_ent->id); + PP_Ent *remote_ent = PP_EntFromKey(remote_ss, local_ent->key); if (remote_ent->valid) { /* Copy all ent data from remote */ @@ -799,20 +799,20 @@ void PP_EncodeSnapshot(BB_Writer *bw, PP_Client *receiver, PP_Snapshot *ss0, PP_ BB_WriteUid(bw, receiver->player_id.uid); - /* Id bins */ + /* Key bins */ /* TODO: Don't encode these */ BB_WriteDebugMarker(bw, Lit("SNAPSHOT BINS")); - for (u64 i = 0; i < ss1->num_id_bins; ++i) + for (u64 i = 0; i < ss1->num_key_bins; ++i) { u32 old_first = 0; u32 old_last = 0; - if (i < ss0->num_id_bins) + if (i < ss0->num_key_bins) { - PP_EntBin *old_bin = &ss0->id_bins[i]; + PP_EntBin *old_bin = &ss0->key_bins[i]; old_first = old_bin->first; old_last = old_bin->last; } - PP_EntBin *bin = &ss1->id_bins[i]; + PP_EntBin *bin = &ss1->key_bins[i]; b32 first_diff = bin->first != old_first; b32 last_diff = bin->last != old_last; if (first_diff || last_diff) @@ -876,7 +876,7 @@ void PP_DecodeSnapshot(BB_Reader *br, PP_Snapshot *ss) ss->local_player = (PP_EntKey){ .uid = BB_ReadUid(br) }; - /* Id bins */ + /* Key bins */ /* TODO: Don't decode these, determine them implicitly from decoded ents */ BB_ReadDebugMarker(br, Lit("SNAPSHOT BINS")); { @@ -884,9 +884,9 @@ void PP_DecodeSnapshot(BB_Reader *br, PP_Snapshot *ss) while (bin_changed) { u32 bin_index = BB_ReadUV(br); - if (bin_index < ss->num_id_bins) + if (bin_index < ss->num_key_bins) { - PP_EntBin *bin = &ss->id_bins[bin_index]; + PP_EntBin *bin = &ss->key_bins[bin_index]; if (BB_ReadBit(br)) { bin->first = BB_ReadUV(br); @@ -1005,7 +1005,7 @@ void PP_EncodeSnapshot(BB_Writer *bw, PP_Client *receiver, PP_Snapshot *ss0, PP_ BB_WriteBit(e1->valid); if (e1->valid) { - BB_WriteUid(bw, e1->id.uid); + BB_WriteUid(bw, e1->key.uid); } } else diff --git a/src/pp/pp_sim.h b/src/pp/pp_sim.h index 96319907..ba97302d 100644 --- a/src/pp/pp_sim.h +++ b/src/pp/pp_sim.h @@ -12,7 +12,7 @@ Struct(PP_ClientKey) u32 gen; }; -#define PP_NilClientHandle ((PP_ClientKey) { .gen = 0, .idx = 0 }) +#define PP_NilClientKey ((PP_ClientKey) { .gen = 0, .idx = 0 }) //////////////////////////////////////////////////////////// @@ -59,7 +59,7 @@ Struct(PP_SnapshotLookupBin) Struct(PP_Client) { b32 valid; - PP_ClientKey handle; + PP_ClientKey key; PP_ClientStore *store; Arena *snapshots_arena; @@ -74,7 +74,7 @@ Struct(PP_Client) PP_ClientKey next_in_bin; PP_ClientKey prev_in_bin; - /* The client's player entity id in the master sim (if relevant) */ + /* The client's player entity key in the master sim (if relevant) */ PP_EntKey player_id; /* This is the highest confirmed tick of ours that we know this client has received */ @@ -205,12 +205,12 @@ Struct(PP_Snapshot) /* The last physics iteration (used for tracking contact lifetime) */ u64 phys_iteration; - /* The id of the receiver's player in the snapshot */ + /* The key of the receiver's player in the snapshot */ PP_EntKey local_player; - /* Id lookup */ - struct PP_EntBin *id_bins; - u64 num_id_bins; + /* Key lookup */ + struct PP_EntBin *key_bins; + u64 num_key_bins; /* Ents */ Arena *ents_arena; @@ -231,7 +231,7 @@ Inline PP_Snapshot *PP_NilSnapshot(void) #define PP_ClientLookupBinsCount 127 #define PP_TickLookupBinsCount 127 -#define PP_IdLookupBinsCount 4096 +#define PP_KeyLookupBinsCount 4096 Struct(PP_SharedSimCtx) { @@ -275,7 +275,7 @@ void PP_ReleaseClient(PP_Client *client); u64 PP_ClientChannelHashFromChannelId(N_ChannelId channel_id); void PP_SetClientChannelId(PP_Client *client, N_ChannelId channel_id); PP_Client *PP_ClientFromChannelId(PP_ClientStore *store, N_ChannelId channel_id); -PP_Client *PP_ClientFromKey(PP_ClientStore *store, PP_ClientKey handle); +PP_Client *PP_ClientFromKey(PP_ClientStore *store, PP_ClientKey key); //////////////////////////////////////////////////////////// //~ Snapshot acquire operations diff --git a/src/pp/pp_space.c b/src/pp/pp_space.c index a71892eb..404ef56c 100644 --- a/src/pp/pp_space.c +++ b/src/pp/pp_space.c @@ -52,7 +52,7 @@ PP_Space *PP_SpaceFromEntry(PP_SpaceEntry *entry) { if (entry->valid) { - u64 first_entry_addr = (u64)(entry - entry->handle.idx); + u64 first_entry_addr = (u64)(entry - entry->key.idx); PP_Space *space = (PP_Space *)(first_entry_addr - PP_SpaceEntriesOffset); Assert(space->entries == (PP_SpaceEntry *)first_entry_addr); return space; @@ -288,14 +288,14 @@ void PP_ReleaseSpaceCellNode(PP_SpaceCellNode *n) //////////////////////////////////////////////////////////// //~ Entry -PP_SpaceEntry *PP_SpaceEntryFromKey(PP_Space *space, PP_SpaceEntryKey handle) +PP_SpaceEntry *PP_SpaceEntryFromKey(PP_Space *space, PP_SpaceEntryKey key) { PP_SpaceEntry *entry = PP_NilSpaceEntry(); - if (handle.gen > 0 && handle.idx < space->num_entries_reserved) + if (key.gen > 0 && key.idx < space->num_entries_reserved) { - PP_SpaceEntry *tmp = &space->entries[handle.idx]; - if (tmp->handle.gen == handle.gen) + PP_SpaceEntry *tmp = &space->entries[key.idx]; + if (tmp->key.gen == key.gen) { entry = tmp; } @@ -307,23 +307,23 @@ PP_SpaceEntry *PP_SpaceEntryFromKey(PP_Space *space, PP_SpaceEntryKey handle) PP_SpaceEntry *PP_AcquireSpaceEntry(PP_Space *space, PP_EntKey ent) { PP_SpaceEntry *entry = 0; - PP_SpaceEntryKey handle = ZI; + PP_SpaceEntryKey key = ZI; if (space->first_free_entry) { entry = space->first_free_entry; space->first_free_entry = entry->next_free; - handle = entry->handle; + key = entry->key; } else { entry = PushStructNoZero(space->entry_arena, PP_SpaceEntry); - handle.idx = space->num_entries_reserved; - handle.gen = 1; + key.idx = space->num_entries_reserved; + key.gen = 1; ++space->num_entries_reserved; } ZeroStruct(entry); entry->valid = 1; - entry->handle = handle; + entry->key = key; entry->ent = ent; return entry; } @@ -343,7 +343,7 @@ void PP_ReleaseSpaceEntry(PP_SpaceEntry *entry) PP_Space *space = PP_SpaceFromEntry(entry); entry->next_free = space->first_free_entry; entry->valid = 0; - ++entry->handle.gen; + ++entry->key.gen; space->first_free_entry = entry; } diff --git a/src/pp/pp_space.h b/src/pp/pp_space.h index 4481c292..b4ef64dd 100644 --- a/src/pp/pp_space.h +++ b/src/pp/pp_space.h @@ -10,7 +10,7 @@ Struct(PP_SpaceEntryKey) Struct(PP_SpaceEntry) { b32 valid; - PP_SpaceEntryKey handle; + PP_SpaceEntryKey key; struct PP_SpaceCellNode *first_node; struct PP_SpaceCellNode *last_node; @@ -146,7 +146,7 @@ void PP_ReleaseSpaceCellNode(PP_SpaceCellNode *n); //////////////////////////////////////////////////////////// //~ Entry -PP_SpaceEntry *PP_SpaceEntryFromKey(PP_Space *space, PP_SpaceEntryKey handle); +PP_SpaceEntry *PP_SpaceEntryFromKey(PP_Space *space, PP_SpaceEntryKey key); PP_SpaceEntry *PP_AcquireSpaceEntry(PP_Space *space, PP_EntKey ent); void PP_ReleaseSpaceEntry(PP_SpaceEntry *entry); void PP_UpdateSpaceEntryAabb(PP_SpaceEntry *entry, Aabb new_aabb); diff --git a/src/pp/pp_step.c b/src/pp/pp_step.c index 466ec0e8..fb38baaf 100644 --- a/src/pp/pp_step.c +++ b/src/pp/pp_step.c @@ -23,7 +23,7 @@ void PP_ResetAccel(PP_Snapshot *ss, PP_Accel *accel) PP_Ent *ent = &ss->ents[sim_ent_index]; if (ent->valid) { - ZeroStruct(&ent->space_handle); + ZeroStruct(&ent->space_key); } } } @@ -94,7 +94,7 @@ PP_Ent *PP_SpawnTestChucker(PP_Ent *parent) collider.radius = 0.1f; zone->local_collider = collider; - chucker->chucker_zone = zone->id; + chucker->chucker_zone = zone->key; } return chucker; @@ -176,7 +176,7 @@ PP_Ent *PP_SpawnTestEmployee(PP_Ent *parent) LAX PP_SpawnTestChucker; PP_Ent *e = PP_SpawnTestChucker(employee); - employee->equipped = e->id; + employee->equipped = e->key; PP_EnableProp(e, PP_Prop_LightTest); e->sprite_emittance = VEC3(1, 1, 1); @@ -195,7 +195,7 @@ PP_Ent *PP_SpawnTestCamera(PP_Ent *parent, PP_Ent *follow) PP_EnableProp(camera_ent, PP_Prop_Camera); PP_EnableProp(camera_ent, PP_Prop_ActiveCamera); - camera_ent->camera_follow = follow->id; + camera_ent->camera_follow = follow->key; f32 width = (f32)DEFAULT_CAMERA_WIDTH; f32 height = (f32)DEFAULT_CAMERA_HEIGHT; @@ -863,7 +863,7 @@ PP_CollisionCallbackFuncDef(PP_OnEntCollision, data, step_ctx) { if (!PP_EqEntKey(e0->top, e1->top) && PP_HasProp(e1, PP_Prop_Solid)) { - e0->chucker_zone_ent = e1->id; + e0->chucker_zone_ent = e1->key; e0->chucker_zone_ent_tick = world->tick; } } @@ -916,20 +916,20 @@ void PP_StepSim(PP_SimStepCtx *ctx) { /* FIXME: Player never released upon disconnect */ player = PP_AcquireSyncSrcEnt(root); - player->player_client_handle = client->handle; + player->player_client_key = client->key; PP_EnableProp(player, PP_Prop_Player); - player->predictor = player->id; + player->predictor = player->key; PP_ActivateEnt(player, world->tick); - client->player_id = player->id; + client->player_id = player->key; if (client == user_input_client) { - user_input_client->player_id = player->id; - world_client->player_id = player->id; - world->local_player = player->id; - player->owner = player->id; + user_input_client->player_id = player->key; + world_client->player_id = player->key; + world->local_player = player->key; + player->owner = player->key; PP_EnableProp(player, PP_Prop_IsMaster); } - P_LogInfoF("Created player with id %F for sim client %F. is_master: %F", FmtUid(player->id.uid), FmtHandle(client->handle), FmtUint(PP_HasProp(player, PP_Prop_IsMaster))); + P_LogInfoF("Created player with key %F for sim client %F. is_master: %F", FmtUid(player->key.uid), FmtHandle(client->key), FmtUint(PP_HasProp(player, PP_Prop_IsMaster))); } /* Update rtt */ @@ -946,7 +946,7 @@ void PP_StepSim(PP_SimStepCtx *ctx) PP_Snapshot *src_ss = PP_SnapshotFromTick(client, world->tick); if (src_ss->valid) { - PP_SyncSnapshotEnts(world, src_ss, player->id, 0); + PP_SyncSnapshotEnts(world, src_ss, player->key, 0); } } } @@ -1027,7 +1027,7 @@ void PP_StepSim(PP_SimStepCtx *ctx) if (PP_ShouldSimulate(player)) { b32 persist_cmd = 0; - if (!is_master && !PP_EqEntKey(player->id, world->local_player)) + if (!is_master && !PP_EqEntKey(player->key, world->local_player)) { /* We are not the master and the command is not our own, skip processing */ continue; @@ -1173,7 +1173,7 @@ void PP_StepSim(PP_SimStepCtx *ctx) { PP_Ent *chat_ent = PP_AcquireSyncSrcEnt(root); PP_EnableProp(chat_ent, PP_Prop_CHAT); - chat_ent->chat_player = player->id; + chat_ent->chat_player = player->key; chat_ent->chat_msg = msg_key; } } break; @@ -1222,22 +1222,22 @@ void PP_StepSim(PP_SimStepCtx *ctx) if (!control_ent->valid) { control_ent = PP_SpawnTestEmployee(root); - control_ent->predictor = ent->id; + control_ent->predictor = ent->key; PP_EnableProp(control_ent, PP_Prop_Controlled); - ent->player_control_ent = control_ent->id; - control_ent->controlling_player = ent->id; + ent->player_control_ent = control_ent->key; + control_ent->controlling_player = ent->key; } PP_Ent *camera_ent = PP_EntFromKey(world, ent->player_camera_ent); if (!camera_ent->valid) { camera_ent = PP_SpawnTestCamera(root, control_ent); - camera_ent->predictor = ent->id; - ent->player_camera_ent = camera_ent->id; + camera_ent->predictor = ent->key; + ent->player_camera_ent = camera_ent->key; } PP_Ent *camera_follow = PP_EntFromKey(world, camera_ent->camera_follow); if (!camera_follow->valid) { - camera_ent->camera_follow = control_ent->id; + camera_ent->camera_follow = control_ent->key; } } } @@ -1464,7 +1464,7 @@ void PP_StepSim(PP_SimStepCtx *ctx) bullet = PP_AcquireSyncSrcEnt(root); PP_EnableProp(bullet, PP_Prop_Bullet); - bullet->bullet_src = ent->id; + bullet->bullet_src = ent->key; bullet->bullet_src_pos = rel_pos; bullet->bullet_src_dir = rel_dir; //bullet->bullet_launch_velocity = 0.75f; @@ -1489,7 +1489,7 @@ void PP_StepSim(PP_SimStepCtx *ctx) tracer->layer = PP_Layer_Tracers; PP_EnableProp(tracer, PP_Prop_Tracer); - bullet->bullet_tracer = tracer->id; + bullet->bullet_tracer = tracer->key; } } } @@ -1513,7 +1513,7 @@ void PP_StepSim(PP_SimStepCtx *ctx) bullet = PP_AcquireSyncSrcEnt(root); PP_EnableProp(bullet, PP_Prop_Bullet); - bullet->bullet_src = ent->id; + bullet->bullet_src = ent->key; bullet->bullet_src_pos = rel_pos; bullet->bullet_src_dir = rel_dir; //bullet->bullet_launch_velocity = 0.75f; @@ -1537,7 +1537,7 @@ void PP_StepSim(PP_SimStepCtx *ctx) tracer->layer = PP_Layer_Tracers; PP_EnableProp(tracer, PP_Prop_Tracer); - bullet->bullet_tracer = tracer->id; + bullet->bullet_tracer = tracer->key; } } } @@ -1555,7 +1555,7 @@ void PP_StepSim(PP_SimStepCtx *ctx) PP_Ent *old_joint_ent = PP_EntFromKey(world, ent->chucker_joint); if (PP_IsValidAndActive(target) && zone->chucker_zone_ent_tick == world->tick - 1) { - if (!PP_EqEntKey(old_joint_ent->weld_joint_data.e1, target->id)) + if (!PP_EqEntKey(old_joint_ent->weld_joint_data.e1, target->key)) { PP_Ent *joint_ent = PP_AcquireSyncSrcEnt(root); PP_EnableProp(joint_ent, PP_Prop_Active); @@ -1566,15 +1566,15 @@ void PP_StepSim(PP_SimStepCtx *ctx) PP_EnableProp(joint_ent, PP_Prop_WeldJoint); PP_WeldJointDesc def = PP_CreateWeldJointDef(); - def.e0 = ent->id; - def.e1 = target->id; + def.e0 = ent->key; + def.e1 = target->key; def.xf = xf0_to_xf1; def.linear_spring_hz = 10; def.linear_spring_damp = 0.3f; def.angular_spring_hz = 10; def.angular_spring_damp = 0.3f; joint_ent->weld_joint_data = PP_WeldJointFromDef(def); - ent->chucker_joint = joint_ent->id; + ent->chucker_joint = joint_ent->key; } } if (old_joint_ent->valid) @@ -1604,12 +1604,12 @@ void PP_StepSim(PP_SimStepCtx *ctx) joint_ent->inertia_unscaled = F32Infinity; PP_EnableProp(joint_ent, PP_Prop_Active); PP_EnableProp(joint_ent, PP_Prop_Kinematic); - ent->move_joint = joint_ent->id; + ent->move_joint = joint_ent->key; PP_EnableProp(joint_ent, PP_Prop_MotorJoint); PP_MotorJointDesc def = PP_CreateMotorJointDef(); - def.e0 = joint_ent->id; /* Re-using joint entity as e0 */ - def.e1 = ent->id; + def.e0 = joint_ent->key; /* Re-using joint entity as e0 */ + def.e1 = ent->key; def.correction_rate = 0; def.max_force = ent->control_force; def.max_torque = 0; @@ -1648,11 +1648,11 @@ void PP_StepSim(PP_SimStepCtx *ctx) PP_EnableProp(joint_ent, PP_Prop_Kinematic); /* Since we'll be setting velocity manually */ PP_EnableProp(joint_ent, PP_Prop_MotorJoint); PP_EnableProp(joint_ent, PP_Prop_Active); - ent->aim_joint = joint_ent->id; + ent->aim_joint = joint_ent->key; PP_MotorJointDesc def = PP_CreateMotorJointDef(); - def.e0 = joint_ent->id; /* Re-using joint entity as e0 */ - def.e1 = ent->id; + def.e0 = joint_ent->key; /* Re-using joint entity as e0 */ + def.e1 = ent->key; def.max_force = 0; def.max_torque = ent->control_torque; joint_ent->motor_joint_data = PP_MotorJointFromDef(def); @@ -1739,8 +1739,8 @@ void PP_StepSim(PP_SimStepCtx *ctx) PP_Ent *joint_ent = PP_EntFromKey(world, ent->ground_friction_joint); PP_MotorJointDesc def = PP_CreateMotorJointDef(); - def.e0 = root->id; - def.e1 = ent->id; + def.e0 = root->key; + def.e1 = ent->key; def.correction_rate = 0; def.max_force = ent->linear_ground_friction; def.max_torque = ent->angular_ground_friction; @@ -1753,7 +1753,7 @@ void PP_StepSim(PP_SimStepCtx *ctx) PP_EnableProp(joint_ent, PP_Prop_MotorJoint); PP_EnableProp(joint_ent, PP_Prop_Active); joint_ent->motor_joint_data = PP_MotorJointFromDef(def); - ent->ground_friction_joint = joint_ent->id; + ent->ground_friction_joint = joint_ent->key; } } } @@ -1793,15 +1793,15 @@ void PP_StepSim(PP_SimStepCtx *ctx) joint_ent = PP_AcquireLocalEnt(root); joint_ent->mass_unscaled = F32Infinity; joint_ent->inertia_unscaled = F32Infinity; - player->player_dbg_drag_joint_ent = joint_ent->id; + player->player_dbg_drag_joint_ent = joint_ent->key; PP_EnableProp(joint_ent, PP_Prop_MouseJoint); PP_EnableProp(joint_ent, PP_Prop_Active); } Xform xf = PP_XformFromEnt(target_ent); PP_MouseJointDesc def = PP_CreateMouseJointDef(); - def.target = target_ent->id; - if (PP_EqEntKey(joint_ent->mouse_joint_data.target, target_ent->id)) + def.target = target_ent->key; + if (PP_EqEntKey(joint_ent->mouse_joint_data.target, target_ent->key)) { def.point_local_start = joint_ent->mouse_joint_data.point_local_start; } @@ -1819,7 +1819,7 @@ void PP_StepSim(PP_SimStepCtx *ctx) } else if (PP_IsValidAndActive(joint_ent)) { - joint_ent->mouse_joint_data.target = target_ent->id; + joint_ent->mouse_joint_data.target = target_ent->key; } } }