fix(drawing/drawing): Don't infringe on and from loose dots

These resulted in false positives for line-of-sight paths.
This commit is contained in:
Mikolaj Wielgus 2025-08-12 22:04:21 +02:00
parent 191e646d68
commit fac52f9d8b
1 changed files with 25 additions and 16 deletions

View File

@ -1140,24 +1140,33 @@ impl<CW: Clone, Cel: Copy, R: AccessRules> Drawing<CW, Cel, R> {
let mut inflated_shape = infringer.primitive(self).shape(); // Unused temporary value just for initialization. let mut inflated_shape = infringer.primitive(self).shape(); // Unused temporary value just for initialization.
let conditions = infringer.primitive(self).conditions(); let conditions = infringer.primitive(self).conditions();
it.filter(|infringee| !self.are_connectable(infringer, *infringee)) it.filter(|infringee| {
.find_map(|primitive_node| { // Infringement with loose dots resulted in false positives for
let infringee_conditions = primitive_node.primitive(self).conditions(); // line-of-sight paths.
!matches!(infringer, PrimitiveIndex::LooseDot(..))
&& !matches!(infringee, PrimitiveIndex::LooseDot(..))
})
.filter(|infringee| !self.are_connectable(infringer, *infringee))
.find_map(|primitive_node| {
let infringee_conditions = primitive_node.primitive(self).conditions();
let epsilon = 1.0; let epsilon = 1.0;
inflated_shape = infringer.primitive(self).shape().inflate( inflated_shape = infringer.primitive(self).shape().inflate(
match (&conditions, infringee_conditions) { match (&conditions, infringee_conditions) {
(None, _) | (_, None) => 0.0, (None, _) | (_, None) => 0.0,
(Some(lhs), Some(rhs)) => { (Some(lhs), Some(rhs)) => {
(self.rules.clearance(lhs, &rhs) - epsilon).clamp(0.0, f64::INFINITY) // Note the epsilon comparison.
} // XXX: Epsilon is probably too large. But what should
}, // it be exactly then?
); (self.rules.clearance(lhs, &rhs) - epsilon).clamp(0.0, f64::INFINITY)
}
},
);
inflated_shape inflated_shape
.intersects(&primitive_node.primitive(self).shape()) .intersects(&primitive_node.primitive(self).shape())
.then_some(Infringement(inflated_shape, primitive_node)) .then_some(Infringement(inflated_shape, primitive_node))
}) })
} }
fn detect_collision_except( fn detect_collision_except(