[Bf-blender-cvs] [80870aebd08] soc-2021-porting-modifiers-to-nodes-remesh-blocks: added mode selector

Fabian Schempp noreply at git.blender.org
Fri Jul 23 23:23:56 CEST 2021


Commit: 80870aebd08bdc9c561d9a37d636696b258405b6
Author: Fabian Schempp
Date:   Fri Jul 23 23:23:49 2021 +0200
Branches: soc-2021-porting-modifiers-to-nodes-remesh-blocks
https://developer.blender.org/rB80870aebd08bdc9c561d9a37d636696b258405b6

added mode selector

===================================================================

M	source/blender/makesrna/intern/rna_nodetree.c
M	source/blender/nodes/CMakeLists.txt
M	source/blender/nodes/NOD_static_types.h
M	source/blender/nodes/geometry/nodes/node_geo_remesh_blocks.cc

===================================================================

diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c
index 3d4256db335..ac36f5881a6 100644
--- a/source/blender/makesrna/intern/rna_nodetree.c
+++ b/source/blender/makesrna/intern/rna_nodetree.c
@@ -9067,6 +9067,26 @@ static void def_geo_triangulate(StructRNA *srna)
   RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
 }
 
+static void def_geo_remesh_blocks(StructRNA *srna)
+{
+  static const EnumPropertyItem remesh_mode_items[] = {
+      {0, "BLOCKS", 0, "Blocks", "Output a blocky surface with no smoothing"},
+      {1, "SMOOTH", 0, "Smooth", "Output a smooth surface with no sharp-features detection"},
+      {2,
+       "SHARP",
+       0,
+       "Sharp",
+       "Output a surface that reproduces sharp edges and corners from the input mesh"},
+      {0, NULL, 0, NULL, NULL},
+  };
+
+  PropertyRNA *prop = RNA_def_property(srna, "remesh_blocks_mode", PROP_ENUM, PROP_NONE);
+  RNA_def_property_enum_sdna(prop, NULL, "custom1");
+  RNA_def_property_enum_items(prop, remesh_mode_items);
+  RNA_def_property_ui_text(prop, "Mode", "Mesh smoothing mode for remesh operation");
+  RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
+}
+
 static void def_geo_attribute_randomize(StructRNA *srna)
 {
   PropertyRNA *prop;
diff --git a/source/blender/nodes/CMakeLists.txt b/source/blender/nodes/CMakeLists.txt
index 0e45676a4f1..5339b9db9f3 100644
--- a/source/blender/nodes/CMakeLists.txt
+++ b/source/blender/nodes/CMakeLists.txt
@@ -211,7 +211,7 @@ set(SRC
   geometry/nodes/node_geo_separate_components.cc
   geometry/nodes/node_geo_subdivision_surface.cc
   geometry/nodes/node_geo_switch.cc
-        geometry/nodes/node_geo_remesh_blocks.cc
+  geometry/nodes/node_geo_remesh_blocks.cc
   geometry/nodes/node_geo_transform.cc
   geometry/nodes/node_geo_triangulate.cc
   geometry/nodes/node_geo_viewer.cc
diff --git a/source/blender/nodes/NOD_static_types.h b/source/blender/nodes/NOD_static_types.h
index c50099617b2..dc297e1167d 100644
--- a/source/blender/nodes/NOD_static_types.h
+++ b/source/blender/nodes/NOD_static_types.h
@@ -337,7 +337,7 @@ DefNode(GeometryNode, GEO_NODE_SEPARATE_COMPONENTS, 0, "SEPARATE_COMPONENTS", Se
 DefNode(GeometryNode, GEO_NODE_MESH_SUBDIVIDE, 0, "MESH_SUBDIVIDE", MeshSubdivide, "Mesh Subdivide", "")
 DefNode(GeometryNode, GEO_NODE_SUBDIVISION_SURFACE, 0, "SUBDIVISION_SURFACE", SubdivisionSurface, "Subdivision Surface", "")
 DefNode(GeometryNode, GEO_NODE_SWITCH, def_geo_switch, "SWITCH", Switch, "Switch", "")
-DefNode(GeometryNode, GEO_NODE_REMESH_BLOCKS, 0, "REMESH_BLOCKS", RemeshBlocks, "Remesh Blocks", "")
+DefNode(GeometryNode, GEO_NODE_REMESH_BLOCKS, def_geo_remesh_blocks, "REMESH_BLOCKS", RemeshBlocks, "Remesh Blocks", "")
 DefNode(GeometryNode, GEO_NODE_TRANSFORM, 0, "TRANSFORM", Transform, "Transform", "")
 DefNode(GeometryNode, GEO_NODE_TRIANGULATE, def_geo_triangulate, "TRIANGULATE", Triangulate, "Triangulate", "")
 DefNode(GeometryNode, GEO_NODE_VIEWER, 0, "VIEWER", Viewer, "Viewer", "")
diff --git a/source/blender/nodes/geometry/nodes/node_geo_remesh_blocks.cc b/source/blender/nodes/geometry/nodes/node_geo_remesh_blocks.cc
index e1b252665e8..8b8a9da9336 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_remesh_blocks.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_remesh_blocks.cc
@@ -23,6 +23,7 @@
 #include "GEO_mesh_remesh_blocks.h"
 
 #include "UI_interface.h"
+#include "UI_resources.h"
 
 #include "node_geometry_util.hh"
 
@@ -39,12 +40,22 @@ static bNodeSocketTemplate geo_node_remesh_blocks_out[] = {
     {-1, ""},
 };
 
+static void geo_node_remesh_blocks_layout(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
+{
+  uiItemR(layout, ptr, "remesh_blocks_mode", 0, "", ICON_NONE);
+}
+
+static void geo_remesh_blocks_init(bNodeTree *UNUSED(ntree), bNode *node)
+{
+  node->custom1 = 0;
+}
+
 namespace blender::nodes {
 static void geo_node_remesh_blocks_exec(GeoNodeExecParams params)
 {
   GeometrySet geometry_set = params.extract_input<GeometrySet>("Geometry");
   const char flag = 0;
-  const char mode = 0;
+  const char mode = params.node().custom1;
   const int hermite_num = 1;
   const int depth = params.extract_input<int>("Depth");
   const float scale = params.extract_input<float>("Scale");
@@ -72,6 +83,8 @@ void register_node_type_geo_remesh_blocks()
 
   geo_node_type_base(&ntype, GEO_NODE_REMESH_BLOCKS, "Remesh Blocks", NODE_CLASS_GEOMETRY, 0);
   node_type_socket_templates(&ntype, geo_node_remesh_blocks_in, geo_node_remesh_blocks_out);
+  node_type_init(&ntype, geo_remesh_blocks_init);
   ntype.geometry_node_execute = blender::nodes::geo_node_remesh_blocks_exec;
+  ntype.draw_buttons = geo_node_remesh_blocks_layout;
   nodeRegisterType(&ntype);
 }



More information about the Bf-blender-cvs mailing list