[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [17580] trunk/blender/source/blender: 2 things:

Robin Allen roblovski at gmail.com
Wed Nov 26 14:07:24 CET 2008


Revision: 17580
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=17580
Author:   kakbarnf
Date:     2008-11-26 14:07:24 +0100 (Wed, 26 Nov 2008)

Log Message:
-----------
2 things:

* Patch #17998
* tex_input_vec now takes 3-vector as first argument (was 4-vector).

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/BKE_node.h
    trunk/blender/source/blender/blenkernel/intern/node.c
    trunk/blender/source/blender/nodes/TEX_node.h
    trunk/blender/source/blender/nodes/intern/TEX_util.c

Added Paths:
-----------
    trunk/blender/source/blender/nodes/intern/TEX_nodes/TEX_coord.c
    trunk/blender/source/blender/nodes/intern/TEX_nodes/TEX_distance.c

Modified: trunk/blender/source/blender/blenkernel/BKE_node.h
===================================================================
--- trunk/blender/source/blender/blenkernel/BKE_node.h	2008-11-26 11:01:56 UTC (rev 17579)
+++ trunk/blender/source/blender/blenkernel/BKE_node.h	2008-11-26 13:07:24 UTC (rev 17580)
@@ -401,6 +401,8 @@
 #define TEX_NODE_ROTATE     114
 #define TEX_NODE_VIEWER     115
 #define TEX_NODE_TRANSLATE  116
+#define TEX_NODE_COORD      117
+#define TEX_NODE_DISTANCE   118
 
 /* 201-299 reserved. Use like this: TEX_NODE_PROC + TEX_CLOUDS, etc */
 #define TEX_NODE_PROC      200

Modified: trunk/blender/source/blender/blenkernel/intern/node.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/node.c	2008-11-26 11:01:56 UTC (rev 17579)
+++ trunk/blender/source/blender/blenkernel/intern/node.c	2008-11-26 13:07:24 UTC (rev 17580)
@@ -2886,6 +2886,8 @@
 	nodeRegisterType(ntypelist, &tex_node_curve_time);
 	nodeRegisterType(ntypelist, &tex_node_invert);
 	nodeRegisterType(ntypelist, &tex_node_hue_sat);
+	nodeRegisterType(ntypelist, &tex_node_coord);
+	nodeRegisterType(ntypelist, &tex_node_distance);
 	
 	nodeRegisterType(ntypelist, &tex_node_output);
 	nodeRegisterType(ntypelist, &tex_node_viewer);

Modified: trunk/blender/source/blender/nodes/TEX_node.h
===================================================================
--- trunk/blender/source/blender/nodes/TEX_node.h	2008-11-26 11:01:56 UTC (rev 17579)
+++ trunk/blender/source/blender/nodes/TEX_node.h	2008-11-26 13:07:24 UTC (rev 17580)
@@ -52,6 +52,8 @@
 extern bNodeType tex_node_curve_time;
 extern bNodeType tex_node_invert;
 extern bNodeType tex_node_hue_sat;
+extern bNodeType tex_node_coord;
+extern bNodeType tex_node_distance;
 
 extern bNodeType tex_node_rotate;
 extern bNodeType tex_node_translate;

Added: trunk/blender/source/blender/nodes/intern/TEX_nodes/TEX_coord.c
===================================================================
--- trunk/blender/source/blender/nodes/intern/TEX_nodes/TEX_coord.c	                        (rev 0)
+++ trunk/blender/source/blender/nodes/intern/TEX_nodes/TEX_coord.c	2008-11-26 13:07:24 UTC (rev 17580)
@@ -0,0 +1,66 @@
+/**
+ *
+ * ***** 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., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ *
+ * The Original Code is Copyright (C) 2005 Blender Foundation.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): Mathias Panzenböck (panzi) <grosser.meister.morti at gmx.net>.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#include "../TEX_util.h"
+
+static bNodeSocketType outputs[]= { 
+	{ SOCK_VECTOR, 0, "Coordinates", 0.0f, 0.0f, 0.0f, 0.0f, -1.0f, 1.0f },
+	{ -1, 0, "" }
+};
+
+static void vectorfn(float *out, float *coord, bNode *node, bNodeStack **in, short thread)
+{
+	out[0] = coord[0];
+	out[1] = coord[1];
+	out[2] = coord[2];
+}
+
+static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
+{
+	tex_output(node, in, out[0], &vectorfn);
+	
+	tex_do_preview(node, out[0], data);
+}
+
+bNodeType tex_node_coord= {
+	/* *next,*prev */	NULL, NULL,
+	/* type code   */	TEX_NODE_COORD,
+	/* name        */	"Coordinates",
+	/* width+range */	120, 110, 160,
+	/* class+opts  */	NODE_CLASS_INPUT, NODE_OPTIONS,
+	/* input sock  */	NULL,
+	/* output sock */	outputs,
+	/* storage     */	"node_coord",
+	/* execfunc    */	exec,
+	/* butfunc     */	NULL,
+	/* initfunc    */	NULL,
+	/* freestoragefunc    */	NULL,
+	/* copystoragefunc    */	NULL,
+	/* id          */	NULL
+};
+

