Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2015-11-05 17:05:38 +0300
committerCampbell Barton <ideasman42@gmail.com>2015-11-05 17:13:23 +0300
commit0f769afe07f96efa7ec6325453c4f04ea391f112 (patch)
tree25fc5257e3d52322334b05ff8d31d5b32f2cb16f /source/blender/bmesh/tools/bmesh_triangulate.c
parentcb39a4171b6a052f13625688cbb5aed267356b50 (diff)
Fix T46692: Triangulate creates duplicate faces
Caused a crash in dyntopo.
Diffstat (limited to 'source/blender/bmesh/tools/bmesh_triangulate.c')
-rw-r--r--source/blender/bmesh/tools/bmesh_triangulate.c31
1 files changed, 25 insertions, 6 deletions
diff --git a/source/blender/bmesh/tools/bmesh_triangulate.c b/source/blender/bmesh/tools/bmesh_triangulate.c
index 6f2aaf28179..ce1bc46d5e8 100644
--- a/source/blender/bmesh/tools/bmesh_triangulate.c
+++ b/source/blender/bmesh/tools/bmesh_triangulate.c
@@ -36,6 +36,7 @@
#include "BLI_memarena.h"
#include "BLI_heap.h"
#include "BLI_edgehash.h"
+#include "BLI_linklist.h"
/* only for defines */
#include "BLI_polyfill2d.h"
@@ -52,7 +53,7 @@ static void bm_face_triangulate_mapping(
BMesh *bm, BMFace *face,
const int quad_method, const int ngon_method,
const bool use_tag,
- BMOperator *op, BMOpSlot *slot_facemap_out,
+ BMOperator *op, BMOpSlot *slot_facemap_out, BMOpSlot *slot_facemap_double_out,
MemArena *pf_arena,
/* use for MOD_TRIANGULATE_NGON_BEAUTY only! */
@@ -60,12 +61,14 @@ static void bm_face_triangulate_mapping(
{
int faces_array_tot = face->len - 3;
BMFace **faces_array = BLI_array_alloca(faces_array, faces_array_tot);
+ LinkNode *faces_double = NULL;
BLI_assert(face->len > 3);
BM_face_triangulate(
bm, face,
faces_array, &faces_array_tot,
NULL, NULL,
+ &faces_double,
quad_method, ngon_method, use_tag,
pf_arena,
pf_heap, pf_ehash);
@@ -76,13 +79,20 @@ static void bm_face_triangulate_mapping(
for (i = 0; i < faces_array_tot; i++) {
BMO_slot_map_elem_insert(op, slot_facemap_out, faces_array[i], face);
}
+
+ while (faces_double) {
+ LinkNode *next = faces_double->next;
+ BMO_slot_map_elem_insert(op, slot_facemap_double_out, faces_double->link, face);
+ MEM_freeN(faces_double);
+ faces_double = next;
+ }
}
}
void BM_mesh_triangulate(
BMesh *bm, const int quad_method, const int ngon_method, const bool tag_only,
- BMOperator *op, BMOpSlot *slot_facemap_out)
+ BMOperator *op, BMOpSlot *slot_facemap_out, BMOpSlot *slot_facemap_double_out)
{
BMIter iter;
BMFace *face;
@@ -107,10 +117,9 @@ void BM_mesh_triangulate(
if (face->len > 3) {
if (tag_only == false || BM_elem_flag_test(face, BM_ELEM_TAG)) {
bm_face_triangulate_mapping(
- bm, face, quad_method,
- ngon_method, tag_only,
- op, slot_facemap_out,
-
+ bm, face,
+ quad_method, ngon_method, tag_only,
+ op, slot_facemap_out, slot_facemap_double_out,
pf_arena,
pf_heap, pf_ehash);
}
@@ -118,6 +127,8 @@ void BM_mesh_triangulate(
}
}
else {
+ LinkNode *faces_double = NULL;
+
BM_ITER_MESH (face, &iter, bm, BM_FACES_OF_MESH) {
if (face->len > 3) {
if (tag_only == false || BM_elem_flag_test(face, BM_ELEM_TAG)) {
@@ -125,12 +136,20 @@ void BM_mesh_triangulate(
bm, face,
NULL, NULL,
NULL, NULL,
+ &faces_double,
quad_method, ngon_method, tag_only,
pf_arena,
pf_heap, pf_ehash);
}
}
}
+
+ while (faces_double) {
+ LinkNode *next = faces_double->next;
+ BM_face_kill(bm, faces_double->link);
+ MEM_freeN(faces_double);
+ faces_double = next;
+ }
}
BLI_memarena_free(pf_arena);