Merged changes in the trunk up to revision 34459.
authorTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>
Sat, 22 Jan 2011 23:38:28 +0000 (23:38 +0000)
committerTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>
Sat, 22 Jan 2011 23:38:28 +0000 (23:38 +0000)
13 files changed:
1  2 
source/blender/blenkernel/intern/object.c
source/blender/blenlib/intern/bpath.c
source/blender/blenloader/intern/readfile.c
source/blender/blenloader/intern/writefile.c
source/blender/editors/space_nla/nla_channels.c
source/blender/editors/space_outliner/outliner.c
source/blender/makesdna/DNA_ID.h
source/blender/makesdna/DNA_action_types.h
source/blender/makesdna/DNA_scene_types.h
source/blender/makesrna/intern/makesrna.c
source/blender/makesrna/intern/rna_internal.h
source/blender/python/intern/bpy.c
source/creator/creator.c

index b71338aaa704974443758b95f7c138ba9c240d41,43a13b2773663f029774cb23ddbd4d21d71f0e86..4c436e8411f65cc679e5f2d23e309188a16b3c3d
  
  #include "GPU_material.h"
  
 +#include "FRS_freestyle.h"
 +
  /* Local function protos */
  static void solve_parenting (Scene *scene, Object *ob, Object *par, float obmat[][4], float slowmat[][4], int simul);
  
@@@ -580,14 -578,6 +580,14 @@@ void unlink_object(Object *ob
                                        }
                                SEQ_END
                        }
 +
 +                      {
 +                              SceneRenderLayer *srl;
 +
 +                              for (srl= sce->r.layers.first; srl; srl= srl->next) {
 +                                      FRS_unlink_target_object(&srl->freestyleConfig, ob);
 +                              }
 +                      }
                }
  
                sce= sce->id.next;
@@@ -1684,7 -1674,7 +1684,7 @@@ void object_rot_to_mat3(Object *ob, flo
                normalize_qt_qt(tquat, ob->quat);
                quat_to_mat3(rmat, tquat);
  
-               normalize_qt_qt(tquat, ob->quat);
+               normalize_qt_qt(tquat, ob->dquat);
                quat_to_mat3(dmat, tquat);
        }
        
index 92deb6fbebc54607bddaec85dfcf3f7d18678924,b145eabed94c7d4ce9e0d7004271df41e18d6a9f..c930bd903b47ea70902f6aac90c67782bfd38a68
@@@ -51,7 -51,6 +51,7 @@@
  #include "DNA_sequence_types.h"
  #include "DNA_vfont_types.h"
  #include "DNA_windowmanager_types.h"
 +#include "DNA_freestyle_types.h"
  
  #include "BLI_blenlib.h"
  #include "BLI_bpath.h"
@@@ -78,12 -77,6 +78,12 @@@ typedef struct BPathIteratorSeqData 
        struct Scene *scene;                    /* Current scene */
  } BPathIteratorSeqData;
  
 +typedef struct BPathIteratorFrsModuleData {
 +      struct Scene *scene;                    /* Current scene */
 +      struct SceneRenderLayer *layer; /* Scene render layer */
 +      struct FreestyleModuleConfig *module;
 +} BPathIteratorFrsModuleData;
 +
  typedef struct BPathIterator {
        char*   _path; /* never access directly, use BLI_bpathIterator_getPath */
        const char*     _lib;
@@@ -91,6 -84,7 +91,7 @@@
        void*   data;
        int             len;
        int             type;
+       int             flag; /* iterator options */
  
        void (*setpath_callback)(struct BPathIterator *, const char *);
        void (*getpath_callback)(struct BPathIterator *, char *);
  
        /* only for seq data */
        struct BPathIteratorSeqData seqdata;
 +      /* only for Freestyle module data */
 +      struct BPathIteratorFrsModuleData frsmoduledata;
  } BPathIterator;
  
  #define FILE_MAX                      240
@@@ -118,12 -110,12 +119,13 @@@ enum BPathTypes 
        BPATH_LIB,
        BPATH_SEQ,
        BPATH_CDATA,
 +      BPATH_FRS_MODULE,
  
         BPATH_DONE
  };
  
