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:
authorIsh Bosamiya <ishbosamiya>2019-03-22 19:55:51 +0300
committerBrecht Van Lommel <brechtvanlommel@gmail.com>2019-03-22 20:11:14 +0300
commitda5b6ed75bf08141dd19a0cc143d1a91b14a0f24 (patch)
tree761250222839c8c9800de88329d153a5ce7daf10 /source/blender/bmesh
parentc89dcc89e6ebc3882f66b3536a51bae83807ad6b (diff)
Modifiers: add minimum number of vertices to triangulate modifier.
This lets you only triangulate n-gons when setting the number to 5 or more. Differential Revision: https://developer.blender.org/D4367
Diffstat (limited to 'source/blender/bmesh')
-rw-r--r--source/blender/bmesh/operators/bmo_triangulate.c2
-rw-r--r--source/blender/bmesh/tools/bmesh_triangulate.c9
-rw-r--r--source/blender/bmesh/tools/bmesh_triangulate.h3
3 files changed, 8 insertions, 6 deletions
diff --git a/source/blender/bmesh/operators/bmo_triangulate.c b/source/blender/bmesh/operators/bmo_triangulate.c
index 747b1769137..35f5c40a213 100644
--- a/source/blender/bmesh/operators/bmo_triangulate.c
+++ b/source/blender/bmesh/operators/bmo_triangulate.c
@@ -47,7 +47,7 @@ void bmo_triangulate_exec(BMesh *bm, BMOperator *op)
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, quad_method, ngon_method, true, op, slot_facemap_out, slot_facemap_double_out);
+ BM_mesh_triangulate(bm, quad_method, ngon_method, 4, true, op, slot_facemap_out, slot_facemap_double_out);
BMO_slot_buffer_from_enabled_hflag(bm, op, op->slots_out, "edges.out", BM_EDGE, BM_ELEM_TAG);
BMO_slot_buffer_from_enabled_hflag(bm, op, op->slots_out, "faces.out", BM_FACE, BM_ELEM_TAG);
diff --git a/source/blender/bmesh/tools/bmesh_triangulate.c b/source/blender/bmesh/tools/bmesh_triangulate.c
index 034151fa584..9be4e8f621c 100644
--- a/source/blender/bmesh/tools/bmesh_triangulate.c
+++ b/source/blender/bmesh/tools/bmesh_triangulate.c
@@ -83,8 +83,9 @@ static void bm_face_triangulate_mapping(
void BM_mesh_triangulate(
- BMesh *bm, const int quad_method, const int ngon_method, const bool tag_only,
- BMOperator *op, BMOpSlot *slot_facemap_out, BMOpSlot *slot_facemap_double_out)
+ BMesh *bm, const int quad_method, const int ngon_method, const int min_vertices,
+ const bool tag_only, BMOperator *op, BMOpSlot *slot_facemap_out,
+ BMOpSlot *slot_facemap_double_out)
{
BMIter iter;
BMFace *face;
@@ -103,7 +104,7 @@ void BM_mesh_triangulate(
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) {
+ if (face->len >= min_vertices) {
if (tag_only == false || BM_elem_flag_test(face, BM_ELEM_TAG)) {
bm_face_triangulate_mapping(
bm, face,
@@ -118,7 +119,7 @@ void BM_mesh_triangulate(
LinkNode *faces_double = NULL;
BM_ITER_MESH (face, &iter, bm, BM_FACES_OF_MESH) {
- if (face->len > 3) {
+ if (face->len >= min_vertices) {
if (tag_only == false || BM_elem_flag_test(face, BM_ELEM_TAG)) {
BM_face_triangulate(
bm, face,
diff --git a/source/blender/bmesh/tools/bmesh_triangulate.h b/source/blender/bmesh/tools/bmesh_triangulate.h
index 1b312ebadbf..b254246720c 100644
--- a/source/blender/bmesh/tools/bmesh_triangulate.h
+++ b/source/blender/bmesh/tools/bmesh_triangulate.h
@@ -24,7 +24,8 @@
#define __BMESH_TRIANGULATE_H__
void BM_mesh_triangulate(
- BMesh *bm, const int quad_method, const int ngon_method, const bool tag_only,
+ BMesh *bm, const int quad_method, const int ngon_method,
+ const int min_vertices, const bool tag_only,
BMOperator *op, BMOpSlot *slot_facemap_out, BMOpSlot *slot_doubles_out);
#endif /* __BMESH_TRIANGULATE_H__ */