[Bf-blender-cvs] [dfa169be9cb] builtin-simulation-nodes: add data type property to Set Particle Attribute node
Jacques Lucke
noreply at git.blender.org
Mon Mar 16 13:59:15 CET 2020
Commit: dfa169be9cb3b801cbfaab1ec40f3cf9b6b63a58
Author: Jacques Lucke
Date: Mon Mar 16 13:35:54 2020 +0100
Branches: builtin-simulation-nodes
https://developer.blender.org/rBdfa169be9cb3b801cbfaab1ec40f3cf9b6b63a58
add data type property to Set Particle Attribute node
===================================================================
M source/blender/editors/space_node/drawnode.c
M source/blender/makesrna/intern/rna_nodetree.c
M source/blender/nodes/NOD_static_types.h
M source/blender/nodes/simulation/nodes/node_sim_set_particle_attribute.cc
===================================================================
diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c
index 373701b6603..f1257769e66 100644
--- a/source/blender/editors/space_node/drawnode.c
+++ b/source/blender/editors/space_node/drawnode.c
@@ -3139,6 +3139,13 @@ static void node_simulation_buts_particle_attribute(uiLayout *layout,
uiItemR(layout, ptr, "data_type", 0, "", ICON_NONE);
}
+static void node_simulation_buts_set_particle_attribute(uiLayout *layout,
+ bContext *UNUSED(C),
+ PointerRNA *ptr)
+{
+ uiItemR(layout, ptr, "data_type", 0, "", ICON_NONE);
+}
+
static void node_simulation_set_butfunc(bNodeType *ntype)
{
switch (ntype->type) {
@@ -3148,6 +3155,9 @@ static void node_simulation_set_butfunc(bNodeType *ntype)
case SIM_NODE_PARTICLE_ATTRIBUTE:
ntype->draw_buttons = node_simulation_buts_particle_attribute;
break;
+ case SIM_NODE_SET_PARTICLE_ATTRIBUTE:
+ ntype->draw_buttons = node_simulation_buts_set_particle_attribute;
+ break;
}
}
diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c
index 48a5c46e560..6294893207d 100644
--- a/source/blender/makesrna/intern/rna_nodetree.c
+++ b/source/blender/makesrna/intern/rna_nodetree.c
@@ -8044,6 +8044,20 @@ static void def_sim_particle_attribute(StructRNA *srna)
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_SimulationNode_socket_update");
}
+static void def_sim_set_particle_attribute(StructRNA *srna)
+{
+ PropertyRNA *prop;
+
+ prop = RNA_def_property(srna, "data_type", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_sdna(prop, NULL, "custom1");
+ RNA_def_property_enum_items(prop, node_socket_particle_attribute_types);
+ RNA_def_property_ui_text(
+ prop,
+ "Data Type",
+ "Expected type of the attribute. Nothing is done if the type is not correct");
+ RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_SimulationNode_socket_update");
+}
+
/* -------------------------------------------------------------------------- */
static void rna_def_shader_node(BlenderRNA *brna)
diff --git a/source/blender/nodes/NOD_static_types.h b/source/blender/nodes/NOD_static_types.h
index d0515df84f8..bb36c197823 100644
--- a/source/blender/nodes/NOD_static_types.h
+++ b/source/blender/nodes/NOD_static_types.h
@@ -260,7 +260,7 @@ DefNode(TextureNode, TEX_NODE_PROC+TEX_DISTNOISE, 0, "TEX_DI
DefNode(SimulationNode, SIM_NODE_PARTICLE_SIMULATION, 0, "PARTICLE_SIMULATION", ParticleSimulation, "Particle Simulation", "")
DefNode(SimulationNode, SIM_NODE_FORCE, 0, "FORCE", Force, "Force", "")
-DefNode(SimulationNode, SIM_NODE_SET_PARTICLE_ATTRIBUTE, 0, "SET_PARTICLE_ATTRIBUTE", SetParticleAttribute, "Set Particle Attribute", "")
+DefNode(SimulationNode, SIM_NODE_SET_PARTICLE_ATTRIBUTE, def_sim_set_particle_attribute, "SET_PARTICLE_ATTRIBUTE", SetParticleAttribute, "Set Particle Attribute", "")
DefNode(SimulationNode, SIM_NODE_PARTICLE_BIRTH_EVENT, 0, "PARTICLE_BIRTH_EVENT", ParticleBirthEvent, "Particle Birth Event", "")
DefNode(SimulationNode, SIM_NODE_PARTICLE_TIME_STEP_EVENT, def_sim_particle_time_step_event, "PARTICLE_TIME_STEP_EVENT", ParticleTimeStepEvent, "Particle Time Step Event", "")
DefNode(SimulationNode, SIM_NODE_EXECUTE_CONDITION, 0, "EXECUTE_CONDITION", ExecuteCondition, "Execute Condition", "")
diff --git a/source/blender/nodes/simulation/nodes/node_sim_set_particle_attribute.cc b/source/blender/nodes/simulation/nodes/node_sim_set_particle_attribute.cc
index 1cb3bf564c5..f72d2d261ab 100644
--- a/source/blender/nodes/simulation/nodes/node_sim_set_particle_attribute.cc
+++ b/source/blender/nodes/simulation/nodes/node_sim_set_particle_attribute.cc
@@ -1,8 +1,16 @@
#include "node_sim_util.h"
+#include "BLI_listbase.h"
static bNodeSocketTemplate sim_node_set_particle_attribute_in[] = {
{SOCK_STRING, N_("Name")},
- {SOCK_FLOAT, N_("Value"), 0.0f, 0.0f, 0.0f, 0.0f, -10000.0f, 10000.0f},
+ {SOCK_FLOAT, N_("Float"), 0.0f, 0.0f, 0.0f, 0.0f, -10000.0f, 10000.0f},
+ {SOCK_INT, N_("Int"), 0, 0, 0, 0, -10000, 10000},
+ {SOCK_BOOLEAN, N_("Boolean")},
+ {SOCK_VECTOR, N_("Vector")},
+ {SOCK_RGBA, N_("Color")},
+ {SOCK_OBJECT, N_("Object")},
+ {SOCK_IMAGE, N_("Image")},
+ {SOCK_SURFACE_HOOK, N_("Surface Hook")},
{-1, ""},
};
@@ -11,6 +19,13 @@ static bNodeSocketTemplate sim_node_set_particle_attribute_out[] = {
{-1, ""},
};
+static void sim_node_set_particle_attribute_update(bNodeTree *UNUSED(ntree), bNode *node)
+{
+ LISTBASE_FOREACH (bNodeSocket *, sock, &node->inputs) {
+ nodeSetSocketAvailability(sock, sock->type == node->custom1);
+ }
+}
+
void register_node_type_sim_set_particle_attribute()
{
static bNodeType ntype;
@@ -18,5 +33,6 @@ void register_node_type_sim_set_particle_attribute()
sim_node_type_base(&ntype, SIM_NODE_SET_PARTICLE_ATTRIBUTE, "Set Particle Attribute", 0, 0);
node_type_socket_templates(
&ntype, sim_node_set_particle_attribute_in, sim_node_set_particle_attribute_out);
+ node_type_update(&ntype, sim_node_set_particle_attribute_update);
nodeRegisterType(&ntype);
}
More information about the Bf-blender-cvs
mailing list