[Bf-blender-cvs] [6be56c13e96] master: Geometry Nodes: initial scattering and geometry nodes

Jacques Lucke noreply at git.blender.org
Wed Dec 2 15:54:36 CET 2020


Commit: 6be56c13e96048cbc494ba5473a8deaf2cf5a6f8
Author: Jacques Lucke
Date:   Wed Dec 2 13:25:25 2020 +0100
Branches: master
https://developer.blender.org/rB6be56c13e96048cbc494ba5473a8deaf2cf5a6f8

Geometry Nodes: initial scattering and geometry nodes

This is the initial merge from the geometry-nodes branch.
Nodes:
* Attribute Math
* Boolean
* Edge Split
* Float Compare
* Object Info
* Point Distribute
* Point Instance
* Random Attribute
* Random Float
* Subdivision Surface
* Transform
* Triangulate

It includes the initial evaluation of geometry node groups in the Geometry Nodes modifier.

Notes on the Generic attribute access API

The API adds an indirection for attribute access. That has the following benefits:
* Most code does not have to care about how an attribute is stored internally.
  This is mainly necessary, because we have to deal with "legacy" attributes
  such as vertex weights and attributes that are embedded into other structs
  such as vertex positions.
* When reading from an attribute, we generally don't care what domain the
  attribute is stored on. So we want to abstract away the interpolation that
  that adapts attributes from one domain to another domain (this is not
  actually implemented yet).

Other possible improvements for later iterations include:
* Actually implement interpolation between domains.
* Don't use inheritance for the different attribute types. A single class for read
  access and one for write access might be enough, because we know all the ways
  in which attributes are stored internally. We don't want more different internal
  structures in the future. On the contrary, ideally we can consolidate the different
  storage formats in the future to reduce the need for this indirection.
* Remove the need for heap allocations when creating attribute accessors.

It includes commits from:
* Dalai Felinto
* Hans Goudey
* Jacques Lucke
* Léo Depoix

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

