[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [31536] branches/particles-2010/source/ blender: Added a few vector math nodes and a vector math category.
Lukas Toenne
lukas.toenne at googlemail.com
Mon Aug 23 19:06:22 CEST 2010
Revision: 31536
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=31536
Author: lukastoenne
Date: 2010-08-23 19:06:22 +0200 (Mon, 23 Aug 2010)
Log Message:
-----------
Added a few vector math nodes and a vector math category.
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_draw.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/node_tree_simulation.c
Added Paths:
-----------
branches/particles-2010/source/blender/nodes/intern/SIM_nodes/SIM_vectormath.c
Modified: branches/particles-2010/source/blender/blenkernel/BKE_node.h
===================================================================
--- branches/particles-2010/source/blender/blenkernel/BKE_node.h 2010-08-23 13:50:09 UTC (rev 31535)
+++ branches/particles-2010/source/blender/blenkernel/BKE_node.h 2010-08-23 17:06:22 UTC (rev 31536)
@@ -147,6 +147,7 @@
#define NODE_CLASS_TEXTURE 13
#define NODE_CLASS_SIMULATION 14
#define NODE_CLASS_MATH 15
+#define NODE_CLASS_VECTORMATH 16
typedef void (*bNodeTreeCallback)(void *calldata, struct ID *owner_id, struct bNodeTree *ntree);
typedef struct bNodeTreeTypeInfo
@@ -528,6 +529,9 @@
/* vector math */
#define SIM_NODE_VECTORCOMPOSE 700
#define SIM_NODE_VECTORDECOMPOSE 701
+#define SIM_NODE_VECTORLENGTH 702
+#define SIM_NODE_DOTPRODUCT 703
+#define SIM_NODE_CROSSPRODUCT 704
/* data input/output */
#define SIM_NODE_TIMESTEP 750
Modified: branches/particles-2010/source/blender/blenkernel/intern/node.c
===================================================================
--- branches/particles-2010/source/blender/blenkernel/intern/node.c 2010-08-23 13:50:09 UTC (rev 31535)
+++ branches/particles-2010/source/blender/blenkernel/intern/node.c 2010-08-23 17:06:22 UTC (rev 31536)
@@ -2960,6 +2960,9 @@
nodeRegisterType(ntypelist, &sim_node_vector_compose);
nodeRegisterType(ntypelist, &sim_node_vector_decompose);
+ nodeRegisterType(ntypelist, &sim_node_vectorlength);
+ nodeRegisterType(ntypelist, &sim_node_dotproduct);
+ nodeRegisterType(ntypelist, &sim_node_crossproduct);
nodeRegisterType(ntypelist, &sim_node_timestep);
nodeRegisterType(ntypelist, &sim_node_getobjectdata);
Modified: branches/particles-2010/source/blender/editors/space_node/node_draw.c
===================================================================
--- branches/particles-2010/source/blender/editors/space_node/node_draw.c 2010-08-23 13:50:09 UTC (rev 31535)
+++ branches/particles-2010/source/blender/editors/space_node/node_draw.c 2010-08-23 17:06:22 UTC (rev 31536)
@@ -581,7 +581,7 @@
col[0]= 30; col[1]= 30; col[2]= 30;
}
else if(sock->type==SOCK_INT) {
- col[0]= 96; col[1]= 215; col[2]= 96;
+ col[0]= 86; col[1]= 185; col[2]= 86;
}
else if(sock->type==SOCK_FLOAT) {
col[0]= 124; col[1]= 242; col[2]= 154;
Modified: branches/particles-2010/source/blender/editors/space_node/node_header.c
===================================================================
--- branches/particles-2010/source/blender/editors/space_node/node_header.c 2010-08-23 13:50:09 UTC (rev 31535)
+++ branches/particles-2010/source/blender/editors/space_node/node_header.c 2010-08-23 17:06:22 UTC (rev 31536)
@@ -192,6 +192,7 @@
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));
+ uiItemMenuF(layout, "Vector Math", 0, node_auto_add_menu, SET_INT_IN_POINTER(NODE_CLASS_VECTORMATH));
uiItemMenuF(layout, "Group", 0, node_auto_add_menu, SET_INT_IN_POINTER(NODE_CLASS_GROUP));
}
}
Modified: branches/particles-2010/source/blender/makesrna/intern/rna_nodetree_types.h
===================================================================
--- branches/particles-2010/source/blender/makesrna/intern/rna_nodetree_types.h 2010-08-23 13:50:09 UTC (rev 31535)
+++ branches/particles-2010/source/blender/makesrna/intern/rna_nodetree_types.h 2010-08-23 17:06:22 UTC (rev 31536)
@@ -158,6 +158,9 @@
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_VECTORLENGTH, 0, "VECTORLENGTH", VectorLength, "VectorLength", "" )
+DefNode( SimulationNode, SIM_NODE_DOTPRODUCT, 0, "DOTPRODUCT", DotProduct, "DotProduct", "" )
+DefNode( SimulationNode, SIM_NODE_CROSSPRODUCT, 0, "CROSSPRODUCT", CrossProduct, "CrossProduct", "" )
DefNode( SimulationNode, SIM_NODE_GETOBJECTDATA, def_sim_objectnode, "GETOBJECTDATA", GetObjectData, "Get Object Data", "" )
DefNode( SimulationNode, SIM_NODE_SETOBJECTDATA, def_sim_objectnode, "SETOBJECTDATA", SetObjectData, "Set Object Data", "" )
DefNode( SimulationNode, SIM_NODE_GETVERTEXDATA, def_sim_objectnode, "GETVERTEXDATA", GetVertexData, "Get Vertex Data", "" )
Modified: branches/particles-2010/source/blender/nodes/SIM_node.h
===================================================================
--- branches/particles-2010/source/blender/nodes/SIM_node.h 2010-08-23 13:50:09 UTC (rev 31535)
+++ branches/particles-2010/source/blender/nodes/SIM_node.h 2010-08-23 17:06:22 UTC (rev 31536)
@@ -64,6 +64,9 @@
extern bNodeType sim_node_vector_compose;
extern bNodeType sim_node_vector_decompose;
+extern bNodeType sim_node_vectorlength;
+extern bNodeType sim_node_dotproduct;
+extern bNodeType sim_node_crossproduct;
extern bNodeType sim_node_timestep;
extern bNodeType sim_node_getobjectdata;
Added: branches/particles-2010/source/blender/nodes/intern/SIM_nodes/SIM_vectormath.c
===================================================================
--- branches/particles-2010/source/blender/nodes/intern/SIM_nodes/SIM_vectormath.c (rev 0)
+++ branches/particles-2010/source/blender/nodes/intern/SIM_nodes/SIM_vectormath.c 2010-08-23 17:06:22 UTC (rev 31536)
@@ -0,0 +1,149 @@
+/**
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2005 Blender Foundation.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#include "../SIM_util.h"
+
+#include "BLI_math_vector.h"
+
+/* **************** Math ******************** */
+static bNodeSocketType inputs_vector[]= {
+ { SOCK_VECTOR, 1, "Input", 1.0f, 0.0f, 0.0f, 0.0f, -1000.0f, 1000.0f},
+ { -1, 0, "" }
+};
+static bNodeSocketType inputs_binary_vector[]= {
+ { SOCK_VECTOR, 1, "A", 1.0f, 0.0f, 0.0f, 0.0f, -1000.0f, 1000.0f},
+ { SOCK_VECTOR, 1, "B", 1.0f, 0.0f, 0.0f, 0.0f, -1000.0f, 1000.0f},
+ { -1, 0, "" }
+};
+
+static bNodeSocketType outputs_float[]= {
+ { SOCK_FLOAT, 0, "Result", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
+ { -1, 0, "" }
+};
+static bNodeSocketType outputs_vector[]= {
+ { SOCK_VECTOR, 0, "Result", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
+ { -1, 0, "" }
+};
+
+static int exec_dotproduct(SimNodeThreadContext *ctx, SimNodeJob *job)
+{
+ SimNodeDataStream istream[2];
+ SimNodeDataStream ostream[1];
+
+ SIM_JOBEXEC_BEGIN(ctx, job, istream, ostream)
+ sim_ostream_write_float(ostream, 0, dot_v3v3(sim_istream_read_vector(istream, 0), sim_istream_read_vector(istream, 1)));
+ SIM_JOBEXEC_END(ctx, job)
+ return NODE_EXEC_FINISHED;
+}
+
+static int exec_crossproduct(SimNodeThreadContext *ctx, SimNodeJob *job)
+{
+ SimNodeDataStream istream[2];
+ SimNodeDataStream ostream[1];
+ float res[3];
+
+ SIM_JOBEXEC_BEGIN(ctx, job, istream, ostream)
+ cross_v3_v3v3(res, sim_istream_read_vector(istream, 0), sim_istream_read_vector(istream, 1));
+ sim_ostream_write_vector(ostream, 0, res);
+ SIM_JOBEXEC_END(ctx, job)
+ return NODE_EXEC_FINISHED;
+}
+
+static int exec_vectorlength(SimNodeThreadContext *ctx, SimNodeJob *job)
+{
+ SimNodeDataStream istream[1];
+ SimNodeDataStream ostream[1];
+
+ SIM_JOBEXEC_BEGIN(ctx, job, istream, ostream)
+ sim_ostream_write_float(ostream, 0, len_v3(sim_istream_read_vector(istream, 0)));
+ SIM_JOBEXEC_END(ctx, job)
+ return NODE_EXEC_FINISHED;
+}
+
+
+bNodeType sim_node_dotproduct = {
+ /* *next,*prev */ NULL, NULL,
+ /* type code */ SIM_NODE_DOTPRODUCT,
+ /* name */ "DotProduct",
+ /* width+range */ 120, 110, 160,
+ /* class+opts */ NODE_CLASS_VECTORMATH, 0,
+ /* input sock */ inputs_binary_vector,
+ /* output sock */ outputs_float,
+ /* storage */ "",
+ /* execfunc */ NULL,
+ /* butfunc */ NULL,
+ /* initfunc */ NULL,
+ /* freestoragefunc */ NULL,
+ /* copystoragefunc */ NULL,
+ /* id */ NULL,
+ /* pynode, pydict */ NULL, NULL,
+ /* gpufunc */ NULL,
+ /* sim_exec */ exec_dotproduct,
+ /* sim_opexec */ NULL
+};
+
+bNodeType sim_node_crossproduct = {
+ /* *next,*prev */ NULL, NULL,
+ /* type code */ SIM_NODE_CROSSPRODUCT,
+ /* name */ "CrossProduct",
+ /* width+range */ 120, 110, 160,
+ /* class+opts */ NODE_CLASS_VECTORMATH, 0,
+ /* input sock */ inputs_binary_vector,
+ /* output sock */ outputs_vector,
+ /* storage */ "",
+ /* execfunc */ NULL,
+ /* butfunc */ NULL,
+ /* initfunc */ NULL,
+ /* freestoragefunc */ NULL,
+ /* copystoragefunc */ NULL,
+ /* id */ NULL,
+ /* pynode, pydict */ NULL, NULL,
+ /* gpufunc */ NULL,
+ /* sim_exec */ exec_crossproduct,
+ /* sim_opexec */ NULL
+};
+
+bNodeType sim_node_vectorlength = {
+ /* *next,*prev */ NULL, NULL,
+ /* type code */ SIM_NODE_VECTORLENGTH,
+ /* name */ "VectorLength",
+ /* width+range */ 120, 110, 160,
+ /* class+opts */ NODE_CLASS_VECTORMATH, 0,
+ /* input sock */ inputs_vector,
+ /* output sock */ outputs_float,
+ /* storage */ "",
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list