Merging r39948 through r39988 from trunk into vgroup_modifiers. vgroup_modifiers
authorBastien Montagne <montagne29@wanadoo.fr>
Wed, 7 Sep 2011 05:40:12 +0000 (05:40 +0000)
committerBastien Montagne <montagne29@wanadoo.fr>
Wed, 7 Sep 2011 05:40:12 +0000 (05:40 +0000)
1  2 
source/blender/blenloader/intern/readfile.c
source/blender/blenloader/intern/writefile.c

index 5518e133daf3d9115964f331e0ff10b50f55e5a0,664148157cbeb5435024350ff18e0e49e2803be9..eb5d6a6fbcb0a5943555913d6e58aabfd0979c13
@@@ -2217,8 -2217,9 +2217,9 @@@ static void direct_link_nodetree(FileDa
                if(node->type == NODE_DYNAMIC) {
                        node->custom1= 0;
                        node->custom1= BSET(node->custom1, NODE_DYNAMIC_LOADED);
-                       node->typeinfo= NULL;
                }
+               node->typeinfo= NULL;
                
                link_list(fd, &node->inputs);
                link_list(fd, &node->outputs);
@@@ -4185,13 -4186,6 +4186,13 @@@ static void direct_link_modifiers(FileD
                        if(tmd->curfalloff)
                                direct_link_curvemapping(fd, tmd->curfalloff);
                }
 +              else if (md->type==eModifierType_WeightVGEdit) {
 +                      WeightVGEditModifierData *wmd = (WeightVGEditModifierData*) md;
 +
 +                      wmd->cmap_curve = newdataadr(fd, wmd->cmap_curve);
 +                      if(wmd->cmap_curve)
 +                              direct_link_curvemapping(fd, wmd->cmap_curve);
 +              }
        }
  }
  
@@@ -7022,6 -7016,15 +7023,15 @@@ static void do_versions_nodetree_defaul
                do_versions_socket_default_value(sock);
  }
  
+ static void do_versions_nodetree_dynamic_sockets(bNodeTree *ntree)
+ {
+       bNodeSocket *sock;
+       for (sock=ntree->inputs.first; sock; sock=sock->next)
+               sock->flag |= SOCK_DYNAMIC;
+       for (sock=ntree->outputs.first; sock; sock=sock->next)
+               sock->flag |= SOCK_DYNAMIC;
+ }
  static void do_versions(FileData *fd, Library *lib, Main *main)
  {
        /* WATCH IT!!!: pointers from libdata have not been converted */
                                tex->nodetree->update |= NTREE_UPDATE;
                        }
                }
+               /* add SOCK_DYNAMIC flag to existing group sockets */
+               {
+                       bNodeTree *ntree;
+                       /* only need to do this for trees in main, local trees are not used as groups */
+                       for (ntree=main->nodetree.first; ntree; ntree=ntree->id.next) {
+                               do_versions_nodetree_dynamic_sockets(ntree);
+                               ntree->update |= NTREE_UPDATE;
+                       }
+               }
+               {
+                       /* Initialize group tree nodetypes.
+                        * These are used to distinguish tree types and
+                        * associate them with specific node types for polling.
+                        */
+                       bNodeTree *ntree;
+                       /* all node trees in main->nodetree are considered groups */
+                       for (ntree=main->nodetree.first; ntree; ntree=ntree->id.next)
+                               ntree->nodetype = NODE_GROUP;
+               }
        }
  
        /* put compatibility code here until next subversion bump */
index c3f51dc6ce48466eff891c66002541d5b8bc277a,5c2d3e0c4582d2b57183c4a507b82b574e8f4f88..3b736e8aeae0e5c59c4896ed1b32bcb33bbb341a
@@@ -135,6 -135,7 +135,7 @@@ Any case: direct data is ALWAYS after t
  #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 +646,38 @@@ static void write_curvemapping(WriteDat
  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);
@@@ -1319,12 -1352,6 +1352,12 @@@ static void write_modifiers(WriteData *
                                write_curvemapping(wd, tmd->curfalloff);
                        }
                }
 +              else if (md->type==eModifierType_WeightVGEdit) {
 +                      WeightVGEditModifierData *wmd = (WeightVGEditModifierData*) md;
 +
 +                      if (wmd->cmap_curve)
 +                              write_curvemapping(wd, wmd->cmap_curve);
 +              }
        }
  }