M	release/scripts/startup/bl_operators/__init__.py
A	release/scripts/startup/bl_operators/geometry_nodes.py
D	release/scripts/startup/bl_operators/simulation.py
M	release/scripts/startup/bl_ui/space_node.py
M	release/scripts/startup/nodeitems_builtins.py
M	source/blender/blenkernel/BKE_attribute.h
A	source/blender/blenkernel/BKE_attribute_access.hh
A	source/blender/blenkernel/BKE_geometry_set.h
A	source/blender/blenkernel/BKE_geometry_set.hh
M	source/blender/blenkernel/BKE_modifier.h
M	source/blender/blenkernel/BKE_node.h
M	source/blender/blenkernel/BKE_pointcloud.h
M	source/blender/blenkernel/CMakeLists.txt
M	source/blender/blenkernel/intern/attribute.c
A	source/blender/blenkernel/intern/attribute_access.cc
M	source/blender/blenkernel/intern/fluid.c
A	source/blender/blenkernel/intern/geometry_set.cc
M	source/blender/blenkernel/intern/hair.c
M	source/blender/blenkernel/intern/lib_remap.c
M	source/blender/blenkernel/intern/node.c
M	source/blender/blenkernel/intern/object.c
M	source/blender/blenkernel/intern/object_dupli.c
M	source/blender/blenkernel/intern/pointcache.c
M	source/blender/blenkernel/intern/pointcloud.cc
M	source/blender/blenkernel/intern/simulation.cc
M	source/blender/blenlib/BLI_rand.h
M	source/blender/blenlib/BLI_rand.hh
A	source/blender/blenlib/BLI_user_counter.hh
M	source/blender/blenlib/CMakeLists.txt
M	source/blender/blenlib/intern/rand.cc
M	source/blender/blenloader/intern/versioning_290.c
M	source/blender/depsgraph/CMakeLists.txt
M	source/blender/depsgraph/DEG_depsgraph_build.h
M	source/blender/depsgraph/intern/depsgraph_build.cc
M	source/blender/editors/include/ED_node.h
M	source/blender/editors/object/object_modifier.c
M	source/blender/editors/space_node/CMakeLists.txt
M	source/blender/editors/space_node/drawnode.c
M	source/blender/editors/space_node/node_draw.c
M	source/blender/editors/space_node/node_edit.c
M	source/blender/editors/space_node/node_group.c
M	source/blender/editors/space_node/node_relationships.c
M	source/blender/editors/space_node/space_node.c
M	source/blender/functions/CMakeLists.txt
A	source/blender/functions/FN_generic_value_map.hh
M	source/blender/functions/FN_multi_function.hh
M	source/blender/makesdna/DNA_modifier_defaults.h
M	source/blender/makesdna/DNA_modifier_types.h
M	source/blender/makesdna/DNA_node_types.h
M	source/blender/makesdna/DNA_object_types.h
M	source/blender/makesdna/intern/dna_defaults.c
M	source/blender/makesrna/RNA_access.h
M	source/blender/makesrna/intern/CMakeLists.txt
M	source/blender/makesrna/intern/rna_access.c
M	source/blender/makesrna/intern/rna_attribute.c
M	source/blender/makesrna/intern/rna_modifier.c
M	source/blender/makesrna/intern/rna_nodetree.c
M	source/blender/makesrna/intern/rna_space.c
M	source/blender/modifiers/CMakeLists.txt
M	source/blender/modifiers/MOD_modifiertypes.h
R079	source/blender/nodes/NOD_simulation.h	source/blender/modifiers/MOD_nodes.h
M	source/blender/modifiers/intern/MOD_edgesplit.c
A	source/blender/modifiers/intern/MOD_nodes.cc
D	source/blender/modifiers/intern/MOD_simulation.cc
M	source/blender/modifiers/intern/MOD_triangulate.c
M	source/blender/modifiers/intern/MOD_util.c
M	source/blender/nodes/CMakeLists.txt
M	source/blender/nodes/NOD_derived_node_tree.hh
A	source/blender/nodes/NOD_geometry.h
A	source/blender/nodes/NOD_geometry_exec.hh
A	source/blender/nodes/NOD_math_functions.hh
M	source/blender/nodes/NOD_node_tree_multi_function.hh
M	source/blender/nodes/NOD_node_tree_ref.hh
M	source/blender/nodes/NOD_static_types.h
A	source/blender/nodes/NOD_type_callbacks.hh
M	source/blender/nodes/function/node_function_util.cc
M	source/blender/nodes/function/nodes/node_fn_float_compare.cc
M	source/blender/nodes/function/nodes/node_fn_random_float.cc
A	source/blender/nodes/geometry/node_geometry_exec.cc
R066	source/blender/nodes/simulation/node_simulation_tree.cc	source/blender/nodes/geometry/node_geometry_tree.cc
R076	source/blender/nodes/simulation/node_simulation_util.cc	source/blender/nodes/geometry/node_geometry_util.cc
R085	source/blender/nodes/simulation/node_simulation_util.h	source/blender/nodes/geometry/node_geometry_util.hh
A	source/blender/nodes/geometry/nodes/node_geo_attribute_math.cc
A	source/blender/nodes/geometry/nodes/node_geo_boolean.cc
R083	source/blender/nodes/simulation/nodes/node_sim_common.cc	source/blender/nodes/geometry/nodes/node_geo_common.cc
A	source/blender/nodes/geometry/nodes/node_geo_edge_split.cc
A	source/blender/nodes/geometry/nodes/node_geo_join_geometry.cc
A	source/blender/nodes/geometry/nodes/node_geo_object_info.cc
A	source/blender/nodes/geometry/nodes/node_geo_point_distribute.cc
A	source/blender/nodes/geometry/nodes/node_geo_point_instance.cc
A	source/blender/nodes/geometry/nodes/node_geo_random_attribute.cc
A	source/blender/nodes/geometry/nodes/node_geo_subdivision_surface.cc
A	source/blender/nodes/geometry/nodes/node_geo_transform.cc
A	source/blender/nodes/geometry/nodes/node_geo_triangulate.cc
M	source/blender/nodes/intern/derived_node_tree.cc
A	source/blender/nodes/intern/math_functions.cc
A	source/blender/nodes/intern/node_geometry_exec.cc
M	source/blender/nodes/intern/node_socket.cc
M	source/blender/nodes/intern/node_tree_multi_function.cc
M	source/blender/nodes/intern/node_tree_ref.cc
A	source/blender/nodes/intern/type_callbacks.cc
M	source/blender/nodes/shader/node_shader_util.c
M	source/blender/nodes/shader/nodes/node_shader_math.cc

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

