NLA SoC: Merge from 2.5 20215:20439 (HEAD)
authorJoshua Leung <aligorith@gmail.com>
Wed, 27 May 2009 00:07:03 +0000 (00:07 +0000)
committerJoshua Leung <aligorith@gmail.com>
Wed, 27 May 2009 00:07:03 +0000 (00:07 +0000)
1  2 
source/blender/blenkernel/intern/object.c
source/blender/blenloader/intern/readfile.c
source/blender/blenloader/intern/writefile.c
source/blender/makesdna/DNA_action_types.h
source/blender/makesdna/DNA_space_types.h

index b090278468788625f51065dbff7704ac7477f140,d7619010808a4f4f8ecfcd2f3e69860ac57443bb..7a83162f7a747f0db238dc2d1d7d7c0fef8a5b49
@@@ -1193,12 -1193,18 +1193,12 @@@ Object *copy_object(Object *ob
                        armature_rebuild_pose(obn, obn->data);
        }
        copy_defgroups(&obn->defbase, &ob->defbase);
 -#if 0 // XXX old animation system
 -      copy_nlastrips(&obn->nlastrips, &ob->nlastrips);
 -#endif // XXX old animation system
        copy_constraints(&obn->constraints, &ob->constraints);
  
        /* increase user numbers */
        id_us_plus((ID *)obn->data);
 -#if 0 // XXX old animation system
 -      id_us_plus((ID *)obn->ipo);
 -      id_us_plus((ID *)obn->action);
 -#endif // XXX old animation system
        id_us_plus((ID *)obn->dup_group);
 +      // FIXME: add this for animdata too...
  
        for(a=0; a<obn->totcol; a++) id_us_plus((ID *)obn->mat[a]);
        
@@@ -1314,6 -1320,18 +1314,18 @@@ void make_local_object(Object *ob
        expand_local_object(ob);
  }
  
+ /* returns true if the Object data is a from an external blend file (libdata) */
+ int object_data_is_libdata(Object *ob)
+ {
+       if(!ob) return 0;
+       if(ob->proxy) return 0;
+       if(ob->id.lib) return 1;
+       if(!ob->data) return 0;
+       if(((ID *)ob->data)->lib) return 1;
+       return 0;
+ }
  /* *************** PROXY **************** */
  
  /* when you make proxy, ensure the exposed layers are extern */
