[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [30578] branches/particles-2010/source/ blender: Added scalar math nodes.

Lukas Toenne lukas.toenne at googlemail.com
Wed Jul 21 12:49:36 CEST 2010


Revision: 30578
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=30578
Author:   lukastoenne
Date:     2010-07-21 12:49:36 +0200 (Wed, 21 Jul 2010)

Log Message:
-----------
Added scalar math nodes. In contrast to math nodes in other tree types, the simulation math nodes are not crammed into a single node type, but implemented as individual nodes.

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/node_header.c
    branches/particles-2010/source/blender/makesrna/intern/rna_nodetree_types.h
    branches/particles-2010/source/blender/nodes/SIM_node.h
    branches/particles-2010/source/blender/nodes/intern/SIM_nodes/SIM_debugprint.c
    branches/particles-2010/source/blender/nodes/intern/SIM_nodes/SIM_get_object_data.c
    branches/particles-2010/source/blender/nodes/intern/SIM_nodes/SIM_if.c
    branches/particles-2010/source/blender/nodes/intern/SIM_util.c
    branches/particles-2010/source/blender/nodes/intern/SIM_util.h

Added Paths:
-----------
    branches/particles-2010/source/blender/nodes/intern/SIM_nodes/SIM_for.c
    branches/particles-2010/source/blender/nodes/intern/SIM_nodes/SIM_math.c
    branches/particles-2010/source/blender/nodes/intern/SIM_nodes/SIM_vector_compose.c
    branches/particles-2010/source/blender/nodes/intern/SIM_nodes/SIM_vector_decompose.c

Modified: branches/particles-2010/source/blender/blenkernel/BKE_node.h
===================================================================
--- branches/particles-2010/source/blender/blenkernel/BKE_node.h	2010-07-21 10:44:46 UTC (rev 30577)
+++ branches/particles-2010/source/blender/blenkernel/BKE_node.h	2010-07-21 10:49:36 UTC (rev 30578)
@@ -148,6 +148,7 @@
 #define NODE_CLASS_PATTERN 12
 #define NODE_CLASS_TEXTURE 13
 #define NODE_CLASS_SIMULATION	14
+#define NODE_CLASS_MATH			15
 
 /* ************** GENERIC API, TREES *************** */
 
@@ -470,16 +471,44 @@
 /* range 1 - 100 is reserved for common nodes */
 /* using toolbox, we add node groups by assuming the values below don't exceed NODE_GROUP_MENU for now */
 
+/* control structures */
 #define SIM_NODE_PROGRAM			601
 #define SIM_NODE_SUBPROGRAM			602
-#define SIM_NODE_IF					603
-#define SIM_NODE_TIMESTEP			604
-#define SIM_NODE_PASS				605
-#define SIM_NODE_GETOBJECTDATA		606
-#define SIM_NODE_SETOBJECTDATA		607
+#define SIM_NODE_PASS				603
+#define SIM_NODE_IF					604
+#define SIM_NODE_FOR				605
 
-#define SIM_NODE_DEBUGPRINT	699
+/* scalar math */
+#define SIM_NODE_SCALAR_ADD			650
+#define SIM_NODE_SCALAR_SUBTRACT	651
+#define SIM_NODE_SCALAR_MULTIPLY	652
+#define SIM_NODE_SCALAR_DIVIDE		653
+#define SIM_NODE_SINE				654
+#define SIM_NODE_COSINE				655
+#define SIM_NODE_TANGENT			656
+#define SIM_NODE_ARCSINE			657
+#define SIM_NODE_ARCCOSINE			658
+#define SIM_NODE_ARCTANGENT			659
+#define SIM_NODE_POWER				660
+#define SIM_NODE_LOGARITHM			661
+#define SIM_NODE_MINIMUM			662
+#define SIM_NODE_MAXIMUM			663
+#define SIM_NODE_ROUND				664
+#define SIM_NODE_LESSTHAN			665
+#define SIM_NODE_GREATERTHAN		666
 
+/* vector math */
+#define SIM_NODE_VECTORCOMPOSE		700
+#define SIM_NODE_VECTORDECOMPOSE	701
+
+/* data input/output */
+#define SIM_NODE_TIMESTEP			750
+#define SIM_NODE_GETOBJECTDATA		751
+#define SIM_NODE_SETOBJECTDATA		752
+
+/* TO BE REMOVED: debugging stuff, testing, etc. */
+#define SIM_NODE_DEBUGPRINT			801
+
 /* API */
 void ntreeSimulationExecTree(struct SimulationContext *sim, int thread);
 

Modified: branches/particles-2010/source/blender/blenkernel/intern/node.c
===================================================================
--- branches/particles-2010/source/blender/blenkernel/intern/node.c	2010-07-21 10:44:46 UTC (rev 30577)
+++ branches/particles-2010/source/blender/blenkernel/intern/node.c	2010-07-21 10:49:36 UTC (rev 30578)
@@ -1115,13 +1115,10 @@
 				valid = 1;
 				/* int and float implicitely convertible */
 			}