diff --git a/release/scripts/startup/bl_operators/__init__.py b/release/scripts/startup/bl_operators/__init__.py
index eff88c835e7..71b2de41d9e 100644
--- a/release/scripts/startup/bl_operators/__init__.py
+++ b/release/scripts/startup/bl_operators/__init__.py
@@ -31,6 +31,7 @@ _modules = [
     "console",
     "constraint",
     "file",
+    "geometry_nodes",
     "image",
     "mesh",
     "node",
@@ -42,7 +43,6 @@ _modules = [
     "rigidbody",
     "screen_play_rendered_anim",
     "sequencer",
-    "simulation",
     "userpref",
     "uvcalc_follow_active",
     "uvcalc_lightmap",
diff --git a/release/scripts/startup/bl_operators/geometry_nodes.py b/release/scripts/startup/bl_operators/geometry_nodes.py
new file mode 100644
index 00000000000..374bd4161a7
--- /dev/null
+++ b/release/scripts/startup/bl_operators/geometry_nodes.py
@@ -0,0 +1,60 @@
+# ##### BEGIN GPL LICENSE BLOCK #####
+#
+#  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.
+#
+# ##### END GPL LICENSE BLOCK #####
+
+import bpy
+
+
+def geometry_modifier_poll(context) -> bool:
+    ob = context.object
+
+    # Test object support for geometry node modifier (No volume or hair object support yet)
+    if not ob or ob.type not in {'MESH', 'CURVE', 'SURFACE', 'META', 'FONT', 'POINTCLOUD'}:
+        return False
+
+    return True
+
+
+class NewGeometryNodeTree(bpy.types.Operator):
+    """Create a new geometry node tree"""
+    bl_idname = "node.new_geometry_node_tree"
+    bl_label = "New Geometry Node Tree"
+    bl_options = {'REGISTER', 'UNDO'}
+
+    @classmethod
+    def poll(cls, context):
+        return geometry_modifier_poll(context)
+
+    def execute(self, context):
+        group = bpy.data.node_groups.new("Geometry Nodes", 'GeometryNodeTree')
+        group.inputs.new('NodeSocketGeometry', "Geometry")
+        group.outputs.new('NodeSocketGeometry', "Geometry")
+        input_node = group.nodes.new('NodeGroupInput')
+        output_node = group.nodes.new('NodeGroupOutput')
+        output_node.is_active_output = True
+
+        input_node.location.x = -200 - input_node.width
+        output_node.location.x = 200
+
+        group.links.new(output_node.inputs[0], input_node.outputs[0])
+
+        return {'FINISHED'}
+
+
+classes = (
+    NewGeometryNodeTree,
+)
diff --git a/release/scripts/startup/bl_operators/simulation.py b/release/scripts/startup/bl_operators/simulation.py
deleted file mode 100644
index 0981baa5941..00000000000
--- a/release/scripts/startup/bl_operators/simulation.py
+++ /dev/null
@@ -1,41 +0,0 @@
-# ##### BEGIN GPL LICENSE BLOCK #####
-#
-#  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.
-#
-# ##### END GPL LICENSE BLOCK #####
-
-import bpy
-
-
-class NewSimulation(bpy.types.Operator):
-    """Create a new simulation data block and edit it in the opened simulation editor"""
-
-    bl_idname = "simulation.new"
-    bl_label = "New Simulation"
-    bl_options = {'REGISTER', 'UNDO'}
-
-    @classmethod
-    def poll(cls, context):
-        return context.area.type == 'NODE_EDITOR' and context.space_data.tree_type == 'SimulationNodeTree'
-
-    def execute(self, context):
-        simulation = bpy.data.simulations.new("Simulation")
-        context.space_data.simulation = simulation
-        return {'FINISHED'}
-
-
-classes = (
-    NewSimulation,
-)
diff --git a/release/scripts/startup/bl_ui/space_node.py b/release/scripts/startup/bl_ui/space_node.py
index c0c38c02c63..4cd38831cdf 100644
--- a/release/scripts/startup/bl_ui/space_node.py
+++ b/release/scripts/startup/bl_ui/space_node.py
@@ -151,13 +151,10 @@ class NODE_HT_header(Header):
             if snode_id:
                 layout.prop(snode_id, "use_nodes")
 
-        elif snode.tree_type == 'SimulationNodeTree':
-            row = layout.row(align=True)
-            row.prop(snode, "simulation", text="")
-            row.operator("simulation.new", text="", icon='ADD')
-            simulation = snode.simulation
-            if simulation:
-                row.prop(snode.simulation, "use_fake_user", text="")
+        elif snode.tree_type == 'GeometryNodeTree':
+            NODE_MT_editor_menus.draw_collapsible(context, layout)
+            layout.separator_spacer()
+            layout.template_ID(snode, "node_tree", new="node.new_geometry_node_tree")
 
         else:
             # Custom node tree is edited as independent ID block
diff --git a/release/scripts/startup/nodeitems_builtins.py b/release/scripts/startup/nodeitems_builtins.py
index 8d2b6198fd5..b1789776728 100644
--- a/release/scripts/startup/nodeitems_builtins.py
+++ b/release/scripts/startup/nodeitems_builtins.py
@@ -58,11 +58,11 @@ class TextureNodeCategory(SortedNodeCategory):
                 context.space_data.tree_type == 'TextureNodeTree')
 
 
-class SimulationNodeCategory(SortedNodeCategory):
+class GeometryNodeCategory(SortedNodeCategory):
     @classmethod
     def poll(cls, context):
         return (context.space_data.type == 'NODE_EDITOR' and
-                context.space_data.tree_type == 'SimulationNodeTree')
+                context.space_data.tree_type == 'GeometryNodeTree')
 
 
 # menu entry for node group tools
