diff options
author | Campbell Barton <ideasman42@gmail.com> | 2013-02-05 15:30:50 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2013-02-05 15:30:50 +0400 |
commit | e7cead09944a97854309c5eea56fb4fadb92fb3d (patch) | |
tree | a6380a3c25e832488501907ec44ddffbcc081bc8 /source/blender/bmesh | |
parent | 9ddf928dbd732a9394a17c65ac95ecee30f3efcd (diff) |
own recent change to triangulate bmesh operator stopped filling in mapping slot 'face_map.out', not used by blender its self but useful for scripts, enable this again.
Diffstat (limited to 'source/blender/bmesh')
-rw-r--r-- | source/blender/bmesh/operators/bmo_triangulate.c | 3 | ||||
-rw-r--r-- | source/blender/bmesh/tools/bmesh_triangulate.c | 40 | ||||
-rw-r--r-- | source/blender/bmesh/tools/bmesh_triangulate.h | 3 |
3 files changed, 38 insertions, 8 deletions
diff --git a/source/blender/bmesh/operators/bmo_triangulate.c b/source/blender/bmesh/operators/bmo_triangulate.c index bbcb07e1174..e06929e339d 100644 --- a/source/blender/bmesh/operators/bmo_triangulate.c +++ b/source/blender/bmesh/operators/bmo_triangulate.c @@ -44,11 +44,12 @@ void bmo_triangulate_exec(BMesh *bm, BMOperator *op) { const bool use_beauty = BMO_slot_bool_get(op->slots_in, "use_beauty"); + BMOpSlot *slot_facemap_out = BMO_slot_get(op->slots_out, "face_map.out"); BM_mesh_elem_hflag_disable_all(bm, BM_FACE | BM_EDGE, BM_ELEM_TAG, false); BMO_slot_buffer_hflag_enable(bm, op->slots_in, "faces", BM_FACE, BM_ELEM_TAG, false); - BM_mesh_triangulate(bm, use_beauty, true); + BM_mesh_triangulate(bm, use_beauty, true, op, slot_facemap_out); if (use_beauty) { BMO_op_callf(bm, op->flag, diff --git a/source/blender/bmesh/tools/bmesh_triangulate.c b/source/blender/bmesh/tools/bmesh_triangulate.c index 4ab5383f0b6..79f6c76afc7 100644 --- a/source/blender/bmesh/tools/bmesh_triangulate.c +++ b/source/blender/bmesh/tools/bmesh_triangulate.c @@ -30,28 +30,56 @@ #include "MEM_guardedalloc.h" #include "BLI_utildefines.h" +#include "BLI_array.h" #include "bmesh.h" #include "bmesh_triangulate.h" /* own include */ -void BM_mesh_triangulate(BMesh *bm, const bool use_beauty, const bool tag_only) +/** + * a version of #BM_face_triangulate that maps to #BMOpSlot + */ +static void bm_face_triangulate_mapping(BMesh *bm, BMFace *face, const bool use_beauty, const bool use_tag, + BMOperator *op, BMOpSlot *slot_facemap_out) +{ + const int faces_array_tot = face->len - 3; + BMFace **faces_array = BLI_array_alloca(faces_array, faces_array_tot); + BLI_assert(face->len > 3); + + BM_face_triangulate(bm, face, faces_array, use_beauty, use_tag); + + if (faces_array) { + int i; + BMO_slot_map_elem_insert(op, slot_facemap_out, face, face); + for (i = 0; i < faces_array_tot; i++) { + BMO_slot_map_elem_insert(op, slot_facemap_out, faces_array[i], face); + } + } +} + + +void BM_mesh_triangulate(BMesh *bm, const bool use_beauty, const bool tag_only, + BMOperator *op, BMOpSlot *slot_facemap_out) { BMIter iter; BMFace *face; - if (tag_only == false) { + if (slot_facemap_out) { + /* same as below but call: bm_face_triangulate_mapping() */ BM_ITER_MESH (face, &iter, bm, BM_FACES_OF_MESH) { if (face->len > 3) { - BM_face_triangulate(bm, face, NULL, use_beauty, false); + if (tag_only == false || BM_elem_flag_test(face, BM_ELEM_TAG)) { + bm_face_triangulate_mapping(bm, face, use_beauty, tag_only, + op, slot_facemap_out); + } } } } else { BM_ITER_MESH (face, &iter, bm, BM_FACES_OF_MESH) { - if (BM_elem_flag_test(face, BM_ELEM_TAG)) { - if (face->len > 3) { - BM_face_triangulate(bm, face, NULL, use_beauty, true); + if (face->len > 3) { + if (tag_only == false || BM_elem_flag_test(face, BM_ELEM_TAG)) { + BM_face_triangulate(bm, face, NULL, use_beauty, tag_only); } } } diff --git a/source/blender/bmesh/tools/bmesh_triangulate.h b/source/blender/bmesh/tools/bmesh_triangulate.h index ea271c98acb..936a90d3a16 100644 --- a/source/blender/bmesh/tools/bmesh_triangulate.h +++ b/source/blender/bmesh/tools/bmesh_triangulate.h @@ -30,6 +30,7 @@ #ifndef __BMESH_TRIAMGULATE_H__ #define __BMESH_TRIAMGULATE_H__ -void BM_mesh_triangulate(BMesh *bm, const bool use_beauty, const bool tag_only); +void BM_mesh_triangulate(BMesh *bm, const bool use_beauty, const bool tag_only, + BMOperator *op, BMOpSlot *slot_facemap_out); #endif /* __BMESH_TRIAMGULATE_H__ */ |