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
This commit is contained in:
@@ -42,6 +42,7 @@ _modules = [
|
||||
"rigidbody",
|
||||
"screen_play_rendered_anim",
|
||||
"sequencer",
|
||||
"simulation",
|
||||
"userpref",
|
||||
"uvcalc_follow_active",
|
||||
"uvcalc_lightmap",
|
||||
|
39
release/scripts/startup/bl_operators/simulation.py
Normal file
39
release/scripts/startup/bl_operators/simulation.py
Normal file
@@ -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,
|
||||
)
|
@@ -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)
|
||||
|
@@ -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__":
|
||||
|
Reference in New Issue
Block a user