[Bf-blender-cvs] [71c8a2d6bc8] soc-2021-adaptive-cloth: modifier: adaptive_remesh: select split or collapse edge operation
ishbosamiya
noreply at git.blender.org
Mon Jul 12 08:23:51 CEST 2021
Commit: 71c8a2d6bc8bf94267e448eb92afaa8fc9f04010
Author: ishbosamiya
Date: Sat Jul 10 17:15:57 2021 +0530
Branches: soc-2021-adaptive-cloth
https://developer.blender.org/rB71c8a2d6bc8bf94267e448eb92afaa8fc9f04010
modifier: adaptive_remesh: select split or collapse edge operation
===================================================================
M source/blender/makesdna/DNA_modifier_defaults.h
M source/blender/makesdna/DNA_modifier_types.h
M source/blender/makesrna/intern/rna_modifier.c
M source/blender/modifiers/intern/MOD_adaptive_remesh.cc
===================================================================
diff --git a/source/blender/makesdna/DNA_modifier_defaults.h b/source/blender/makesdna/DNA_modifier_defaults.h
index dea3dec1faa..859a51e7511 100644
--- a/source/blender/makesdna/DNA_modifier_defaults.h
+++ b/source/blender/makesdna/DNA_modifier_defaults.h
@@ -53,6 +53,7 @@
{ \
.edge_index = 0, \
.flag = 0, \
+ .mode = 0, \
}
#define _DNA_DEFAULT_BevelModifierData \
diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h
index 1e87856ae61..8b9cd15be40 100644
--- a/source/blender/makesdna/DNA_modifier_types.h
+++ b/source/blender/makesdna/DNA_modifier_types.h
@@ -2351,12 +2351,24 @@ typedef struct AdaptiveRemeshModifierData {
/* AdaptiveRemeshFlag */
uint32_t flag;
+
+ /* AdaptiveRemeshMode */
+ uint32_t mode;
+
+ char _pad[4];
+
} AdaptiveRemeshModifierData;
typedef enum AdaptiveRemeshFlag {
- ADAPTIVE_REMESH_SPLIT_EDGE_ACROSS_SEAMS = 1 << 0,
+ ADAPTIVE_REMESH_ACROSS_SEAMS = 1 << 0,
+ ADAPTIVE_REMESH_VERTS_SWAPPED = 1 << 1,
} AdaptiveRemeshFlag;
+typedef enum AdaptiveRemeshMode {
+ ADAPTIVE_REMESH_SPLIT_EDGE = 0,
+ ADAPTIVE_REMESH_COLLAPSE_EDGE = 1,
+} AdaptiveRemeshMode;
+
#ifdef __cplusplus
}
#endif
diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c
index 8bd0c2eca29..0e43feb72f7 100644
--- a/source/blender/makesrna/intern/rna_modifier.c
+++ b/source/blender/makesrna/intern/rna_modifier.c
@@ -7232,6 +7232,16 @@ static void rna_def_modifier_adaptive_remesh(BlenderRNA *brna)
StructRNA *srna;
PropertyRNA *prop;
+ static EnumPropertyItem operation_mode_items[] = {
+ {ADAPTIVE_REMESH_SPLIT_EDGE, "SPLIT_EDGE", 0, "Split Edge", "Split edge of given index"},
+ {ADAPTIVE_REMESH_COLLAPSE_EDGE,
+ "COLLAPSE_EDGE",
+ 0,
+ "Collapse Edge",
+ "Collapse edge of given index"},
+ {0, NULL, 0, NULL, NULL},
+ };
+
srna = RNA_def_struct(brna, "AdaptiveRemeshModifier", "Modifier");
RNA_def_struct_ui_text(srna, "Adaptive Remesh Modifier", "");
RNA_def_struct_sdna(srna, "AdaptiveRemeshModifierData");
@@ -7239,6 +7249,11 @@ static void rna_def_modifier_adaptive_remesh(BlenderRNA *brna)
RNA_define_lib_overridable(true);
+ prop = RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_items(prop, operation_mode_items);
+ RNA_def_property_ui_text(prop, "Operation Mode", "Which operation to do on the specified edge");
+ RNA_def_property_update(prop, 0, "rna_Modifier_update");
+
prop = RNA_def_property(srna, "edge_index", PROP_INT, PROP_UNSIGNED);
RNA_def_property_int_sdna(prop, NULL, "edge_index");
RNA_def_property_ui_text(prop, "Edge Index", "Edge index number for the operation");
@@ -7246,10 +7261,15 @@ static void rna_def_modifier_adaptive_remesh(BlenderRNA *brna)
RNA_def_property_update(prop, 0, "rna_Modifier_update");
prop = RNA_def_property(srna, "use_across_seams", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", ADAPTIVE_REMESH_SPLIT_EDGE_ACROSS_SEAMS);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", ADAPTIVE_REMESH_ACROSS_SEAMS);
RNA_def_property_ui_text(prop, "Across Seams", "Run current Mesh operation across UV seams");
RNA_def_property_update(prop, 0, "rna_Modifier_update");
+ prop = RNA_def_property(srna, "is_verts_swapped", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", ADAPTIVE_REMESH_VERTS_SWAPPED);
+ RNA_def_property_ui_text(prop, "Verts Swapped", "Swap verts during the operation");
+ RNA_def_property_update(prop, 0, "rna_Modifier_update");
+
RNA_define_lib_overridable(false);
}
diff --git a/source/blender/modifiers/intern/MOD_adaptive_remesh.cc b/source/blender/modifiers/intern/MOD_adaptive_remesh.cc
index d8a68dcaf57..64973878eaa 100644
--- a/source/blender/modifiers/intern/MOD_adaptive_remesh.cc
+++ b/source/blender/modifiers/intern/MOD_adaptive_remesh.cc
@@ -44,7 +44,9 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *UNUSED(ctx)
AdaptiveRemeshModifierData *armd = (AdaptiveRemeshModifierData *)md;
auto edge_i = armd->edge_index;
- auto across_seams = armd->flag & ADAPTIVE_REMESH_SPLIT_EDGE_ACROSS_SEAMS;
+ auto across_seams = armd->flag & ADAPTIVE_REMESH_ACROSS_SEAMS;
+ auto verts_swapped = armd->flag & ADAPTIVE_REMESH_VERTS_SWAPPED;
+ auto mode = armd->mode;
internal::MeshIO reader;
reader.read(mesh);
@@ -60,8 +62,13 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *UNUSED(ctx)
if (op_edge_index) {
auto edge_index = op_edge_index.value();
std::cout << "edge_index: " << edge_index << " edge_i: " << armd->edge_index
- << " across_seams: " << across_seams << std::endl;
- internal_mesh.split_edge_triangulate(edge_index, across_seams);
+ << " across_seams: " << across_seams << " mode: " << mode << std::endl;
+ if (mode == ADAPTIVE_REMESH_SPLIT_EDGE) {
+ internal_mesh.split_edge_triangulate(edge_index, across_seams);
+ }
+ else if (mode == ADAPTIVE_REMESH_COLLAPSE_EDGE) {
+ internal_mesh.collapse_edge_triangulate(edge_index, verts_swapped, across_seams);
+ }
}
internal::MeshIO writer = internal_mesh.write();
@@ -83,8 +90,10 @@ static void panel_draw(const bContext *UNUSED(C), Panel *panel)
uiLayoutSetPropSep(layout, true);
+ uiItemR(layout, ptr, "mode", 0, nullptr, ICON_NONE);
uiItemR(layout, ptr, "edge_index", 0, nullptr, ICON_NONE);
uiItemR(layout, ptr, "use_across_seams", 0, nullptr, ICON_NONE);
+ uiItemR(layout, ptr, "is_verts_swapped", 0, nullptr, ICON_NONE);
modifier_panel_end(layout, ptr);
}
More information about the Bf-blender-cvs
mailing list