index c919a6dd6a98574bbea4eebd2a842ae886e9f18b,9c5735a3020150f5103d80cc99b7bc7ab9e94d5c..192016f712d6008d59104578be301d6d33e8ad75
@@@ -1657,26 -1657,10 +1657,26 @@@ static void lib_link_constraint_channel
  
  /* Data Linking ----------------------------- */
  
 +static void lib_link_fmodifiers(FileData *fd, ID *id, ListBase *list)
 +{
 +      FModifier *fcm;
 +      
 +      for (fcm= list->first; fcm; fcm= fcm->next) {
 +              /* data for specific modifiers */
 +              switch (fcm->type) {
 +                      case FMODIFIER_TYPE_PYTHON:
 +                      {
 +                              FMod_Python *data= (FMod_Python *)fcm->data;
 +                              data->script = newlibadr(fd, id->lib, data->script);
 +                      }
 +                              break;
 +              }
 +      }
 +}
 +
  static void lib_link_fcurves(FileData *fd, ID *id, ListBase *list) 
  {
        FCurve *fcu;
 -      FModifier *fcm;
        
        /* relink ID-block references... */
        for (fcu= list->first; fcu; fcu= fcu->next) {
                }
                
                /* modifiers */
 -              for (fcm= fcu->modifiers.first; fcm; fcm= fcm->next) {
 -                      /* data for specific modifiers */
 -                      switch (fcm->type) {
 -                              case FMODIFIER_TYPE_PYTHON:
 -                              {
 -                                      FMod_Python *data= (FMod_Python *)fcm->data;
 -                                      data->script = newlibadr(fd, id->lib, data->script);
 -                              }
 -                                      break;
 +              lib_link_fmodifiers(fd, id, &fcu->modifiers);
 +      }
 +}
 +
 +
 +/* NOTE: this assumes that link_list has already been called on the list */
 +static void direct_link_fmodifiers(FileData *fd, ListBase *list)
 +{
 +      FModifier *fcm;
 +      
 +      for (fcm= list->first; fcm; fcm= fcm->next) {
 +              /* relink general data */
 +              fcm->data = newdataadr(fd, fcm->data);
 +              fcm->edata= NULL;
 +              
 +              /* do relinking of data for specific types */
 +              switch (fcm->type) {
 +                      case FMODIFIER_TYPE_GENERATOR:
 +                      {
 +                              FMod_Generator *data= (FMod_Generator *)fcm->data;
 +                              
 +                              data->coefficients= newdataadr(fd, data->coefficients);
 +                      }
 +                              break;
 +                      case FMODIFIER_TYPE_ENVELOPE:
 +                      {
 +                              FMod_Envelope *data= (FMod_Envelope *)fcm->data;
 +                              
 +                              data->data= newdataadr(fd, data->data);
                        }
 +                              break;
 +                      case FMODIFIER_TYPE_PYTHON:
 +                      {
 +                              FMod_Python *data= (FMod_Python *)fcm->data;
 +                              
 +                              data->prop = newdataadr(fd, data->prop);
 +                              IDP_DirectLinkProperty(data->prop, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd);
 +                      }
 +                              break;
                }
        }
  }
  static void direct_link_fcurves(FileData *fd, ListBase *list)
  {
        FCurve *fcu;
 -      FModifier *fcm;
        
        /* link F-Curve data to F-Curve again (non ID-libs) */
        for (fcu= list->first; fcu; fcu= fcu->next) {
                
                /* modifiers */
                link_list(fd, &fcu->modifiers);
 -              for (fcm= fcu->modifiers.first; fcm; fcm= fcm->next) {
 -                      /* relink general data */
 -                      fcm->data = newdataadr(fd, fcm->data);
 -                      fcm->edata= NULL;
 -                      
 -                      /* do relinking of data for specific types */
 -                      switch (fcm->type) {
 -                              case FMODIFIER_TYPE_GENERATOR:
 -                              {
 -                                      FMod_Generator *data= (FMod_Generator *)fcm->data;
 -                                      
 -                                      data->coefficients= newdataadr(fd, data->coefficients);
 -                              }
 -                                      break;
 -                              case FMODIFIER_TYPE_ENVELOPE:
 -                              {
 -                                      FMod_Envelope *data= (FMod_Envelope *)fcm->data;
 -                                      
 -                                      data->data= newdataadr(fd, data->data);
 -                              }
 -                                      break;
 -                              case FMODIFIER_TYPE_PYTHON:
 -                              {
 -                                      FMod_Python *data= (FMod_Python *)fcm->data;
 -                                      
 -                                      data->prop = newdataadr(fd, data->prop);
 -                                      IDP_DirectLinkProperty(data->prop, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd);
 -                              }
 -                                      break;
 -                      }
 -              }
 +              direct_link_fmodifiers(fd, &fcu->modifiers);
        }
  }
  
@@@ -1816,44 -1802,6 +1816,44 @@@ static void direct_link_action(FileDat
        }
  }
  
 +
 +static void lib_link_nladata (FileData *fd, ID *id, ListBase *list)
 +{
 +      NlaTrack *nlt;
 +      NlaStrip *strip;
 +      
 +      /* we only acare about the NLA strips inside the tracks */
 +      for (nlt= list->first; nlt; nlt= nlt->next) {
 +              for (strip= nlt->strips.first; strip; strip= strip->next) {
 +                      /* reassign the counted-reference to action */
 +                      strip->act = newlibadr_us(fd, id->lib, strip->act);
 +              }
 +      }
 +}
 +
 +/* NOTE: this assumes that link_list has already been called on the list */
 +static void direct_link_nladata(FileData *fd, ListBase *list)
 +{
 +      NlaTrack *nlt;
 +      NlaStrip *strip;
 +      
 +      for (nlt= list->first; nlt; nlt= nlt->next) {
 +              /* relink list of strips */
 +              link_list(fd, &nlt->strips);
 +              
 +              /* relink strip data */
 +              for (strip= nlt->strips.first; strip; strip= strip->next) {
 +                      /* strip's F-Curves */
 +                      link_list(fd, &strip->fcurves);
 +                      direct_link_fcurves(fd, &strip->fcurves);
 +                      
 +                      /* strip's F-Modifiers */
 +                      link_list(fd, &strip->modifiers);
 +                      direct_link_fcurves(fd, &strip->modifiers);
 +              }
 +      }
 +}
 +
  /* ------- */
  
  static void lib_link_keyingsets(FileData *fd, ID *id, ListBase *list)
