summaryrefslogtreecommitdiff
path: root/src/sim/lib/force.rs
diff options
context:
space:
mode:
authorKai Stevenson <kai@kaistevenson.com>2026-08-25 00:41:17 -0700
committerKai Stevenson <kai@kaistevenson.com>2026-08-25 00:41:17 -0700
commitda01c6e887d6865f0ad75c8dfe68bbad702afb99 (patch)
tree113163d6dde8ed0e5ffa8c073ca46b46ed82319a /src/sim/lib/force.rs
parenta779011b9048cdda04887c77e20ee8936f332a7a (diff)
tweaks
Diffstat (limited to 'src/sim/lib/force.rs')
-rw-r--r--src/sim/lib/force.rs6
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
}