-			else if (ELEM(fromtype, SOCK_INT, SOCK_FLOAT) && ELEM(totype, SOCK_INT, SOCK_FLOAT)) {
+			else if (ELEM3(fromtype, SOCK_INT, SOCK_FLOAT, SOCK_BOOL) && ELEM3(totype, SOCK_INT, SOCK_FLOAT, SOCK_BOOL)) {
 				valid = 1;
 			}
-			/* int and float can be converted to boolean */
-			else if (ELEM(fromtype, SOCK_INT, SOCK_FLOAT) && totype == SOCK_BOOL) {
-				valid = 1;
-			}
+			/* by default only allow perfect type matches */
 			else {
 				valid = (fromtype == totype);
 			}
@@ -2614,12 +2611,36 @@
 {
 	nodeRegisterType(ntypelist, &sim_node_program);
 	nodeRegisterType(ntypelist, &sim_node_subprogram);
+	nodeRegisterType(ntypelist, &sim_node_pass);
 	nodeRegisterType(ntypelist, &sim_node_if);
-	nodeRegisterType(ntypelist, &sim_node_pass);
+	nodeRegisterType(ntypelist, &sim_node_for);
+
+	nodeRegisterType(ntypelist, &sim_node_scalar_add);
+	nodeRegisterType(ntypelist, &sim_node_scalar_subtract);
+	nodeRegisterType(ntypelist, &sim_node_scalar_multiply);
+	nodeRegisterType(ntypelist, &sim_node_scalar_divide);
+	nodeRegisterType(ntypelist, &sim_node_sine);
+	nodeRegisterType(ntypelist, &sim_node_cosine);
+	nodeRegisterType(ntypelist, &sim_node_tangent);
+	nodeRegisterType(ntypelist, &sim_node_arcsine);
+	nodeRegisterType(ntypelist, &sim_node_arccosine);
+	nodeRegisterType(ntypelist, &sim_node_arctangent);
+	nodeRegisterType(ntypelist, &sim_node_power);
+	nodeRegisterType(ntypelist, &sim_node_logarithm);
+	nodeRegisterType(ntypelist, &sim_node_minimum);
+	nodeRegisterType(ntypelist, &sim_node_maximum);
+	nodeRegisterType(ntypelist, &sim_node_round);
+	nodeRegisterType(ntypelist, &sim_node_lessthan);
+	nodeRegisterType(ntypelist, &sim_node_greaterthan);
+
+	nodeRegisterType(ntypelist, &sim_node_vector_compose);
+	nodeRegisterType(ntypelist, &sim_node_vector_decompose);
+
 	nodeRegisterType(ntypelist, &sim_node_timestep);
-	nodeRegisterType(ntypelist, &sim_node_debugprint);
 	nodeRegisterType(ntypelist, &sim_node_getobjectdata);
 	nodeRegisterType(ntypelist, &sim_node_setobjectdata);
+
+	nodeRegisterType(ntypelist, &sim_node_debugprint);
 }
 
 static void remove_dynamic_typeinfos(ListBase *list)

Modified: branches/particles-2010/source/blender/editors/space_node/node_header.c
===================================================================
--- branches/particles-2010/source/blender/editors/space_node/node_header.c	2010-07-21 10:44:46 UTC (rev 30577)
+++ branches/particles-2010/source/blender/editors/space_node/node_header.c	2010-07-21 10:49:36 UTC (rev 30578)
@@ -194,6 +194,7 @@
 		uiItemMenuF(layout, "Input", 0, node_auto_add_menu, SET_INT_IN_POINTER(NODE_CLASS_INPUT));
 		uiItemMenuF(layout, "Output", 0, node_auto_add_menu, SET_INT_IN_POINTER(NODE_CLASS_OUTPUT));
 		uiItemMenuF(layout, "Simulation", 0, node_auto_add_menu, SET_INT_IN_POINTER(NODE_CLASS_SIMULATION));
+		uiItemMenuF(layout, "Math", 0, node_auto_add_menu, SET_INT_IN_POINTER(NODE_CLASS_MATH));
 	}
 }
 

Modified: branches/particles-2010/source/blender/makesrna/intern/rna_nodetree_types.h
===================================================================
--- branches/particles-2010/source/blender/makesrna/intern/rna_nodetree_types.h	2010-07-21 10:44:46 UTC (rev 30577)
+++ branches/particles-2010/source/blender/makesrna/intern/rna_nodetree_types.h	2010-07-21 10:49:36 UTC (rev 30578)
@@ -135,8 +135,28 @@
 
 DefNode( SimulationNode, SIM_NODE_PROGRAM,        0,                      "PROGRAM",        Program,          "Program",           ""              )
 DefNode( SimulationNode, SIM_NODE_SUBPROGRAM,     0,                      "SUBPROGRAM",     SubProgram,       "SubProgram",        ""              )