@@@ -1903,7 -1851,7 +1903,7 @@@ static void lib_link_animdata(FileData 
        /* overrides don't have lib-link for now, so no need to do anything */
        
        /* link NLA-data */
 -      // TODO... 
 +      lib_link_nladata(fd, id, &adt->nla_tracks);
  }
  
  static void direct_link_animdata(FileData *fd, AnimData *adt)
        // TODO...
        
        /* link NLA-data */
 -      // TODO...
 +      link_list(fd, &adt->nla_tracks);
 +      direct_link_nladata(fd, &adt->nla_tracks);
  }     
  
  /* ************ READ NODE TREE *************** */
@@@ -2229,9 -2176,12 +2229,12 @@@ static void direct_link_constraints(Fil
                
                if (cons->type == CONSTRAINT_TYPE_PYTHON) {
                        bPythonConstraint *data= cons->data;
+                       
                        link_list(fd, &data->targets);
+                       
                        data->prop = newdataadr(fd, data->prop);
-                       IDP_DirectLinkProperty(data->prop, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd);
+                       if (data->prop)
+                               IDP_DirectLinkProperty(data->prop, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd);
                }
        }
  }
@@@ -3470,7 -3420,13 +3473,13 @@@ static void direct_link_pose(FileData *
                pchan->bone= NULL;
                pchan->parent= newdataadr(fd, pchan->parent);
                pchan->child= newdataadr(fd, pchan->child);
+               
                direct_link_constraints(fd, &pchan->constraints);
+               
+               pchan->prop = newdataadr(fd, pchan->prop);
+               if (pchan->prop)
+                       IDP_DirectLinkProperty(pchan->prop, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd);
+               
                pchan->iktree.first= pchan->iktree.last= NULL;
                pchan->path= NULL;
        }
