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:
authorHenrik Dick <hen-di@web.de>2022-01-11 20:49:08 +0300
committerHenrik Dick <hen-di@web.de>2022-01-11 20:51:25 +0300
commit631067e5597dec9cb5641b69a410d03746b7fa05 (patch)
treed286f8fa34a7ddb0ceb82526a0ab2e85e1499f46
parent41ce7807a65a0b44adea3732143b691b2b001b90 (diff)
Add support for a longest diagonal quad triangulation mode
The new triangulation mode for quads is the opposite of the current default shortest diagonal mode. It is optimal for cloth simulations using quad meshes. Differential Revision: http://developer.blender.org/D13777
-rw-r--r--source/blender/bmesh/intern/bmesh_opdefines.c1
-rw-r--r--source/blender/bmesh/intern/bmesh_polygon.c7
-rw-r--r--source/blender/makesdna/DNA_modifier_types.h1
-rw-r--r--source/blender/makesdna/DNA_node_types.h1
-rw-r--r--source/blender/makesrna/intern/rna_modifier.c7
-rw-r--r--source/blender/makesrna/intern/rna_nodetree.c7
6 files changed, 22 insertions, 2 deletions
diff --git a/source/blender/bmesh/intern/bmesh_opdefines.c b/source/blender/bmesh/intern/bmesh_opdefines.c
index 7865c79323d..85ea27b0f4e 100644
--- a/source/blender/bmesh/intern/bmesh_opdefines.c
+++ b/source/blender/bmesh/intern/bmesh_opdefines.c
@@ -1186,6 +1186,7 @@ static BMO_FlagSet bmo_enum_triangulate_quad_method[] = {
{MOD_TRIANGULATE_QUAD_FIXED, "FIXED"},
{MOD_TRIANGULATE_QUAD_ALTERNATE, "ALTERNATE"},
{MOD_TRIANGULATE_QUAD_SHORTEDGE, "SHORT_EDGE"},
+ {MOD_TRIANGULATE_QUAD_LONGEDGE, "LONG_EDGE"},
{0, NULL},
};
diff --git a/source/blender/bmesh/intern/bmesh_polygon.c b/source/blender/bmesh/intern/bmesh_polygon.c
index e9eaf865e3c..e7280303c26 100644
--- a/source/blender/bmesh/intern/bmesh_polygon.c
+++ b/source/blender/bmesh/intern/bmesh_polygon.c
@@ -1007,6 +1007,7 @@ void BM_face_triangulate(BMesh *bm,
break;
}
case MOD_TRIANGULATE_QUAD_SHORTEDGE:
+ case MOD_TRIANGULATE_QUAD_LONGEDGE:
case MOD_TRIANGULATE_QUAD_BEAUTY:
default: {
BMLoop *l_v3, *l_v4;
@@ -1023,6 +1024,12 @@ void BM_face_triangulate(BMesh *bm,
d2 = len_squared_v3v3(l_v1->v->co, l_v3->v->co);
split_24 = ((d2 - d1) > 0.0f);
}
+ else if (quad_method == MOD_TRIANGULATE_QUAD_LONGEDGE) {
+ float d1, d2;
+ d1 = len_squared_v3v3(l_v4->v->co, l_v2->v->co);
+ d2 = len_squared_v3v3(l_v1->v->co, l_v3->v->co);
+ split_24 = ((d2 - d1) < 0.0f);
+ }
else {
/* first check if the quad is concave on either diagonal */
const int flip_flag = is_quad_flip_v3(
diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h
index fc041e257b0..1d0796bda8b 100644
--- a/source/blender/makesdna/DNA_modifier_types.h
+++ b/source/blender/makesdna/DNA_modifier_types.h
@@ -1852,6 +1852,7 @@ enum {
MOD_TRIANGULATE_QUAD_FIXED = 1,
MOD_TRIANGULATE_QUAD_ALTERNATE = 2,
MOD_TRIANGULATE_QUAD_SHORTEDGE = 3,
+ MOD_TRIANGULATE_QUAD_LONGEDGE = 4,
};
typedef struct LaplacianSmoothModifierData {
diff --git a/source/blender/makesdna/DNA_node_types.h b/source/blender/makesdna/DNA_node_types.h
index 29d61bcf2ff..114e350b582 100644
--- a/source/blender/makesdna/DNA_node_types.h
+++ b/source/blender/makesdna/DNA_node_types.h
@@ -2118,6 +2118,7 @@ typedef enum GeometryNodeTriangulateQuads {
GEO_NODE_TRIANGULATE_QUAD_FIXED = 1,
GEO_NODE_TRIANGULATE_QUAD_ALTERNATE = 2,
GEO_NODE_TRIANGULATE_QUAD_SHORTEDGE = 3,
+ GEO_NODE_TRIANGULATE_QUAD_LONGEDGE = 4,
} GeometryNodeTriangulateQuads;
typedef enum GeometryNodePointInstanceType {
diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c
index d46ae13b482..0f0734c8448 100644
--- a/source/blender/makesrna/intern/rna_modifier.c
+++ b/source/blender/makesrna/intern/rna_modifier.c
@@ -331,7 +331,12 @@ const EnumPropertyItem rna_enum_modifier_triangulate_quad_method_items[] = {
"SHORTEST_DIAGONAL",
0,
"Shortest Diagonal",
- "Split the quads based on the distance between the vertices"},
+ "Split the quads along their shortest diagonal"},
+ {MOD_TRIANGULATE_QUAD_LONGEDGE,
+ "LONGEST_DIAGONAL",
+ 0,
+ "Longest Diagonal",
+ "Split the quads along their longest diagonal"},
{0, NULL, 0, NULL, NULL},
};
diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c
index e7307e6e058..ecbeadf1fa4 100644
--- a/source/blender/makesrna/intern/rna_nodetree.c
+++ b/source/blender/makesrna/intern/rna_nodetree.c
@@ -9488,7 +9488,12 @@ static void def_geo_triangulate(StructRNA *srna)
"SHORTEST_DIAGONAL",
0,
"Shortest Diagonal",
- "Split the quads based on the distance between the vertices"},
+ "Split the quads along their shortest diagonal"},
+ {GEO_NODE_TRIANGULATE_QUAD_LONGEDGE,
+ "LONGEST_DIAGONAL",
+ 0,
+ "Longest Diagonal",
+ "Split the quads along their longest diagonal"},
{0, NULL, 0, NULL, NULL},
};