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
path: root/source
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2013-02-05 15:30:50 +0400
committerCampbell Barton <ideasman42@gmail.com>2013-02-05 15:30:50 +0400
commite7cead09944a97854309c5eea56fb4fadb92fb3d (patch)
treea6380a3c25e832488501907ec44ddffbcc081bc8 /source
parent9ddf928dbd732a9394a17c65ac95ecee30f3efcd (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')
-rw-r--r--source/blender/bmesh/operators/bmo_triangulate.c3
-rw-r--r--source/blender/bmesh/tools/bmesh_triangulate.c40
-rw-r--r--source/blender/bmesh/tools/bmesh_triangulate.h3
-rw-r--r--source/blender/editors/sculpt_paint/sculpt.c2
-rw-r--r--source/blender/modifiers/intern/MOD_triangulate.c2
5 files changed, 40 insertions, 10 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__ */
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index c4d09de3d0e..10f4dc2aebc 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -4526,7 +4526,7 @@ static void SCULPT_OT_set_persistent_base(wmOperatorType *ot)
static void sculpt_dynamic_topology_triangulate(BMesh *bm)
{
- BM_mesh_triangulate(bm, false, false);
+ BM_mesh_triangulate(bm, false, false, NULL, NULL);
}
void sculpt_pbvh_clear(Object *ob)
diff --git a/source/blender/modifiers/intern/MOD_triangulate.c b/source/blender/modifiers/intern/MOD_triangulate.c
index 2f0fbbd0507..1c22e9bf364 100644
--- a/source/blender/modifiers/intern/MOD_triangulate.c
+++ b/source/blender/modifiers/intern/MOD_triangulate.c
@@ -42,7 +42,7 @@ static DerivedMesh *triangulate_dm(DerivedMesh *dm, const int flag)
bm = DM_to_bmesh(dm);
- BM_mesh_triangulate(bm, (flag & MOD_TRIANGULATE_BEAUTY), false);
+ BM_mesh_triangulate(bm, (flag & MOD_TRIANGULATE_BEAUTY), false, NULL, NULL);
result = CDDM_from_bmesh(bm, FALSE);
BM_mesh_free(bm);