small tweak

This commit is contained in:
jacob 2024-08-23 13:25:04 -05:00
parent bd237e211b
commit 17f7e3daaa

View File

@ -598,17 +598,14 @@ INTERNAL void game_update(struct game_cmd_array game_cmds)
struct xform xf = entity_get_xform(ent); struct xform xf = entity_get_xform(ent);
f32 mass = ent->mass_unscaled * xform_get_determinant(xf); f32 mass = ent->mass_unscaled * xform_get_determinant(xf);
/* Apply forces and impulses */ /* Determine acceleration from forces and impulses */
struct v2 acceleration = V2(0, 0); struct v2 acceleration = V2(0, 0);
for (struct entity *child = entity_from_handle(store, ent->first); child->valid; child = entity_from_handle(store, child->next)) { for (struct entity *child = entity_from_handle(store, ent->first); child->valid; child = entity_from_handle(store, child->next)) {
b32 is_force = entity_has_prop(child, ENTITY_PROP_FORCE); if (entity_has_prop(child, ENTITY_PROP_IMPULSE)) {
b32 is_impulse = entity_has_prop(child, ENTITY_PROP_IMPULSE); acceleration = v2_add(acceleration, child->force);
if (is_force || is_impulse) { entity_enable_prop(child, ENTITY_PROP_RELEASE);
if (is_impulse) { } else if (entity_has_prop(child, ENTITY_PROP_FORCE)) {
acceleration = v2_add(acceleration, child->force); acceleration = v2_add(acceleration, v2_mul(child->force, dt));
} else {
acceleration = v2_add(acceleration, v2_mul(child->force, dt));
}
entity_enable_prop(child, ENTITY_PROP_RELEASE); entity_enable_prop(child, ENTITY_PROP_RELEASE);
} }
} }