+DefNode( SimulationNode, SIM_NODE_PASS,           0,                      "PASS",           Pass,             "Pass",              ""              )
 DefNode( SimulationNode, SIM_NODE_IF,             0,                      "IF",             If,               "If",                ""              )
-DefNode( SimulationNode, SIM_NODE_PASS,           0,                      "PASS",           Pass,             "Pass",              ""              )
+DefNode( SimulationNode, SIM_NODE_FOR,            0,                      "FOR",            For,              "For",               ""              )
+DefNode( SimulationNode, SIM_NODE_SCALAR_ADD,     0,                      "SCALAR_ADD",     ScalarAdd,        "Add",               ""              )
+DefNode( SimulationNode, SIM_NODE_SCALAR_SUBTRACT, 0,                     "SCALAR_SUBTRACT", ScalarSubtract,  "Subtract",          ""              )
+DefNode( SimulationNode, SIM_NODE_SCALAR_MULTIPLY, 0,                     "SCALAR_MULTIPLY", ScalarMultiply,  "Multiply",          ""              )
+DefNode( SimulationNode, SIM_NODE_SCALAR_DIVIDE,  0,                      "SCALAR_DIVIDE",  ScalarDivide,     "Divide",            ""              )
+DefNode( SimulationNode, SIM_NODE_SINE,           0,                      "SINE",           Sine,             "Sine",              ""              )
+DefNode( SimulationNode, SIM_NODE_COSINE,         0,                      "COSINE",         Cosine,           "Cosine",            ""              )
+DefNode( SimulationNode, SIM_NODE_TANGENT,        0,                      "TANGENT",        Tangent,          "Tangent",           ""              )
+DefNode( SimulationNode, SIM_NODE_ARCSINE,        0,                      "ARCSINE",        Arcsine,          "Arcsine",           ""              )
+DefNode( SimulationNode, SIM_NODE_ARCCOSINE,      0,                      "ARCCOSINE",      Arccosine,        "Arccosine",         ""              )
+DefNode( SimulationNode, SIM_NODE_ARCTANGENT,     0,                      "ARCTANGENT",     Arctangent,       "Arctangent",        ""              )
+DefNode( SimulationNode, SIM_NODE_POWER,          0,                      "POWER",          Power,            "Power",             ""              )
+DefNode( SimulationNode, SIM_NODE_LOGARITHM,      0,                      "LOGARITHM",      Logarithm,        "Logarithm",         ""              )
+DefNode( SimulationNode, SIM_NODE_MINIMUM,        0,                      "MINIMUM",        Minimum,          "Minimum",           ""              )
+DefNode( SimulationNode, SIM_NODE_MAXIMUM,        0,                      "MAXIMUM",        Maximum,          "Maximum",           ""              )
+DefNode( SimulationNode, SIM_NODE_ROUND,          0,                      "ROUND",          Round,            "Round",             ""              )
+DefNode( SimulationNode, SIM_NODE_LESSTHAN,       0,                      "LESSTHAN",       LessThan,         "Less",              ""              )
+DefNode( SimulationNode, SIM_NODE_GREATERTHAN,    0,                      "GREATERTHAN",    GreaterThan,      "Greater",           ""              )
+DefNode( SimulationNode, SIM_NODE_VECTORCOMPOSE,  0,                      "VECTORCOMPOSE",  VectorCompose,    "VectorCompose",     ""              )
+DefNode( SimulationNode, SIM_NODE_VECTORDECOMPOSE, 0,                     "VECTORDECOMPOSE", VectorDecompose, "VectorDecompose",   ""              )
 DefNode( SimulationNode, SIM_NODE_GETOBJECTDATA,  def_sim_getobjectdata,  "GETOBJECTDATA",  GetObjectData,    "Get Object Data",   ""              )
 DefNode( SimulationNode, SIM_NODE_SETOBJECTDATA,  def_sim_setobjectdata,  "SETOBJECTDATA",  SetObjectData,    "Set Object Data",   ""              )
 DefNode( SimulationNode, SIM_NODE_TIMESTEP,       0,                      "TIMESTEP",       TimeStep,         "Time Step",         ""              )

Modified: branches/particles-2010/source/blender/nodes/SIM_node.h
===================================================================
--- branches/particles-2010/source/blender/nodes/SIM_node.h	2010-07-21 10:44:46 UTC (rev 30577)
+++ branches/particles-2010/source/blender/nodes/SIM_node.h	2010-07-21 10:49:36 UTC (rev 30578)

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list