Skip to content

Commit 0af8bc6

Browse files
committed
Make find vertecies use 64 bit again this is slower but less likely to cause issues
1 parent c3d5cc6 commit 0af8bc6

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

libraries/path-bool/src/path_boolean.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -534,8 +534,8 @@ impl Direction {
534534

535535
const ROUNDING_FACTOR: f64 = 1.0 / (2. * EPS.point);
536536

537-
fn round_point(point: DVec2) -> IVec2 {
538-
(point * ROUNDING_FACTOR).as_ivec2()
537+
fn round_point(point: DVec2) -> I64Vec2 {
538+
(point * ROUNDING_FACTOR).as_i64vec2()
539539
}
540540

541541
// TODO: Using 32bit values here might lead to incorrect results when the values collide. Even though this is very unlikely we should think about this case
@@ -546,7 +546,7 @@ fn find_vertices(edges: &[MajorGraphEdgeStage1], total_bounding_box: Aabb) -> Ma
546546
};
547547

548548
let mut vertex_pair_id_to_edges: HashMap<_, SmallVec<[(PathSegment, u8, MajorEdgeKey, MajorEdgeKey); 2]>> = new_hash_map(edges.len());
549-
let mut vertex_hashmap: HashMap<IVec2, MajorVertexKey> = new_hash_map(edges.len() * 2);
549+
let mut vertex_hashmap: HashMap<I64Vec2, MajorVertexKey> = new_hash_map(edges.len() * 2);
550550

551551
// let mut vertex_tree = QuadTree::new(bounding_box, POINT_TREE_DEPTH, 8);
552552
// let mut graph = MajorGraph {
@@ -575,16 +575,16 @@ fn find_vertices(edges: &[MajorGraphEdgeStage1], total_bounding_box: Aabb) -> Ma
575575
if let Some(&vertex) = vertex_hashmap.get(&rounded) {
576576
return vertex;
577577
}
578-
if let Some(&vertex) = vertex_hashmap.get(&(rounded - IVec2::X)) {
578+
if let Some(&vertex) = vertex_hashmap.get(&(rounded - I64Vec2::X)) {
579579
return vertex;
580580
}
581-
if let Some(&vertex) = vertex_hashmap.get(&(rounded - IVec2::Y)) {
581+
if let Some(&vertex) = vertex_hashmap.get(&(rounded - I64Vec2::Y)) {
582582
return vertex;
583583
}
584-
if let Some(&vertex) = vertex_hashmap.get(&(rounded + IVec2::X)) {
584+
if let Some(&vertex) = vertex_hashmap.get(&(rounded + I64Vec2::X)) {
585585
return vertex;
586586
}
587-
if let Some(&vertex) = vertex_hashmap.get(&(rounded + IVec2::Y)) {
587+
if let Some(&vertex) = vertex_hashmap.get(&(rounded + I64Vec2::Y)) {
588588
return vertex;
589589
}
590590

@@ -595,16 +595,16 @@ fn find_vertices(edges: &[MajorGraphEdgeStage1], total_bounding_box: Aabb) -> Ma
595595
// for offset in offsets.iter() {
596596
// for dx in -1..=1 {
597597
// for dy in -1..=1 {
598-
let offset = IVec2::ZERO;
598+
let offset = I64Vec2::ZERO;
599599
// let offset = IVec2::new(dx, dy);
600600
vertex_hashmap.insert(rounded + offset, vertex_key);
601601
// }
602602
// }
603603
vertex_key
604604
};
605605
// we should subtract the center instead here
606-
let start_vertex = get_vertex(seg.start() - total_bounding_box.min());
607-
let end_vertex = get_vertex(seg.end() - total_bounding_box.min());
606+
let start_vertex = get_vertex(seg.start());
607+
let end_vertex = get_vertex(seg.end());
608608

609609
if start_vertex == end_vertex {
610610
match seg {

0 commit comments

Comments
 (0)