@@ -77,11 +77,11 @@ node_tree_group_type = {
     'CompositorNodeTree': 'CompositorNodeGroup',
     'ShaderNodeTree': 'ShaderNodeGroup',
     'TextureNodeTree': 'TextureNodeGroup',
-    'SimulationNodeTree': 'SimulationNodeGroup',
+    'GeometryNodeTree': 'GeometryNodeGroup',
 }
 
 
-# generic node group items generator for shader, compositor, simulation and texture node groups
+# generic node group items generator for shader, compositor, geometry and texture node groups
 def node_group_items(context):
     if context is None:
         return
@@ -483,13 +483,55 @@ def not_implemented_node(idname):
     return NodeItem(idname, label=label)
 
 
-simulation_node_categories = [
-    # Simulation Nodes
-    SimulationNodeCategory("SIM_GROUP", "Group", items=node_group_items),
-    SimulationNodeCategory("SIM_LAYOUT", "Layout", items=[
+geometry_node_categories = [
+    # Geometry Nodes
+    GeometryNodeCategory("GEO_ATTRIBUTE", "Attribute", items=[
+        NodeItem("GeometryNodeRandomAttribute"),
+        NodeItem("GeometryNodeAttributeMath"),
+    ]),
+    GeometryNodeCategory("GEO_COLOR", "Color", items=[
+        NodeItem("ShaderNodeValToRGB"),
+        NodeItem("ShaderNodeSeparateRGB"),
+        NodeItem("ShaderNodeCombineRGB"),
+    ]),
+    GeometryNodeCategory("GEO_GEOMETRY", "Geometry", items=[
+        NodeItem("GeometryNodeTransform"),
+        NodeItem("GeometryNodeBoolean"),
+        NodeItem("GeometryNodeJoinGeometry"),
+    ]),
+    GeometryNodeCategory("GEO_INPUT", "Input", items=[
+        NodeItem("GeometryNodeObjectInfo"),
+        NodeItem("FunctionNodeRandomFloat"),
+        NodeItem("ShaderNodeValue"),
+    ]),
+    GeometryNodeCategory("GEO_MESH", "Mesh", items=[
+        NodeItem("GeometryNodeTriangulate"),
+        NodeItem("GeometryNodeEdgeSplit"),
+        NodeItem("GeometryNodeSubdivisionSurface"),
+    ]),
+    GeometryNodeCategory("GEO_POINT", "Point", items=[
+        NodeItem("GeometryNodePointDistribute"),
+        NodeItem("GeometryNodePointInstance"),
+    ]),
+    GeometryNodeCategory("GEO_UTILITIES", "Utilities", items=[
+        NodeItem("ShaderNodeMapRange"),
+        NodeItem("ShaderNodeClamp"),
+        NodeItem("ShaderNodeMath"),
+        NodeItem("FunctionNodeBooleanMath"),
+        NodeItem("FunctionNodeFloatCompare"),
+    ]),
+    GeometryNodeCategory("GEO_VECTOR", "Vector", items=[
+        NodeItem("ShaderNodeSeparateXYZ"),
+        NodeItem("ShaderNodeCombineXYZ"),
+        NodeItem("ShaderNodeVectorMath"),
+    ]),
+    GeometryNodeCategory("GEO_GROUP", "Group", items=node_group_items),
+    GeometryNodeCategory("GEO_LAYOUT", "Layout", items=[
         NodeItem("NodeFrame"),
         NodeItem("NodeReroute"),
     ]),
+    # NodeItem("FunctionNodeCombineStrings"),
+    # NodeItem("FunctionNodeGroupInstanceID"),
 ]
 
 
@@ -497,14 +539,14 @@ 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('SIMULATION', simulation_node_categories)
+    nodeitems_utils.register_node_categories('GEOMETRY', geometry_node_categories)
 
 
 def unregister():
     nodeitems_utils.unregister_node_categories('SHADER')
     nodeitems_utils.unregister_node_categories('COMPOSITING')
     nodeitems_utils.unregister_node_categories('TEXTURE')
-    nodeitems_utils.unregister_node_categories('SIMULATION')
+    nodeitems_utils.unregister_node_categories('GEOMETRY')
 
 
 if __name__ == "__main__":
diff --git a/source/blender/blenkernel/BKE_attribute.h b/source/blender/blenkernel/BKE_attribute.h
index aab962d42a6..55

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list