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);
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);
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);
b32 is_impulse = entity_has_prop(child, ENTITY_PROP_IMPULSE);
if (is_force || is_impulse) {
if (is_impulse) {
acceleration = v2_add(acceleration, child->force);
} else {
acceleration = v2_add(acceleration, v2_mul(child->force, dt));
}
if (entity_has_prop(child, ENTITY_PROP_IMPULSE)) {
acceleration = v2_add(acceleration, child->force);
entity_enable_prop(child, ENTITY_PROP_RELEASE);
} else if (entity_has_prop(child, ENTITY_PROP_FORCE)) {
acceleration = v2_add(acceleration, v2_mul(child->force, dt));
entity_enable_prop(child, ENTITY_PROP_RELEASE);
}
}