Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2011-09-06 20:51:10 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2011-09-06 20:51:10 +0400
commitc8a092789f5e53ebf418457bd2f7ea1a3818d0b7 (patch)
treeb9e3a67fb4c439ef27f0f147e977d7ea9d94328c /source/blender
parent84b8ec2ec37e21f6672044c4bff1339365d76b55 (diff)
Node merge: some forward compatibility code to avoid crash loading files with
node groups in older version, and to keep unconnected/default socket values.
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/blenloader/intern/writefile.c33
-rw-r--r--source/blender/makesdna/DNA_node_types.h6
2 files changed, 36 insertions, 3 deletions
diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c
index b982630ec41..5c2d3e0c458 100644
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@ -135,6 +135,7 @@ Any case: direct data is ALWAYS after the lib block
#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_curvemapping(WriteData *wd, CurveMapping *cumap)
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);
diff --git a/source/blender/makesdna/DNA_node_types.h b/source/blender/makesdna/DNA_node_types.h
index 3a51a6a56a4..bac1e3cd8ca 100644
--- a/source/blender/makesdna/DNA_node_types.h
+++ b/source/blender/makesdna/DNA_node_types.h
@@ -84,7 +84,7 @@ typedef struct bNodeSocket {
/* 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 @@ typedef struct bNodeLink {
} 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 */