[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [39977] trunk/blender/source/blender: Node merge: some forward compatibility code to avoid crash loading files with

Brecht Van Lommel brechtvanlommel at pandora.be
Tue Sep 6 18:51:10 CEST 2011


Revision: 39977
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=39977
Author:   blendix
Date:     2011-09-06 16:51:10 +0000 (Tue, 06 Sep 2011)
Log Message:
-----------
Node merge: some forward compatibility code to avoid crash loading files with
node groups in older version, and to keep unconnected/default socket values.

Modified Paths:
--------------
    trunk/blender/source/blender/blenloader/intern/writefile.c
    trunk/blender/source/blender/makesdna/DNA_node_types.h

Modified: trunk/blender/source/blender/blenloader/intern/writefile.c
===================================================================
--- trunk/blender/source/blender/blenloader/intern/writefile.c	2011-09-06 16:48:28 UTC (rev 39976)
+++ trunk/blender/source/blender/blenloader/intern/writefile.c	2011-09-06 16:51:10 UTC (rev 39977)
@@ -135,6 +135,7 @@
 #include "BLI_blenlib.h"
 #include "BLI_linklist.h"
 #include "BLI_bpath.h"
+#include "BLI_math.h"
 #include "BLI_utildefines.h"
 
 #include "BKE_action.h"
@@ -645,6 +646,38 @@
 static void write_node_socket(WriteData *wd, bNodeSocket *sock)
 {
 	bNodeSocketType *stype= ntreeGetSocketType(sock->type);
+
+	/* forward compatibility code, so older blenders still open */
+	sock->stack_type = 1;
+
+	if(sock->default_value) {
+		bNodeSocketValueFloat *valfloat;
+		bNodeSocketValueVector *valvector;
+		bNodeSocketValueRGBA *valrgba;
+		
+		switch (sock->type) {
+		case SOCK_FLOAT:
+			valfloat = sock->default_value;
+			sock->ns.vec[0] = valfloat->value;
+			sock->ns.min = valfloat->min;
+			sock->ns.max = valfloat->max;
+			break;
+		case SOCK_VECTOR:
+			valvector = sock->default_value;
+			copy_v3_v3(sock->ns.vec, valvector->value);
+			sock->ns.min = valvector->min;
+			sock->ns.max = valvector->max;
+			break;
+		case SOCK_RGBA:
+			valrgba = sock->default_value;
+			copy_v4_v4(sock->ns.vec, valrgba->value);
+			sock->ns.min = 0.0f;
+			sock->ns.max = 1.0f;
+			break;
+		}
+	}
+
+	/* actual socket writing */
 	writestruct(wd, DATA, "bNodeSocket", 1, sock);
 	if (sock->default_value)
 		writestruct(wd, DATA, stype->value_structname, 1, sock->default_value);

Modified: trunk/blender/source/blender/makesdna/DNA_node_types.h
===================================================================
--- trunk/blender/source/blender/makesdna/DNA_node_types.h	2011-09-06 16:48:28 UTC (rev 39976)
+++ trunk/blender/source/blender/makesdna/DNA_node_types.h	2011-09-06 16:51:10 UTC (rev 39977)
@@ -84,7 +84,7 @@
 	
 	/* execution data */
 	short stack_index;			/* local stack index */
-	short pad2;
+	short stack_type;			/* deprecated, kept for forward compatibility */
 	int pad3;
 	void *cache;				/* cached data from execution */
 	
@@ -198,8 +198,8 @@
 } bNodeLink;
 
 /* link->flag */
-#define NODE_LINK_VALID			1		/* link has been successfully validated */
-#define NODE_LINKFLAG_HILITE	2
+#define NODE_LINKFLAG_HILITE	1		/* link has been successfully validated */
+#define NODE_LINK_VALID			2
 
 /* the basis for a Node tree, all links and nodes reside internal here */
 /* only re-usable node trees are in the library though, materials and textures allocate own tree struct */




More information about the Bf-blender-cvs mailing list