@@@ -4679,11 -4635,6 +4688,11 @@@ static void direct_link_screen(FileDat
                                sipo->ads= newdataadr(fd, sipo->ads);
                                sipo->ghostCurves.first= sipo->ghostCurves.last= NULL;
                        }
 +                      else if (sl->spacetype==SPACE_NLA) {
 +                              SpaceNla *snla= (SpaceNla*)sl;
 +                              
 +                              snla->ads= newdataadr(fd, snla->ads);
 +                      }
                        else if (sl->spacetype==SPACE_OUTLINER) {
                                SpaceOops *soops= (SpaceOops*) sl;
                                
@@@ -5699,7 -5650,6 +5708,6 @@@ static void area_add_window_regions(Scr
                        {
                                SpaceButs *sbuts= (SpaceButs *)sl;
                                memcpy(&ar->v2d, &sbuts->v2d, sizeof(View2D));
-                               ar->v2d.keepzoom |= V2D_KEEPASPECT;
                                break;
                        }
                        case SPACE_FILE:
@@@ -8962,6 -8912,7 +8970,7 @@@ static void do_versions(FileData *fd, L
           bump the version (or sub-version.) */
        {
                Object *ob;
+               Material *ma;
                int i;
  
                for(ob = main->object.first; ob; ob = ob->id.next) {
                                ob->data = olddata;
                        }
                }
+               for(ma = main->mat.first; ma; ma = ma->id.next) {
+                       if(ma->mode & MA_HALO) {
+                               ma->material_type= MA_TYPE_HALO;
+                               ma->mode &= ~MA_HALO;
+                       }
+               }
        }
  
        /* WATCH IT!!!: pointers from libdata have not been converted yet here! */
@@@ -9360,8 -9318,6 +9376,8 @@@ static void expand_keyingsets(FileData 
  static void expand_animdata(FileData *fd, Main *mainvar, AnimData *adt)
  {
        FCurve *fcd;
 +      NlaTrack *nlt;
 +      NlaStrip *strip;
        
        /* own action */
        expand_doit(fd, mainvar, adt->action);
                for (dtar= driver->targets.first; dtar; dtar= dtar->next)
                        expand_doit(fd, mainvar, dtar->id);
        }
 +      
 +      /* nla-data - referenced actions */
 +      for (nlt= adt->nla_tracks.first; nlt; nlt= nlt->next) {
 +              for (strip= nlt->strips.first; strip; strip= strip->next) 
 +                      expand_doit(fd, mainvar, strip->act);
 +      }
  }     
  
  static void expand_particlesettings(FileData *fd, Main *mainvar, ParticleSettings *part)
index bb1ee15eaea73cfe592c70e8d16399910e478563,943e23861adc2c086468a351837d355af380084b..5cf46b6fd281e33da33436181f33eaee8004c163
@@@ -760,59 -760,10 +760,59 @@@ static void write_actuators(WriteData *
        }
  }
  
 +static void write_fmodifiers(WriteData *wd, ListBase *fmodifiers)
 +{
 +      FModifier *fcm;
 +      
 +      /* Modifiers */
 +      for (fcm= fmodifiers->first; fcm; fcm= fcm->next) {
 +              FModifierTypeInfo *fmi= fmodifier_get_typeinfo(fcm);
 +              
 +              /* Write the specific data */
 +              if (fmi && fcm->data) {
 +                      /* firstly, just write the plain fmi->data struct */
 +                      writestruct(wd, DATA, fmi->structName, 1, fcm->data);
 +                      
 +                      /* do any modifier specific stuff */
 +                      switch (fcm->type) {
 +                              case FMODIFIER_TYPE_GENERATOR:
 +                              {
 +                                      FMod_Generator *data= (FMod_Generator *)fcm->data;
 +                                      
 +                                      /* write coefficients array */
 +                                      if (data->coefficients)
 +                                              writedata(wd, DATA, sizeof(float)*(data->arraysize), data->coefficients);
 +                              }
 +                                      break;
 +                              case FMODIFIER_TYPE_ENVELOPE:
 +                              {
 +                                      FMod_Envelope *data= (FMod_Envelope *)fcm->data;
 +                                      
 +                                      /* write envelope data */
 +                                      if (data->data)
 +                                              writedata(wd, DATA, sizeof(FCM_EnvelopeData)*(data->totvert), data->data);
 +                              }
 +                                      break;
 +                              case FMODIFIER_TYPE_PYTHON:
 +                              {
 +                                      FMod_Python *data = (FMod_Python *)fcm->data;
 +                                      
 +                                      /* Write ID Properties -- and copy this comment EXACTLY for easy finding
 +                                       of library blocks that implement this.*/
 +                                      IDP_WriteProperty(data->prop, wd);
 +                              }
 +                                      break;
 +                      }
 +              }
 +              
 +              /* Write the modifier */
 +              writestruct(wd, DATA, "FModifier", 1, fcm);
 +      }
 +}
 +
  static void write_fcurves(WriteData *wd, ListBase *fcurves)
  {
        FCurve *fcu;
 -      FModifier *fcm;
        
        for (fcu=fcurves->first; fcu; fcu=fcu->next) {
                /* F-Curve */
                        }
                }
                
 -              /* Modifiers */
 -              for (fcm= fcu->modifiers.first; fcm; fcm= fcm->next) {
 -                      FModifierTypeInfo *fmi= fmodifier_get_typeinfo(fcm);
 -                      
 -                      /* Write the specific data */
 -                      if (fmi && fcm->data) {
 -                              /* firstly, just write the plain fmi->data struct */
 -                              writestruct(wd, DATA, fmi->structName, 1, fcm->data);
 -                              
 -                              /* do any modifier specific stuff */
 -                              switch (fcm->type) {
 -                                      case FMODIFIER_TYPE_GENERATOR:
 -                                      {
 -                                              FMod_Generator *data= (FMod_Generator *)fcm->data;
 -                                              
 -                                              /* write coefficients array */
 -                                              if (data->coefficients)
 -                                                      writedata(wd, DATA, sizeof(float)*(data->arraysize), data->coefficients);
 -                                      }
 -                                              break;
 -                                      case FMODIFIER_TYPE_ENVELOPE:
 -                                      {
 -                                              FMod_Envelope *data= (FMod_Envelope *)fcm->data;
 -                                              
 -                                              /* write envelope data */
 -                                              if (data->data)
 -                                                      writedata(wd, DATA, sizeof(FCM_EnvelopeData)*(data->totvert), data->data);
 -                                      }
 -                                              break;
 -                                      case FMODIFIER_TYPE_PYTHON:
 -                                      {
 -                                              FMod_Python *data = (FMod_Python *)fcm->data;
 -                                              
 -                                              /* Write ID Properties -- and copy this comment EXACTLY for easy finding
 -                                               of library blocks that implement this.*/
 -                                              IDP_WriteProperty(data->prop, wd);
 -                                      }
 -                                              break;
 -                              }
 -                      }
 -                      
 -                      /* Write the modifier */
 -                      writestruct(wd, DATA, "FModifier", 1, fcm);
 -              }
 +              /* write F-Modifiers */
 +              write_fmodifiers(wd, &fcu->modifiers);
        }
  }
  
