diff options
Diffstat (limited to 'crates/fparkan-runtime/src/projectile.rs')
| -rw-r--r-- | crates/fparkan-runtime/src/projectile.rs | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/crates/fparkan-runtime/src/projectile.rs b/crates/fparkan-runtime/src/projectile.rs index 51adc045..55e5da46 100644 --- a/crates/fparkan-runtime/src/projectile.rs +++ b/crates/fparkan-runtime/src/projectile.rs @@ -702,6 +702,22 @@ mod tests { device.class9_values_bits = Some([0; 6]); } } + let pose = transform_state(&engine.world, plant).unwrap(); + let assets = &engine.loaded.as_ref().unwrap().mission_assets; + let ([x, y, z], radius) = unit_sphere(assets, 5, pose).unwrap(); + let shooter = crate::starting_cockpit(&engine).unwrap().handle; + let intact_roof = (-8..=8) + .flat_map(|i| (-8..=8).map(move |j| (i, j))) + .filter_map(|(i, j)| { + let x = x + radius * i as f32 / 8.0; + let y = y + radius * j as f32 / 8.0; + let start = [x, y, z + radius]; + let hit = projectile_unit_hit(&engine, shooter, [start, [x, y, z - radius]])?; + (hit.handle == plant && hit.node == Some(ProjectileNode::Building(1))) + .then_some([start, [x, y, hit.position[2] - 0.25]]) + }) + .collect::<Vec<_>>(); + assert!(!intact_roof.is_empty()); let stage_contact = ProjectileContact { handle: plant, fraction: 0.5, @@ -733,6 +749,9 @@ mod tests { .visible_stage, 0 ); + assert!(intact_roof + .iter() + .any(|&ray| projectile_unit_hit(&engine, shooter, ray).is_none())); let contact = ProjectileContact { handle: plant, fraction: 0.5, |
