diff options
Diffstat (limited to 'src/sim/lib/force.rs')
| -rw-r--r-- | src/sim/lib/force.rs | 6 |
1 files changed, 5 insertions, 1 deletions
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 } |
