[Bf-blender-cvs] [60fc5fc9f30] builtin-simulation-nodes: add first node using builtin node registration methods
Jacques Lucke
noreply at git.blender.org
Mon Mar 2 13:05:59 CET 2020
Commit: 60fc5fc9f30a2df81d95b1ad4c7ebb057595483e
Author: Jacques Lucke
Date: Mon Mar 2 11:47:59 2020 +0100
Branches: builtin-simulation-nodes
https://developer.blender.org/rB60fc5fc9f30a2df81d95b1ad4c7ebb057595483e
add first node using builtin node registration methods
===================================================================
M release/scripts/startup/nodeitems_builtins.py
M source/blender/blenkernel/BKE_node.h
M source/blender/blenkernel/intern/node.c
M source/blender/makesrna/RNA_access.h
M source/blender/makesrna/intern/rna_nodetree.c
M source/blender/nodes/CMakeLists.txt
M source/blender/nodes/NOD_simulation.h
M source/blender/nodes/NOD_static_types.h
M source/blender/nodes/simulation/node_sim_util.cc
M source/blender/nodes/simulation/node_sim_util.h
M source/blender/nodes/simulation/nodes/node_sim_particle_simulation.cc
===================================================================
diff --git a/release/scripts/startup/nodeitems_builtins.py b/release/scripts/startup/nodeitems_builtins.py
index 969a1ca1bd7..040f4ed330c 100644
--- a/release/scripts/startup/nodeitems_builtins.py
+++ b/release/scripts/startup/nodeitems_builtins.py
@@ -57,6 +57,12 @@ class TextureNodeCategory(SortedNodeCategory):
return (context.space_data.type == 'NODE_EDITOR' and
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):
@@ -70,6 +76,7 @@ node_tree_group_type = {
'CompositorNodeTree': 'CompositorNodeGroup',
'ShaderNodeTree': 'ShaderNodeGroup',
'TextureNodeTree': 'TextureNodeGroup',
+ # TODO: simulation node group
}
@@ -467,17 +474,25 @@ texture_node_categories = [
]),
]
+simulation_node_categories = [
+ SimulationNodeCategory("SIM_OUTPUT", "Output", items=[
+ NodeItem("SimulationNodeParticleSimulation"),
+ ]),
+]
+
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__":
diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h
index 53404055d8c..0e4ccef71a1 100644
--- a/source/blender/blenkernel/BKE_node.h
+++ b/source/blender/blenkernel/BKE_node.h
@@ -1004,6 +1004,8 @@ void BKE_nodetree_remove_layer_n(struct bNodeTree *ntree,
#define SH_NODE_OUTPUT_AOV 707
#define SH_NODE_VECTOR_ROTATE 708
+#define SIM_NODE_PARTICLE_SIMULATION 1000
+
/* custom defines options for Material node */
// #define SH_NODE_MAT_DIFF 1
// #define SH_NODE_MAT_SPEC 2
diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c
index 9c1b095331d..e239a37b3b7 100644
--- a/source/blender/blenkernel/intern/node.c
+++ b/source/blender/blenkernel/intern/node.c
@@ -4100,6 +4100,11 @@ static void registerTextureNodes(void)
register_node_type_tex_proc_distnoise();
}
+static void registerSimulationNodes(void)
+{
+ register_node_type_sim_particle_simulation();
+}
+
void init_nodesystem(void)
{
nodetreetypes_hash = BLI_ghash_str_new("nodetreetypes_hash gh");
@@ -4123,6 +4128,7 @@ void init_nodesystem(void)
registerCompositNodes();
registerShaderNodes();
registerTextureNodes();
+ registerSimulationNodes();
}
void free_nodesystem(void)
diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h
index bd6f9148d1e..a29f19793f5 100644
--- a/source/blender/makesrna/RNA_access.h
+++ b/source/blender/makesrna/RNA_access.h
@@ -547,6 +547,7 @@ extern StructRNA RNA_ShrinkwrapConstraint;
extern StructRNA RNA_ShrinkwrapModifier;
extern StructRNA RNA_SimpleDeformModifier;
extern StructRNA RNA_SimplifyGpencilModifier;
+extern StructRNA RNA_SimulationNode;
extern StructRNA RNA_SimulationNodeTree;
extern StructRNA RNA_SkinModifier;
extern StructRNA RNA_SmoothGpencilModifier;
diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c
index 93105efd1e0..762e2e4928c 100644
--- a/source/blender/makesrna/intern/rna_nodetree.c
+++ b/source/blender/makesrna/intern/rna_nodetree.c
@@ -669,6 +669,20 @@ static const EnumPropertyItem *rna_node_static_type_itemf(bContext *UNUSED(C),
# undef DefNode
}
+ if (RNA_struct_is_a(ptr->type, &RNA_SimulationNode)) {
+# define DefNode(Category, ID, DefFunc, EnumName, StructName, UIName, UIDesc) \
+ if (STREQ(#Category, "SimulationNode")) { \
+ tmp.value = ID; \
+ tmp.identifier = EnumName; \
+ tmp.name = UIName; \
+ tmp.description = UIDesc; \
+ tmp.icon = ICON_NONE; \
+ RNA_enum_item_add(&item, &totitem, &tmp); \
+ }
+# include "../../nodes/NOD_static_types.h"
+# undef DefNode
+ }
+
RNA_enum_item_end(&item, &totitem);
*r_free = true;
@@ -1785,6 +1799,28 @@ static StructRNA *rna_TextureNode_register(Main *bmain,
return nt->ext.srna;
}
+static StructRNA *rna_SimulationNode_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);
+ if (!nt) {
+ return NULL;
+ }
+
+ nodeRegisterType(nt);
+
+ /* update while blender is running */
+ WM_main_add_notifier(NC_NODE | NA_EDITED, NULL);
+
+ return nt->ext.srna;
+}
+
static IDProperty *rna_Node_idprops(PointerRNA *ptr, bool create)
{
bNode *node = ptr->data;
@@ -7930,6 +7966,16 @@ 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)
+{
+ StructRNA *srna;
+
+ srna = RNA_def_struct(brna, "SimulationNode", "NodeInternal");
+ RNA_def_struct_ui_text(srna, "Simulation Node", "");
+ RNA_def_struct_sdna(srna, "bNode");
+ RNA_def_struct_register_funcs(srna, "rna_SimulationNode_register", "rna_Node_unregister", NULL);
+}
+
/* -------------------------------------------------------------------------- */
static void rna_def_node_socket(BlenderRNA *brna)
@@ -9565,6 +9611,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_nodetree(brna);
diff --git a/source/blender/nodes/CMakeLists.txt b/source/blender/nodes/CMakeLists.txt
index eb12f1fe871..264949896ea 100644
--- a/source/blender/nodes/CMakeLists.txt
+++ b/source/blender/nodes/CMakeLists.txt
@@ -23,6 +23,7 @@ set(INC
composite
intern
shader
+ simulation
texture
../blenkernel
../blenlib
@@ -220,7 +221,9 @@ set(SRC
shader/node_shader_tree.c
shader/node_shader_util.c
+ simulation/nodes/node_sim_particle_simulation.cc
simulation/node_sim_tree.cc
+ simulation/node_sim_util.cc
texture/nodes/node_texture_at.c
texture/nodes/node_texture_bricks.c
diff --git a/source/blender/nodes/NOD_simulation.h b/source/blender/nodes/NOD_simulation.h
index 4625c80bbeb..93ae1faedd8 100644
--- a/source/blender/nodes/NOD_simulation.h
+++ b/source/blender/nodes/NOD_simulation.h
@@ -9,6 +9,8 @@ extern struct bNodeTreeType *ntreeType_Simulation;
void register_node_tree_type_sim(void);
+void register_node_type_sim_particle_simulation(void);
+
#ifdef __cplusplus
}
#endif
diff --git a/source/blender/nodes/NOD_static_types.h b/source/blender/nodes/NOD_static_types.h
index 7fec3324aab..a509e6b4839 100644
--- a/source/blender/nodes/NOD_static_types.h
+++ b/source/blender/nodes/NOD_static_types.h
@@ -258,6 +258,8 @@ DefNode(TextureNode, TEX_NODE_PROC+TEX_NOISE, 0, "TEX_NO
DefNode(TextureNode, TEX_NODE_PROC+TEX_STUCCI, 0, "TEX_STUCCI", TexStucci, "Stucci", "" )
DefNode(TextureNode, TEX_NODE_PROC+TEX_DISTNOISE, 0, "TEX_DISTNOISE", TexDistNoise, "Distorted Noise", "" )
+DefNode(SimulationNode, SIM_NODE_PARTICLE_SIMULATION, 0, "PARTICLE_SIMULATION", ParticleSimulation, "Particle Simulation", "")
+
/* undefine macros */
#undef DefNode
diff --git a/source/blender/nodes/simulation/node_sim_util.cc b/source/blender/nodes/simulation/node_sim_util.cc
index e101a1554f8..c6da8b0951a 100644
--- a/source/blender/nodes/simulation/node_sim_util.cc
+++ b/source/blender/nodes/simulation/node_sim_util.cc
@@ -1,4 +1,15 @@
#ifndef __NODE_SIMULATION_UTIL_H__
#define __NODE_SIMULATION_UTIL_H__
+#include "node_sim_util.h"
+#include "node_util.h"
+
+void sim_node_type_base(bNodeType *ntype, int type, const char *name, short nclass, short flag)
+{
+ node_type_base(ntype, type, name, nclass, flag);
+ ntype->poll = [](bNodeType *UNUSED(ntype), bNodeTree *ntree) {
+ return STREQ(ntree->idname, "SimulationNodeTree");
+ };
+}
+
#endif /* __NODE_SIMULATION_UTIL_H__ */
\ No newline at end of file
diff --git a/source/blender/nodes/simulation/node_sim_util.h b/source/blender/nodes/simulation/node_sim_util.h
index e69de29bb2d..09d014940ef 100644
--- a/source/blender/nodes/simulation/node_sim_util.h
+++ b/source/blender/nodes/simulation/node_sim_util.h
@@ -0,0 +1,19 @@
+#ifndef __NODE_SHADER_UTIL_H__
+#define __NODE_SHADER_UTIL_H__
+
+#include <string.h>
+
+#include "BLI_utildefines.h"
+
+#include "MEM_guardedalloc.h"
+
+#include "DNA_node_types.h"
+
+#include "BKE_node.h"
+
+#include "BLT_translation.h"
+
+void sim_node_type_base(
+ struct bNodeType *ntype, int type, const char *name, short nclass, short flag);
+
+#endif /* __NODE_SHADER_UTIL_H__ */
\ No newline at end of file
diff --git a/source/blender/nodes/simulation/nodes/node_sim_particle_simulation.cc b/source/blender/nodes/simulation/nodes/node_sim_particle_simulation.cc
index e69de29bb2d..d147b2fb30c 100644
--- a/source/blender/nodes/simulation/nodes/node_sim_particle_simulation.cc
+++ b/source/blender/nodes/simulation/nodes/node_sim_particle_simulation.cc
@@ -0,0 +1,22 @@
+#include "NOD_simulation.h"
+
+#include "node_sim_util.h"
+
+static bNodeSocketTemplate sim_node_particle_simulation_in[] = {
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list