[Bf-blender-cvs] [03d31e568f9] temp-attribute-processor: add initial nodes to menu

Jacques Lucke noreply at git.blender.org
Thu May 27 12:51:40 CEST 2021


Commit: 03d31e568f9ec5dd16a3ee90ad7b51314285908d
Author: Jacques Lucke
Date:   Mon May 24 15:37:16 2021 +0200
Branches: temp-attribute-processor
https://developer.blender.org/rB03d31e568f9ec5dd16a3ee90ad7b51314285908d

add initial nodes to menu

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

M	release/scripts/startup/nodeitems_builtins.py
M	source/blender/nodes/function/node_function_util.cc
M	source/blender/nodes/shader/node_shader_util.c

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

diff --git a/release/scripts/startup/nodeitems_builtins.py b/release/scripts/startup/nodeitems_builtins.py
index bae2c14e3d9..3a10aaeb2ae 100644
--- a/release/scripts/startup/nodeitems_builtins.py
+++ b/release/scripts/startup/nodeitems_builtins.py
@@ -64,6 +64,12 @@ class GeometryNodeCategory(SortedNodeCategory):
         return (context.space_data.type == 'NODE_EDITOR' and
                 context.space_data.tree_type == 'GeometryNodeTree')
 
+class AttributeNodeCategory(SortedNodeCategory):
+    @classmethod
+    def poll(cls, context):
+        return (context.space_data.type == 'NODE_EDITOR' and
+                context.space_data.tree_type == 'AttributeNodeTree')
+
 
 # menu entry for node group tools
 def group_tools_draw(self, layout, context):
@@ -581,12 +587,45 @@ geometry_node_categories = [
     ]),
 ]
 
+attribute_node_categories = [
+    # Attribute Processor Nodes
+    AttributeNodeCategory("ATTR_COLOR", "Color", items=[
+        NodeItem("ShaderNodeValToRGB"),
+        NodeItem("ShaderNodeSeparateRGB"),
+        NodeItem("ShaderNodeCombineRGB"),
+    ]),
+    AttributeNodeCategory("ATTR_INPUT", "Input", items=[
+        NodeItem("FunctionNodeRandomFloat"),
+        NodeItem("ShaderNodeValue"),
+        NodeItem("FunctionNodeInputString"),
+        NodeItem("FunctionNodeInputVector"),
+    ]),
+    AttributeNodeCategory("ATTR_UTILITIES", "Utilities", items=[
+        NodeItem("ShaderNodeMapRange"),
+        NodeItem("ShaderNodeClamp"),
+        NodeItem("ShaderNodeMath"),
+        NodeItem("FunctionNodeBooleanMath"),
+        NodeItem("FunctionNodeFloatCompare"),
+    ]),
+    AttributeNodeCategory("ATTR_VECTOR", "Vector", items=[
+        NodeItem("ShaderNodeSeparateXYZ"),
+        NodeItem("ShaderNodeCombineXYZ"),
+        NodeItem("ShaderNodeVectorMath"),
+        NodeItem("ShaderNodeVectorRotate"),
+    ]),
+    AttributeNodeCategory("ATTR_LAYOUT", "Layout", items=[
+        NodeItem("NodeFrame"),
+        NodeItem("NodeReroute"),
+    ]),
+]
+
 
 def register():
     nodeitems_utils.register_node_categories('SHADER', shader_node_categories)
     nodeitems_utils.register_node_categories('COMPOSITING', compositor_node_categories)
     nodeitems_utils.register_node_categories('TEXTURE', texture_node_categories)
     nodeitems_utils.register_node_categories('GEOMETRY', geometry_node_categories)
+    nodeitems_utils.register_node_categories('ATTRIBUTE', attribute_node_categories)
 
 
 def unregister():
@@ -594,6 +633,7 @@ def unregister():
     nodeitems_utils.unregister_node_categories('COMPOSITING')
     nodeitems_utils.unregister_node_categories('TEXTURE')
     nodeitems_utils.unregister_node_categories('GEOMETRY')
+    nodeitems_utils.unregister_node_categories('ATTRIBUTE')
 
 
 if __name__ == "__main__":
diff --git a/source/blender/nodes/function/node_function_util.cc b/source/blender/nodes/function/node_function_util.cc
index 8ff8b416310..7b099e57088 100644
--- a/source/blender/nodes/function/node_function_util.cc
+++ b/source/blender/nodes/function/node_function_util.cc
@@ -22,7 +22,7 @@ static bool fn_node_poll_default(bNodeType *UNUSED(ntype),
                                  const char **r_disabled_hint)
 {
   /* Function nodes are only supported in simulation node trees so far. */
-  if (!STREQ(ntree->idname, "GeometryNodeTree")) {
+  if (!STREQ(ntree->idname, "GeometryNodeTree") && !STREQ(ntree->idname, "AttributeNodeTree")) {
     *r_disabled_hint = "Not a geometry node tree";
     return false;
   }
diff --git a/source/blender/nodes/shader/node_shader_util.c b/source/blender/nodes/shader/node_shader_util.c
index abc2c7008c7..895a16575f7 100644
--- a/source/blender/nodes/shader/node_shader_util.c
+++ b/source/blender/nodes/shader/node_shader_util.c
@@ -40,7 +40,8 @@ static bool sh_fn_poll_default(bNodeType *UNUSED(ntype),
                                bNodeTree *ntree,
                                const char **r_disabled_hint)
 {
-  if (!STREQ(ntree->idname, "ShaderNodeTree") && !STREQ(ntree->idname, "GeometryNodeTree")) {
+  if (!STREQ(ntree->idname, "ShaderNodeTree") && !STREQ(ntree->idname, "GeometryNodeTree") &&
+      !STREQ(ntree->idname, "AttributeNodeTree")) {
     *r_disabled_hint = "Not a shader or geometry node tree";
     return false;
   }



More information about the Bf-blender-cvs mailing list