From da01c6e887d6865f0ad75c8dfe68bbad702afb99 Mon Sep 17 00:00:00 2001 From: Kai Stevenson Date: Tue, 25 Aug 2026 00:41:17 -0700 Subject: tweaks --- src/sim/lib/force.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/sim/lib') diff --git a/src/sim/lib/force.rs b/src/sim/lib/force.rs index d461589..e3150c0 100644 --- a/src/sim/lib/force.rs +++ b/src/sim/lib/force.rs @@ -100,12 +100,13 @@ pub fn apply_explosion( // TODO profile packing entity ID into cells? // TODO sink power in a radius around the impact // might improve performance by a lot if we don't have to raycast for hit entities -pub fn apply_bullet(ctx: &mut SimCtx, from: Vec2, to: Vec2, power: u32) { +pub fn apply_bullet(ctx: &mut SimCtx, from: Vec2, to: Vec2, power: u32) -> Vec2 { let dda = AwDda::new(from, to); let mut p = power as i32; let dir = (to - from).normalize(); + let mut stopped_at = to; for collision in dda { if let Some(cell) = ctx .cell_manager @@ -124,6 +125,7 @@ pub fn apply_bullet(ctx: &mut SimCtx, from: Vec2, to: Vec2, power: u32) { p -= m.density as i32; if p <= 0 { + stopped_at = collision.as_vec2(); break; } @@ -145,4 +147,6 @@ pub fn apply_bullet(ctx: &mut SimCtx, from: Vec2, to: Vec2, power: u32) { } } } + + stopped_at } -- cgit v1.3.1