[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [33125] branches/particles-2010/source/ blender: Added constant value nodes.

Lukas Toenne lukas.toenne at googlemail.com
Wed Nov 17 12:06:01 CET 2010


Revision: 33125
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=33125
Author:   lukastoenne
Date:     2010-11-17 12:06:01 +0100 (Wed, 17 Nov 2010)

Log Message:
-----------
Added constant value nodes. These are useful when using the same input for a couple of different nodes. Excluded from this are surface points (and possible future types), for which there is no useful numerical description and/or button type.

Modified Paths:
--------------
    branches/particles-2010/source/blender/blenkernel/BKE_node.h
    branches/particles-2010/source/blender/blenkernel/intern/node.c
    branches/particles-2010/source/blender/editors/space_node/drawnode.c
    branches/particles-2010/source/blender/makesdna/DNA_node_types.h
    branches/particles-2010/source/blender/makesrna/intern/rna_nodetree.c
    branches/particles-2010/source/blender/makesrna/intern/rna_nodetree_types.h
    branches/particles-2010/source/blender/nodes/CMakeLists.txt
    branches/particles-2010/source/blender/nodes/SIM_node.h
    branches/particles-2010/source/blender/nodes/intern/SIM_util.h

Modified: branches/particles-2010/source/blender/blenkernel/BKE_node.h
===================================================================
--- branches/particles-2010/source/blender/blenkernel/BKE_node.h	2010-11-17 09:45:45 UTC (rev 33124)
+++ branches/particles-2010/source/blender/blenkernel/BKE_node.h	2010-11-17 11:06:01 UTC (rev 33125)
@@ -593,6 +593,14 @@
 #define SIM_NODE_INDEX				752
 #define SIM_NODE_TIMESTEP			753
 #define SIM_NODE_RANDOM				754
+#define SIM_NODE_CONSTFLOAT			770
+#define SIM_NODE_CONSTINT			771
+#define SIM_NODE_CONSTBOOL			772
+#define SIM_NODE_CONSTVECTOR		773
+#define SIM_NODE_CONSTRGBA			774
+#define SIM_NODE_CONSTQUAT			775
+#define SIM_NODE_CONSTMATRIX		776
+#define SIM_NODE_CONSTSTRING		777
 
 /* particles */
 #define SIM_NODE_ADDPARTICLE		800

Modified: branches/particles-2010/source/blender/blenkernel/intern/node.c
===================================================================
--- branches/particles-2010/source/blender/blenkernel/intern/node.c	2010-11-17 09:45:45 UTC (rev 33124)
+++ branches/particles-2010/source/blender/blenkernel/intern/node.c	2010-11-17 11:06:01 UTC (rev 33125)
@@ -2562,6 +2562,7 @@
 	nodeRegisterSimIndex(ntypelist);
 	nodeRegisterSimTimeStep(ntypelist);
 	nodeRegisterSimRandom(ntypelist);
+	nodeRegisterSimConstants(ntypelist);
 	nodeRegisterSimDebugPrint(ntypelist);
 
 	nodeRegisterSimAddParticle(ntypelist);

Modified: branches/particles-2010/source/blender/editors/space_node/drawnode.c
===================================================================
--- branches/particles-2010/source/blender/editors/space_node/drawnode.c	2010-11-17 09:45:45 UTC (rev 33124)
+++ branches/particles-2010/source/blender/editors/space_node/drawnode.c	2010-11-17 11:06:01 UTC (rev 33125)
@@ -1520,6 +1520,40 @@
 	uiItemR(col, ptr, "distribution", 0, NULL, 0);
 }
 
