fix(game): restore swept target sensors
Move claw contact and all eleven initially active type-4 circle records onto a swept millipixel sensor test with per-object enter latching. Preserve the exact left-bank and top-gate coordinates, radii, and scores from the initialized object ledger. Remove the inferred top-bank completion rule. Each original top target now scores 500 and independently starts recovered magnetic-gate timing instead of requiring all three for an invented bonus. Test Plan: - `cargo test --all-targets` -- 44 passed - `cargo clippy --all-targets -- -D warnings` -- passed - `cargo build --profile production` -- passed - top sensor contact-latch and re-entry test -- passed - 20-second deterministic launch remained in active table motion - `git diff --cached --check` -- passed
This commit is contained in:
@@ -204,6 +204,45 @@ pub fn collide_with_circle(
|
||||
true
|
||||
}
|
||||
|
||||
/// Test a non-physical circle record against the complete ball-center path.
|
||||
pub fn path_intersects_circle(
|
||||
old_position: MilliVec,
|
||||
velocity: MilliVec,
|
||||
center: Vec2,
|
||||
radius: f32,
|
||||
) -> bool {
|
||||
let center = MilliVec::from_position(center);
|
||||
let offset = subtract(old_position, center);
|
||||
let radius_milli = (radius * 1_000.0).round() as i32;
|
||||
let radius_squared = i64::from(radius_milli).pow(2);
|
||||
let old_distance_squared = i64::from(offset.x).pow(2) + i64::from(offset.y).pow(2);
|
||||
if old_distance_squared <= radius_squared {
|
||||
return true;
|
||||
}
|
||||
let next = offset.add(velocity);
|
||||
let next_distance_squared = i64::from(next.x).pow(2) + i64::from(next.y).pow(2);
|
||||
if next_distance_squared <= radius_squared {
|
||||
return true;
|
||||
}
|
||||
|
||||
let vx = f64::from(velocity.x);
|
||||
let vy = f64::from(velocity.y);
|
||||
let offset_x = f64::from(offset.x);
|
||||
let offset_y = f64::from(offset.y);
|
||||
let quadratic_a = vx * vx + vy * vy;
|
||||
if quadratic_a == 0.0 {
|
||||
return false;
|
||||
}
|
||||
let quadratic_b = 2.0 * (offset_x * vx + offset_y * vy);
|
||||
let quadratic_c = old_distance_squared as f64 - f64::from(radius_milli).powi(2);
|
||||
let discriminant = quadratic_b * quadratic_b - 4.0 * quadratic_a * quadratic_c;
|
||||
if discriminant < 0.0 {
|
||||
return false;
|
||||
}
|
||||
let progress = (-quadratic_b - discriminant.sqrt()) / (2.0 * quadratic_a);
|
||||
0.0 < progress && progress <= 1.0
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
Reference in New Issue
Block a user