test out adding shooter velocity to bullet

This commit is contained in:
jacob 2025-01-12 18:30:06 -06:00
parent 37f10d76dd
commit e961b6dceb

View File

@ -376,7 +376,6 @@ INTERNAL PHYS_COLLISION_CALLBACK_FUNC_DEF(on_collision, array)
/* Create test blood */ /* Create test blood */
/* TODO: Remove this */ /* TODO: Remove this */
#if 0
{ {
struct xform xf = XFORM_TRS(.t = point); struct xform xf = XFORM_TRS(.t = point);
struct entity *decal = entity_alloc(root); struct entity *decal = entity_alloc(root);
@ -387,10 +386,6 @@ INTERNAL PHYS_COLLISION_CALLBACK_FUNC_DEF(on_collision, array)
decal->linear_velocity = v2_mul(v2_norm(normal), 0.5f); decal->linear_velocity = v2_mul(v2_norm(normal), 0.5f);
decal->angular_velocity = 1 - (((f32)sys_rand_u32() / (f32)U32_MAX) * 2); decal->angular_velocity = 1 - (((f32)sys_rand_u32() / (f32)U32_MAX) * 2);
} }
#else
(UNUSED)normal;
(UNUSED)root;
#endif
} }
} }
} }
@ -820,8 +815,8 @@ INTERNAL void game_update(struct game_cmd_array game_cmds)
bullet->bullet_src_pos = rel_pos; bullet->bullet_src_pos = rel_pos;
bullet->bullet_src_dir = rel_dir; bullet->bullet_src_dir = rel_dir;
//bullet->bullet_impulse = 0.1f; //bullet->bullet_impulse = 0.1f;
bullet->bullet_impulse = 0.25f; //bullet->bullet_impulse = 0.25f;
//bullet->bullet_impulse = 0.5f; bullet->bullet_impulse = 0.5f;
//bullet->bullet_impulse = 1.0f; //bullet->bullet_impulse = 1.0f;
//bullet->bullet_impulse = 5.f; //bullet->bullet_impulse = 5.f;
bullet->mass_unscaled = 0.04f; bullet->mass_unscaled = 0.04f;
@ -1075,8 +1070,6 @@ INTERNAL void game_update(struct game_cmd_array game_cmds)
if (!entity_is_valid_and_active(ent)) continue; if (!entity_is_valid_and_active(ent)) continue;
if (!entity_has_prop(ent, ENTITY_PROP_BULLET)) continue; if (!entity_has_prop(ent, ENTITY_PROP_BULLET)) continue;
/* FIXME: Apply src entity velocity to bullet velocity */
if (ent->activation_tick == G.tick.tick_id) { if (ent->activation_tick == G.tick.tick_id) {
struct entity *src = entity_from_handle(store, ent->bullet_src); struct entity *src = entity_from_handle(store, ent->bullet_src);
struct xform src_xf = entity_get_xform(src); struct xform src_xf = entity_get_xform(src);
@ -1085,6 +1078,15 @@ INTERNAL void game_update(struct game_cmd_array game_cmds)
struct v2 impulse = xform_basis_mul_v2(src_xf, ent->bullet_src_dir); struct v2 impulse = xform_basis_mul_v2(src_xf, ent->bullet_src_dir);
impulse = v2_with_len(impulse, ent->bullet_impulse); impulse = v2_with_len(impulse, ent->bullet_impulse);
#if 0
/* Add shooter velocity to bullet */
{
/* TODO: Add angular velocity as well? */
struct entity *top = entity_from_handle(store, src->top);
impulse = v2_add(impulse, v2_mul(top->linear_velocity, dt));
}
#endif
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);
entity_set_xform(ent, xf); entity_set_xform(ent, xf);
entity_enable_prop(ent, ENTITY_PROP_PHYSICAL_KINEMATIC); entity_enable_prop(ent, ENTITY_PROP_PHYSICAL_KINEMATIC);