Added: trunk/blender/source/blender/nodes/intern/TEX_nodes/TEX_distance.c
===================================================================
--- trunk/blender/source/blender/nodes/intern/TEX_nodes/TEX_distance.c	                        (rev 0)
+++ trunk/blender/source/blender/nodes/intern/TEX_nodes/TEX_distance.c	2008-11-26 13:07:24 UTC (rev 17580)
@@ -0,0 +1,82 @@
+/**
+ *
+ * ***** 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., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ *
+ * The Original Code is Copyright (C) 2005 Blender Foundation.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): Mathias Panzenböck (panzi) <grosser.meister.morti at gmx.net>.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#include <math.h>
+#include "../TEX_util.h"
+
+static bNodeSocketType inputs[]= {
+	{ SOCK_VECTOR, 1, "Coordinate 1", 0.0f, 0.0f, 0.0f, 0.0f, -1.0f, 1.0f },
+	{ SOCK_VECTOR, 1, "Coordinate 2", 0.0f, 0.0f, 0.0f, 0.0f, -1.0f, 1.0f },
+	{ -1, 0, "" } 
+};
+
+static bNodeSocketType outputs[]= {
+	{ SOCK_VALUE, 0, "Value", 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f },
+	{ -1, 0, "" }
+};
+
+static void valuefn(float *out, float *coord, bNode *node, bNodeStack **in, short thread)
+{
+	float coord1[3], coord2[3];
+	float x, y, z;
+
+	tex_input_vec(coord1, in[0], coord, thread);
+	tex_input_vec(coord2, in[1], coord, thread);
+
+	x = coord2[0] - coord1[0];
+	y = coord2[1] - coord1[1];
+	z = coord2[2] - coord1[2];
+
+	*out = sqrt(x * x + y * y + z * z);
+}
+
+static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
+{
+	tex_output(node, in, out[0], &valuefn);
+	
+	tex_do_preview(node, out[0], data);
+}
+
+bNodeType tex_node_distance= {
+	/* *next,*prev */	NULL, NULL,
+	/* type code   */	TEX_NODE_DISTANCE,
+	/* name        */	"Distance",
+	/* width+range */	120, 110, 160,
+	/* class+opts  */	NODE_CLASS_CONVERTOR, NODE_OPTIONS,
+	/* input sock  */	inputs,
+	/* output sock */	outputs,
+	/* storage     */	"node_distance",
+	/* execfunc    */	exec,
+	/* butfunc     */	NULL,
+	/* initfunc    */	NULL,
+	/* freestoragefunc    */	NULL,
+	/* copystoragefunc    */	NULL,
+	/* id          */	NULL
+};
+
+

Modified: trunk/blender/source/blender/nodes/intern/TEX_util.c
===================================================================
--- trunk/blender/source/blender/nodes/intern/TEX_util.c	2008-11-26 11:01:56 UTC (rev 17579)
+++ trunk/blender/source/blender/nodes/intern/TEX_util.c	2008-11-26 13:07:24 UTC (rev 17580)
@@ -46,26 +46,33 @@
 	dg->fn(out, coord, dg->node, dg->in, thread);
 }
 
-void tex_input_vec(float *out, bNodeStack *in, float *coord, short thread)
+void tex_input(float *out, int sz, bNodeStack *in, float *coord, short thread)
 {
 	TexDelegate *dg = in->data;
 	if(dg) {
-		tex_call_delegate(dg, out, coord, thread);
+		tex_call_delegate(dg, in->vec, coord, thread);
 	
-		if(in->hasoutput && in->sockettype == SOCK_VALUE) {
-			out[1] = out[2] = out[0];
-			out[3] = 1;
-		}
+		if(in->hasoutput && in->sockettype == SOCK_VALUE)
+			in->vec[1] = in->vec[2] = in->vec[0];
 	}
-	else {
-		QUATCOPY(out, in->vec);
-	}
+	memcpy(out, in->vec, sz * sizeof(float));
 }
 
+void tex_input_vec(float *out, bNodeStack *in, float *coord, short thread)
+{
+	tex_input(out, 3, in, coord, thread);
+}
+
 void tex_input_rgba(float *out, bNodeStack *in, float *coord, short thread)
 {
-	tex_input_vec(out, in, coord, thread);
+	tex_input(out, 4, in, coord, thread);
 	
+	if(in->hasoutput && in->sockettype == SOCK_VALUE)
+	{
+		out[1] = out[2] = out[0];
+		out[3] = 1;
+	}
+	
 	if(in->hasoutput && in->sockettype == SOCK_VECTOR) {
 		out[0] = out[0] * .5f + .5f;
 		out[1] = out[1] * .5f + .5f;
@@ -83,8 +90,8 @@
 
 static void init_preview(bNode *node)
 {
-	int xsize = node->prvr.xmax - node->prvr.xmin;
-	int ysize = node->prvr.ymax - node->prvr.ymin;
+	int xsize = (int)(node->prvr.xmax - node->prvr.xmin);
+	int ysize = (int)(node->prvr.ymax - node->prvr.ymin);
 	
 	if(xsize == 0) {
 		xsize = PREV_RES;





More information about the Bf-blender-cvs mailing list