[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [33132] branches/particles-2010/source/ blender/nodes/intern/SIM_nodes/SIM_constant.c: added missing file to svn.

Lukas Toenne lukas.toenne at googlemail.com
Wed Nov 17 15:02:36 CET 2010


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

Log Message:
-----------
added missing file to svn.

Added Paths:
-----------
    branches/particles-2010/source/blender/nodes/intern/SIM_nodes/SIM_constant.c

Added: branches/particles-2010/source/blender/nodes/intern/SIM_nodes/SIM_constant.c
===================================================================
--- branches/particles-2010/source/blender/nodes/intern/SIM_nodes/SIM_constant.c	                        (rev 0)
+++ branches/particles-2010/source/blender/nodes/intern/SIM_nodes/SIM_constant.c	2010-11-17 14:02:36 UTC (rev 33132)
@@ -0,0 +1,214 @@
+/**
+* ***** 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) 2006 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"
+
+/* **************** Constant values  ******************** */
+  
+static bNodeSocketDefinition outputs_float[]= { 
+	{ SOCK_FLOAT, 0, "Value", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f },
+	{ -1, 0, "" }
+};
+
+static bNodeSocketDefinition outputs_int[]= { 
+	{ SOCK_INT, 0, "Value", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f },
+	{ -1, 0, "" }
+};
+
+static bNodeSocketDefinition outputs_bool[]= { 
+	{ SOCK_BOOL, 0, "Value", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f },
+	{ -1, 0, "" }
+};
+
+static bNodeSocketDefinition outputs_vector[]= { 
+	{ SOCK_VECTOR, 0, "Value", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f },
+	{ -1, 0, "" }
+};
+
+static bNodeSocketDefinition outputs_rgba[]= { 
+	{ SOCK_RGBA, 0, "Value", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f },
+	{ -1, 0, "" }
+};
+
+static bNodeSocketDefinition outputs_quat[]= { 
+	{ SOCK_QUAT, 0, "Value", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f },
+	{ -1, 0, "" }
+};
+
+static bNodeSocketDefinition outputs_matrix[]= { 
+	{ SOCK_MATRIX, 0, "Value", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f },
+	{ -1, 0, "" }
+};
+
+static bNodeSocketDefinition outputs_string[]= { 
+	{ SOCK_STRING, 0, "Value", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f },
+	{ -1, 0, "" }
+};
+
+static void prepare_outputs(SimExecData *execdata, SimNodeStack *node, SimDataContext *self)
+{
+	SimDataContext ctx;
+	
+	sim_context_create(self->scene, NULL, NULL, 0, &ctx);
+	node->outstack[0].context = ctx;
+}
+
+static void init(bNode *node)
+{
+	SimNodeConstant *data= MEM_callocN(sizeof(SimNodeConstant), "SimNodeConstant storage");
+	node->storage = data;
+	
+	switch (node->type) {
+	case SIM_NODE_CONSTFLOAT:
+		data->value_float = 0.0f;
+		break;
+	case SIM_NODE_CONSTINT:
+		data->value_int = 0;
+		break;
+	case SIM_NODE_CONSTBOOL:
+		data->value_bool = 0;
+		break;
+	case SIM_NODE_CONSTVECTOR:
+		zero_v3(data->value_vector);
+		break;
+	case SIM_NODE_CONSTRGBA:
+		data->value_rgba[0]=data->value_rgba[1]=data->value_rgba[2]= 0.0f;
+		data->value_rgba[3]= 1.0f;
+		break;
+	case SIM_NODE_CONSTQUAT:
+		unit_qt(data->value_quat);
+		break;
+	case SIM_NODE_CONSTMATRIX:
+		unit_m4(data->value_matrix);
+		break;
+	case SIM_NODE_CONSTSTRING:
+		data->value_string[0] = '\0';
+		break;
+	}
+}
+
+static void enqueue(SimExecData *execdata, SimNodeStack *node, SimDataContext *self)
+{
+	SimNodeConstant *data= (SimNodeConstant*)node->base->storage;
+	SimSocketIterator sockiter;
+	
+	sim_output_begin(execdata, &node->outstack[0], &sockiter);
+	switch (node->base->type) {
+	case SIM_NODE_CONSTFLOAT:
+		sim_output_write_float(execdata, &sockiter, data->value_float);
+		break;
+	case SIM_NODE_CONSTINT:
+		sim_output_write_int(execdata, &sockiter, data->value_int);
+		break;
+	case SIM_NODE_CONSTBOOL:
+		sim_output_write_bool(execdata, &sockiter, data->value_bool);
+		break;
+	case SIM_NODE_CONSTVECTOR:
+		sim_output_write_vector(execdata, &sockiter, data->value_vector);
+		break;
+	case SIM_NODE_CONSTRGBA:
+		sim_output_write_rgba(execdata, &sockiter, data->value_rgba);
+		break;
+	case SIM_NODE_CONSTQUAT:
+		sim_output_write_quat(execdata, &sockiter, data->value_quat);
+		break;
+	case SIM_NODE_CONSTMATRIX:
+		sim_output_write_matrix(execdata, &sockiter, data->value_matrix);
+		break;
+	case SIM_NODE_CONSTSTRING:
+		sim_output_write_string(execdata, &sockiter, data->value_string);
+		break;
+	}
+	sim_output_end(execdata, &sockiter);
+}
+
+static void init_common_type(bNodeType *type)
+{
+	memset(type, 0, sizeof(bNodeType));
+	type->nclass = NODE_CLASS_DATA;
+	type->width = 140;
+	type->minwidth = 100;
+	type->maxwidth = 320;
+	type->flag = NODE_OPTIONS;
+	type->initfunc = init;
+	type->prepare_outputs = prepare_outputs;
+	type->enqueue = enqueue;
+}
+
+void nodeRegisterSimConstants(ListBase *typelist)
+{
+	static bNodeType type_float, type_int, type_bool, type_vector, type_rgba, type_quat, type_matrix, type_string;
+	
+	init_common_type(&type_float);
+	type_float.type = SIM_NODE_CONSTFLOAT;
+	type_float.name = "Float";
+	type_float.outputs = outputs_float;
+	nodeRegisterType(typelist, &type_float);
+	
+	init_common_type(&type_int);
+	type_int.type = SIM_NODE_CONSTINT;
+	type_int.name = "Integer";
+	type_int.outputs = outputs_int;
+	nodeRegisterType(typelist, &type_int);
+	
+	init_common_type(&type_bool);
+	type_bool.type = SIM_NODE_CONSTBOOL;
+	type_bool.name = "Boolean";
+	type_bool.outputs = outputs_bool;
+	nodeRegisterType(typelist, &type_bool);
+	
+	init_common_type(&type_vector);
+	type_vector.type = SIM_NODE_CONSTVECTOR;
+	type_vector.name = "Vector";
+	type_vector.outputs = outputs_vector;
+	nodeRegisterType(typelist, &type_vector);
+	
+	init_common_type(&type_rgba);
+	type_rgba.type = SIM_NODE_CONSTRGBA;
+	type_rgba.name = "Color";
+	type_rgba.outputs = outputs_rgba;
+	nodeRegisterType(typelist, &type_rgba);
+	
+	init_common_type(&type_quat);
+	type_quat.type = SIM_NODE_CONSTQUAT;
+	type_quat.name = "Quaternion";
+	type_quat.outputs = outputs_quat;
+	nodeRegisterType(typelist, &type_quat);
+	
+	init_common_type(&type_matrix);
+	type_matrix.type = SIM_NODE_CONSTMATRIX;
+	type_matrix.name = "Matrix";
+	type_matrix.outputs = outputs_matrix;
+	nodeRegisterType(typelist, &type_matrix);
+	
+	init_common_type(&type_string);
+	type_string.type = SIM_NODE_CONSTSTRING;
+	type_string.name = "String";
+	type_string.outputs = outputs_string;
+	nodeRegisterType(typelist, &type_string);
+}





More information about the Bf-blender-cvs mailing list