[Bf-blender-cvs] [6b8a52e2b15] attribute-accessor: initial random attribute node

Jacques Lucke noreply at git.blender.org
Tue Nov 17 16:40:07 CET 2020


Commit: 6b8a52e2b158140868058c06fda469808f9c298c
Author: Jacques Lucke
Date:   Tue Nov 17 15:25:56 2020 +0100
Branches: attribute-accessor
https://developer.blender.org/rB6b8a52e2b158140868058c06fda469808f9c298c

initial random attribute node

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

M	release/scripts/startup/nodeitems_builtins.py
M	source/blender/blenkernel/BKE_node.h
M	source/blender/blenkernel/intern/node.c
M	source/blender/nodes/CMakeLists.txt
M	source/blender/nodes/NOD_geometry.h
M	source/blender/nodes/NOD_static_types.h
A	source/blender/nodes/geometry/nodes/node_geo_random_attribute.cc

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

diff --git a/release/scripts/startup/nodeitems_builtins.py b/release/scripts/startup/nodeitems_builtins.py
index 1f5284eddfb..93c40ceb30a 100644
--- a/release/scripts/startup/nodeitems_builtins.py
+++ b/release/scripts/startup/nodeitems_builtins.py
@@ -499,6 +499,9 @@ geometry_node_categories = [
         NodeItem("GeometryNodePointDistribute"),
         NodeItem("GeometryNodePointInstance"),
     ]),
+    GeometryNodeCategory("GEO_ATTRIBUTES", "Attributes", items=[
+        NodeItem("GeometryNodeRandomAttribute"),
+    ]),
     GeometryNodeCategory("GEO_MATH", "Misc", items=[
         NodeItem("ShaderNodeMapRange"),
         NodeItem("ShaderNodeClamp"),
diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h
index 5c2346f2c94..d2cb3891d4f 100644
--- a/source/blender/blenkernel/BKE_node.h
+++ b/source/blender/blenkernel/BKE_node.h
@@ -1345,6 +1345,7 @@ int ntreeTexExecTree(struct bNodeTree *ntree,
 #define GEO_NODE_POINT_INSTANCE 1005
 #define GEO_NODE_SUBDIVISION_SURFACE 1006
 #define GEO_NODE_OBJECT_INFO 1007
+#define GEO_NODE_RANDOM_ATTRIBUTE 1008
 
 /** \} */
 
diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c
index 685017eb37f..c3f5e58c307 100644
--- a/source/blender/blenkernel/intern/node.c
+++ b/source/blender/blenkernel/intern/node.c
@@ -4688,6 +4688,7 @@ static void registerGeometryNodes(void)
   register_node_type_geo_point_distribute();
   register_node_type_geo_point_instance();
   register_node_type_geo_object_info();
+  register_node_type_geo_random_attribute();
 }
 
 static void registerFunctionNodes(void)
diff --git a/source/blender/nodes/CMakeLists.txt b/source/blender/nodes/CMakeLists.txt
index 74bdd44cc7a..570fc5e8bd2 100644
--- a/source/blender/nodes/CMakeLists.txt
+++ b/source/blender/nodes/CMakeLists.txt
@@ -145,6 +145,7 @@ set(SRC
   geometry/nodes/node_geo_subdivision_surface.cc
   geometry/nodes/node_geo_point_distribute.cc
   geometry/nodes/node_geo_point_instance.cc
+  geometry/nodes/node_geo_random_attribute.cc
   geometry/nodes/node_geo_transform.cc
   geometry/nodes/node_geo_triangulate.cc
   geometry/node_geometry_exec.cc
diff --git a/source/blender/nodes/NOD_geometry.h b/source/blender/nodes/NOD_geometry.h
index 16b99070cba..9c86b02a3b1 100644
--- a/source/blender/nodes/NOD_geometry.h
+++ b/source/blender/nodes/NOD_geometry.h
@@ -34,6 +34,7 @@ void register_node_type_geo_triangulate(void);
 void register_node_type_geo_point_distribute(void);
 void register_node_type_geo_point_instance(void);
 void register_node_type_geo_object_info(void);
+void register_node_type_geo_random_attribute(void);
 
 #ifdef __cplusplus
 }
diff --git a/source/blender/nodes/NOD_static_types.h b/source/blender/nodes/NOD_static_types.h
index af07ba87c84..246b42a4e40 100644
--- a/source/blender/nodes/NOD_static_types.h
+++ b/source/blender/nodes/NOD_static_types.h
@@ -274,6 +274,7 @@ DefNode(GeometryNode, GEO_NODE_BOOLEAN, def_geo_boolean, "BOOLEAN", Boolean, "Bo
 DefNode(GeometryNode, GEO_NODE_POINT_DISTRIBUTE, 0, "POINT_DISTRIBUTE", PointDistribute, "Point Distribute", "")
 DefNode(GeometryNode, GEO_NODE_POINT_INSTANCE, 0, "POINT_INSTANCE", PointInstance, "Point Instance", "")
 DefNode(GeometryNode, GEO_NODE_OBJECT_INFO, 0, "OBJECT_INFO", ObjectInfo, "Object Info", "")
+DefNode(GeometryNode, GEO_NODE_RANDOM_ATTRIBUTE, 0, "RANDOM_ATTRIBUTE", RandomAttribute, "Random Attribute", "")
 
 /* undefine macros */
 #undef DefNode
diff --git a/source/blender/nodes/geometry/nodes/node_geo_random_attribute.cc b/source/blender/nodes/geometry/nodes/node_geo_random_attribute.cc
new file mode 100644
index 00000000000..12eda279c5f
--- /dev/null
+++ b/source/blender/nodes/geometry/nodes/node_geo_random_attribute.cc
@@ -0,0 +1,54 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include "node_geometry_util.hh"
+
+static bNodeSocketTemplate geo_node_random_attribute_in[] = {
+    {SOCK_GEOMETRY, N_("Geometry")},
+    {SOCK_STRING, N_("Attribute")},
+    {SOCK_VECTOR, N_("Min"), 0.0f, 0.0f, 0.0f, 0.0f, -FLT_MAX, FLT_MAX},
+    {SOCK_VECTOR, N_("Max"), 1.0f, 1.0f, 1.0f, 0.0f, -FLT_MAX, FLT_MAX},
+    {SOCK_INT, N_("Seed"), 0, 0, 0, 0, -10000, 10000},
+    {-1, ""},
+};
+
+static bNodeSocketTemplate geo_node_random_attribute_out[] = {
+    {SOCK_GEOMETRY, N_("Geometry")},
+    {-1, ""},
+};
+
+namespace blender::nodes {
+
+static void geo_random_attribute_exec(GeoNodeExecParams params)
+{
+  GeometrySet geometry_set = params.extract_input<GeometrySet>("Geometry");
+  const std::string attribute_name = params.extract_input<std::string>("Attribute");
+  const float3 min_value = params.extract_input<float3>("Min");
+  const float3 max_value = params.extract_input<float3>("Max");
+  const int seed = params.extract_input<int>("Seed");
+}
+
+}  // namespace blender::nodes
+
+void register_node_type_geo_random_attribute()
+{
+  static bNodeType ntype;
+
+  geo_node_type_base(&ntype, GEO_NODE_RANDOM_ATTRIBUTE, "Random Attribute", 0, 0);
+  node_type_socket_templates(&ntype, geo_node_random_attribute_in, geo_node_random_attribute_out);
+  ntype.geometry_node_execute = blender::nodes::geo_random_attribute_exec;
+  nodeRegisterType(&ntype);
+}



More information about the Bf-blender-cvs mailing list