@@@ -895,29 -888,6 +895,29 @@@ static void write_keyingsets(WriteData 
        }
  }
  
 +static void write_nladata(WriteData *wd, ListBase *nlabase)
 +{
 +      NlaTrack *nlt;
 +      NlaStrip *strip;
 +      
 +      /* write all the tracks */
 +      for (nlt= nlabase->first; nlt; nlt= nlt->next) {
 +              /* write the track first */
 +              writestruct(wd, DATA, "NlaTrack", 1, nlt);
 +              
 +              for (strip= nlt->strips.first; strip; strip= strip->next) {
 +                      /* write the strip first */
 +                      writestruct(wd, DATA, "NlaStrip", 1, strip);
 +                      
 +                      /* write the strip's F-Curves and modifiers */
 +                      write_fcurves(wd, &strip->fcurves);
 +                      write_fmodifiers(wd, &strip->modifiers);
 +                      
 +                      // TODO write the remaps
 +              }
 +      }
 +}
 +
  static void write_animdata(WriteData *wd, AnimData *adt)
  {
        AnimOverride *aor;
        write_fcurves(wd, &adt->drivers);
        
        /* write overrides */
 +      // FIXME: are these needed?
        for (aor= adt->overrides.first; aor; aor= aor->next) {
                /* overrides consist of base data + rna_path */
                writestruct(wd, DATA, "AnimOverride", 1, aor);
                writedata(wd, DATA, strlen(aor->rna_path)+1, aor->rna_path);
        }
        
 +      // TODO write the remaps (if they are needed)
 +      
        /* write NLA data */
 -      // XXX todo...
 +      write_nladata(wd, &adt->nla_tracks);
  }
  
  static void write_constraints(WriteData *wd, ListBase *conlist)
