Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacques Lucke <jacques@blender.org>2020-04-20 13:56:16 +0300
committerJacques Lucke <jacques@blender.org>2020-04-20 13:56:16 +0300
commit2b2d3c14fe1a29da0ec01198cec2c0593c38391a (patch)
tree672442c9086cf193de3378e735ceaf8fbe362d99 /release
parent8d53e59e32a3c704f0c42e11370cc7812b71b294 (diff)
Simulations: Embed simulation node tree in simulation data block
This adds an embedded node tree to the simulation data block dna. The UI in the `Simulation Editor` has been updated to show a list of simulation data blocks, instead of individual node trees. The new `SpaceNodeEditor.simulation` property wraps the existing `SpaceNodeEditor.id` property. It allows scripts to get and set the simulation data block that is being edited. Reviewers: brecht, mont29 Differential Revision: https://developer.blender.org/D7301
Diffstat (limited to 'release')
-rw-r--r--release/scripts/startup/bl_operators/__init__.py1
-rw-r--r--release/scripts/startup/bl_operators/simulation.py39
-rw-r--r--release/scripts/startup/bl_ui/space_node.py8
-rw-r--r--release/scripts/startup/nodeitems_builtins.py19
4 files changed, 67 insertions, 0 deletions
diff --git a/release/scripts/startup/bl_operators/__init__.py b/release/scripts/startup/bl_operators/__init__.py
index 5af2bd22222..d7df29f1769 100644
--- a/release/scripts/startup/bl_operators/__init__.py
+++ b/release/scripts/startup/bl_operators/__init__.py
@@ -42,6 +42,7 @@ _modules = [
"rigidbody",
"screen_play_rendered_anim",
"sequencer",
+ "simulation",
"userpref",
"uvcalc_follow_active",
"uvcalc_lightmap",
diff --git a/release/scripts/startup/bl_operators/simulation.py b/release/scripts/startup/bl_operators/simulation.py
new file mode 100644
index 00000000000..5d9c9476318
--- /dev/null
+++ b/release/scripts/startup/bl_operators/simulation.py
@@ -0,0 +1,39 @@
+# ##### 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 bdda0ebbe9a..b5926692324 100644
--- a/release/scripts/startup/bl_ui/space_node.py
+++ b/release/scripts/startup/bl_ui/space_node.py
@@ -151,6 +151,14 @@ 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="")
+
else:
# Custom node tree is edited as independent ID block
NODE_MT_editor_menus.draw_collapsible(context, layout)
diff --git a/release/scripts/startup/nodeitems_builtins.py b/release/scripts/startup/nodeitems_builtins.py
index 969a1ca1bd7..4396e00dfd3 100644
--- a/release/scripts/startup/nodeitems_builtins.py
+++ b/release/scripts/startup/nodeitems_builtins.py
@@ -58,6 +58,13 @@ class TextureNodeCategory(SortedNodeCategory):
context.space_data.tree_type == 'TextureNodeTree')
+class SimulationNodeCategory(SortedNodeCategory):
+ @classmethod
+ def poll(cls, context):
+ return (context.space_data.type == 'NODE_EDITOR' and
+ context.space_data.tree_type == 'SimulationNodeTree')
+
+
# menu entry for node group tools
def group_tools_draw(self, layout, context):
layout.operator("node.group_make")
@@ -70,6 +77,7 @@ node_tree_group_type = {
'CompositorNodeTree': 'CompositorNodeGroup',
'ShaderNodeTree': 'ShaderNodeGroup',
'TextureNodeTree': 'TextureNodeGroup',
+ 'SimulationNodeTree': 'SimulationNodeGroup',
}
@@ -467,17 +475,28 @@ texture_node_categories = [
]),
]
+simulation_node_categories = [
+ # Simulation Nodes
+ SimulationNodeCategory("SIM_GROUP", "Group", items=node_group_items),
+ SimulationNodeCategory("SIM_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('SIMULATION', simulation_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')
if __name__ == "__main__":