+static void node_simulation_buts_constant(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
+{
+	bNode *node= ptr->data;
+	uiLayout *col;
+	
+	col = uiLayoutColumn(layout, 0);
+	switch (node->type) {
+	case SIM_NODE_CONSTFLOAT:
+		uiItemR(col, ptr, "value_float", 0, NULL, 0);
+		break;
+	case SIM_NODE_CONSTINT:
+		uiItemR(col, ptr, "value_int", 0, NULL, 0);
+		break;
+	case SIM_NODE_CONSTBOOL:
+		uiItemR(col, ptr, "value_bool", 0, NULL, 0);
+		break;
+	case SIM_NODE_CONSTVECTOR:
+		uiItemR(col, ptr, "value_vector", 0, NULL, 0);
+		break;
+	case SIM_NODE_CONSTRGBA:
+		uiItemR(col, ptr, "value_rgba", 0, NULL, 0);
+		break;
+	case SIM_NODE_CONSTQUAT:
+		uiItemR(col, ptr, "value_quat", 0, NULL, 0);
+		break;
+	case SIM_NODE_CONSTMATRIX:
+		uiItemR(col, ptr, "value_matrix", 0, NULL, 0);
+		break;
+	case SIM_NODE_CONSTSTRING:
+		uiItemR(col, ptr, "value_string", 0, NULL, 0);
+		break;
+	}
+}
+
 static void node_simulation_buts_while(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
 {
 	uiLayout *col;
@@ -1565,6 +1599,16 @@
 	case SIM_NODE_RANDOM:
 		ntype->uifunc = node_simulation_buts_random;
 		break;
+	case SIM_NODE_CONSTFLOAT:
+	case SIM_NODE_CONSTINT:
+	case SIM_NODE_CONSTBOOL:
+	case SIM_NODE_CONSTVECTOR:
+	case SIM_NODE_CONSTRGBA:
+	case SIM_NODE_CONSTQUAT:
+	case SIM_NODE_CONSTMATRIX:
+	case SIM_NODE_CONSTSTRING:
+		ntype->uifunc = node_simulation_buts_constant;
+		break;
 	case SIM_NODE_WHILE:
 		ntype->uifunc = node_simulation_buts_while;
 		break;

Modified: branches/particles-2010/source/blender/makesdna/DNA_node_types.h
===================================================================
--- branches/particles-2010/source/blender/makesdna/DNA_node_types.h	2010-11-17 09:45:45 UTC (rev 33124)
+++ branches/particles-2010/source/blender/makesdna/DNA_node_types.h	2010-11-17 11:06:01 UTC (rev 33125)
@@ -391,6 +391,10 @@
 	char name[32];
 } TexNodeOutput;
 
+/**** Simulation Nodes ****/
+
+#define SIM_STRINGLENGTH		128
+
 /* stores associated properties for GetData/SetData node sockets */
 typedef struct SimDataNodeSocket {
 	int type;						/* type of property */
@@ -406,6 +410,21 @@
 	char propsearch[128];			/* used as search string when adding property sockets */
 } SimDataNode;
 
+/* Data values for the constant node.
+ * Has all data types to be able to have just one storage struct for each type.
+ */
+typedef struct SimNodeConstant {
+	float value_float;
+	int value_int;
+	char value_bool;
+	char pad[3];
+	float value_vector[3];
+	float value_rgba[4];
+	float value_quat[4];
+	float value_matrix[4][4];
+	char value_string[SIM_STRINGLENGTH];
+} SimNodeConstant;
+
 /* comp channel matte */
 #define CMP_NODE_CHANNEL_MATTE_CS_RGB	1
 #define CMP_NODE_CHANNEL_MATTE_CS_HSV	2

Modified: branches/particles-2010/source/blender/makesrna/intern/rna_nodetree.c
===================================================================
--- branches/particles-2010/source/blender/makesrna/intern/rna_nodetree.c	2010-11-17 09:45:45 UTC (rev 33124)
+++ branches/particles-2010/source/blender/makesrna/intern/rna_nodetree.c	2010-11-17 11:06:01 UTC (rev 33125)
@@ -2324,6 +2324,59 @@
 	RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
 }
 
+static void def_sim_constant(StructRNA *srna)
+{
+	PropertyRNA *prop;
+	int matrix_dimsize[]= {4, 4};
+
+	RNA_def_struct_sdna_from(srna, "SimNodeConstant", "storage");
+
+	prop = RNA_def_property(srna, "value_float", PROP_FLOAT, PROP_NONE);
+	RNA_def_property_float_sdna(prop, NULL, "value_float");
+	RNA_def_property_ui_text(prop, "Value", "");
+	RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
+
+	prop = RNA_def_property(srna, "value_int", PROP_INT, PROP_NONE);
+	RNA_def_property_int_sdna(prop, NULL, "value_int");
+	RNA_def_property_ui_text(prop, "Value", "");
+	RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
+
+	prop = RNA_def_property(srna, "value_bool", PROP_BOOLEAN, PROP_NONE);
+	RNA_def_property_boolean_sdna(prop, NULL, "value_bool", 1);
+	RNA_def_property_ui_text(prop, "Value", "");
+	RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
+
+	prop = RNA_def_property(srna, "value_vector", PROP_FLOAT, PROP_NONE);
+	RNA_def_property_float_sdna(prop, NULL, "value_vector");
+	RNA_def_property_array(prop, 3);
+	RNA_def_property_ui_text(prop, "Value", "");
+	RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
+
+	prop = RNA_def_property(srna, "value_rgba", PROP_FLOAT, PROP_COLOR);
+	RNA_def_property_float_sdna(prop, NULL, "value_rgba");
+	RNA_def_property_array(prop, 4);
+	RNA_def_property_ui_text(prop, "Value", "");
+	RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
+
+	prop = RNA_def_property(srna, "value_quat", PROP_FLOAT, PROP_QUATERNION);
+	RNA_def_property_float_sdna(prop, NULL, "value_quat");
+	RNA_def_property_array(prop, 4);
+	RNA_def_property_ui_text(prop, "Value", "");
+	RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
+
+	prop = RNA_def_property(srna, "value_matrix", PROP_FLOAT, PROP_MATRIX);
+	RNA_def_property_float_sdna(prop, NULL, "value_matrix");
+	RNA_def_property_multi_array(prop, 2, matrix_dimsize);
+	RNA_def_property_ui_text(prop, "Value", "");
+	RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
+
+	prop = RNA_def_property(srna, "value_string", PROP_STRING, PROP_NONE);
+	RNA_def_property_string_sdna(prop, NULL, "value_string");
+	RNA_def_property_string_maxlength(prop, SIM_STRINGLENGTH);
+	RNA_def_property_ui_text(prop, "Value", "");
+	RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
+}
+
 static void def_sim_while(StructRNA *srna)
 {
 	PropertyRNA *prop;

Modified: branches/particles-2010/source/blender/makesrna/intern/rna_nodetree_types.h
===================================================================
--- branches/particles-2010/source/blender/makesrna/intern/rna_nodetree_types.h	2010-11-17 09:45:45 UTC (rev 33124)
+++ branches/particles-2010/source/blender/makesrna/intern/rna_nodetree_types.h	2010-11-17 11:06:01 UTC (rev 33125)
@@ -174,3 +174,11 @@
 DefNode( SimulationNode, SIM_NODE_ADDPARTICLEFORCE, 0,                    "ADDPARTICLEFORCE", AddParticleForce, "Add Particle Force", ""            )
 DefNode( SimulationNode, SIM_NODE_TIMESTEP,       0,                      "TIMESTEP",       TimeStep,         "Time Step",         ""              )
 DefNode( SimulationNode, SIM_NODE_DEBUGPRINT,     0,                      "DEBUGPRINT",     DebugPrint,       "Debug Print",       ""              )
+DefNode( SimulationNode, SIM_NODE_CONSTFLOAT,     def_sim_constant,       "CONSTFLOAT",     ConstFloat,       "Float",             ""              )
+DefNode( SimulationNode, SIM_NODE_CONSTINT,       def_sim_constant,       "CONSTINT",       ConstInt,         "Integer",           ""              )
+DefNode( SimulationNode, SIM_NODE_CONSTBOOL,      def_sim_constant,       "CONSTBOOL",      ConstBool,        "Boolean",           ""              )
+DefNode( SimulationNode, SIM_NODE_CONSTVECTOR,    def_sim_constant,       "CONSTVECTOR",    ConstVector,      "Vector",            ""              )
+DefNode( SimulationNode, SIM_NODE_CONSTRGBA,      def_sim_constant,       "CONSTRGBA",      ConstRGBA,        "Color",             ""              )
+DefNode( SimulationNode, SIM_NODE_CONSTQUAT,      def_sim_constant,       "CONSTQUAT",      ConstQuat,        "Quaternion",        ""              )
+DefNode( SimulationNode, SIM_NODE_CONSTMATRIX,    def_sim_constant,       "CONSTMATRIX",    ConstMatrix,      "Matrix",            ""              )
+DefNode( SimulationNode, SIM_NODE_CONSTSTRING,    def_sim_constant,       "CONSTSTRING",    ConstString,      "String",            ""              )

Modified: branches/particles-2010/source/blender/nodes/CMakeLists.txt
===================================================================
--- branches/particles-2010/source/blender/nodes/CMakeLists.txt	2010-11-17 09:45:45 UTC (rev 33124)
+++ branches/particles-2010/source/blender/nodes/CMakeLists.txt	2010-11-17 11:06:01 UTC (rev 33125)
@@ -143,6 +143,7 @@
 	intern/TEX_util.c
 	intern/SIM_nodes/SIM_add_particle.c
 	intern/SIM_nodes/SIM_add_particle_force.c
+	intern/SIM_nodes/SIM_constant.c
 	intern/SIM_nodes/SIM_debugprint.c
 	intern/SIM_nodes/SIM_filter.c
 	intern/SIM_nodes/SIM_for.c

Modified: branches/particles-2010/source/blender/nodes/SIM_node.h
===================================================================
--- branches/particles-2010/source/blender/nodes/SIM_node.h	2010-11-17 09:45:45 UTC (rev 33124)

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list