diff options
Diffstat (limited to 'source/blender/blenloader/intern/writefile.c')
-rw-r--r-- | source/blender/blenloader/intern/writefile.c | 41 |
1 files changed, 35 insertions, 6 deletions
diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index e1cbdc89022..dece8740789 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -963,6 +963,39 @@ static void write_CurveProfile(WriteData *wd, CurveProfile *profile) writestruct(wd, DATA, CurveProfilePoint, profile->path_len, profile->path); } +static void write_node_socket_default_value(WriteData *wd, bNodeSocket *sock) +{ + if (sock->default_value == NULL) { + return; + } + + switch ((eNodeSocketDatatype)sock->type) { + case SOCK_FLOAT: + writestruct(wd, DATA, bNodeSocketValueFloat, 1, sock->default_value); + break; + case SOCK_VECTOR: + writestruct(wd, DATA, bNodeSocketValueVector, 1, sock->default_value); + break; + case SOCK_RGBA: + writestruct(wd, DATA, bNodeSocketValueRGBA, 1, sock->default_value); + break; + case SOCK_BOOLEAN: + writestruct(wd, DATA, bNodeSocketValueBoolean, 1, sock->default_value); + break; + case SOCK_INT: + writestruct(wd, DATA, bNodeSocketValueInt, 1, sock->default_value); + break; + case SOCK_STRING: + writestruct(wd, DATA, bNodeSocketValueString, 1, sock->default_value); + break; + case __SOCK_MESH: + case SOCK_CUSTOM: + case SOCK_SHADER: + BLI_assert(false); + break; + } +} + static void write_node_socket(WriteData *wd, bNodeSocket *sock) { /* actual socket writing */ @@ -972,9 +1005,7 @@ static void write_node_socket(WriteData *wd, bNodeSocket *sock) IDP_WriteProperty(sock->prop, wd); } - if (sock->default_value) { - writedata(wd, DATA, MEM_allocN_len(sock->default_value), sock->default_value); - } + write_node_socket_default_value(wd, sock); } static void write_node_socket_interface(WriteData *wd, bNodeSocket *sock) { @@ -985,9 +1016,7 @@ static void write_node_socket_interface(WriteData *wd, bNodeSocket *sock) IDP_WriteProperty(sock->prop, wd); } - if (sock->default_value) { - writedata(wd, DATA, MEM_allocN_len(sock->default_value), sock->default_value); - } + write_node_socket_default_value(wd, sock); } /* this is only direct data, tree itself should have been written */ static void write_nodetree_nolib(WriteData *wd, bNodeTree *ntree) |