[Bf-blender-cvs] [94717157204] master: Fix crash in delaunay C interface test.
Howard Trickey
noreply at git.blender.org
Tue Jul 20 13:30:51 CEST 2021
Commit: 9471715720489b36f2472f00363440546e9a07a5
Author: Howard Trickey
Date: Tue Jul 20 07:28:46 2021 -0400
Branches: master
https://developer.blender.org/rB9471715720489b36f2472f00363440546e9a07a5
Fix crash in delaunay C interface test.
The test forgot to set the new need_ids field, which luckily
exposed a bug in the C api for delaunay when that field is false.
Fixed the bug and the test, and added a test for the need_ids false
case.
===================================================================
M source/blender/blenlib/intern/delaunay_2d.cc
M source/blender/blenlib/tests/BLI_delaunay_2d_test.cc
===================================================================
diff --git a/source/blender/blenlib/intern/delaunay_2d.cc b/source/blender/blenlib/intern/delaunay_2d.cc
index 362dbdf15c5..08f18d5cbf3 100644
--- a/source/blender/blenlib/intern/delaunay_2d.cc
+++ b/source/blender/blenlib/intern/delaunay_2d.cc
@@ -2851,10 +2851,12 @@ extern "C" ::CDT_result *BLI_delaunay_2d_cdt_calc(const ::CDT_input *input,
for (int e = 0; e < ne; ++e) {
tot_e_orig += res.edge_orig[e].size();
}
- for (int f = 0; f < nf; ++f) {
+ }
+ for (int f = 0; f < nf; ++f) {
+ if (input->need_ids) {
tot_f_orig += res.face_orig[f].size();
- tot_f_lens += res.face[f].size();
}
+ tot_f_lens += res.face[f].size();
}
output->vert_coords = static_cast<decltype(output->vert_coords)>(
diff --git a/source/blender/blenlib/tests/BLI_delaunay_2d_test.cc b/source/blender/blenlib/tests/BLI_delaunay_2d_test.cc
index bc6b7e9fe4e..cd2d48eac4d 100644
--- a/source/blender/blenlib/tests/BLI_delaunay_2d_test.cc
+++ b/source/blender/blenlib/tests/BLI_delaunay_2d_test.cc
@@ -1756,9 +1756,34 @@ TEST(delaunay_d, CintTwoFace)
input.faces_len_table = faces_len;
input.faces_start_table = faces_start;
input.epsilon = 1e-5f;
+ input.need_ids = false;
::CDT_result *output = BLI_delaunay_2d_cdt_calc(&input, CDT_FULL);
BLI_delaunay_2d_cdt_free(output);
}
+
+TEST(delaunay_d, CintTwoFaceNoIds)
+{
+ float vert_coords[][2] = {
+ {0.0, 0.0}, {1.0, 0.0}, {0.5, 1.0}, {1.1, 1.0}, {1.1, 0.0}, {1.6, 1.0}};
+ int faces[] = {0, 1, 2, 3, 4, 5};
+ int faces_len[] = {3, 3};
+ int faces_start[] = {0, 3};
+
+ ::CDT_input input;
+ input.verts_len = 6;
+ input.edges_len = 0;
+ input.faces_len = 2;
+ input.vert_coords = vert_coords;
+ input.edges = nullptr;
+ input.faces = faces;
+ input.faces_len_table = faces_len;
+ input.faces_start_table = faces_start;
+ input.epsilon = 1e-5f;
+ input.need_ids = true;
+ ::CDT_result *output = BLI_delaunay_2d_cdt_calc(&input, CDT_FULL);
+ BLI_delaunay_2d_cdt_free(output);
+}
+
#endif
#if DO_TEXT_TESTS
More information about the Bf-blender-cvs
mailing list