[Bf-blender-cvs] [a321c9a29ab] builtin-simulation-nodes: add custom force node ui

Jacques Lucke noreply at git.blender.org
Mon Mar 2 17:24:02 CET 2020


Commit: a321c9a29abc393d9bf1c45c95f1978b01b1f719
Author: Jacques Lucke
Date:   Mon Mar 2 16:33:03 2020 +0100
Branches: builtin-simulation-nodes
https://developer.blender.org/rBa321c9a29abc393d9bf1c45c95f1978b01b1f719

add custom force node ui

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

M	release/scripts/startup/nodeitems_builtins.py
M	source/blender/blenkernel/BKE_node.h
M	source/blender/blenkernel/intern/node.c
M	source/blender/nodes/CMakeLists.txt
M	source/blender/nodes/NOD_simulation.h
M	source/blender/nodes/NOD_static_types.h
A	source/blender/nodes/simulation/nodes/node_sim_custom_force.cc

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

diff --git a/release/scripts/startup/nodeitems_builtins.py b/release/scripts/startup/nodeitems_builtins.py
index 107b9682c7b..0a471d10229 100644
--- a/release/scripts/startup/nodeitems_builtins.py
+++ b/release/scripts/startup/nodeitems_builtins.py
@@ -478,6 +478,9 @@ simulation_node_categories = [
     SimulationNodeCategory("SIM_OUTPUT", "Output", items=[
         NodeItem("SimulationNodeParticleSimulation"),
     ]),
+    SimulationNodeCategory("FORCE", "Force", items=[
+        NodeItem("SimulationNodeCustomForce"),
+    ]),
 ]
 
 
diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h
index 29adca03d70..9385da7eacb 100644
--- a/source/blender/blenkernel/BKE_node.h
+++ b/source/blender/blenkernel/BKE_node.h
@@ -1006,6 +1006,7 @@ void BKE_nodetree_remove_layer_n(struct bNodeTree *ntree,
 #define SH_NODE_VECTOR_ROTATE 708
 
 #define SIM_NODE_PARTICLE_SIMULATION 1000
+#define SIM_NODE_CUSTOM_FORCE 1001
 
 /* custom defines options for Material node */
 // #define SH_NODE_MAT_DIFF 1
diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c
index 7d09595bdf2..03e734a84bb 100644
--- a/source/blender/blenkernel/intern/node.c
+++ b/source/blender/blenkernel/intern/node.c
@@ -4122,6 +4122,7 @@ static void registerSimulationNodes(void)
   register_node_type_sim_group();
 
   register_node_type_sim_particle_simulation();
+  register_node_type_sim_custom_force();
 }
 
 void init_nodesystem(void)
diff --git a/source/blender/nodes/CMakeLists.txt b/source/blender/nodes/CMakeLists.txt
index 893054ad523..104d240cb8a 100644
--- a/source/blender/nodes/CMakeLists.txt
+++ b/source/blender/nodes/CMakeLists.txt
@@ -222,6 +222,7 @@ set(SRC
   shader/node_shader_util.c
 
   simulation/nodes/node_sim_common.cc
+  simulation/nodes/node_sim_custom_force.cc
   simulation/nodes/node_sim_particle_simulation.cc
   simulation/node_sim_tree.cc
   simulation/node_sim_util.cc
diff --git a/source/blender/nodes/NOD_simulation.h b/source/blender/nodes/NOD_simulation.h
index 0edfa1a1b9f..dcf4b358ca7 100644
--- a/source/blender/nodes/NOD_simulation.h
+++ b/source/blender/nodes/NOD_simulation.h
@@ -12,9 +12,10 @@ void register_node_tree_type_sim(void);
 void register_node_type_sim_group(void);
 
 void register_node_type_sim_particle_simulation(void);
+void register_node_type_sim_custom_force(void);
 
 #ifdef __cplusplus
 }
 #endif
 
-#endif /* __NOD_SIMULATION_H__ */
\ No newline at end of file
+#endif /* __NOD_SIMULATION_H__ */
diff --git a/source/blender/nodes/NOD_static_types.h b/source/blender/nodes/NOD_static_types.h
index a509e6b4839..671228a169c 100644
--- a/source/blender/nodes/NOD_static_types.h
+++ b/source/blender/nodes/NOD_static_types.h
@@ -259,6 +259,7 @@ DefNode(TextureNode,    TEX_NODE_PROC+TEX_STUCCI, 0,                     "TEX_ST
 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", "")
+DefNode(SimulationNode, SIM_NODE_CUSTOM_FORCE,        0,                 "CUSTOM_FORCE",        CustomForce,        "Custom Force",        "")
 
 /* undefine macros */
 #undef DefNode
diff --git a/source/blender/nodes/simulation/nodes/node_sim_custom_force.cc b/source/blender/nodes/simulation/nodes/node_sim_custom_force.cc
new file mode 100644
index 00000000000..553463df268
--- /dev/null
+++ b/source/blender/nodes/simulation/nodes/node_sim_custom_force.cc
@@ -0,0 +1,20 @@
+#include "node_sim_util.h"
+
+static bNodeSocketTemplate sim_node_custom_force_in[] = {
+    {SOCK_VECTOR, 1, N_("Force"), 0.0f, 0.0f, 0.0f, 0.0f, -10000.0f, 10000.0f},
+    {-1, 0, ""},
+};
+
+static bNodeSocketTemplate sim_node_custom_force_out[] = {
+    {SOCK_FORCES, 0, N_("Force")},
+    {-1, 0, ""},
+};
+
+void register_node_type_sim_custom_force()
+{
+  static bNodeType ntype;
+
+  sim_node_type_base(&ntype, SIM_NODE_CUSTOM_FORCE, "Custom Force", 0, 0);
+  node_type_socket_templates(&ntype, sim_node_custom_force_in, sim_node_custom_force_out);
+  nodeRegisterType(&ntype);
+}



More information about the Bf-blender-cvs mailing list