- void BLI_bpathIterator_init(struct BPathIterator **bpi_pt, Main *bmain, const char *basedir) {
+ void BLI_bpathIterator_init(struct BPathIterator **bpi_pt, Main *bmain, const char *basedir, const int flag)
+ {
        BPathIterator *bpi;
  
        bpi= MEM_mallocN(sizeof(BPathIterator), "BLI_bpathIterator_init");
        bpi->seqdata.seq= 0;
        bpi->seqdata.seqar= NULL;
        bpi->seqdata.scene= NULL;
-       
+       bpi->flag= flag;
 +      /* Freestyle module specific */
 +      bpi->frsmoduledata.scene= NULL;
 +      bpi->frsmoduledata.layer= NULL;
 +      bpi->frsmoduledata.module= NULL;
 +
        bpi->base_path= basedir; /* normally bmain->name */
        bpi->bmain= bmain;
  
@@@ -156,35 -145,32 +160,35 @@@ void BLI_bpathIterator_alloc(struct BPa
        *bpi= MEM_mallocN(sizeof(BPathIterator), "BLI_bpathIterator_alloc");
  }
  
 -void BLI_bpathIterator_free(struct BPathIterator *bpi) {
 +void BLI_bpathIterator_free( struct BPathIterator *bpi ) {
        if (bpi->seqdata.seqar)
                MEM_freeN((void *)bpi->seqdata.seqar);
        bpi->seqdata.seqar= NULL;
        bpi->seqdata.scene= NULL;
 +      bpi->frsmoduledata.scene= NULL;
 +      bpi->frsmoduledata.layer= NULL;
 +      bpi->frsmoduledata.module= NULL;
        
        MEM_freeN(bpi);
  }
  
 -void BLI_bpathIterator_getPath(struct BPathIterator *bpi, char *path) {
 +void BLI_bpathIterator_getPath( struct BPathIterator *bpi, char *path) {
        if (bpi->getpath_callback) {
 -              bpi->getpath_callback(bpi, path);
 +              bpi->getpath_callback( bpi, path );
        } else {
                strcpy(path, bpi->_path); /* warning, we assume 'path' are long enough */
        }
  }
  
 -void BLI_bpathIterator_setPath(struct BPathIterator *bpi, const char *path) {
 +void BLI_bpathIterator_setPath( struct BPathIterator *bpi, const char *path) {
        if (bpi->setpath_callback) {
 -              bpi->setpath_callback(bpi, path);
 +              bpi->setpath_callback( bpi, path );
        } else {
                strcpy(bpi->_path, path); /* warning, we assume 'path' are long enough */
        }
  }
  
 -void BLI_bpathIterator_getPathExpanded(struct BPathIterator *bpi, char *path_expanded) {
 +void BLI_bpathIterator_getPathExpanded( struct BPathIterator *bpi, char *path_expanded) {
        const char *libpath;
        
        BLI_bpathIterator_getPath(bpi, path_expanded);
        }
        BLI_cleanup_file(NULL, path_expanded);
  }
 -const char* BLI_bpathIterator_getLib(struct BPathIterator *bpi) {
 +const char* BLI_bpathIterator_getLib( struct BPathIterator *bpi) {
        return bpi->_lib;
  }
 -const char* BLI_bpathIterator_getName(struct BPathIterator *bpi) {
 +const char* BLI_bpathIterator_getName( struct BPathIterator *bpi) {
        return bpi->_name;
  }
 -int   BLI_bpathIterator_getType(struct BPathIterator *bpi) {
 +int   BLI_bpathIterator_getType( struct BPathIterator *bpi) {
        return bpi->type;
  }
 -int   BLI_bpathIterator_getPathMaxLen(struct BPathIterator *bpi) {
 +int   BLI_bpathIterator_getPathMaxLen( struct BPathIterator *bpi) {
        return bpi->len;
  }
 -const char* BLI_bpathIterator_getBasePath(struct BPathIterator *bpi) {
 +const char* BLI_bpathIterator_getBasePath( struct BPathIterator *bpi) {
        return bpi->base_path;
  }
  
  /* gets the first or the next image that has a path - not a viewer node or generated image */
- static struct Image *ima_stepdata__internal(struct Image *ima, int step_next) {
+ static struct Image *ima_stepdata__internal(struct Image *ima, const int step_next, const int flag)
+ {
        if (ima==NULL)
                return NULL;
        
                ima= ima->id.next;
        
        while (ima) {
-               if (ima->packedfile==NULL && ELEM3(ima->source, IMA_SRC_FILE, IMA_SRC_MOVIE, IMA_SRC_SEQUENCE))
-                       break;
+               if (ELEM3(ima->source, IMA_SRC_FILE, IMA_SRC_MOVIE, IMA_SRC_SEQUENCE)) {
+                       if(ima->packedfile==NULL || (flag & BPATH_USE_PACKED)) {
+                               break;
+                       }
+               }
                /* image is not a image with a path, skip it */
                ima= ima->id.next;
        }       
        return ima;
  }
  
- static struct Tex *tex_stepdata__internal(struct Tex *tex, int step_next) {
+ static struct Tex *tex_stepdata__internal(struct Tex *tex, const int step_next, const int UNUSED(flag))
+ {
        if (tex==NULL)
                return NULL;
  
        return tex;
  }
  
- static struct Text *text_stepdata__internal(struct Text *text, int step_next) {
+ static struct Text *text_stepdata__internal(struct Text *text, const int step_next, const int UNUSED(flag))
+ {
        if (text==NULL)
                return NULL;
  
        return text;
  }
  
- static struct VFont *vf_stepdata__internal(struct VFont *vf, int step_next) {
+ static struct VFont *vf_stepdata__internal(struct VFont *vf, const int step_next, const int flag)
+ {
        if (vf==NULL)
                return NULL;
        
                vf= vf->id.next;
        
        while (vf) {
-               if (vf->packedfile==NULL && strcmp(vf->name, FO_BUILTIN_NAME)!=0) {
-                       break;
+               if (strcmp(vf->name, FO_BUILTIN_NAME)!=0) {
+                       if(vf->packedfile==NULL || (flag & BPATH_USE_PACKED)) {
+                               break;
+                       }
                }
                
                /* font with no path, skip it */
        return vf;
  }
  
- static struct bSound *snd_stepdata__internal(struct bSound *snd, int step_next) {
+ static struct bSound *snd_stepdata__internal(struct bSound *snd, int step_next, const int flag)
+ {
        if (snd==NULL)
                return NULL;
        
                snd= snd->id.next;
        
        while (snd) {
-               if (snd->packedfile==NULL) {
+               if(snd->packedfile==NULL || (flag & BPATH_USE_PACKED)) {
                        break;
                }
-               
                /* font with no path, skip it */
                snd= snd->id.next;
        }       
@@@ -353,35 -349,6 +367,35 @@@ static struct Sequence *seq_stepdata__i
        return NULL;
  }
  
 +static struct FreestyleModuleConfig *frs_module_stepdata__internal(struct BPathIterator *bpi, int step_next)
 +{
 +      struct FreestyleModuleConfig *module;
 +
 +      /* Initializing */
 +      if (bpi->frsmoduledata.scene==NULL) {
 +              bpi->frsmoduledata.scene= G.main->scene.first;
 +              bpi->frsmoduledata.layer= (bpi->frsmoduledata.scene) ? bpi->frsmoduledata.scene->r.layers.first : NULL;
 +              bpi->frsmoduledata.module= (bpi->frsmoduledata.layer) ? bpi->frsmoduledata.layer->freestyleConfig.modules.first : NULL;
 +      }
 +
 +      while (bpi->frsmoduledata.scene) {
 +              while (bpi->frsmoduledata.layer) {
 +                      while (bpi->frsmoduledata.module) {
 +                              module= bpi->frsmoduledata.module;
 +                              bpi->frsmoduledata.module= module->next;
 +                              return module;
 +                      }
 +                      bpi->frsmoduledata.layer= bpi->frsmoduledata.layer->next;
 +                      bpi->frsmoduledata.module= (bpi->frsmoduledata.layer) ? bpi->frsmoduledata.layer->freestyleConfig.modules.first : NULL;
 +              }
 +              bpi->frsmoduledata.scene= bpi->frsmoduledata.scene->id.next;
 +              bpi->frsmoduledata.layer= (bpi->frsmoduledata.scene) ? bpi->frsmoduledata.scene->r.layers.first : NULL;
 +              bpi->frsmoduledata.module= (bpi->frsmoduledata.layer) ? bpi->frsmoduledata.layer->freestyleConfig.modules.first : NULL;
 +      }
 +
 +      return NULL;
 +}
 +
  static void seq_getpath(struct BPathIterator *bpi, char *path) {
        Sequence *seq= (Sequence *)bpi->data;
  
@@@ -461,7 -428,7 +475,7 @@@ static struct Mesh *cdata_stepdata__int
        return me;
  }
  
 -static void bpi_type_step__internal(struct BPathIterator *bpi) {
 +static void bpi_type_step__internal( struct BPathIterator *bpi) {
        bpi->type++; /* advance to the next type */
        bpi->data= NULL;
        
        }
  }
  
 -void BLI_bpathIterator_step(struct BPathIterator *bpi) {
 +void BLI_bpathIterator_step( struct BPathIterator *bpi) {
        while (bpi->type != BPATH_DONE) {
                
                if  ((bpi->type) == BPATH_IMAGE) {
                        /*if (bpi->data)        bpi->data= ((ID *)bpi->data)->next;*/
-                       if (bpi->data)  bpi->data= ima_stepdata__internal( (Image *)bpi->data, 1 ); /* must skip images that have no path */
-                       else                    bpi->data= ima_stepdata__internal(bpi->bmain->image.first, 0);
+                       if (bpi->data)  bpi->data= ima_stepdata__internal((Image *)bpi->data, 1, bpi->flag); /* must skip images that have no path */
+                       else                    bpi->data= ima_stepdata__internal(bpi->bmain->image.first, 0, bpi->flag);
                        
                        if (bpi->data) {
                                /* get the path info from this datatype */
  
                if  ((bpi->type) == BPATH_TEXTURE) {
                        /*if (bpi->data)        bpi->data= ((ID *)bpi->data)->next;*/
-                       if (bpi->data)  bpi->data= tex_stepdata__internal( (Tex *)bpi->data, 1 ); /* must skip images that have no path */
-                       else                    bpi->data= tex_stepdata__internal(bpi->bmain->tex.first, 0);
+                       if (bpi->data)  bpi->data= tex_stepdata__internal( (Tex *)bpi->data, 1, bpi->flag); /* must skip images that have no path */
+                       else                    bpi->data= tex_stepdata__internal(bpi->bmain->tex.first, 0, bpi->flag);
  
                        if (bpi->data) {
                                /* get the path info from this datatype */
  
                if  ((bpi->type) == BPATH_TEXT) {
                        /*if (bpi->data)        bpi->data= ((ID *)bpi->data)->next;*/
-                       if (bpi->data)  bpi->data= text_stepdata__internal( (Text *)bpi->data, 1 ); /* must skip images that have no path */
-                       else                    bpi->data= text_stepdata__internal(bpi->bmain->text.first, 0);
+                       if (bpi->data)  bpi->data= text_stepdata__internal((Text *)bpi->data, 1, bpi->flag); /* must skip images that have no path */
+                       else                    bpi->data= text_stepdata__internal(bpi->bmain->text.first, 0, bpi->flag);
  
                        if (bpi->data) {
                                /* get the path info from this datatype */
                }
  
                else if  ((bpi->type) == BPATH_SOUND) {
-                       if (bpi->data)  bpi->data= snd_stepdata__internal( (bSound *)bpi->data, 1 ); /* must skip images that have no path */
-                       else                    bpi->data= snd_stepdata__internal(bpi->bmain->sound.first, 0);
+                       if (bpi->data)  bpi->data= snd_stepdata__internal((bSound *)bpi->data, 1, bpi->flag); /* must skip images that have no path */
+                       else                    bpi->data= snd_stepdata__internal(bpi->bmain->sound.first, 0, bpi->flag);
  
                        if (bpi->data) {
                                /* get the path info from this datatype */
                        
                } else if  ((bpi->type) == BPATH_FONT) {
                        
-                       if (bpi->data)  bpi->data= vf_stepdata__internal( (VFont *)bpi->data, 1 );
-                       else                    bpi->data= vf_stepdata__internal( bpi->bmain->vfont.first, 0 );
+                       if (bpi->data)  bpi->data= vf_stepdata__internal((VFont *)bpi->data, 1, bpi->flag);
+                       else                    bpi->data= vf_stepdata__internal(bpi->bmain->vfont.first, 0, bpi->flag);
                        
                        if (bpi->data) {
                                /* get the path info from this datatype */
                        } else {
                                bpi_type_step__internal(bpi);
                        }
 +              } else if  ((bpi->type) == BPATH_FRS_MODULE) {
 +                      if (bpi->data)  bpi->data= frs_module_stepdata__internal( bpi, 1 );
 +                      else                    bpi->data= frs_module_stepdata__internal( bpi, 0 );
 +
 +                      if (bpi->data) {
 +                              FreestyleModuleConfig *module= (FreestyleModuleConfig *)bpi->data;
 +                              bpi->_lib= NULL;
 +                              bpi->_path= module->module_path;
 +                              bpi->_name= NULL;
 +                              bpi->len= sizeof(module->module_path);
 +                              break;
 +                      } else {
 +                              bpi_type_step__internal(bpi);
 +                      }
                }
        }
  }
@@@ -696,9 -649,6 +710,9 @@@ static void bpath_as_report(struct BPat
        case BPATH_CDATA:
                prefix= "Mesh Data";
                break;
 +      case BPATH_FRS_MODULE:
 +              prefix= "Freestyle Module";
 +              break;
        default:
                prefix= "Unknown";
                break;
@@@ -721,7 -671,7 +735,7 @@@ void checkMissingFiles(Main *bmain, Rep
        /* be sure there is low chance of the path being too short */
        char filepath_expanded[FILE_MAXDIR*2]; 
        
-       BLI_bpathIterator_init(&bpi, bmain, bmain->name);
+       BLI_bpathIterator_init(&bpi, bmain, bmain->name, 0);
        while (!BLI_bpathIterator_isDone(bpi)) {
                BLI_bpathIterator_getPathExpanded(bpi, filepath_expanded);
                
@@@ -743,7 -693,7 +757,7 @@@ void makeFilesRelative(Main *bmain, con
        /* be sure there is low chance of the path being too short */
        char filepath_relative[(FILE_MAXDIR * 2) + FILE_MAXFILE];
        
-       BLI_bpathIterator_init(&bpi, bmain, basedir);
+       BLI_bpathIterator_init(&bpi, bmain, basedir, 0);
        while (!BLI_bpathIterator_isDone(bpi)) {
                BLI_bpathIterator_getPath(bpi, filepath);
                libpath= BLI_bpathIterator_getLib(bpi);
@@@ -794,7 -744,7 +808,7 @@@ void makeFilesAbsolute(Main *bmain, con
        /* be sure there is low chance of the path being too short */
        char filepath_absolute[(FILE_MAXDIR * 2) + FILE_MAXFILE];
        
-       BLI_bpathIterator_init(&bpi, bmain, basedir);
+       BLI_bpathIterator_init(&bpi, bmain, basedir, 0);
        while (!BLI_bpathIterator_isDone(bpi)) {
                BLI_bpathIterator_getPath(bpi, filepath);
                libpath= BLI_bpathIterator_getLib(bpi);
@@@ -900,7 -850,7 +914,7 @@@ void findMissingFiles(Main *bmain, cons
        
        BLI_split_dirfile(str, dirname, NULL);
        
-       BLI_bpathIterator_init(&bpi, bmain, bmain->name);
+       BLI_bpathIterator_init(&bpi, bmain, bmain->name, 0);
        
        while (!BLI_bpathIterator_isDone(bpi)) {
                BLI_bpathIterator_getPath(bpi, filepath);
index 60b56df12587a2fc935ce90f8b74f5521bce84fb,6fa70b0a9c253df1fbd69a06ba82b2858814ef16..a5077af56478b31b2ab89f7a9daf88c788948586
@@@ -62,7 -62,6 +62,7 @@@
  #include "DNA_key_types.h"
  #include "DNA_lattice_types.h"
  #include "DNA_lamp_types.h"
 +#include "DNA_linestyle_types.h"
  #include "DNA_meta_types.h"
  #include "DNA_material_types.h"
  #include "DNA_mesh_types.h"
@@@ -2105,8 -2104,11 +2105,11 @@@ static void direct_link_nodetree(FileDa
                                else if(ELEM3(node->type, CMP_NODE_IMAGE, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER))
                                        ((ImageUser *)node->storage)->ok= 1;
                        }
-                       else if( ntree->type==NTREE_TEXTURE && (node->type==TEX_NODE_CURVE_RGB || node->type==TEX_NODE_CURVE_TIME) ) {
-                               direct_link_curvemapping(fd, node->storage);
+                       else if( ntree->type==NTREE_TEXTURE) {
+                               if(node->type==TEX_NODE_CURVE_RGB || node->type==TEX_NODE_CURVE_TIME)
+                                       direct_link_curvemapping(fd, node->storage);
+                               else if(node->type==TEX_NODE_IMAGE)
+                                       ((ImageUser *)node->storage)->ok= 1;
                        }
                }
                link_list(fd, &node->inputs);
@@@ -3821,11 -3823,11 +3824,11 @@@ static void direct_link_modifiers(FileD
                                clmd->sim_parms->reset = 0;
  
                                clmd->sim_parms->effector_weights = newdataadr(fd, clmd->sim_parms->effector_weights);
-                       }
  
-                       if(!clmd->sim_parms->effector_weights)
-                               clmd->sim_parms->effector_weights = BKE_add_effector_weights(NULL);
-                       
+                               if(!clmd->sim_parms->effector_weights) {
+                                       clmd->sim_parms->effector_weights = BKE_add_effector_weights(NULL);
+                               }
+                       }
                }
                else if (md->type==eModifierType_Fluidsim) {
                        FluidsimModifierData *fluidmd = (FluidsimModifierData*) md;
@@@ -4223,7 -4225,6 +4226,7 @@@ static void lib_link_scene(FileData *fd
        Base *base, *next;
        Sequence *seq;
        SceneRenderLayer *srl;
 +      FreestyleLineSet *fls;
        TimeMarker *marker;
        
        sce= main->scene.first;
                        for(srl= sce->r.layers.first; srl; srl= srl->next) {
                                srl->mat_override= newlibadr_us(fd, sce->id.lib, srl->mat_override);
                                srl->light_override= newlibadr_us(fd, sce->id.lib, srl->light_override);
 +                              for(fls=srl->freestyleConfig.linesets.first; fls; fls= fls->next) {
 +                                      fls->linestyle= newlibadr_us(fd, sce->id.lib, fls->linestyle);
 +                                      fls->group= newlibadr_us(fd, sce->id.lib, fls->group);
 +                              }
                        }
                        /*Game Settings: Dome Warp Text*/
                        sce->gm.dome.warptext= newlibadr(fd, sce->id.lib, sce->gm.dome.warptext);
@@@ -4341,7 -4338,6 +4344,7 @@@ static void direct_link_scene(FileData 
        Editing *ed;
        Sequence *seq;
        MetaStack *ms;
 +      SceneRenderLayer *srl;
  
        sce->theDag = NULL;
        sce->dagisvalid = 0;
        link_list(fd, &(sce->transform_spaces));
        link_list(fd, &(sce->r.layers));
  
 +      for(srl= sce->r.layers.first; srl; srl= srl->next) {
 +              link_list(fd, &(srl->freestyleConfig.modules));
 +      }
 +      for(srl= sce->r.layers.first; srl; srl= srl->next) {
 +              link_list(fd, &(srl->freestyleConfig.linesets));
 +      }
 +      
        sce->nodetree= newdataadr(fd, sce->nodetree);
        if(sce->nodetree)
                direct_link_nodetree(fd, sce->nodetree);
@@@ -5451,138 -5440,6 +5454,138 @@@ static void lib_link_group(FileData *fd
        }
  }
  
 +/* ************ READ LINE STYLE ***************** */
 +
 +static void lib_link_linestyle(FileData *fd, Main *main)
 +{
 +      FreestyleLineStyle *linestyle;
 +      LineStyleModifier *m;
 +
 +      linestyle = main->linestyle.first;
 +      while (linestyle) {
 +              if (linestyle->id.flag & LIB_NEEDLINK) {
 +                      linestyle->id.flag -= LIB_NEEDLINK;
 +
 +                      if (linestyle->id.properties) IDP_LibLinkProperty(linestyle->id.properties, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd);
 +                      if (linestyle->adt) lib_link_animdata(fd, &linestyle->id, linestyle->adt);
 +                      for (m = linestyle->color_modifiers.first; m; m = m->next) {
 +                              if (m->type == LS_MODIFIER_DISTANCE_FROM_OBJECT) {
 +                                      LineStyleColorModifier_DistanceFromObject *cm = (LineStyleColorModifier_DistanceFromObject *)m;
 +                                      cm->target = newlibadr(fd, linestyle->id.lib, cm->target);
 +                              }
 +                      }
 +                      for (m = linestyle->alpha_modifiers.first; m; m = m->next){
 +                              if (m->type == LS_MODIFIER_DISTANCE_FROM_OBJECT) {
 +                                      LineStyleAlphaModifier_DistanceFromObject *am = (LineStyleAlphaModifier_DistanceFromObject *)m;
 +                                      am->target = newlibadr(fd, linestyle->id.lib, am->target);
 +                              }
 +                      }
 +                      for (m = linestyle->thickness_modifiers.first; m; m = m->next){
 +                              if (m->type == LS_MODIFIER_DISTANCE_FROM_OBJECT) {
 +                                      LineStyleThicknessModifier_DistanceFromObject *tm = (LineStyleThicknessModifier_DistanceFromObject *)m;
 +                                      tm->target = newlibadr(fd, linestyle->id.lib, tm->target);
 +                              }
 +                      }
 +              }
 +              linestyle = linestyle->id.next;
 +      }
 +}
 +
 +static void direct_link_linestyle_color_modifier(FileData *fd, LineStyleModifier *modifier)
 +{
 +      switch (modifier->type) {
 +      case LS_MODIFIER_ALONG_STROKE:
 +              {
 +                      LineStyleColorModifier_AlongStroke *m = (LineStyleColorModifier_AlongStroke *)modifier;
 +                      m->color_ramp = newdataadr(fd, m->color_ramp);
 +              }
 +              break;
 +      case LS_MODIFIER_DISTANCE_FROM_CAMERA:
 +              {
 +                      LineStyleColorModifier_DistanceFromCamera *m = (LineStyleColorModifier_DistanceFromCamera *)modifier;
 +                      m->color_ramp = newdataadr(fd, m->color_ramp);
 +              }
 +              break;
 +      case LS_MODIFIER_DISTANCE_FROM_OBJECT:
 +              {
 +                      LineStyleColorModifier_DistanceFromObject *m = (LineStyleColorModifier_DistanceFromObject *)modifier;
 +                      m->color_ramp = newdataadr(fd, m->color_ramp);
 +              }
 +              break;
 +      }
 +}
 +
 +static void direct_link_linestyle_alpha_modifier(FileData *fd, LineStyleModifier *modifier)
 +{
 +      switch (modifier->type) {
 +      case LS_MODIFIER_ALONG_STROKE:
 +              {
 +                      LineStyleAlphaModifier_AlongStroke *m = (LineStyleAlphaModifier_AlongStroke *)modifier;
 +                      m->curve = newdataadr(fd, m->curve);
 +                      direct_link_curvemapping(fd, m->curve);
 +              }
 +              break;
 +      case LS_MODIFIER_DISTANCE_FROM_CAMERA:
 +              {
 +                      LineStyleAlphaModifier_DistanceFromCamera *m = (LineStyleAlphaModifier_DistanceFromCamera *)modifier;
 +                      m->curve = newdataadr(fd, m->curve);
 +                      direct_link_curvemapping(fd, m->curve);
 +              }
 +              break;
 +      case LS_MODIFIER_DISTANCE_FROM_OBJECT:
 +              {
 +                      LineStyleAlphaModifier_DistanceFromObject *m = (LineStyleAlphaModifier_DistanceFromObject *)modifier;
 +                      m->curve = newdataadr(fd, m->curve);
 +                      direct_link_curvemapping(fd, m->curve);
 +              }
 +              break;
 +      }
 +}
 +
 +static void direct_link_linestyle_thickness_modifier(FileData *fd, LineStyleModifier *modifier)
 +{
 +      switch (modifier->type) {
 +      case LS_MODIFIER_ALONG_STROKE:
 +              {
 +                      LineStyleThicknessModifier_AlongStroke *m = (LineStyleThicknessModifier_AlongStroke *)modifier;
 +                      m->curve = newdataadr(fd, m->curve);
 +                      direct_link_curvemapping(fd, m->curve);
 +              }
 +              break;
 +      case LS_MODIFIER_DISTANCE_FROM_CAMERA:
 +              {
 +                      LineStyleThicknessModifier_DistanceFromCamera *m = (LineStyleThicknessModifier_DistanceFromCamera *)modifier;
 +                      m->curve = newdataadr(fd, m->curve);
 +                      direct_link_curvemapping(fd, m->curve);
 +              }
 +              break;
 +      case LS_MODIFIER_DISTANCE_FROM_OBJECT:
 +              {
 +                      LineStyleThicknessModifier_DistanceFromObject *m = (LineStyleThicknessModifier_DistanceFromObject *)modifier;
 +                      m->curve = newdataadr(fd, m->curve);
 +                      direct_link_curvemapping(fd, m->curve);
 +              }
 +              break;
 +      }
 +}
 +
 +static void direct_link_linestyle(FileData *fd, FreestyleLineStyle *linestyle)
 +{
 +      LineStyleModifier *modifier;
 +
 +      linestyle->adt= newdataadr(fd, linestyle->adt);
 +      direct_link_animdata(fd, linestyle->adt);
 +      link_list(fd, &linestyle->color_modifiers);
 +      for(modifier=linestyle->color_modifiers.first; modifier; modifier= modifier->next)
 +              direct_link_linestyle_color_modifier(fd, modifier);
 +      link_list(fd, &linestyle->alpha_modifiers);
 +      for(modifier=linestyle->alpha_modifiers.first; modifier; modifier= modifier->next)
 +              direct_link_linestyle_alpha_modifier(fd, modifier);
 +      link_list(fd, &linestyle->thickness_modifiers);
 +      for(modifier=linestyle->thickness_modifiers.first; modifier; modifier= modifier->next)
 +              direct_link_linestyle_thickness_modifier(fd, modifier);
 +}
 +
  /* ************** GENERAL & MAIN ******************** */
  
  
@@@ -5616,7 -5473,6 +5619,7 @@@ static const char *dataname(short id_co
                case ID_BR: return "Data from BR";
                case ID_PA: return "Data from PA";
                case ID_GD: return "Data from GD";
 +              case ID_LS: return "Data from LS";
        }
        return "Data from Lib Block";
        
@@@ -5784,9 -5640,6 +5787,9 @@@ static BHead *read_libblock(FileData *f
                case ID_GD:
                        direct_link_gpencil(fd, (bGPdata *)id);
                        break;
 +              case ID_LS:
 +                      direct_link_linestyle(fd, (FreestyleLineStyle *)id);
 +                      break;
        }
        
        /*link direct data of ID properties*/
@@@ -9014,9 -8867,13 +9017,13 @@@ static void do_versions(FileData *fd, L
                                ob->soft->pointcache= BKE_ptcache_add(&ob->soft->ptcaches);
  
                        for(psys=ob->particlesystem.first; psys; psys=psys->next) {
-                               //if(psys->soft && !psys->soft->pointcache)
-                               //      psys->soft->pointcache= BKE_ptcache_add(&psys->soft->ptcaches);
-                               if(!psys->pointcache)
+                               if(psys->pointcache) {
+                                       if(psys->pointcache->flag & PTCACHE_BAKED && (psys->pointcache->flag & PTCACHE_DISK_CACHE)==0) {
+                                               printf("Old memory cache isn't supported for particles, so re-bake the simulation!\n");
+                                               psys->pointcache->flag &= ~PTCACHE_BAKED;
+                                       }
+                               }
+                               else
                                        psys->pointcache= BKE_ptcache_add(&psys->ptcaches);
                        }
  
@@@ -11468,7 -11325,6 +11475,7 @@@ static void lib_link_all(FileData *fd, 
        lib_link_nodetree(fd, main);    /* has to be done after scene/materials, this will verify group nodes */
        lib_link_brush(fd, main);
        lib_link_particlesettings(fd, main);
 +      lib_link_linestyle(fd, main);
  
        lib_link_mesh(fd, main);                /* as last: tpage images with users at zero */
  
@@@ -12395,25 -12251,6 +12402,25 @@@ static void expand_sound(FileData *fd, 
        expand_doit(fd, mainvar, snd->ipo); // XXX depreceated - old animation system
  }
  
 +static void expand_linestyle(FileData *fd, Main *mainvar, FreestyleLineStyle *linestyle)
 +{
 +      LineStyleModifier *m;
 +
 +      if (linestyle->adt)
 +              expand_animdata(fd, mainvar, linestyle->adt);
 +      for (m = linestyle->color_modifiers.first; m; m = m->next) {
 +              if (m->type == LS_MODIFIER_DISTANCE_FROM_OBJECT)
 +                      expand_doit(fd, mainvar, ((LineStyleColorModifier_DistanceFromObject *)m)->target);
 +      }
 +      for (m = linestyle->alpha_modifiers.first; m; m = m->next){
 +              if (m->type == LS_MODIFIER_DISTANCE_FROM_OBJECT)
 +                      expand_doit(fd, mainvar, ((LineStyleAlphaModifier_DistanceFromObject *)m)->target);
 +      }
 +      for (m = linestyle->thickness_modifiers.first; m; m = m->next){
 +              if (m->type == LS_MODIFIER_DISTANCE_FROM_OBJECT)
 +                      expand_doit(fd, mainvar, ((LineStyleThicknessModifier_DistanceFromObject *)m)->target);
 +      }
 +}
  
  static void expand_main(FileData *fd, Main *mainvar)
  {
                                                break;
                                        case ID_PA:
                                                expand_particlesettings(fd, mainvar, (ParticleSettings *)id);
 +                                              break;
 +                                      case ID_LS:
 +                                              expand_linestyle(fd, mainvar, (FreestyleLineStyle *)id);
 +                                              break;
                                        }
  
                                        doit= 1;
index 1b2c44cfb31fb2daee1310facc407de49b8923dc,263d799aa69656f94fc17ada50d9ea336fec5bc1..ba275ae7f4828a2ab75695b390a9e89f3cd069e2
@@@ -101,7 -101,6 +101,7 @@@ Any case: direct data is ALWAYS after t
  #include "DNA_key_types.h"
  #include "DNA_lattice_types.h"
  #include "DNA_lamp_types.h"
 +#include "DNA_linestyle_types.h"
  #include "DNA_meta_types.h"
  #include "DNA_mesh_types.h"
  #include "DNA_meshdata_types.h"
@@@ -1806,8 -1805,6 +1806,8 @@@ static void write_scenes(WriteData *wd
        TimeMarker *marker;
        TransformOrientation *ts;
        SceneRenderLayer *srl;
 +      FreestyleModuleConfig *fmc;
 +      FreestyleLineSet *fls;
        ToolSettings *tos;
        
        sce= scebase->first;
                for(ts = sce->transform_spaces.first; ts; ts = ts->next)
                        writestruct(wd, DATA, "TransformOrientation", 1, ts);
                
 -              for(srl= sce->r.layers.first; srl; srl= srl->next)
 +              for(srl= sce->r.layers.first; srl; srl= srl->next) {
                        writestruct(wd, DATA, "SceneRenderLayer", 1, srl);
 +                      
 +                      for(fmc= srl->freestyleConfig.modules.first; fmc; fmc = fmc->next) {
 +                              writestruct(wd, DATA, "FreestyleModuleConfig", 1, fmc);
 +                      }
 +                      
 +                      for(fls= srl->freestyleConfig.linesets.first; fls; fls = fls->next) {
 +                              writestruct(wd, DATA, "FreestyleLineSet", 1, fls);
 +                              writestruct(wd, DATA, "FreestyleLineStyle", 1, fls->linestyle);
 +                              writestruct(wd, DATA, "Group", 1, fls->group);
 +                      }
 +
 +              }
                
                if(sce->nodetree) {
                        writestruct(wd, DATA, "bNodeTree", 1, sce->nodetree);
@@@ -1963,21 -1948,23 +1963,23 @@@ static void write_gpencils(WriteData *w
        bGPDstroke *gps;
        
        for (gpd= lb->first; gpd; gpd= gpd->id.next) {
-               /* write gpd data block to file */
-               writestruct(wd, ID_GD, "bGPdata", 1, gpd);
-               
-               /* write grease-pencil layers to file */
-               for (gpl= gpd->layers.first; gpl; gpl= gpl->next) {
-                       writestruct(wd, DATA, "bGPDlayer", 1, gpl);
+               if (gpd->id.us>0 || wd->current) {
+                       /* write gpd data block to file */
+                       writestruct(wd, ID_GD, "bGPdata", 1, gpd);
                        
-                       /* write this layer's frames to file */
-                       for (gpf= gpl->frames.first; gpf; gpf= gpf->next) {
-                               writestruct(wd, DATA, "bGPDframe", 1, gpf);
+                       /* write grease-pencil layers to file */
+                       for (gpl= gpd->layers.first; gpl; gpl= gpl->next) {
+                               writestruct(wd, DATA, "bGPDlayer", 1, gpl);
                                
-                               /* write strokes */
-                               for (gps= gpf->strokes.first; gps; gps= gps->next) {
-                                       writestruct(wd, DATA, "bGPDstroke", 1, gps);
-                                       writestruct(wd, DATA, "bGPDspoint", gps->totpoints, gps->points);                               
+                               /* write this layer's frames to file */
+                               for (gpf= gpl->frames.first; gpf; gpf= gpf->next) {
+                                       writestruct(wd, DATA, "bGPDframe", 1, gpf);
+                                       
+                                       /* write strokes */
+                                       for (gps= gpf->strokes.first; gps; gps= gps->next) {
+                                               writestruct(wd, DATA, "bGPDstroke", 1, gps);
+                                               writestruct(wd, DATA, "bGPDspoint", gps->totpoints, gps->points);                               
+                                       }
                                }
                        }
                }
@@@ -2392,130 -2379,6 +2394,130 @@@ static void write_scripts(WriteData *wd
        }
  }
  
 +static void write_linestyle_color_modifiers(WriteData *wd, ListBase *modifiers)
 +{
 +      LineStyleModifier *m;
 +      char *struct_name;
 +
 +      for (m = modifiers->first; m; m = m->next) {
 +              switch (m->type) {
 +              case LS_MODIFIER_ALONG_STROKE:
 +                      struct_name = "LineStyleColorModifier_AlongStroke";
 +                      break;
 +              case LS_MODIFIER_DISTANCE_FROM_CAMERA:
 +                      struct_name = "LineStyleColorModifier_DistanceFromCamera";
 +                      break;
 +              case LS_MODIFIER_DISTANCE_FROM_OBJECT:
 +                      struct_name = "LineStyleColorModifier_DistanceFromObject";
 +                      break;
 +              default:
 +                      struct_name = "LineStyleColorModifier"; // this should not happen
 +              }
 +              writestruct(wd, DATA, struct_name, 1, m);
 +      }
 +      for (m = modifiers->first; m; m = m->next) {
 +              switch (m->type) {
 +              case LS_MODIFIER_ALONG_STROKE:
 +                      writestruct(wd, DATA, "ColorBand", 1, ((LineStyleColorModifier_AlongStroke *)m)->color_ramp);
 +                      break;
 +              case LS_MODIFIER_DISTANCE_FROM_CAMERA:
 +                      writestruct(wd, DATA, "ColorBand", 1, ((LineStyleColorModifier_DistanceFromCamera *)m)->color_ramp);
 +                      break;
 +              case LS_MODIFIER_DISTANCE_FROM_OBJECT:
 +                      writestruct(wd, DATA, "ColorBand", 1, ((LineStyleColorModifier_DistanceFromObject *)m)->color_ramp);
 +                      break;
 +              }
 +      }
 +}
 +
 +static void write_linestyle_alpha_modifiers(WriteData *wd, ListBase *modifiers)
 +{
 +      LineStyleModifier *m;
 +      char *struct_name;
 +
 +      for (m = modifiers->first; m; m = m->next) {
 +              switch (m->type) {
 +              case LS_MODIFIER_ALONG_STROKE:
 +                      struct_name = "LineStyleAlphaModifier_AlongStroke";
 +                      break;
 +              case LS_MODIFIER_DISTANCE_FROM_CAMERA:
 +                      struct_name = "LineStyleAlphaModifier_DistanceFromCamera";
 +                      break;
 +              case LS_MODIFIER_DISTANCE_FROM_OBJECT:
 +                      struct_name = "LineStyleAlphaModifier_DistanceFromObject";
 +                      break;
 +              default:
 +                      struct_name = "LineStyleAlphaModifier"; // this should not happen
 +              }
 +              writestruct(wd, DATA, struct_name, 1, m);
 +      }
 +      for (m = modifiers->first; m; m = m->next) {
 +              switch (m->type) {
 +              case LS_MODIFIER_ALONG_STROKE:
 +                      write_curvemapping(wd, ((LineStyleAlphaModifier_AlongStroke *)m)->curve);
 +                      break;
 +              case LS_MODIFIER_DISTANCE_FROM_CAMERA:
 +                      write_curvemapping(wd, ((LineStyleAlphaModifier_DistanceFromCamera *)m)->curve);
 +                      break;
 +              case LS_MODIFIER_DISTANCE_FROM_OBJECT:
 +                      write_curvemapping(wd, ((LineStyleAlphaModifier_DistanceFromObject *)m)->curve);
 +                      break;
 +              }
 +      }
 +}
 +
 +static void write_linestyle_thickness_modifiers(WriteData *wd, ListBase *modifiers)
 +{
 +      LineStyleModifier *m;
 +      char *struct_name;
 +
 +      for (m = modifiers->first; m; m = m->next) {
 +              switch (m->type) {
 +              case LS_MODIFIER_ALONG_STROKE:
 +                      struct_name = "LineStyleThicknessModifier_AlongStroke";
 +                      break;
 +              case LS_MODIFIER_DISTANCE_FROM_CAMERA:
 +                      struct_name = "LineStyleThicknessModifier_DistanceFromCamera";
 +                      break;
 +              case LS_MODIFIER_DISTANCE_FROM_OBJECT:
 +                      struct_name = "LineStyleThicknessModifier_DistanceFromObject";
 +                      break;
 +              default:
 +                      struct_name = "LineStyleThicknessModifier"; // this should not happen
 +              }
 +              writestruct(wd, DATA, struct_name, 1, m);
 +      }
 +      for (m = modifiers->first; m; m = m->next) {
 +              switch (m->type) {
 +              case LS_MODIFIER_ALONG_STROKE:
 +                      write_curvemapping(wd, ((LineStyleThicknessModifier_AlongStroke *)m)->curve);
 +                      break;
 +              case LS_MODIFIER_DISTANCE_FROM_CAMERA:
 +                      write_curvemapping(wd, ((LineStyleThicknessModifier_DistanceFromCamera *)m)->curve);
 +                      break;
 +              case LS_MODIFIER_DISTANCE_FROM_OBJECT:
 +                      write_curvemapping(wd, ((LineStyleThicknessModifier_DistanceFromObject *)m)->curve);
 +                      break;
 +              }
 +      }
 +}
 +
 +static void write_linestyles(WriteData *wd, ListBase *idbase)
 +{
 +      FreestyleLineStyle *linestyle;
 +
 +      for(linestyle=idbase->first; linestyle; linestyle= linestyle->id.next) {
 +              if(linestyle->id.us>0 || wd->current) {
 +                      writestruct(wd, ID_LS, "FreestyleLineStyle", 1, linestyle);
 +                      if (linestyle->id.properties) IDP_WriteProperty(linestyle->id.properties, wd);
 +                      if (linestyle->adt) write_animdata(wd, linestyle->adt);
 +                      write_linestyle_color_modifiers(wd, &linestyle->color_modifiers);
 +                      write_linestyle_alpha_modifiers(wd, &linestyle->alpha_modifiers);
 +                      write_linestyle_thickness_modifiers(wd, &linestyle->thickness_modifiers);
 +              }
 +      }
 +}
 +
  /* context is usually defined by WM, two cases where no WM is available:
   * - for forward compatibility, curscreen has to be saved
   * - for undofile, curscene needs to be saved */
@@@ -2525,6 -2388,10 +2527,10 @@@ static void write_global(WriteData *wd
        bScreen *screen;
        char subvstr[8];
        
+       /* prevent mem checkers from complaining */
+       fg.pads= fg.pad= 0;
+       memset(fg.filename, 0, sizeof(fg.filename));
        current_screen_compat(mainvar, &screen);
  
        /* XXX still remap G */
  #else
        fg.revision= 0;
  #endif
-       fg.pads= fg.pad= 0; /* prevent mem checkers from complaining */
        writestruct(wd, GLOB, "FileGlobal", 1, &fg);
  }
  
@@@ -2613,7 -2479,6 +2618,7 @@@ static int write_file_handle(Main *main
        write_brushes  (wd, &mainvar->brush);
        write_scripts  (wd, &mainvar->script);
        write_gpencils (wd, &mainvar->gpencil);
 +      write_linestyles(wd, &mainvar->linestyle);
        write_libraries(wd,  mainvar->next);
  
        if (write_user_block) {
index fd3623eec11a4d59fe09d8202fcc0a14f3fd6986,006e390be2bf4378651613641a0f44e2acd4b26a..7d4db6fd89cdc089cbe2a74bf5d7feeed2b8cbd2
@@@ -174,7 -174,6 +174,7 @@@ static int mouse_nla_channels (bAnimCon
                case ANIMTYPE_DSMESH:
                case ANIMTYPE_DSTEX:
                case ANIMTYPE_DSLAT:
 +              case ANIMTYPE_DSLINESTYLE:
                {
                        /* sanity checking... */
                        if (ale->adt) {
@@@ -342,8 -341,9 +342,9 @@@ static int nlachannels_mouseclick_invok
  void NLA_OT_channels_click (wmOperatorType *ot)
  {
        /* identifiers */
-       ot->name= "Mouse Click on Channels";
+       ot->name= "Mouse Click on NLA Channels";
        ot->idname= "NLA_OT_channels_click";
+       ot->description= "Handle clicks to select NLA channels";
        
        /* api callbacks */
        ot->invoke= nlachannels_mouseclick_invoke;
index fe587bd98d6f2e4c037c29b2634221285ddfe9ff,b16fae73980b02d35c98fe958fc8552656c35cc2..dad85626886b18e90e703e2509b2e6c96a9df101
@@@ -1409,7 -1409,6 +1409,6 @@@ static void outliner_build_tree(Main *m
                for(group= mainvar->group.first; group; group= group->id.next) {
                        if(group->gobject.first) {
                                te= outliner_add_element(soops, &soops->tree, group, NULL, 0, 0);
-                               tselem= TREESTORE(te);
                                
                                for(go= group->gobject.first; go; go= go->next) {
                                        ten= outliner_add_element(soops, &te->subtree, go->ob, te, 0, 0);
@@@ -1846,6 -1845,7 +1845,7 @@@ void OUTLINER_OT_show_one_level(wmOpera
        /* identifiers */
        ot->name= "Show/Hide One Level";
        ot->idname= "OUTLINER_OT_show_one_level";
+       ot->description= "Expand/collapse all entries by one level";
        
        /* callbacks */
        ot->exec= outliner_one_level_exec;
@@@ -2022,13 -2022,13 +2022,13 @@@ static int tree_element_active_material
  static int tree_element_active_texture(bContext *C, Scene *scene, SpaceOops *soops, TreeElement *te, int set)
  {
        TreeElement *tep;
-       TreeStoreElem *tselem, *tselemp;
+       TreeStoreElem /* *tselem,*/ *tselemp;
        Object *ob=OBACT;
        SpaceButs *sbuts=NULL;
        
        if(ob==NULL) return 0; // no active object
        
-       tselem= TREESTORE(te);
+       /*tselem= TREESTORE(te);*/ /*UNUSED*/
        
        /* find buttons area (note, this is undefined really still, needs recode in blender) */
        /* XXX removed finding sbuts */
@@@ -2595,6 -2595,7 +2595,7 @@@ void OUTLINER_OT_item_activate(wmOperat
  {
        ot->name= "Activate Item";
        ot->idname= "OUTLINER_OT_item_activate";
+       ot->description= "Handle mouse clicks to activate/select items";
        
        ot->invoke= outliner_item_activate;
        
@@@ -2657,6 -2658,7 +2658,7 @@@ void OUTLINER_OT_item_openclose(wmOpera
  {
        ot->name= "Open/Close Item";
        ot->idname= "OUTLINER_OT_item_openclose";
+       ot->description= "Toggle whether item under cursor is enabled or closed";
        
        ot->invoke= outliner_item_openclose;
        
@@@ -2687,9 -2689,11 +2689,11 @@@ static int do_outliner_item_rename(bCon
                                error("Cannot edit sequence name");
                        else if(tselem->id->lib) {
                                // XXX                                          error_libdata();
-                       } else if(te->idcode == ID_LI && te->parent) {
+                       } 
+                       else if(te->idcode == ID_LI && te->parent) {
                                error("Cannot edit the path of an indirectly linked library");
-                       } else {
+                       } 
+                       else {
                                tselem->flag |= TSE_TEXTBUT;
                                ED_region_tag_redraw(ar);
                        }
@@@ -2724,6 -2728,7 +2728,7 @@@ void OUTLINER_OT_item_rename(wmOperator
  {
        ot->name= "Rename Item";
        ot->idname= "OUTLINER_OT_item_rename";
+       ot->description= "Rename item under cursor";
        
        ot->invoke= outliner_item_rename;
        
@@@ -3778,6 -3783,7 +3783,7 @@@ void OUTLINER_OT_operation(wmOperatorTy
  {
        ot->name= "Execute Operation";
        ot->idname= "OUTLINER_OT_operation";
+       ot->description= "Context menu for item operations";
        
        ot->invoke= outliner_operation;
        
@@@ -4052,7 -4058,7 +4058,7 @@@ void OUTLINER_OT_drivers_add_selected(w
        ot->poll= ed_operator_outliner_datablocks_active;
        
        /* flags */
-       ot->flag = OPTYPE_UNDO;
+       ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
  }
  
  
@@@ -4087,7 -4093,7 +4093,7 @@@ void OUTLINER_OT_drivers_delete_selecte
        ot->poll= ed_operator_outliner_datablocks_active;
        
        /* flags */
-       ot->flag = OPTYPE_UNDO;
+       ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
  }
  
  /* ***************** KEYINGSET OPERATIONS *************** */
@@@ -4217,14 -4223,15 +4223,15 @@@ void OUTLINER_OT_keyingset_add_selected
  {
        /* identifiers */
        ot->idname= "OUTLINER_OT_keyingset_add_selected";
-       ot->name= "Keyingset Add Selected";
+       ot->name= "Keying Set Add Selected";
+       ot->description= "Add selected items (blue-grey rows) to active Keying Set";
        
        /* api callbacks */
        ot->exec= outliner_keyingset_additems_exec;
        ot->poll= ed_operator_outliner_datablocks_active;
        
        /* flags */
-       ot->flag = OPTYPE_UNDO;
+       ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
  }
  
  
@@@ -4253,14 -4260,15 +4260,15 @@@ void OUTLINER_OT_keyingset_remove_selec
  {
        /* identifiers */
        ot->idname= "OUTLINER_OT_keyingset_remove_selected";
-       ot->name= "Keyingset Remove Selected";
+       ot->name= "Keying Set Remove Selected";
+       ot->description = "Remove selected items (blue-grey rows) from active Keying Set";
        
        /* api callbacks */
        ot->exec= outliner_keyingset_removeitems_exec;
        ot->poll= ed_operator_outliner_datablocks_active;
        
        /* flags */
-       ot->flag = OPTYPE_UNDO;
+       ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
  }
  
  /* ***************** DRAW *************** */
@@@ -4540,13 -4548,17 +4548,12 @@@ static void outliner_draw_iconrow(bCont
        int active;
  
        for(te= lb->first; te; te= te->next) {
 -              
 -              /* exit drawing early */
 -              if((*offsx) - OL_X > xmax)
 -                      break;
 -
                tselem= TREESTORE(te);
                
                /* object hierarchy always, further constrained on level */
                if(level<1 || (tselem->type==0 && te->idcode==ID_OB)) {
  
                        /* active blocks get white circle */
-                       active= 0;
                        if(tselem->type==0) {
                                if(te->idcode==ID_OB) active= (OBACT==(Object *)tselem->id);
                                else if(scene->obedit && scene->obedit->data==tselem->id) active= 1;    // XXX use context?
index 7b53dd9ef7749d04f5151c4570ecad6ebff4848d,7d4d3d7c333b56904864a22ff7b71f72d20f3359..d79b63e9c38817fd88239607dfc2cbf46b7b30a0
@@@ -127,8 -127,9 +127,9 @@@ typedef struct Library 
  #define PREVIEW_MIPMAP_LARGE 1
  
  typedef struct PreviewImage {
+       /* All values of 2 are really PREVIEW_MIPMAPS */
        unsigned int w[2];
-       unsigned int h[2];      
+       unsigned int h[2];
        short changed[2];
        short changed_timestamp[2];
        unsigned int * rect[2];
  #define ID_PA         MAKE_ID2('P', 'A') /* ParticleSettings */
  #define ID_GD         MAKE_ID2('G', 'D') /* GreasePencil */
  #define ID_WM         MAKE_ID2('W', 'M') /* WindowManager */
 +#define ID_LS         MAKE_ID2('L', 'S') /* FreestyleLineStyle */
  
        /* NOTE! Fake IDs, needed for g.sipo->blocktype or outliner */
  #define ID_SEQ                MAKE_ID2('S', 'Q')
index b12ffac044b6b2395b4139fc960fbda43e41db34,17f9afce7c3e103b0a273dd8c2fb9ecd8e40c7cb..5261ad6577691386d8391af342e77b5e94e994e4
@@@ -327,7 -327,9 +327,9 @@@ typedef struct bPose 
        ListBase chanbase;                      /* list of pose channels, PoseBones in RNA */
        struct GHash *chanhash;         /* ghash for quicker string lookups */
        
-       short flag, proxy_layer;        /* proxy layer: copy from armature, gets synced */
+       short flag, pad;
+       unsigned int proxy_layer;       /* proxy layer: copy from armature, gets synced */
+       int pad1;
        
        float ctime;                            /* local action time of this pose */
        float stride_offset[3];         /* applied to object */
@@@ -542,7 -544,6 +544,7 @@@ typedef enum eDopeSheet_FilterFlag 
        ADS_FILTER_NOARM                        = (1<<18),
        ADS_FILTER_NONTREE                      = (1<<19),
        ADS_FILTER_NOTEX                        = (1<<20),
 +      ADS_FILTER_NOLINESTYLE          = (1<<21),
        
                /* NLA-specific filters */
        ADS_FILTER_NLA_NOACT            = (1<<25),      /* if the AnimData block has no NLA data, don't include to just show Action-line */
index 85a93a87f74adf83b5974d65f5b197ab9c04e603,f214598f6057ce5bb10668297337ae0eeda68131..e7302fff6df20c45655f2d9c19ed2f58c5270034
@@@ -39,7 -39,6 +39,7 @@@ extern "C" 
  #include "DNA_vec_types.h"
  #include "DNA_listBase.h"
  #include "DNA_ID.h"
 +#include "DNA_freestyle_types.h"
  
  struct Object;
  struct Brush;
@@@ -162,9 -161,6 +162,9 @@@ typedef struct SceneRenderLayer 
        
        int passflag;                   /* pass_xor has to be after passflag */
        int pass_xor;
 +      
 +      struct FreestyleConfig freestyleConfig;
 +      
  } SceneRenderLayer;
  
  /* srl->layflag */
  #define SCE_LAY_EDGE  8
  #define SCE_LAY_SKY           16
  #define SCE_LAY_STRAND        32
 -      /* flags between 32 and 0x8000 are set to 1 already, for future options */
 +#define SCE_LAY_FRS           64
 +      /* flags between 64 and 0x8000 are set to 1 already, for future options */
  
  #define SCE_LAY_ALL_Z         0x8000
  #define SCE_LAY_XOR                   0x10000
@@@ -873,7 -868,6 +873,7 @@@ typedef struct Scene 
  #define R_NO_OVERWRITE        0x400000 /* skip existing files */
  #define R_TOUCH                       0x800000 /* touch files before rendering */
  #define R_SIMPLIFY            0x1000000
 +#define R_EDGE_FRS            0x2000000 /* R_EDGE for Freestyle */
  
  /* seq_flag */
  #define R_SEQ_GL_PREV 1
@@@ -1176,7 -1170,7 +1176,7 @@@ typedef enum SculptFlags 
  
  /* toolsettings->uvcalc_flag */
  #define UVCALC_FILLHOLES                      1
#define UVCALC_NO_ASPECT_CORRECT      2       /* would call this UVCALC_ASPECT_CORRECT, except it should be default with old file */
/*#define UVCALC_NO_ASPECT_CORRECT    2*/     /* would call this UVCALC_ASPECT_CORRECT, except it should be default with old file */
  #define UVCALC_TRANSFORM_CORRECT      4       /* adjust UV's while transforming to avoid distortion */
  
  /* toolsettings->uv_flag */
  #define RETOPO 1
  #define RETOPO_PAINT 2
  
- /* toolsettings->retopo_paint_tool */
- #define RETOPO_PEN 1
- #define RETOPO_LINE 2
- #define RETOPO_ELLIPSE 4
+ /* toolsettings->retopo_paint_tool */ /*UNUSED*/
+ /* #define RETOPO_PEN 1 */
+ /* #define RETOPO_LINE 2 */
+ /* #define RETOPO_ELLIPSE 4 */
  
  /* toolsettings->skgen_options */
  #define SKGEN_FILTER_INTERNAL (1 << 0)
index 05cb3436ce49ac2f01cb1e1873cd65bf19806f41,6283ba226e50112df2c3f2de01d8f70a2a7b4afd..d5d9c4c6cb311d13872001d4bc9a4a0618f94cc3
@@@ -948,7 -948,7 +948,7 @@@ static char *rna_def_property_begin_fun
  
  static char *rna_def_property_lookup_int_func(FILE *f, StructRNA *srna, PropertyRNA *prop, PropertyDefRNA *dp, char *manualfunc, char *nextfunc)
  {
-       /* note on indicies, this is for external functions and ignores skipped values.
+       /* note on indices, this is for external functions and ignores skipped values.
         * so the the index can only be checked against the length when there is no 'skip' funcion. */
        char *func;
  
@@@ -2296,11 -2296,9 +2296,9 @@@ static void rna_generate_struct(Blender
        prop= srna->cont.properties.last;
        if(prop) fprintf(f, "(PropertyRNA*)&rna_%s_%s}},\n", srna->identifier, prop->identifier);
        else fprintf(f, "NULL}},\n");
-       fprintf(f, "\tNULL,NULL,\n"); /* PyType - Cant initialize here */
-       
        fprintf(f, "\t");
        rna_print_c_string(f, srna->identifier);
+       fprintf(f, "\t, NULL,NULL\n"); /* PyType - Cant initialize here */
        fprintf(f, ", %d, ", srna->flag);
        rna_print_c_string(f, srna->name);
        fprintf(f, ", ");
@@@ -2385,7 -2383,6 +2383,7 @@@ RNAProcessItem PROCESS_ITEMS[]= 
        {"rna_key.c", NULL, RNA_def_key},
        {"rna_lamp.c", NULL, RNA_def_lamp},
        {"rna_lattice.c", NULL, RNA_def_lattice},
 +      {"rna_linestyle.c", NULL, RNA_def_linestyle},
        {"rna_main.c", "rna_main_api.c", RNA_def_main},
        {"rna_material.c", "rna_material_api.c", RNA_def_material},
        {"rna_mesh.c", "rna_mesh_api.c", RNA_def_mesh},
index 8f7604665138c65614be9cbf8cf6899ccb757582,87e35c09b123c412a7965f4cb6dd9de86d079ada..71d66dffcbe2e6091422b48b0b7c75d62fd3a0c5
@@@ -142,7 -142,6 +142,7 @@@ void RNA_def_image(struct BlenderRNA *b
  void RNA_def_key(struct BlenderRNA *brna);
  void RNA_def_lamp(struct BlenderRNA *brna);
  void RNA_def_lattice(struct BlenderRNA *brna);
 +void RNA_def_linestyle(struct BlenderRNA *brna);
  void RNA_def_main(struct BlenderRNA *brna);
  void RNA_def_material(struct BlenderRNA *brna);
  void RNA_def_mesh(struct BlenderRNA *brna);
@@@ -277,7 -276,6 +277,7 @@@ void RNA_def_main_armatures(BlenderRNA 
  void RNA_def_main_actions(BlenderRNA *brna, PropertyRNA *cprop);
  void RNA_def_main_particles(BlenderRNA *brna, PropertyRNA *cprop);
  void RNA_def_main_gpencil(BlenderRNA *brna, PropertyRNA *cprop);
 +void RNA_def_main_linestyles(BlenderRNA *brna, PropertyRNA *cprop);
  
  /* ID Properties */
  
@@@ -327,11 -325,11 +327,11 @@@ typedef struct ArrayIterator 
        void *free_ptr; /* will be free'd if set */
        int itemsize;
  
-       /* array length with no skip functins applied, take care not to compare against index from animsys or python indicies */
+       /* array length with no skip functins applied, take care not to compare against index from animsys or python indices */
        int length;
  
        /* optional skip function, when set the array as viewed by rna can contain only a subset of the members.
-        * this changes indicies so quick array index lookups are not possible when skip function is used. */
+        * this changes indices so quick array index lookups are not possible when skip function is used. */
        IteratorSkipFunc skip;
  } ArrayIterator;
  
@@@ -364,9 -362,9 +364,9 @@@ int rna_parameter_size(struct PropertyR
  int rna_parameter_size_alloc(struct PropertyRNA *parm);
  
  // XXX, these should not need to be defined here~!
- struct MTex *rna_mtex_texture_slots_add(struct ID *self, struct ReportList *reports);
- struct MTex *rna_mtex_texture_slots_create(struct ID *self, struct ReportList *reports, int index);
- void rna_mtex_texture_slots_clear(struct ID *self, struct ReportList *reports, int index);
+ struct MTex *rna_mtex_texture_slots_add(struct ID *self, struct bContext *C, struct ReportList *reports);
+ struct MTex *rna_mtex_texture_slots_create(struct ID *self, struct bContext *C, struct ReportList *reports, int index);
+ void rna_mtex_texture_slots_clear(struct ID *self, struct bContext *C, struct ReportList *reports, int index);
  
  #endif /* RNA_INTERNAL_H */
  
index c50c37d0261a5dfff6ac6d256954f3517cb24512,c5a071d7d7df39447e0bfcf36eb1b5987e4aa762..be5c9a8f1e091b8e83ac08c1d3fd2ba6716b9284
@@@ -50,8 -50,6 +50,8 @@@
  
  #include "AUD_PyInit.h"
  
 +#include "BPy_Freestyle.h"
 +
  static char bpy_script_paths_doc[] =
  ".. function:: script_paths()\n"
  "\n"
@@@ -98,7 -96,7 +98,7 @@@ static PyObject *bpy_blend_paths(PyObje
  
        list= PyList_New(0);
  
-       for(BLI_bpathIterator_init(&bpi, G.main, NULL); !BLI_bpathIterator_isDone(bpi); BLI_bpathIterator_step(bpi)) {
+       for(BLI_bpathIterator_init(&bpi, G.main, NULL, 0); !BLI_bpathIterator_isDone(bpi); BLI_bpathIterator_step(bpi)) {
                /* build the list */
                if (absolute) {
                        BLI_bpathIterator_getPathExpanded(bpi, filepath_expanded);
@@@ -195,7 -193,6 +195,7 @@@ void BPy_init_modules( void 
        }
        /* stand alone utility modules not related to blender directly */
        IDProp_Init_Types(); /* not actually a submodule, just types */
 +      Freestyle_Init();
  
        mod = PyModule_New("_bpy");
  
diff --combined source/creator/creator.c
index 7d78bb1e439adb5baf159c67cb50884f64b21c07,b5aea70ac8eff95a636fdaa0d756a1b61081a69b..71173b7b483331195a0a34870817052bb793e185
@@@ -96,8 -96,6 +96,8 @@@
  #include "GPU_draw.h"
  #include "GPU_extensions.h"
  
 +#include "FRS_freestyle.h"
 +
  /* for passing information between creator and gameengine */
  #ifdef WITH_GAMEENGINE
  #include "GEN_messaging.h"
@@@ -247,9 -245,15 +247,15 @@@ static int print_help(int UNUSED(argc)
        printf ("Misc Options:\n");
        BLI_argsPrintArgDoc(ba, "--debug");
        BLI_argsPrintArgDoc(ba, "--debug-fpe");
        printf("\n");
+       BLI_argsPrintArgDoc(ba, "--factory-startup");
+       printf("\n");
+       BLI_argsPrintArgDoc(ba, "--env-system-config");
+       BLI_argsPrintArgDoc(ba, "--env-system-datafiles");
+       BLI_argsPrintArgDoc(ba, "--env-system-scripts");
+       BLI_argsPrintArgDoc(ba, "--env-system-plugins");
+       BLI_argsPrintArgDoc(ba, "--env-system-python");
+       printf("\n");
        BLI_argsPrintArgDoc(ba, "-nojoystick");
        BLI_argsPrintArgDoc(ba, "-noglsl");
        BLI_argsPrintArgDoc(ba, "-noaudio");
@@@ -394,6 -398,34 +400,34 @@@ static int set_fpe(int UNUSED(argc), ch
        return 0;
  }
  
+ static int set_factory_startup(int UNUSED(argc), char **UNUSED(argv), void *UNUSED(data))
+ {
+       G.factory_startup= 1;
+       return 0;
+ }
+ static int set_env(int argc, char **argv, void *UNUSED(data))
+ {
+       /* "--env-system-scripts" --> "BLENDER_SYSTEM_SCRIPTS" */
+       char env[64]= "BLENDER";
+       char *ch_dst= env + 7; /* skip BLENDER */
+       char *ch_src= argv[0] + 5; /* skip --env */
+       if (argc < 2) {
+               printf("%s requires one argument\n", argv[0]);
+               exit(1);
+       }
+       for(; *ch_src; ch_src++, ch_dst++) {
+               *ch_dst= (*ch_src == '-') ? '_' : (*ch_src)-32; /* toupper() */
+       }
+       *ch_dst= '\0';
+       BLI_setenv(env, argv[1]);
+       return 1;
+ }
  static int playback_mode(int UNUSED(argc), char **UNUSED(argv), void *UNUSED(data))
  {
        /* not if -b was given first */
@@@ -1008,7 -1040,16 +1042,16 @@@ void setupArguments(bContext *C, bArgs 
        BLI_argsAdd(ba, 1, "-a", NULL, playback_doc, playback_mode, NULL);
  
        BLI_argsAdd(ba, 1, "-d", "--debug", debug_doc, debug_mode, ba);
-     BLI_argsAdd(ba, 1, NULL, "--debug-fpe", "\n\tEnable floating point exceptions", set_fpe, NULL);
+       BLI_argsAdd(ba, 1, NULL, "--debug-fpe", "\n\tEnable floating point exceptions", set_fpe, NULL);
+       BLI_argsAdd(ba, 1, NULL, "--factory-startup", "\n\tSkip reading the "STRINGIFY(BLENDER_STARTUP_FILE)" in the users home directory", set_factory_startup, NULL);
+       /* TODO, add user env vars? */
+       BLI_argsAdd(ba, 1, NULL, "--env-system-config",         "\n\tSet the "STRINGIFY_ARG(BLENDER_SYSTEM_CONFIG)" environment variable", set_env, NULL);
+       BLI_argsAdd(ba, 1, NULL, "--env-system-datafiles",      "\n\tSet the "STRINGIFY_ARG(BLENDER_SYSTEM_DATAFILES)" environment variable", set_env, NULL);
+       BLI_argsAdd(ba, 1, NULL, "--env-system-scripts",        "\n\tSet the "STRINGIFY_ARG(BLENDER_SYSTEM_SCRIPTS)" environment variable", set_env, NULL);
+       BLI_argsAdd(ba, 1, NULL, "--env-system-plugins",        "\n\tSet the "STRINGIFY_ARG(BLENDER_SYSTEM_PLUGINS)" environment variable", set_env, NULL);
+       BLI_argsAdd(ba, 1, NULL, "--env-system-python",         "\n\tSet the "STRINGIFY_ARG(BLENDER_SYSTEM_PYTHON)" environment variable", set_env, NULL);
  
        /* second pass: custom window stuff */
        BLI_argsAdd(ba, 2, "-p", "--window-geometry", "<sx> <sy> <w> <h>\n\tOpen with lower left corner at <sx>, <sy> and width and height as <w>, <h>", prefsize, NULL);
@@@ -1141,7 -1182,7 +1184,7 @@@ int main(int argc, char **argv
                BLI_argsParse(ba, 3, NULL, NULL);
  
                WM_init(C, argc, argv);
-               
                /* this is properly initialized with user defs, but this is default */
                BLI_where_is_temp( btempdir, 1 ); /* call after loading the startup.blend so we can read U.tempdir */
  
        CTX_py_init_set(C, 1);
        WM_keymap_init(C);
  
 +      /* initialize Freestyle */
 +      FRS_initialize();
 +      FRS_set_context(C);
 +
        /* OK we are ready for it */
        BLI_argsParse(ba, 4, load_file, C);