prediction progress
This commit is contained in:
parent
4d419da97b
commit
f0834c203f
@ -488,7 +488,6 @@ struct string32 {
|
||||
};
|
||||
|
||||
#define UID(hi, lo) (struct uid) { .v = U128((hi), (lo)) }
|
||||
#define UID0 (struct uid) { 0 }
|
||||
struct uid {
|
||||
union {
|
||||
u128 v;
|
||||
@ -499,6 +498,7 @@ struct uid {
|
||||
};
|
||||
};
|
||||
INLINE b32 uid_eq(struct uid a, struct uid b) { return u128_eq(a.v, b.v); }
|
||||
INLINE b32 uid_is_zero(struct uid uid) { return u128_eq(uid.v, U128(0, 0)); }
|
||||
|
||||
struct image_rgba {
|
||||
u32 width;
|
||||
|
||||
@ -332,6 +332,8 @@ struct sim_snapshot *sim_snapshot_alloc(struct sim_client *client, struct sim_sn
|
||||
root->handle = SIM_ENT_ROOT_HANDLE;
|
||||
root->valid = true;
|
||||
root->is_root = true;
|
||||
root->mass_unscaled = F32_INFINITY;
|
||||
root->inertia_unscaled = F32_INFINITY;
|
||||
++ss->num_ents_allocated;
|
||||
++ss->num_ents_reserved;
|
||||
} else {
|
||||
|
||||
@ -99,7 +99,7 @@ void sim_ent_release_raw(struct sim_ent *ent)
|
||||
}
|
||||
|
||||
/* Release uid */
|
||||
sim_ent_set_uid(ent, UID0);
|
||||
sim_ent_set_uid(ent, UID(0, 0));
|
||||
|
||||
/* Release */
|
||||
++ent->handle.gen;
|
||||
@ -174,7 +174,7 @@ void sim_ent_set_uid(struct sim_ent *ent, struct uid uid)
|
||||
struct uid old_uid = ent->uid;
|
||||
|
||||
/* Release old from lookup */
|
||||
if (!uid_eq(old_uid, UID0)) {
|
||||
if (!uid_is_zero(old_uid)) {
|
||||
u64 hash = hash_from_uid(old_uid);
|
||||
struct sim_ent_bucket *bucket = &buckets[hash % num_uid_buckets];
|
||||
struct sim_ent *prev = sim_ent_nil();
|
||||
@ -203,7 +203,7 @@ void sim_ent_set_uid(struct sim_ent *ent, struct uid uid)
|
||||
}
|
||||
|
||||
/* Insert new uid into lookup */
|
||||
if (!uid_eq(uid, UID0)) {
|
||||
if (!uid_is_zero(uid)) {
|
||||
u64 hash = hash_from_uid(uid);
|
||||
struct sim_ent_bucket *bucket = &buckets[hash % num_uid_buckets];
|
||||
struct sim_ent *last = sim_ent_from_handle(ss, bucket->last);
|
||||
@ -223,7 +223,7 @@ struct sim_ent *sim_ent_from_uid(struct sim_snapshot *ss, struct uid uid)
|
||||
{
|
||||
struct sim_ent *res = sim_ent_nil();
|
||||
u64 num_buckets = ss->num_uid_buckets;
|
||||
if (num_buckets > 0 && !uid_eq(uid, UID0)) {
|
||||
if (num_buckets > 0 && !uid_is_zero(uid)) {
|
||||
u64 hash = hash_from_uid(uid);
|
||||
struct sim_ent_bucket *bucket = &ss->uid_buckets[hash % num_buckets];
|
||||
for (struct sim_ent *e = sim_ent_from_handle(ss, bucket->first); e->valid; e = sim_ent_from_handle(ss, e->next_in_uid_bucket)) {
|
||||
|
||||
@ -387,6 +387,11 @@ INLINE b32 sim_ent_is_valid_and_active(struct sim_ent *ent)
|
||||
return ent->valid && sim_ent_has_prop(ent, SIM_ENT_PROP_ACTIVE);
|
||||
}
|
||||
|
||||
INLINE b32 sim_ent_should_simulate(struct sim_ent *ent)
|
||||
{
|
||||
return !sim_ent_has_prop(ent, SIM_ENT_PROP_SYNC_DST);
|
||||
}
|
||||
|
||||
/* ========================== *
|
||||
* Ent functions
|
||||
* ========================== */
|
||||
|
||||
1450
src/sim_step.c
1450
src/sim_step.c
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user