From 8e120230a167bbaa69572daa8b9a6e3b86fc1c31 Mon Sep 17 00:00:00 2001 From: Marcel Admiraal Date: Mon, 29 Jun 2020 16:40:25 +0100 Subject: [PATCH 1/2] Create degenerate triangles when inserting an edge into a CSG face. They will be deleted when the faces are merged, but their edges are needed for merging faces. --- modules/csg/csg.cpp | 9 --------- 1 file changed, 9 deletions(-) diff --git a/modules/csg/csg.cpp b/modules/csg/csg.cpp index 54b913711ad..660deec8b57 100644 --- a/modules/csg/csg.cpp +++ b/modules/csg/csg.cpp @@ -1066,15 +1066,6 @@ void CSGBrushOperation::Build2DFaces::_find_edge_intersections(const Vector2 p_s break; } - // Don't create degenerate triangles. - Vector2 split_edge1[2] = { vertices[new_vertex_idx].point, edge_points[0] }; - Vector2 split_edge2[2] = { vertices[new_vertex_idx].point, edge_points[1] }; - Vector2 new_edge[2] = { vertices[new_vertex_idx].point, vertices[opposite_vertex_idx].point }; - if (are_segements_parallel(split_edge1, new_edge, vertex_snap2) && - are_segements_parallel(split_edge2, new_edge, vertex_snap2)) { - break; - } - // If opposite point is on the segemnt, add its index to segment indices too. Vector2 closest_point = Geometry::get_closest_point_to_segment_2d(vertices[opposite_vertex_idx].point, p_segment_points); if ((closest_point - vertices[opposite_vertex_idx].point).length_squared() < vertex_snap2) From 22ff17793c836b0d00d2417e0ac45bb96d628a3a Mon Sep 17 00:00:00 2001 From: Marcel Admiraal Date: Mon, 29 Jun 2020 17:52:36 +0100 Subject: [PATCH 2/2] Use is_equal_approx() instead of vertex_snap when checking if ray is colliding with equiplanar CSG faces. --- modules/csg/csg.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/csg/csg.cpp b/modules/csg/csg.cpp index 660deec8b57..b34cfbfaab9 100644 --- a/modules/csg/csg.cpp +++ b/modules/csg/csg.cpp @@ -524,7 +524,7 @@ void CSGBrushOperation::MeshMerge::_add_distance(List &r_intersectionsA, // Check if distance exists. for (const List::Element *E = intersections.front(); E; E = E->next()) - if (Math::abs(**E - p_distance) < vertex_snap) return; + if (Math::is_equal_approx(**E, p_distance)) return; intersections.push_back(p_distance); }