@@@ -989,6 -956,11 +989,11 @@@ static void write_pose(WriteData *wd, b
  
        /* Write channels */
        for (chan=pose->chanbase.first; chan; chan=chan->next) {
+               /* Write ID Properties -- and copy this comment EXACTLY for easy finding
+                of library blocks that implement this.*/
+               if (chan->prop)
+                       IDP_WriteProperty(chan->prop, wd);
+               
                write_constraints(wd, &chan->constraints);
                
                /* prevent crashes with autosave, when a bone duplicated in editmode has not yet been assigned to its posechannel */
@@@ -1904,10 -1876,7 +1909,10 @@@ static void write_screens(WriteData *wd
                                        writestruct(wd, DATA, "SpaceSound", 1, sl);
                                }
                                else if(sl->spacetype==SPACE_NLA){
 -                                      writestruct(wd, DATA, "SpaceNla", 1, sl);
 +                                      SpaceNla *snla= (SpaceNla *)sl;
 +                                      
 +                                      writestruct(wd, DATA, "SpaceNla", 1, snla);
 +                                      if(snla->ads) writestruct(wd, DATA, "bDopeSheet", 1, snla->ads);
                                }
                                else if(sl->spacetype==SPACE_TIME){
                                        writestruct(wd, DATA, "SpaceTime", 1, sl);
index 9643e012ad4ac7f2205984ecc476f811c7a4b534,7e54045b5e4bfb2e777bf9d5673a98c6d91b6e60..802f8d88c0343534c4185f1b6d20fa9ebced28e6
@@@ -52,6 -52,9 +52,9 @@@ struct Object
   */
  typedef struct bPoseChannel {
        struct bPoseChannel     *next, *prev;
+       
+       IDProperty                      *prop;          /* User-Defined Properties on this PoseChannel */                       
+       
        ListBase                        constraints;/* Constraints that act on this PoseChannel */
        char                            name[32];       /* Channels need longer names than normal blender objects */
        
@@@ -287,7 -290,6 +290,7 @@@ typedef enum DOPESHEET_FILTERFLAG 
                /* general filtering */
        ADS_FILTER_ONLYSEL                      = (1<<0),
        ADS_FILTER_ONLYDRIVERS          = (1<<1),
 +      ADS_FILTER_ONLYNLA                      = (1<<2),
        
                /* datatype-based filtering */
        ADS_FILTER_NOSHAPEKEYS          = (1<<6),
@@@ -420,3 -422,4 +423,4 @@@ typedef enum ACHAN_FLAG 
  
  #endif
  
index 2dea6c4c9695f9bbe462fc43b2a188fde646304c,8cdb51bcab0e0051880f677e17fc88c5e30154ea..ba4ef1f164a6deb49efd20d6905f70554b34a75a
@@@ -244,11 -244,10 +244,11 @@@ typedef struct SpaceNla 
  
        short blockhandler[8];
  
 -      short menunr, lock;
        short autosnap;                 /* this uses the same settings as autosnap for Action Editor */
        short flag;
 +      int pad;
        
 +      struct bDopeSheet *ads;
        View2D v2d;      /* depricated, copied to region */
  } SpaceNla;
  
@@@ -578,6 -577,8 +578,8 @@@ typedef struct SpaceImaSel 
  #define SI_DISPGP             1<<22
  #define SI_DRAW_OTHER 1<<23
  
+ #define SI_COLOR_CORRECTION   1<<24
  /* SpaceIpo->flag (Graph Editor Settings) */
  #define SIPO_LOCK_VIEW                        (1<<0)
  #define SIPO_NOTRANSKEYCULL           (1<<1)
@@@ -683,7 -684,7 +685,7 @@@ enum 
  #define TIME_ONLYACTSEL               4
  
  /* time->redraws */
- #define TIME_LEFTMOST_3D_WIN  1
+ #define TIME_REGION                           1
  #define TIME_ALL_3D_WIN                       2
  #define TIME_ALL_ANIM_WIN             4
  #define TIME_ALL_BUTS_WIN             8