diff options
37 files changed, 253 insertions, 238 deletions
diff --git a/release/scripts/startup/bl_operators/__init__.py b/release/scripts/startup/bl_operators/__init__.py index c927cc184a3..7682effaf41 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/simulation.py b/release/scripts/startup/bl_operators/geometry_nodes.py index 0981baa5941..0d43541e65c 100644 --- a/release/scripts/startup/bl_operators/simulation.py +++ b/release/scripts/startup/bl_operators/geometry_nodes.py @@ -19,23 +19,30 @@ import bpy -class NewSimulation(bpy.types.Operator): - """Create a new simulation data block and edit it in the opened simulation editor""" +class NewGeometryNodeTree(bpy.types.Operator): + """Create a new geometry node tree""" - bl_idname = "simulation.new" - bl_label = "New Simulation" + bl_idname = "node.new_geometry_node_tree" + bl_label = "New Geometry Node Tree" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): - return context.area.type == 'NODE_EDITOR' and context.space_data.tree_type == 'SimulationNodeTree' + return context.area.type == 'NODE_EDITOR' and context.space_data.tree_type == 'GeometryNodeTree' def execute(self, context): - simulation = bpy.data.simulations.new("Simulation") - context.space_data.simulation = simulation + group = bpy.data.node_groups.new("Node Tree", 'GeometryNodeTree') + group.inputs.new('NodeSocketGeometry', "Geometry") + group.outputs.new('NodeSocketGeometry', "Geometry") + input_node = group.nodes.new('NodeGroupInput') + output_node = group.nodes.new('NodeGroupOutput') + + input_node.location.x = -200 - input_node.width + output_node.location.x = 200 + context.space_data.node_tree = group return {'FINISHED'} classes = ( - NewSimulation, + NewGeometryNodeTree, ) 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..4223b2ffb23 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,10 +483,13 @@ 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_CONVERTER", "Converter", items=[ + NodeItem("ShaderNodeMath"), + ]), + GeometryNodeCategory("GEO_GROUP", "Group", items=node_group_items), + GeometryNodeCategory("GEO_LAYOUT", "Layout", items=[ NodeItem("NodeFrame"), NodeItem("NodeReroute"), ]), @@ -497,14 +500,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/intern/node.c b/source/blender/blenkernel/intern/node.c index 80a553ff525..3ead32d84df 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -65,7 +65,6 @@ #include "BKE_lib_query.h" #include "BKE_main.h" #include "BKE_node.h" -#include "BKE_simulation.h" #include "BLI_ghash.h" #include "BLI_threads.h" @@ -75,8 +74,8 @@ #include "NOD_common.h" #include "NOD_composite.h" #include "NOD_function.h" +#include "NOD_geometry.h" #include "NOD_shader.h" -#include "NOD_simulation.h" #include "NOD_socket.h" #include "NOD_texture.h" @@ -281,6 +280,7 @@ static void library_foreach_node_socket(LibraryForeachIDData *data, bNodeSocket case __SOCK_MESH: case SOCK_CUSTOM: case SOCK_SHADER: + case SOCK_GEOMETRY: break; } } @@ -373,6 +373,7 @@ static void write_node_socket_default_value(BlendWriter *writer, bNodeSocket *so case __SOCK_MESH: case SOCK_CUSTOM: case SOCK_SHADER: + case SOCK_GEOMETRY: BLI_assert(false); break; } @@ -715,6 +716,7 @@ static void lib_link_node_socket(BlendLibReader *reader, Library *lib, bNodeSock case __SOCK_MESH: case SOCK_CUSTOM: case SOCK_SHADER: + case SOCK_GEOMETRY: break; } } @@ -793,6 +795,7 @@ static void expand_node_socket(BlendExpander *expander, bNodeSocket *sock) case __SOCK_MESH: case SOCK_CUSTOM: case SOCK_SHADER: + case SOCK_GEOMETRY: break; } } @@ -1345,6 +1348,7 @@ static void socket_id_user_increment(bNodeSocket *sock) case __SOCK_MESH: case SOCK_CUSTOM: case SOCK_SHADER: + case SOCK_GEOMETRY: break; } } @@ -1371,6 +1375,7 @@ static void socket_id_user_decrement(bNodeSocket *sock) case __SOCK_MESH: case SOCK_CUSTOM: case SOCK_SHADER: + case SOCK_GEOMETRY: break; } } @@ -1498,6 +1503,8 @@ const char *nodeStaticSocketType(int type, int subtype) return "NodeSocketObject"; case SOCK_IMAGE: return "NodeSocketImage"; + case SOCK_GEOMETRY: + return "NodeSocketGeometry"; } return NULL; } @@ -1563,6 +1570,8 @@ const char *nodeStaticSocketInterfaceType(int type, int subtype) return "NodeSocketInterfaceObject"; case SOCK_IMAGE: return "NodeSocketInterfaceImage"; + case SOCK_GEOMETRY: + return "NodeSocketInterfaceGeometry"; } return NULL; } @@ -4646,9 +4655,9 @@ static void registerTextureNodes(void) register_node_type_tex_proc_distnoise(); } -static void registerSimulationNodes(void) +static void registerGeometryNodes(void) { - register_node_type_sim_group(); + register_node_type_geo_group(); } static void registerFunctionNodes(void) @@ -4675,7 +4684,7 @@ void init_nodesystem(void) register_node_tree_type_cmp(); register_node_tree_type_sh(); register_node_tree_type_tex(); - register_node_tree_type_sim(); + register_node_tree_type_geo(); register_node_type_frame(); register_node_type_reroute(); @@ -4685,7 +4694,7 @@ void init_nodesystem(void) registerCompositNodes(); registerShaderNodes(); registerTextureNodes(); - registerSimulationNodes(); + registerGeometryNodes(); registerFunctionNodes(); } diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index 7c8527a8702..5944d1a693b 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -1187,9 +1187,6 @@ static bool foreach_object_modifier_ptcache(Object *object, } } } - else if (md->type == eModifierType_Simulation) { - /* TODO(jacques): */ - } } return true; } diff --git a/source/blender/blenkernel/intern/simulation.cc b/source/blender/blenkernel/intern/simulation.cc index 2e1f8bd581e..418746a680e 100644 --- a/source/blender/blenkernel/intern/simulation.cc +++ b/source/blender/blenkernel/intern/simulation.cc @@ -48,8 +48,8 @@ #include "BKE_pointcache.h" #include "BKE_simulation.h" +#include "NOD_geometry.h" #include "NOD_node_tree_multi_function.hh" -#include "NOD_simulation.h" #include "BLI_map.hh" #include "BLT_translation.h" @@ -70,7 +70,7 @@ static void simulation_init_data(ID *id) MEMCPY_STRUCT_AFTER(simulation, DNA_struct_default_get(Simulation), id); - bNodeTree *ntree = ntreeAddTree(nullptr, "Simulation Nodetree", ntreeType_Simulation->idname); + bNodeTree *ntree = ntreeAddTree(nullptr, "Geometry Nodetree", ntreeType_Geometry->idname); simulation->nodetree = ntree; } diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index c49808c3718..5ff3d383a72 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -158,7 +158,6 @@ #include "BKE_screen.h" #include "BKE_sequencer.h" #include "BKE_shader_fx.h" -#include "BKE_simulation.h" #include "BKE_sound.h" #include "BKE_volume.h" #include "BKE_workspace.h" diff --git a/source/blender/depsgraph/DEG_depsgraph_build.h b/source/blender/depsgraph/DEG_depsgraph_build.h index 2147a584765..f894bdabba4 100644 --- a/source/blender/depsgraph/DEG_depsgraph_build.h +++ b/source/blender/depsgraph/DEG_depsgraph_build.h @@ -141,6 +141,9 @@ void DEG_add_object_relation(struct DepsNodeHandle *node_handle, void DEG_add_simulation_relation(struct DepsNodeHandle *node_handle, struct Simulation *simulation, const char *description); +void DEG_add_node_tree_relation(struct DepsNodeHandle *node_handle, + struct bNodeTree *node_tree, + const char *description); void DEG_add_bone_relation(struct DepsNodeHandle *handle, struct Object *object, const char *bone_name, diff --git a/source/blender/depsgraph/intern/depsgraph_build.cc b/source/blender/depsgraph/intern/depsgraph_build.cc index 96c17ae4dc5..6717ba521f6 100644 --- a/source/blender/depsgraph/intern/depsgraph_build.cc +++ b/source/blender/depsgraph/intern/depsgraph_build.cc @@ -32,6 +32,7 @@ #include "PIL_time_utildefines.h" #include "DNA_cachefile_types.h" +#include "DNA_node_types.h" #include "DNA_object_types.h" #include "DNA_scene_types.h" #include "DNA_simulation_types.h" @@ -116,6 +117,17 @@ void DEG_add_simulation_relation(DepsNodeHandle *node_handle, deg_node_handle->builder->add_node_handle_relation(operation_key, deg_node_handle, description); } +void DEG_add_node_tree_relation(DepsNodeHandle *node_handle, + bNodeTree *node_tree, + const char *description) +{ + /* Using shading key, because that's the one that exists right now. Should use something else in + * the future. */ + deg::ComponentKey shading_key(&node_tree->id, deg::NodeType::SHADING); + deg::DepsNodeHandle *deg_node_handle = get_node_handle(node_handle); + deg_node_handle->builder->add_node_handle_relation(shading_key, deg_node_handle, description); +} + void DEG_add_object_cache_relation(DepsNodeHandle *node_handle, CacheFile *cache_file, eDepsObjectComponentType component, diff --git a/source/blender/editors/include/ED_node.h b/source/blender/editors/include/ED_node.h index ecb98a46f99..417cae800ea 100644 --- a/source/blender/editors/include/ED_node.h +++ b/source/blender/editors/include/ED_node.h @@ -96,7 +96,7 @@ void ED_node_set_tree_type(struct SpaceNode *snode, struct bNodeTreeType *typein bool ED_node_is_compositor(struct SpaceNode *snode); bool ED_node_is_shader(struct SpaceNode *snode); bool ED_node_is_texture(struct SpaceNode *snode); -bool ED_node_is_simulation(struct SpaceNode *snode); +bool ED_node_is_geometry(struct SpaceNode *snode); void ED_node_shader_default(const struct bContext *C, struct ID *id); void ED_node_composit_default(const struct bContext *C, struct Scene *scene); diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c index 66da2887427..b9495519427 100644 --- a/source/blender/editors/space_node/drawnode.c +++ b/source/blender/editors/space_node/drawnode.c @@ -68,8 +68,8 @@ #include "IMB_imbuf_types.h" #include "NOD_composite.h" +#include "NOD_geometry.h" #include "NOD_shader.h" -#include "NOD_simulation.h" #include "NOD_texture.h" #include "node_intern.h" /* own include */ @@ -3138,9 +3138,9 @@ static void node_texture_set_butfunc(bNodeType *ntype) } } -/* ****************** BUTTON CALLBACKS FOR SIMULATION NODES ***************** */ +/* ****************** BUTTON CALLBACKS FOR GEOMETRY NODES ***************** */ -static void node_simulation_set_butfunc(bNodeType *UNUSED(ntype)) +static void node_geometry_set_butfunc(bNodeType *UNUSED(ntype)) { } @@ -3286,7 +3286,7 @@ void ED_node_init_butfuncs(void) node_composit_set_butfunc(ntype); node_shader_set_butfunc(ntype); node_texture_set_butfunc(ntype); - node_simulation_set_butfunc(ntype); + node_geometry_set_butfunc(ntype); node_function_set_butfunc(ntype); /* define update callbacks for socket properties */ @@ -3298,7 +3298,7 @@ void ED_node_init_butfuncs(void) ntreeType_Composite->ui_icon = ICON_NODE_COMPOSITING; ntreeType_Shader->ui_icon = ICON_NODE_MATERIAL; ntreeType_Texture->ui_icon = ICON_NODE_TEXTURE; - ntreeType_Simulation->ui_icon = ICON_PHYSICS; /* TODO: Use correct icon. */ + ntreeType_Geometry->ui_icon = ICON_PHYSICS; /* TODO: Use correct icon. */ } void ED_init_custom_node_type(bNodeType *ntype) @@ -3329,6 +3329,7 @@ static const float std_node_socket_colors[][4] = { {0.39, 0.39, 0.39, 1.0}, /* SOCK_STRING */ {0.40, 0.10, 0.10, 1.0}, /* SOCK_OBJECT */ {0.10, 0.40, 0.10, 1.0}, /* SOCK_IMAGE */ + {0.00, 0.00, 0.00, 1.0}, /* SOCK_GEOMETRY, TODO: Choose color. */ }; /* common color callbacks for standard types */ diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c index b1659bcd023..49a598090f4 100644 --- a/source/blender/editors/space_node/node_edit.c +++ b/source/blender/editors/space_node/node_edit.c @@ -68,8 +68,8 @@ #include "IMB_imbuf_types.h" #include "NOD_composite.h" +#include "NOD_geometry.h" #include "NOD_shader.h" -#include "NOD_simulation.h" #include "NOD_texture.h" #include "node_intern.h" /* own include */ @@ -391,6 +391,7 @@ void snode_dag_update(bContext *C, SpaceNode *snode) } DEG_id_tag_update(snode->id, 0); + DEG_id_tag_update(&snode->nodetree->id, 0); } void snode_notify(bContext *C, SpaceNode *snode) @@ -443,9 +444,9 @@ bool ED_node_is_texture(struct SpaceNode *snode) return STREQ(snode->tree_idname, ntreeType_Texture->idname); } -bool ED_node_is_simulation(struct SpaceNode *snode) +bool ED_node_is_geometry(struct SpaceNode *snode) { - return STREQ(snode->tree_idname, ntreeType_Simulation->idname); + return STREQ(snode->tree_idname, ntreeType_Geometry->idname); } /* assumes nothing being done in ntree yet, sets the default in/out node */ @@ -1696,7 +1697,7 @@ static int node_mute_exec(bContext *C, wmOperator *UNUSED(op)) } } - do_tag_update |= ED_node_is_simulation(snode); + do_tag_update |= ED_node_is_geometry(snode); snode_notify(C, snode); if (do_tag_update) { @@ -1740,7 +1741,7 @@ static int node_delete_exec(bContext *C, wmOperator *UNUSED(op)) } } - do_tag_update |= ED_node_is_simulation(snode); + do_tag_update |= ED_node_is_geometry(snode); ntreeUpdateTree(CTX_data_main(C), snode->edittree); diff --git a/source/blender/editors/space_node/node_group.c b/source/blender/editors/space_node/node_group.c index c6c14a9886e..1e679d7d7c9 100644 --- a/source/blender/editors/space_node/node_group.c +++ b/source/blender/editors/space_node/node_group.c @@ -71,7 +71,7 @@ static bool node_group_operator_active(bContext *C) if (STREQ(snode->tree_idname, "ShaderNodeTree") || STREQ(snode->tree_idname, "CompositorNodeTree") || STREQ(snode->tree_idname, "TextureNodeTree") || - STREQ(snode->tree_idname, "SimulationNodeTree")) { + STREQ(snode->tree_idname, "GeometryNodeTree")) { return true; } } @@ -88,7 +88,7 @@ static bool node_group_operator_editable(bContext *C) * with same keymap. */ if (ED_node_is_shader(snode) || ED_node_is_compositor(snode) || ED_node_is_texture(snode) || - ED_node_is_simulation(snode)) { + ED_node_is_geometry(snode)) { return true; } } @@ -114,8 +114,8 @@ static const char *group_node_idname(bContext *C) if (ED_node_is_texture(snode)) { return "TextureNodeGroup"; } - if (ED_node_is_simulation(snode)) { - return "SimulationNodeGroup"; + if (ED_node_is_geometry(snode)) { + return "GeometryNodeGroup"; } return ""; diff --git a/source/blender/editors/space_node/node_relationships.c b/source/blender/editors/space_node/node_relationships.c index b6d9cdc729d..203aebfc041 100644 --- a/source/blender/editors/space_node/node_relationships.c +++ b/source/blender/editors/space_node/node_relationships.c @@ -655,7 +655,7 @@ static void node_link_exit(bContext *C, wmOperator *op, bool apply_links) } ntree->is_updating = false; - do_tag_update |= ED_node_is_simulation(snode); + do_tag_update |= ED_node_is_geometry(snode); ntreeUpdateTree(bmain, ntree); snode_notify(C, snode); @@ -1052,7 +1052,7 @@ static int cut_links_exec(bContext *C, wmOperator *op) } } - do_tag_update |= ED_node_is_simulation(snode); + do_tag_update |= ED_node_is_geometry(snode); if (found) { ntreeUpdateTree(CTX_data_main(C), snode->edittree); diff --git a/source/blender/editors/space_node/space_node.c b/source/blender/editors/space_node/space_node.c index d2502e6408c..ec294ed4298 100644 --- a/source/blender/editors/space_node/space_node.c +++ b/source/blender/editors/space_node/space_node.c @@ -936,7 +936,7 @@ static void node_space_subtype_item_extend(bContext *C, EnumPropertyItem **item, const EnumPropertyItem *item_src = RNA_enum_node_tree_types_itemf_impl(C, &free); for (const EnumPropertyItem *item_iter = item_src; item_iter->identifier; item_iter++) { if (!U.experimental.use_new_geometry_nodes && - STREQ(item_iter->identifier, "SimulationNodeTree")) { + STREQ(item_iter->identifier, "GeometryNodeTree")) { continue; } RNA_enum_item_add(item, totitem, item_iter); diff --git a/source/blender/makesdna/DNA_modifier_defaults.h b/source/blender/makesdna/DNA_modifier_defaults.h index 34a951ca988..0131339127e 100644 --- a/source/blender/makesdna/DNA_modifier_defaults.h +++ b/source/blender/makesdna/DNA_modifier_defaults.h @@ -574,7 +574,7 @@ .flag = 0, \ } -#define _DNA_DEFAULT_SimulationModifierData \ +#define _DNA_DEFAULT_NodesModifierData \ { 0 } #define _DNA_DEFAULT_SkinModifierData \ diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h index 29bcc5fe903..7e3c2deb6be 100644 --- a/source/blender/makesdna/DNA_modifier_types.h +++ b/source/blender/makesdna/DNA_modifier_types.h @@ -94,7 +94,7 @@ typedef enum ModifierType { eModifierType_WeightedNormal = 54, eModifierType_Weld = 55, eModifierType_Fluid = 56, - eModifierType_Simulation = 57, + eModifierType_Nodes = 57, eModifierType_MeshToVolume = 58, eModifierType_VolumeDisplace = 59, eModifierType_VolumeToMesh = 60, @@ -2217,9 +2217,10 @@ enum { #define MOD_MESHSEQ_READ_ALL \ (MOD_MESHSEQ_READ_VERT | MOD_MESHSEQ_READ_POLY | MOD_MESHSEQ_READ_UV | MOD_MESHSEQ_READ_COLOR) -typedef struct SimulationModifierData { +typedef struct NodesModifierData { ModifierData modifier; -} SimulationModifierData; + struct bNodeTree *node_tree; +} NodesModifierData; typedef struct MeshToVolumeModifierData { ModifierData modifier; diff --git a/source/blender/makesdna/DNA_node_types.h b/source/blender/makesdna/DNA_node_types.h index cba93bbadfc..c3dbd9f7d30 100644 --- a/source/blender/makesdna/DNA_node_types.h +++ b/source/blender/makesdna/DNA_node_types.h @@ -155,6 +155,7 @@ typedef enum eNodeSocketDatatype { SOCK_STRING = 7, SOCK_OBJECT = 8, SOCK_IMAGE = 9, + SOCK_GEOMETRY = 10, } eNodeSocketDatatype; /* socket shape */ @@ -499,7 +500,7 @@ typedef struct bNodeTree { #define NTREE_SHADER 0 #define NTREE_COMPOSIT 1 #define NTREE_TEXTURE 2 -#define NTREE_SIMULATION 3 +#define NTREE_GEOMETRY 3 /* ntree->init, flag */ #define NTREE_TYPE_INIT 1 @@ -1422,15 +1423,3 @@ typedef enum NodeShaderOutputTarget { SHD_OUTPUT_EEVEE = 1, SHD_OUTPUT_CYCLES = 2, } NodeShaderOutputTarget; - -/* Particle Time Step Event node */ -typedef enum NodeSimParticleTimeStepEventType { - NODE_PARTICLE_TIME_STEP_EVENT_BEGIN = 0, - NODE_PARTICLE_TIME_STEP_EVENT_END = 1, -} NodeSimParticleTimeStepEventType; - -/* Simulation Time node */ -typedef enum NodeSimInputTimeType { - NODE_SIM_INPUT_SIMULATION_TIME = 0, - NODE_SIM_INPUT_SCENE_TIME = 1, -} NodeSimInputTimeType; diff --git a/source/blender/makesdna/intern/dna_defaults.c b/source/blender/makesdna/intern/dna_defaults.c index 8c95a6d2a31..1a8bd25215f 100644 --- a/source/blender/makesdna/intern/dna_defaults.c +++ b/source/blender/makesdna/intern/dna_defaults.c @@ -271,7 +271,7 @@ SDNA_DEFAULT_DECL_STRUCT(ScrewModifierData); /* Shape key modifier has no items. */ SDNA_DEFAULT_DECL_STRUCT(ShrinkwrapModifierData); SDNA_DEFAULT_DECL_STRUCT(SimpleDeformModifierData); -SDNA_DEFAULT_DECL_STRUCT(SimulationModifierData); +SDNA_DEFAULT_DECL_STRUCT(NodesModifierData); SDNA_DEFAULT_DECL_STRUCT(SkinModifierData); SDNA_DEFAULT_DECL_STRUCT(SmoothModifierData); /* Softbody modifier skipped for now. */ @@ -491,7 +491,7 @@ const void *DNA_default_table[SDNA_TYPE_MAX] = { /* Shape key modifier has no items. */ SDNA_DEFAULT_DECL(ShrinkwrapModifierData), SDNA_DEFAULT_DECL(SimpleDeformModifierData), - SDNA_DEFAULT_DECL(SimulationModifierData), + SDNA_DEFAULT_DECL(NodesModifierData), SDNA_DEFAULT_DECL(SkinModifierData), SDNA_DEFAULT_DECL(SmoothModifierData), /* Softbody modifier skipped for now. */ diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h index 6dfd7b0fdf5..a6601951e3b 100644 --- a/source/blender/makesrna/RNA_access.h +++ b/source/blender/makesrna/RNA_access.h @@ -566,10 +566,10 @@ extern StructRNA RNA_SimpleDeformModifier; extern StructRNA RNA_SimplifyGpencilModifier; extern StructRNA RNA_Simulation; #ifdef WITH_GEOMETRY_NODES -extern StructRNA RNA_SimulationModifier; +extern StructRNA RNA_NodesModifier; #endif -extern StructRNA RNA_SimulationNode; -extern StructRNA RNA_SimulationNodeTree; +extern StructRNA RNA_GeometryNode; +extern StructRNA RNA_GeometryNodeTree; extern StructRNA RNA_SkinModifier; extern StructRNA RNA_SmoothGpencilModifier; extern StructRNA RNA_SmoothModifier; diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c index 7885e182787..65804bc54d2 100644 --- a/source/blender/makesrna/intern/rna_modifier.c +++ b/source/blender/makesrna/intern/rna_modifier.c @@ -29,7 +29,6 @@ #include "DNA_object_force_types.h" #include "DNA_object_types.h" #include "DNA_scene_types.h" -#include "DNA_simulation_types.h" #include "MEM_guardedalloc.h" @@ -161,6 +160,7 @@ const EnumPropertyItem rna_enum_object_modifier_type_items[] = { ICON_MOD_MULTIRES, "Multiresolution", "Subdivide the mesh in a way that allows editing the higher subdivision levels"}, + {eModifierType_Nodes, "NODES", ICON_MESH_DATA, "Nodes", ""}, /* TODO: Use correct icon. */ {eModifierType_Remesh, "REMESH", ICON_MOD_REMESH, @@ -305,11 +305,6 @@ const EnumPropertyItem rna_enum_object_modifier_type_items[] = { "Spawn particles from the shape"}, {eModifierType_Softbody, "SOFT_BODY", ICON_MOD_SOFT, "Soft Body", ""}, {eModifierType_Surface, "SURFACE", ICON_MODIFIER, "Surface", ""}, - {eModifierType_Simulation, - "SIMULATION", - ICON_PHYSICS, - "Simulation", - ""}, /* TODO: Use correct icon. */ {0, NULL, 0, NULL, NULL}, }; @@ -1602,6 +1597,14 @@ static int rna_MeshSequenceCacheModifier_read_velocity_get(PointerRNA *ptr) # endif } +static bool rna_NodesModifier_node_tree_poll(PointerRNA *ptr, PointerRNA value) +{ + NodesModifierData *nmd = ptr->data; + bNodeTree *ntree = value.data; + UNUSED_VARS(nmd, ntree); + return true; +} + #else /* NOTE: *MUST* return subdivision_type property. */ @@ -6920,17 +6923,24 @@ static void rna_def_modifier_weightednormal(BlenderRNA *brna) } # ifdef WITH_GEOMETRY_NODES -static void rna_def_modifier_simulation(BlenderRNA *brna) +static void rna_def_modifier_nodes(BlenderRNA *brna) { StructRNA *srna; + PropertyRNA *prop; - srna = RNA_def_struct(brna, "SimulationModifier", "Modifier"); - RNA_def_struct_ui_text(srna, "Simulation Modifier", ""); - RNA_def_struct_sdna(srna, "SimulationModifierData"); - RNA_def_struct_ui_icon(srna, ICON_PHYSICS); /* TODO: Use correct icon. */ + srna = RNA_def_struct(brna, "NodesModifier", "Modifier"); + RNA_def_struct_ui_text(srna, "Nodes Modifier", ""); + RNA_def_struct_sdna(srna, "NodesModifierData"); + RNA_def_struct_ui_icon(srna, ICON_MESH_DATA); /* TODO: Use correct icon. */ RNA_define_lib_overridable(true); + prop = RNA_def_property(srna, "node_tree", PROP_POINTER, PROP_NONE); + RNA_def_property_ui_text(prop, "Node Tree", "Node tree that controls what this modifier does"); + RNA_def_property_pointer_funcs(prop, NULL, NULL, NULL, "rna_NodesModifier_node_tree_poll"); + RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_update(prop, 0, "rna_Modifier_dependency_update"); + RNA_define_lib_overridable(false); } # endif @@ -7290,7 +7300,7 @@ void RNA_def_modifier(BlenderRNA *brna) rna_def_modifier_surfacedeform(brna); rna_def_modifier_weightednormal(brna); # ifdef WITH_GEOMETRY_NODES - rna_def_modifier_simulation(brna); + rna_def_modifier_nodes(brna); # endif rna_def_modifier_mesh_to_volume(brna); rna_def_modifier_volume_displace(brna); diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index 0dea0e47978..b0f039c5b21 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -38,7 +38,6 @@ #include "BKE_animsys.h" #include "BKE_image.h" #include "BKE_node.h" -#include "BKE_simulation.h" #include "BKE_texture.h" #include "RNA_access.h" @@ -84,6 +83,7 @@ static const EnumPropertyItem node_socket_type_items[] = { {SOCK_SHADER, "SHADER", 0, "Shader", ""}, {SOCK_OBJECT, "OBJECT", 0, "Object", ""}, {SOCK_IMAGE, "IMAGE", 0, "Image", ""}, + {SOCK_GEOMETRY, "GEOMETRY", 0, "Geometry", ""}, {0, NULL, 0, NULL, NULL}, }; @@ -96,6 +96,7 @@ static const EnumPropertyItem node_socket_data_type_items[] = { {SOCK_RGBA, "RGBA", 0, "Color", ""}, {SOCK_OBJECT, "OBJECT", 0, "Object", ""}, {SOCK_IMAGE, "IMAGE", 0, "Image", ""}, + {SOCK_GEOMETRY, "GEOMETRY", 0, "Geometry", ""}, {0, NULL, 0, NULL, NULL}, }; @@ -725,9 +726,9 @@ static const EnumPropertyItem *rna_node_static_type_itemf(bContext *UNUSED(C), # undef DefNode } - if (RNA_struct_is_a(ptr->type, &RNA_SimulationNode)) { + if (RNA_struct_is_a(ptr->type, &RNA_GeometryNode)) { # define DefNode(Category, ID, DefFunc, EnumName, StructName, UIName, UIDesc) \ - if (STREQ(#Category, "SimulationNode")) { \ + if (STREQ(#Category, "GeometryNode")) { \ tmp.value = ID; \ tmp.identifier = EnumName; \ tmp.name = UIName; \ @@ -1868,16 +1869,16 @@ static StructRNA *rna_TextureNode_register(Main *bmain, return nt->rna_ext.srna; } -static StructRNA *rna_SimulationNode_register(Main *bmain, - ReportList *reports, - void *data, - const char *identifier, - StructValidateFunc validate, - StructCallbackFunc call, - StructFreeFunc free) +static StructRNA *rna_GeometryNode_register(Main *bmain, + ReportList *reports, + void *data, + const char *identifier, + StructValidateFunc validate, + StructCallbackFunc call, + StructFreeFunc free) { bNodeType *nt = rna_Node_register_base( - bmain, reports, &RNA_SimulationNode, data, identifier, validate, call, free); + bmain, reports, &RNA_GeometryNode, data, identifier, validate, call, free); if (!nt) { return NULL; } @@ -8177,14 +8178,14 @@ static void rna_def_texture_node(BlenderRNA *brna) RNA_def_struct_register_funcs(srna, "rna_TextureNode_register", "rna_Node_unregister", NULL); } -static void rna_def_simulation_node(BlenderRNA *brna) +static void rna_def_geometry_node(BlenderRNA *brna) { StructRNA *srna; - srna = RNA_def_struct(brna, "SimulationNode", "NodeInternal"); - RNA_def_struct_ui_text(srna, "Simulation Node", ""); + srna = RNA_def_struct(brna, "GeometryNode", "NodeInternal"); + RNA_def_struct_ui_text(srna, "Geometry Node", ""); RNA_def_struct_sdna(srna, "bNode"); - RNA_def_struct_register_funcs(srna, "rna_SimulationNode_register", "rna_Node_unregister", NULL); + RNA_def_struct_register_funcs(srna, "rna_GeometryNode_register", "rna_Node_unregister", NULL); } static void rna_def_function_node(BlenderRNA *brna) @@ -8831,6 +8832,21 @@ static void rna_def_node_socket_image(BlenderRNA *brna, RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeSocketInterface_update"); } +static void rna_def_node_socket_geometry(BlenderRNA *brna, + const char *identifier, + const char *interface_idname) +{ + StructRNA *srna; + + srna = RNA_def_struct(brna, identifier, "NodeSocketStandard"); + RNA_def_struct_ui_text(srna, "Geometry Node Socket", "Geometry socket of a node"); + RNA_def_struct_sdna(srna, "bNodeSocket"); + + srna = RNA_def_struct(brna, interface_idname, "NodeSocketInterfaceStandard"); + RNA_def_struct_ui_text(srna, "Geometry Node Socket Interface", "Geometry socket of a node"); + RNA_def_struct_sdna(srna, "bNodeSocket"); +} + static void rna_def_node_socket_standard_types(BlenderRNA *brna) { /* XXX Workaround: Registered functions are not exposed in python by bpy, @@ -8969,6 +8985,8 @@ static void rna_def_node_socket_standard_types(BlenderRNA *brna) rna_def_node_socket_object(brna, "NodeSocketObject", "NodeSocketInterfaceObject"); rna_def_node_socket_image(brna, "NodeSocketImage", "NodeSocketInterfaceImage"); + + rna_def_node_socket_geometry(brna, "NodeSocketGeometry", "NodeSocketInterfaceGeometry"); } static void rna_def_internal_node(BlenderRNA *brna) @@ -9606,7 +9624,7 @@ static void rna_def_nodetree(BlenderRNA *brna) {NTREE_SHADER, "SHADER", ICON_MATERIAL, "Shader", "Shader nodes"}, {NTREE_TEXTURE, "TEXTURE", ICON_TEXTURE, "Texture", "Texture nodes"}, {NTREE_COMPOSIT, "COMPOSITING", ICON_RENDERLAYERS, "Compositing", "Compositing nodes"}, - {NTREE_SIMULATION, "SIMULATION", ICON_PHYSICS, "Simulation", "Simulation nodes"}, + {NTREE_GEOMETRY, "GEOMETRY", ICON_MESH_DATA, "Geometry", "Geometry nodes"}, {0, NULL, 0, NULL, NULL}, }; @@ -9830,15 +9848,15 @@ static void rna_def_texture_nodetree(BlenderRNA *brna) RNA_def_struct_ui_icon(srna, ICON_TEXTURE); } -static void rna_def_simulation_nodetree(BlenderRNA *brna) +static void rna_def_geometry_nodetree(BlenderRNA *brna) { StructRNA *srna; - srna = RNA_def_struct(brna, "SimulationNodeTree", "NodeTree"); + srna = RNA_def_struct(brna, "GeometryNodeTree", "NodeTree"); RNA_def_struct_ui_text( - srna, "Simulation Node Tree", "Node tree consisting of linked nodes used for simulations"); + srna, "Geometry Node Tree", "Node tree consisting of linked nodes used for geometries"); RNA_def_struct_sdna(srna, "bNodeTree"); - RNA_def_struct_ui_icon(srna, ICON_PHYSICS); /* TODO: Use correct icon. */ + RNA_def_struct_ui_icon(srna, ICON_MESH_DATA); /* TODO: Use correct icon. */ } static StructRNA *define_specific_node(BlenderRNA *brna, @@ -9927,7 +9945,7 @@ void RNA_def_nodetree(BlenderRNA *brna) rna_def_shader_node(brna); rna_def_compositor_node(brna); rna_def_texture_node(brna); - rna_def_simulation_node(brna); + rna_def_geometry_node(brna); rna_def_function_node(brna); rna_def_nodetree(brna); @@ -9937,7 +9955,7 @@ void RNA_def_nodetree(BlenderRNA *brna) rna_def_composite_nodetree(brna); rna_def_shader_nodetree(brna); rna_def_texture_nodetree(brna); - rna_def_simulation_nodetree(brna); + rna_def_geometry_nodetree(brna); # define DefNode(Category, ID, DefFunc, EnumName, StructName, UIName, UIDesc) \ { \ @@ -9954,13 +9972,13 @@ void RNA_def_nodetree(BlenderRNA *brna) */ # include "../../nodes/NOD_static_types.h" - /* Node group types need to be defined for shader, compositor, texture, simulation nodes + /* Node group types need to be defined for shader, compositor, texture, geometry nodes * individually. Cannot use the static types header for this, since they share the same int id. */ define_specific_node(brna, "ShaderNodeGroup", "ShaderNode", "Group", "", def_group); define_specific_node(brna, "CompositorNodeGroup", "CompositorNode", "Group", "", def_group); define_specific_node(brna, "TextureNodeGroup", "TextureNode", "Group", "", def_group); - define_specific_node(brna, "SimulationNodeGroup", "SimulationNode", "Group", "", def_group); + define_specific_node(brna, "GeometryNodeGroup", "GeometryNode", "Group", "", def_group); def_custom_group(brna, "ShaderNodeCustomGroup", "ShaderNode", diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index 3255f335e74..91e572caab0 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -45,7 +45,6 @@ #include "DNA_node_types.h" #include "DNA_object_types.h" #include "DNA_sequence_types.h" -#include "DNA_simulation_types.h" #include "DNA_space_types.h" #include "DNA_view3d_types.h" #include "DNA_workspace_types.h" @@ -2178,40 +2177,6 @@ static void rna_SpaceNodeEditor_node_tree_update(const bContext *C, PointerRNA * ED_node_tree_update(C); } -# ifdef WITH_GEOMETRY_NODES -static PointerRNA rna_SpaceNodeEditor_simulation_get(PointerRNA *ptr) -{ - SpaceNode *snode = (SpaceNode *)ptr->data; - ID *id = snode->id; - if (id && GS(id->name) == ID_SIM) { - return rna_pointer_inherit_refine(ptr, &RNA_Simulation, snode->id); - } - else { - return PointerRNA_NULL; - } -} - -static void rna_SpaceNodeEditor_simulation_set(PointerRNA *ptr, - const PointerRNA value, - struct ReportList *UNUSED(reports)) -{ - SpaceNode *snode = (SpaceNode *)ptr->data; - if (!STREQ(snode->tree_idname, "SimulationNodeTree")) { - return; - } - - Simulation *sim = (Simulation *)value.data; - if (sim != NULL) { - bNodeTree *ntree = sim->nodetree; - ED_node_tree_start(snode, ntree, NULL, NULL); - } - else { - ED_node_tree_start(snode, NULL, NULL, NULL); - } - snode->id = &sim->id; -} -# endif - static int rna_SpaceNodeEditor_tree_type_get(PointerRNA *ptr) { SpaceNode *snode = (SpaceNode *)ptr->data; @@ -6347,19 +6312,6 @@ static void rna_def_space_node(BlenderRNA *brna) RNA_def_property_ui_text( prop, "ID From", "Data-block from which the edited data-block is linked"); -# ifdef WITH_GEOMETRY_NODES - prop = RNA_def_property(srna, "simulation", PROP_POINTER, PROP_NONE); - RNA_def_property_flag(prop, PROP_EDITABLE); - RNA_def_property_struct_type(prop, "Simulation"); - RNA_def_property_ui_text(prop, "Simulation", "Simulation that is being edited"); - RNA_def_property_pointer_funcs(prop, - "rna_SpaceNodeEditor_simulation_get", - "rna_SpaceNodeEditor_simulation_set", - NULL, - NULL); - RNA_def_property_update(prop, NC_SPACE | ND_SPACE_NODE, NULL); -# endif - prop = RNA_def_property(srna, "path", PROP_COLLECTION, PROP_NONE); RNA_def_property_collection_sdna(prop, NULL, "treepath", NULL); RNA_def_property_struct_type(prop, "NodeTreePath"); diff --git a/source/blender/modifiers/CMakeLists.txt b/source/blender/modifiers/CMakeLists.txt index 65024e46a2b..f4b45936ef1 100644 --- a/source/blender/modifiers/CMakeLists.txt +++ b/source/blender/modifiers/CMakeLists.txt @@ -86,7 +86,7 @@ set(SRC intern/MOD_shapekey.c intern/MOD_shrinkwrap.c intern/MOD_simpledeform.c - intern/MOD_simulation.cc + intern/MOD_nodes.cc intern/MOD_skin.c intern/MOD_smooth.c intern/MOD_softbody.c diff --git a/source/blender/modifiers/MOD_modifiertypes.h b/source/blender/modifiers/MOD_modifiertypes.h index 9c488780366..f36cb7ded9c 100644 --- a/source/blender/modifiers/MOD_modifiertypes.h +++ b/source/blender/modifiers/MOD_modifiertypes.h @@ -85,7 +85,7 @@ extern ModifierTypeInfo modifierType_CorrectiveSmooth; extern ModifierTypeInfo modifierType_MeshSequenceCache; extern ModifierTypeInfo modifierType_SurfaceDeform; extern ModifierTypeInfo modifierType_WeightedNormal; -extern ModifierTypeInfo modifierType_Simulation; +extern ModifierTypeInfo modifierType_Nodes; extern ModifierTypeInfo modifierType_MeshToVolume; extern ModifierTypeInfo modifierType_VolumeDisplace; extern ModifierTypeInfo modifierType_VolumeToMesh; diff --git a/source/blender/modifiers/intern/MOD_simulation.cc b/source/blender/modifiers/intern/MOD_nodes.cc index 10a4b3f7cf9..579168268cd 100644 --- a/source/blender/modifiers/intern/MOD_simulation.cc +++ b/source/blender/modifiers/intern/MOD_nodes.cc @@ -36,11 +36,11 @@ #include "DNA_mesh_types.h" #include "DNA_meshdata_types.h" #include "DNA_modifier_types.h" +#include "DNA_node_types.h" #include "DNA_object_types.h" #include "DNA_pointcloud_types.h" #include "DNA_scene_types.h" #include "DNA_screen_types.h" -#include "DNA_simulation_types.h" #include "BKE_customdata.h" #include "BKE_lib_query.h" @@ -67,34 +67,33 @@ using blender::float3; static void initData(ModifierData *md) { - SimulationModifierData *smd = (SimulationModifierData *)md; + NodesModifierData *nmd = (NodesModifierData *)md; - BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(smd, modifier)); + BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(nmd, modifier)); - MEMCPY_STRUCT_AFTER(smd, DNA_struct_default_get(SimulationModifierData), modifier); + MEMCPY_STRUCT_AFTER(nmd, DNA_struct_default_get(NodesModifierData), modifier); } -static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphContext *UNUSED(ctx)) +static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphContext *ctx) { - SimulationModifierData *smd = reinterpret_cast<SimulationModifierData *>(md); - UNUSED_VARS(smd); + NodesModifierData *nmd = reinterpret_cast<NodesModifierData *>(md); + if (nmd->node_tree != nullptr) { + DEG_add_node_tree_relation(ctx->node, nmd->node_tree, "Nodes Modifier"); + } } -static void foreachIDLink(ModifierData *md, - Object *UNUSED(ob), - IDWalkFunc UNUSED(walk), - void *UNUSED(userData)) +static void foreachIDLink(ModifierData *md, Object *ob, IDWalkFunc walk, void *userData) { - SimulationModifierData *smd = reinterpret_cast<SimulationModifierData *>(md); - UNUSED_VARS(smd); + NodesModifierData *nmd = reinterpret_cast<NodesModifierData *>(md); + walk(userData, ob, (ID **)&nmd->node_tree, IDWALK_CB_USER); } static bool isDisabled(const struct Scene *UNUSED(scene), ModifierData *md, bool UNUSED(useRenderParams)) { - SimulationModifierData *smd = reinterpret_cast<SimulationModifierData *>(md); - UNUSED_VARS(smd); + NodesModifierData *nmd = reinterpret_cast<NodesModifierData *>(md); + UNUSED_VARS(nmd); return false; } @@ -102,11 +101,20 @@ static PointCloud *modifyPointCloud(ModifierData *md, const ModifierEvalContext *UNUSED(ctx), PointCloud *pointcloud) { - SimulationModifierData *smd = reinterpret_cast<SimulationModifierData *>(md); - UNUSED_VARS(smd); + NodesModifierData *nmd = reinterpret_cast<NodesModifierData *>(md); + UNUSED_VARS(nmd); + std::cout << __func__ << "\n"; return pointcloud; } +static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *UNUSED(ctx), Mesh *mesh) +{ + NodesModifierData *nmd = reinterpret_cast<NodesModifierData *>(md); + UNUSED_VARS(nmd); + std::cout << __func__ << "\n"; + return mesh; +} + static void panel_draw(const bContext *UNUSED(C), Panel *panel) { uiLayout *layout = panel->layout; @@ -117,55 +125,55 @@ static void panel_draw(const bContext *UNUSED(C), Panel *panel) uiLayoutSetPropSep(layout, true); uiLayoutSetPropDecorate(layout, false); - uiItemL(layout, "This modifier does nothing currently", ICON_INFO); + uiItemR(layout, ptr, "node_tree", 0, NULL, ICON_MESH_DATA); modifier_panel_end(layout, ptr); } static void panelRegister(ARegionType *region_type) { - modifier_panel_register(region_type, eModifierType_Simulation, panel_draw); + modifier_panel_register(region_type, eModifierType_Nodes, panel_draw); } static void blendWrite(BlendWriter *writer, const ModifierData *md) { - const SimulationModifierData *smd = reinterpret_cast<const SimulationModifierData *>(md); - UNUSED_VARS(smd, writer); + const NodesModifierData *nmd = reinterpret_cast<const NodesModifierData *>(md); + UNUSED_VARS(nmd, writer); } static void blendRead(BlendDataReader *reader, ModifierData *md) { - SimulationModifierData *smd = reinterpret_cast<SimulationModifierData *>(md); - UNUSED_VARS(smd, reader); + NodesModifierData *nmd = reinterpret_cast<NodesModifierData *>(md); + UNUSED_VARS(nmd, reader); } static void copyData(const ModifierData *md, ModifierData *target, const int flag) { - const SimulationModifierData *smd = reinterpret_cast<const SimulationModifierData *>(md); - SimulationModifierData *tsmd = reinterpret_cast<SimulationModifierData *>(target); - UNUSED_VARS(smd, tsmd); + const NodesModifierData *nmd = reinterpret_cast<const NodesModifierData *>(md); + NodesModifierData *tnmd = reinterpret_cast<NodesModifierData *>(target); + UNUSED_VARS(nmd, tnmd); BKE_modifier_copydata_generic(md, target, flag); } static void freeData(ModifierData *md) { - SimulationModifierData *smd = reinterpret_cast<SimulationModifierData *>(md); - UNUSED_VARS(smd); + NodesModifierData *nmd = reinterpret_cast<NodesModifierData *>(md); + UNUSED_VARS(nmd); } -ModifierTypeInfo modifierType_Simulation = { - /* name */ "Simulation", - /* structName */ "SimulationModifierData", - /* structSize */ sizeof(SimulationModifierData), +ModifierTypeInfo modifierType_Nodes = { + /* name */ "Nodes", + /* structName */ "NodesModifierData", + /* structSize */ sizeof(NodesModifierData), #ifdef WITH_GEOMETRY_NODES - /* srna */ &RNA_SimulationModifier, + /* srna */ &RNA_NodesModifier, #else /* srna */ &RNA_Modifier, #endif - /* type */ eModifierTypeType_None, - /* flags */ (ModifierTypeFlag)0, - /* icon */ ICON_PHYSICS, /* TODO: Use correct icon. */ + /* type */ eModifierTypeType_Constructive, + /* flags */ eModifierTypeFlag_AcceptsMesh, + /* icon */ ICON_MESH_DATA, /* TODO: Use correct icon. */ /* copyData */ copyData, @@ -173,7 +181,7 @@ ModifierTypeInfo modifierType_Simulation = { /* deformMatrices */ NULL, /* deformVertsEM */ NULL, /* deformMatricesEM */ NULL, - /* modifyMesh */ NULL, + /* modifyMesh */ modifyMesh, /* modifyHair */ NULL, /* modifyPointCloud */ modifyPointCloud, /* modifyVolume */ NULL, diff --git a/source/blender/modifiers/intern/MOD_util.c b/source/blender/modifiers/intern/MOD_util.c index e0802dc5fb4..32d40027537 100644 --- a/source/blender/modifiers/intern/MOD_util.c +++ b/source/blender/modifiers/intern/MOD_util.c @@ -342,7 +342,7 @@ void modifier_type_init(ModifierTypeInfo *types[]) INIT_TYPE(MeshSequenceCache); INIT_TYPE(SurfaceDeform); INIT_TYPE(WeightedNormal); - INIT_TYPE(Simulation); + INIT_TYPE(Nodes); INIT_TYPE(MeshToVolume); INIT_TYPE(VolumeDisplace); INIT_TYPE(VolumeToMesh); diff --git a/source/blender/nodes/CMakeLists.txt b/source/blender/nodes/CMakeLists.txt index 78b3e6236f0..cf09e6b15c7 100644 --- a/source/blender/nodes/CMakeLists.txt +++ b/source/blender/nodes/CMakeLists.txt @@ -24,7 +24,7 @@ set(INC function intern shader - simulation + geometry texture ../blenkernel ../blenlib @@ -137,6 +137,10 @@ set(SRC function/nodes/node_fn_switch.cc function/node_function_util.cc + geometry/nodes/node_geo_common.cc + geometry/node_geometry_tree.cc + geometry/node_geometry_util.cc + shader/nodes/node_shader_add_shader.c shader/nodes/node_shader_ambient_occlusion.c shader/nodes/node_shader_attribute.c @@ -230,10 +234,6 @@ set(SRC shader/node_shader_tree.c shader/node_shader_util.c - simulation/nodes/node_sim_common.cc - simulation/node_simulation_tree.cc - simulation/node_simulation_util.cc - texture/nodes/node_texture_at.c texture/nodes/node_texture_bricks.c texture/nodes/node_texture_checker.c @@ -272,7 +272,7 @@ set(SRC composite/node_composite_util.h function/node_function_util.hh shader/node_shader_util.h - simulation/node_simulation_util.h + geometry/node_geometry_util.h texture/node_texture_util.h NOD_common.h @@ -283,7 +283,7 @@ set(SRC NOD_node_tree_multi_function.hh NOD_node_tree_ref.hh NOD_shader.h - NOD_simulation.h + NOD_geometry.h NOD_socket.h NOD_static_types.h NOD_texture.h diff --git a/source/blender/nodes/NOD_simulation.h b/source/blender/nodes/NOD_geometry.h index 6b3d51b46a9..0f8c49930ad 100644 --- a/source/blender/nodes/NOD_simulation.h +++ b/source/blender/nodes/NOD_geometry.h @@ -20,11 +20,11 @@ extern "C" { #endif -extern struct bNodeTreeType *ntreeType_Simulation; +extern struct bNodeTreeType *ntreeType_Geometry; -void register_node_tree_type_sim(void); +void register_node_tree_type_geo(void); -void register_node_type_sim_group(void); +void register_node_type_geo_group(void); #ifdef __cplusplus } diff --git a/source/blender/nodes/function/node_function_util.cc b/source/blender/nodes/function/node_function_util.cc index 342c330a8fa..05b452e61a5 100644 --- a/source/blender/nodes/function/node_function_util.cc +++ b/source/blender/nodes/function/node_function_util.cc @@ -20,7 +20,7 @@ bool fn_node_poll_default(bNodeType *UNUSED(ntype), bNodeTree *ntree) { /* Function nodes are only supported in simulation node trees so far. */ - return STREQ(ntree->idname, "SimulationNodeTree"); + return STREQ(ntree->idname, "GeometryNodeTree"); } void fn_node_type_base(bNodeType *ntype, int type, const char *name, short nclass, short flag) diff --git a/source/blender/nodes/simulation/node_simulation_tree.cc b/source/blender/nodes/geometry/node_geometry_tree.cc index eb3257d7e66..d4a9805f311 100644 --- a/source/blender/nodes/simulation/node_simulation_tree.cc +++ b/source/blender/nodes/geometry/node_geometry_tree.cc @@ -18,7 +18,7 @@ #include "MEM_guardedalloc.h" -#include "NOD_simulation.h" +#include "NOD_geometry.h" #include "BKE_node.h" @@ -28,18 +28,18 @@ #include "RNA_access.h" -bNodeTreeType *ntreeType_Simulation; +bNodeTreeType *ntreeType_Geometry; -void register_node_tree_type_sim(void) +void register_node_tree_type_geo(void) { - bNodeTreeType *tt = ntreeType_Simulation = static_cast<bNodeTreeType *>( - MEM_callocN(sizeof(bNodeTreeType), "simulation node tree type")); - tt->type = NTREE_SIMULATION; - strcpy(tt->idname, "SimulationNodeTree"); - strcpy(tt->ui_name, N_("Simulation Editor")); + bNodeTreeType *tt = ntreeType_Geometry = static_cast<bNodeTreeType *>( + MEM_callocN(sizeof(bNodeTreeType), "geometry node tree type")); + tt->type = NTREE_GEOMETRY; + strcpy(tt->idname, "GeometryNodeTree"); + strcpy(tt->ui_name, N_("Geometry Node Editor")); tt->ui_icon = 0; /* defined in drawnode.c */ - strcpy(tt->ui_description, N_("Simulation nodes")); - tt->rna_ext.srna = &RNA_SimulationNodeTree; + strcpy(tt->ui_description, N_("Geometry nodes")); + tt->rna_ext.srna = &RNA_GeometryNodeTree; ntreeTypeAdd(tt); } diff --git a/source/blender/nodes/simulation/node_simulation_util.cc b/source/blender/nodes/geometry/node_geometry_util.cc index ae875335da8..82354d6cf66 100644 --- a/source/blender/nodes/simulation/node_simulation_util.cc +++ b/source/blender/nodes/geometry/node_geometry_util.cc @@ -14,16 +14,16 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#include "node_simulation_util.h" +#include "node_geometry_util.h" #include "node_util.h" -bool sim_node_poll_default(bNodeType *UNUSED(ntype), bNodeTree *ntree) +bool geo_node_poll_default(bNodeType *UNUSED(ntype), bNodeTree *ntree) { - return STREQ(ntree->idname, "SimulationNodeTree"); + return STREQ(ntree->idname, "GeometryNodeTree"); } -void sim_node_type_base(bNodeType *ntype, int type, const char *name, short nclass, short flag) +void geo_node_type_base(bNodeType *ntype, int type, const char *name, short nclass, short flag) { node_type_base(ntype, type, name, nclass, flag); - ntype->poll = sim_node_poll_default; + ntype->poll = geo_node_poll_default; } diff --git a/source/blender/nodes/simulation/node_simulation_util.h b/source/blender/nodes/geometry/node_geometry_util.h index 76a10715cff..9d949e8d1ef 100644 --- a/source/blender/nodes/simulation/node_simulation_util.h +++ b/source/blender/nodes/geometry/node_geometry_util.h @@ -28,10 +28,10 @@ #include "BLT_translation.h" -#include "NOD_simulation.h" +#include "NOD_geometry.h" #include "node_util.h" -void sim_node_type_base( +void geo_node_type_base( struct bNodeType *ntype, int type, const char *name, short nclass, short flag); -bool sim_node_poll_default(struct bNodeType *ntype, struct bNodeTree *ntree); +bool geo_node_poll_default(struct bNodeType *ntype, struct bNodeTree *ntree); diff --git a/source/blender/nodes/simulation/nodes/node_sim_common.cc b/source/blender/nodes/geometry/nodes/node_geo_common.cc index fbc03905d4f..beb4bc440ed 100644 --- a/source/blender/nodes/simulation/nodes/node_sim_common.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_common.cc @@ -16,23 +16,23 @@ #include "BKE_node.h" -#include "NOD_simulation.h" +#include "NOD_geometry.h" #include "NOD_common.h" #include "node_common.h" -#include "node_simulation_util.h" +#include "node_geometry_util.h" -void register_node_type_sim_group(void) +void register_node_type_geo_group(void) { static bNodeType ntype; - node_type_base_custom(&ntype, "SimulationNodeGroup", "Group", 0, 0); + node_type_base_custom(&ntype, "GeometryNodeGroup", "Group", 0, 0); ntype.type = NODE_GROUP; - ntype.poll = sim_node_poll_default; + ntype.poll = geo_node_poll_default; ntype.poll_instance = node_group_poll_instance; ntype.insert_link = node_insert_link_default; ntype.update_internal_links = node_update_internal_links_default; - ntype.rna_ext.srna = RNA_struct_find("SimulationNodeGroup"); + ntype.rna_ext.srna = RNA_struct_find("GeometryNodeGroup"); BLI_assert(ntype.rna_ext.srna != NULL); RNA_struct_blender_type_set(ntype.rna_ext.srna, &ntype); diff --git a/source/blender/nodes/intern/node_socket.cc b/source/blender/nodes/intern/node_socket.cc index 0cedc6597c8..84a51afb922 100644 --- a/source/blender/nodes/intern/node_socket.cc +++ b/source/blender/nodes/intern/node_socket.cc @@ -672,6 +672,12 @@ static bNodeSocketType *make_socket_type_object() return socktype; } +static bNodeSocketType *make_socket_type_geometry() +{ + bNodeSocketType *socktype = make_standard_socket_type(SOCK_GEOMETRY, PROP_NONE); + return socktype; +} + void register_standard_node_socket_types(void) { /* draw callbacks are set in drawnode.c to avoid bad-level calls */ @@ -708,5 +714,7 @@ void register_standard_node_socket_types(void) nodeRegisterSocketType(make_standard_socket_type(SOCK_IMAGE, PROP_NONE)); + nodeRegisterSocketType(make_socket_type_geometry()); + nodeRegisterSocketType(make_socket_type_virtual()); } diff --git a/source/blender/nodes/shader/node_shader_util.c b/source/blender/nodes/shader/node_shader_util.c index 4464a61c48c..25d6aef69e5 100644 --- a/source/blender/nodes/shader/node_shader_util.c +++ b/source/blender/nodes/shader/node_shader_util.c @@ -34,7 +34,7 @@ bool sh_node_poll_default(bNodeType *UNUSED(ntype), bNodeTree *ntree) static bool sh_fn_poll_default(bNodeType *UNUSED(ntype), bNodeTree *ntree) { - return STREQ(ntree->idname, "ShaderNodeTree") || STREQ(ntree->idname, "SimulationNodeTree"); + return STREQ(ntree->idname, "ShaderNodeTree") || STREQ(ntree->idname, "GeometryNodeTree"); } void sh_node_type_base( |