Merged changes in the trunk up to revision 43881.
authorTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>
Sat, 4 Feb 2012 14:22:05 +0000 (14:22 +0000)
committerTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>
Sat, 4 Feb 2012 14:22:05 +0000 (14:22 +0000)
12 files changed:
1  2 
source/blender/blenlib/intern/bpath.c
source/blender/blenloader/intern/readfile.c
source/blender/editors/animation/anim_channels_edit.c
source/blender/editors/interface/interface_templates.c
source/blender/editors/space_view3d/drawobject.c
source/blender/editors/transform/transform.c
source/blender/makesrna/intern/rna_mesh.c
source/blender/makesrna/intern/rna_scene.c
source/blender/makesrna/intern/rna_userdef.c
source/blender/render/intern/source/pipeline.c
source/blender/render/intern/source/shadeoutput.c
source/blender/windowmanager/intern/wm_files.c

index 12795280ddd38482a2eaee1baac456c18c86dc6c,fdda9166c94b1d03826835055f4179d9f8284850..7acbf450fed8efe2e229724a2e6884af969d5344
@@@ -68,7 -68,6 +68,7 @@@
  #include "DNA_vfont_types.h"
  #include "DNA_scene_types.h"
  #include "DNA_smoke_types.h"
 +#include "DNA_freestyle_types.h"
  
  #include "BLI_blenlib.h"
  #include "BLI_bpath.h"
@@@ -195,10 -194,12 +195,12 @@@ void makeFilesAbsolute(Main *bmain, con
  
  
  /* find this file recursively, use the biggest file so thumbnails dont get used by mistake
-  - dir: subdir to search
-  - filename: set this filename
-  - filesize: filesize for the file
- */
+  * - dir: subdir to search
+  * - filename: set this filename
+  * - filesize: filesize for the file
+  *
+  * return found: 1/0.
+  */
  #define MAX_RECUR 16
  static int findFileRecursive(char *filename_new,
                               const char *dirname,
        struct stat status;
        char path[FILE_MAX];
        int size;
+       int found = FALSE;
+       filename_new[0] = '\0';
  
        dir= opendir(dirname);
  
        if (dir==NULL)
-               return 0;
+               return found;
  
        if (*filesize == -1)
                *filesize= 0; /* dir opened fine */
                                if ((size > 0) && (size > *filesize)) { /* find the biggest file */
                                        *filesize= size;
                                        BLI_strncpy(filename_new, path, FILE_MAX);
+                                       found = TRUE;
                                }
                        }
                }
                else if (S_ISDIR(status.st_mode)) { /* is subdir */
                        if (*recur_depth <= MAX_RECUR) {
                                (*recur_depth)++;
-                               findFileRecursive(filename_new, path, filename, filesize, recur_depth);
+                               found |= findFileRecursive(filename_new, path, filename, filesize, recur_depth);
                                (*recur_depth)--;
                        }
                }
        }
        closedir(dir);
-       return 1;
+       return found;
  }
  
  typedef struct BPathFind_Data
@@@ -267,19 -272,26 +273,26 @@@ static int findMissingFiles_visit_cb(vo
  
        int filesize= -1;
        int recur_depth= 0;
+       int found;
  
-       findFileRecursive(filename_new,
-                         data->searchdir, BLI_path_basename((char *)path_src),
-                         &filesize, &recur_depth);
+       found = findFileRecursive(filename_new,
+                                 data->searchdir, BLI_path_basename((char *)path_src),
+                                 &filesize, &recur_depth);
  
        if (filesize == -1) { /* could not open dir */
+               BKE_reportf(data->reports, RPT_WARNING,
+                           "Could open directory \"%s\"",
+                           BLI_path_basename(data->searchdir));
+               return FALSE;
+       }
+       else if (found == FALSE) {
                BKE_reportf(data->reports, RPT_WARNING,
                            "Could not find \"%s\" in \"%s\"",
                            BLI_path_basename((char *)path_src), data->searchdir);
                return FALSE;
        }
        else {
-               strcpy(path_dst, filename_new);
+               BLI_strncpy(path_dst, filename_new, FILE_MAX);
                return TRUE;
        }
  }
@@@ -499,7 -511,6 +512,7 @@@ void bpath_traverse_id(Main *bmain, ID 
        case ID_SCE:
                {
                        Scene *scene= (Scene *)id;
 +                      SceneRenderLayer *srl= scene->r.layers.first;
                        if (scene->ed) {
                                Sequence *seq;
  
                                }
                                SEQ_END
                        }
 +                      for(; srl; srl= srl->next) {
 +                              FreestyleModuleConfig* module= srl->freestyleConfig.modules.first;
 +                              for (; module; module= module->next) {
 +                                      rewrite_path_fixed(module->module_path, visit_cb, absbase, bpath_user_data);
 +                              }
 +                      }
                }
                break;
        case ID_ME:
index 16d2c4998be30376c6e4eafb272cceaa27053d02,6bd12e8d3f65df461dfd08415dbc3afdff5367ed..80953b2dbbbc6b10869edccdb7b4001ce974e88a
@@@ -70,7 -70,6 +70,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"
@@@ -4695,7 -4694,6 +4695,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);
@@@ -4822,7 -4816,6 +4822,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);
@@@ -5323,6 -5309,30 +5323,30 @@@ static void *restore_pointer_by_name(Ma
        return NULL;
  }
  
+ static int lib_link_seq_clipboard_cb(Sequence *seq, void *arg_pt)
+ {
+       Main *newmain = (Main *)arg_pt;
+       if(seq->sound) {
+               seq->sound = restore_pointer_by_name(newmain, (ID *)seq->sound, 0);
+               seq->sound->id.us++;
+       }
+       if(seq->scene)
+               seq->scene = restore_pointer_by_name(newmain, (ID *)seq->scene, 1);
+       if(seq->scene_camera)
+               seq->scene_camera = restore_pointer_by_name(newmain, (ID *)seq->scene_camera, 1);
+       return 1;
+ }
+ static void lib_link_clipboard_restore(Main *newmain)
+ {
+       /* update IDs stored in sequencer clipboard */
+       seqbase_recursive_apply(&seqbase_clipboard, lib_link_seq_clipboard_cb, newmain);
+ }
  /* called from kernel/blender.c */
  /* used to link a file (without UI) to the current UI */
  /* note that it assumes the old pointers in UI are still valid, so old Main is not freed */
@@@ -5530,6 -5540,9 +5554,9 @@@ void lib_link_screen_restore(Main *newm
                        sa= sa->next;
                }
        }
+       /* update IDs stored in all possible clipboards */
+       lib_link_clipboard_restore(newmain);
  }
  
  static void direct_link_region(FileData *fd, ARegion *ar, int spacetype)
@@@ -6082,177 -6095,6 +6109,177 @@@ static void lib_link_movieclip(FileDat
        }
  }
  
 +/* ************ 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) {
 +                              switch (m->type) {
 +                              case LS_MODIFIER_DISTANCE_FROM_OBJECT:
 +                                      {
 +                                              LineStyleColorModifier_DistanceFromObject *cm = (LineStyleColorModifier_DistanceFromObject *)m;
 +                                              cm->target = newlibadr(fd, linestyle->id.lib, cm->target);
 +                                      }
 +                                      break;
 +                              }
 +                      }
 +                      for (m = linestyle->alpha_modifiers.first; m; m = m->next){
 +                              switch (m->type) {
 +                              case LS_MODIFIER_DISTANCE_FROM_OBJECT:
 +                                      {
 +                                              LineStyleAlphaModifier_DistanceFromObject *am = (LineStyleAlphaModifier_DistanceFromObject *)m;
 +                                              am->target = newlibadr(fd, linestyle->id.lib, am->target);
 +                                      }
 +                                      break;
 +                              }
 +                      }
 +                      for (m = linestyle->thickness_modifiers.first; m; m = m->next){
 +                              switch (m->type) {
 +                              case LS_MODIFIER_DISTANCE_FROM_OBJECT:
 +                                      {
 +                                              LineStyleThicknessModifier_DistanceFromObject *tm = (LineStyleThicknessModifier_DistanceFromObject *)m;
 +                                              tm->target = newlibadr(fd, linestyle->id.lib, tm->target);
 +                                      }
 +                                      break;
 +                              }
 +                      }
 +              }
 +              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;
 +      case LS_MODIFIER_MATERIAL:
 +              {
 +                      LineStyleColorModifier_Material *m = (LineStyleColorModifier_Material *)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;
 +      case LS_MODIFIER_MATERIAL:
 +              {
 +                      LineStyleAlphaModifier_Material *m = (LineStyleAlphaModifier_Material *)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;
 +      case LS_MODIFIER_MATERIAL:
 +              {
 +                      LineStyleThicknessModifier_Material *m = (LineStyleThicknessModifier_Material *)modifier;
 +                      m->curve = newdataadr(fd, m->curve);
 +                      direct_link_curvemapping(fd, m->curve);
 +              }
 +              break;
 +      }
 +}
 +
 +static void direct_link_linestyle_geometry_modifier(FileData *fd, LineStyleModifier *modifier)
 +{
 +}
 +
 +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);
 +      link_list(fd, &linestyle->geometry_modifiers);
 +      for(modifier=linestyle->geometry_modifiers.first; modifier; modifier= modifier->next)
 +              direct_link_linestyle_geometry_modifier(fd, modifier);
 +}
 +
  /* ************** GENERAL & MAIN ******************** */
  
  
@@@ -6288,7 -6130,6 +6315,7 @@@ static const char *dataname(short id_co
                case ID_PA: return "Data from PA";
                case ID_GD: return "Data from GD";
                case ID_MC: return "Data from MC";
 +              case ID_LS: return "Data from LS";
        }
        return "Data from Lib Block";
        
@@@ -6461,9 -6302,6 +6488,9 @@@ static BHead *read_libblock(FileData *f
                case ID_MC:
                        direct_link_movieclip(fd, (MovieClip *)id);
                        break;
 +              case ID_LS:
 +                      direct_link_linestyle(fd, (FreestyleLineStyle *)id);
 +                      break;
        }
        
        /*link direct data of ID properties*/
@@@ -13243,28 -13081,6 +13270,28 @@@ static void do_versions(FileData *fd, L
                }
        }
  
 +      /* default values in Freestyle settings */
 +      {
 +              Scene *sce;
 +              SceneRenderLayer *srl;
 +              FreestyleLineStyle *linestyle;
 +
 +              for(sce = main->scene.first; sce; sce = sce->id.next) {
 +                      for(srl= sce->r.layers.first; srl; srl= srl->next) {
 +                              if (srl->freestyleConfig.mode == 0)
 +                                      srl->freestyleConfig.mode= FREESTYLE_CONTROL_EDITOR_MODE;
 +                              if (srl->freestyleConfig.raycasting_algorithm == 0)
 +                                      srl->freestyleConfig.raycasting_algorithm= FREESTYLE_ALGO_CULLED_ADAPTIVE_CUMULATIVE;
 +                      }
 +              }
 +              for(linestyle = main->linestyle.first; linestyle; linestyle = linestyle->id.next) {
 +                      if (linestyle->chaining == 0)
 +                              linestyle->chaining= LS_CHAINING_PLAIN;
 +                      if (linestyle->rounds == 0)
 +                              linestyle->rounds= 3;
 +              }
 +      }
 +      
        /* WATCH IT!!!: pointers from libdata have not been converted yet here! */
        /* WATCH IT 2!: Userdef struct init has to be in editors/interface/resources.c! */
  
@@@ -13310,7 -13126,6 +13337,7 @@@ static void lib_link_all(FileData *fd, 
        lib_link_brush(fd, main);
        lib_link_particlesettings(fd, main);
        lib_link_movieclip(fd, main);
 +      lib_link_linestyle(fd, main);
  
        lib_link_mesh(fd, main);                /* as last: tpage images with users at zero */
  
@@@ -14194,7 -14009,6 +14221,7 @@@ static void expand_scene(FileData *fd, 
  {
        Base *base;
        SceneRenderLayer *srl;
 +      FreestyleLineSet *lineset;
  
        for(base= sce->base.first; base; base= base->next) {
                expand_doit(fd, mainvar, base->object);
        for(srl= sce->r.layers.first; srl; srl= srl->next) {
                expand_doit(fd, mainvar, srl->mat_override);
                expand_doit(fd, mainvar, srl->light_override);
 +
 +              for (lineset= srl->freestyleConfig.linesets.first; lineset; lineset= lineset->next) {
 +                      if (lineset->group)
 +                              expand_doit(fd, mainvar, lineset->group);
 +                      expand_doit(fd, mainvar, lineset->linestyle);
 +              }
        }
  
        if(sce->r.dometext)
@@@ -14274,25 -14082,6 +14301,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 9122bc277d95667f762cfe5fd5033d58365fe0e8,8ac7406462d9a3b951e9fa07e4e081d66e7748ea..0c8d633be5ce38635e4bfc1406f20267b29c64ec
@@@ -122,7 -122,6 +122,7 @@@ void ANIM_set_active_channel (bAnimCont
                        case ANIMTYPE_DSMESH:
                        case ANIMTYPE_DSTEX:
                        case ANIMTYPE_DSLAT:
 +                      case ANIMTYPE_DSLINESTYLE:
                        case ANIMTYPE_DSSPK:
                        {
                                /* need to verify that this data is valid for now */
                        case ANIMTYPE_DSARM:
                        case ANIMTYPE_DSMESH:
                        case ANIMTYPE_DSLAT:
 +                      case ANIMTYPE_DSLINESTYLE:
                        case ANIMTYPE_DSSPK:
                        {
                                /* need to verify that this data is valid for now */
@@@ -249,7 -247,6 +249,7 @@@ void ANIM_deselect_anim_channels (bAnim
                                case ANIMTYPE_DSNTREE:
                                case ANIMTYPE_DSTEX:
                                case ANIMTYPE_DSLAT:
 +                              case ANIMTYPE_DSLINESTYLE:
                                case ANIMTYPE_DSSPK:
                                {
                                        if ((ale->adt) && (ale->adt->flag & ADT_UI_SELECTED))
                        case ANIMTYPE_DSNTREE:
                        case ANIMTYPE_DSTEX:
                        case ANIMTYPE_DSLAT:
 +                      case ANIMTYPE_DSLINESTYLE:
                        case ANIMTYPE_DSSPK:
                        {
                                /* need to verify that this data is valid for now */
@@@ -1533,7 -1529,7 +1533,7 @@@ static int animchannels_setflag_exec(bC
        return OPERATOR_FINISHED;
  }
  
+ /* duplicate of 'ANIM_OT_channels_setting_toggle' for menu title only, weak! */
  static void ANIM_OT_channels_setting_enable (wmOperatorType *ot)
  {
        /* identifiers */
                /* setting to set */
        ot->prop= RNA_def_enum(ot->srna, "type", prop_animchannel_settings_types, 0, "Type", "");
  }
+ /* duplicate of 'ANIM_OT_channels_setting_toggle' for menu title only, weak! */
  static void ANIM_OT_channels_setting_disable (wmOperatorType *ot)
  {
        /* identifiers */
        ot->prop= RNA_def_enum(ot->srna, "type", prop_animchannel_settings_types, 0, "Type", "");
  }
  
- static void ANIM_OT_channels_setting_invert (wmOperatorType *ot)
- {
-       /* identifiers */
-       ot->name= "Invert Channel Setting";
-       ot->idname= "ANIM_OT_channels_setting_toggle";
-       ot->description= "Invert specified setting on all selected animation channels";
-       
-       /* api callbacks */
-       ot->invoke= WM_menu_invoke;
-       ot->exec= animchannels_setflag_exec;
-       ot->poll= animedit_poll_channels_active;
-       
-       /* flags */
-       ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
-       
-       /* props */
-               /* flag-setting mode */
-       RNA_def_enum(ot->srna, "mode", prop_animchannel_setflag_types, ACHANNEL_SETFLAG_INVERT, "Mode", "");
-               /* setting to set */
-       ot->prop= RNA_def_enum(ot->srna, "type", prop_animchannel_settings_types, 0, "Type", "");
- }
  static void ANIM_OT_channels_setting_toggle (wmOperatorType *ot)
  {
        /* identifiers */
@@@ -2186,7 -2160,6 +2164,7 @@@ static int mouse_anim_channels (bAnimCo
                case ANIMTYPE_DSNTREE:
                case ANIMTYPE_DSTEX:
                case ANIMTYPE_DSLAT:
 +              case ANIMTYPE_DSLINESTYLE:
                case ANIMTYPE_DSSPK:
                {
                        /* sanity checking... */
@@@ -2406,7 -2379,6 +2384,6 @@@ void ED_operatortypes_animchannels(void
        
        WM_operatortype_append(ANIM_OT_channels_setting_enable);
        WM_operatortype_append(ANIM_OT_channels_setting_disable);
-       WM_operatortype_append(ANIM_OT_channels_setting_invert);
        WM_operatortype_append(ANIM_OT_channels_setting_toggle);
        
        WM_operatortype_append(ANIM_OT_channels_delete);
index 4a8fba530b0501d96750bd9a38f958a2e43b0d72,4a797b0e960007b42ef11546ab48c45f7e8a0455..9eefb469146a860b921e23be2d31b36ea8885e83
@@@ -332,7 -332,6 +332,7 @@@ static const char *template_id_browse_t
                        case ID_BR: return N_("Browse Brush to be linked");
                        case ID_PA: return N_("Browse Particle System to be linked");
                        case ID_GD: return N_("Browse Grease Pencil Data to be linked");
 +                      case ID_LS: return N_("Browse Line Style Data to be linked");
                }
        }
        return N_("Browse ID data to be linked");
@@@ -1306,6 -1305,16 +1306,16 @@@ static void colorband_flip_cb(bContext 
        rna_update_cb(C, cb_v, NULL);
  }
  
+ static void colorband_update_cb(bContext *UNUSED(C), void *bt_v, void *coba_v)
+ {
+       uiBut *bt= bt_v;
+       ColorBand *coba= coba_v;
+       /* sneaky update here, we need to sort the colorband points to be in order,
+          however the RNA pointer then is wrong, so we update it */
+       colorband_update_sort(coba);
+       bt->rnapoin.data = coba->data + coba->cur;
+ }
  
  /* offset aligns from bottom, standard width 300, height 115 */
  static void colorband_buttons_large(uiLayout *layout, uiBlock *block, ColorBand *coba, int xoffs, int yoffs, RNAUpdateCb *cb)
                PointerRNA ptr;
                RNA_pointer_create(cb->ptr.id.data, &RNA_ColorRampElement, cbd, &ptr);
                row= uiLayoutRow(layout, 0);
                uiItemR(row, &ptr, "position", 0, "Pos", ICON_NONE);
+               bt= block->buttons.last;
+               uiButSetFunc(bt, colorband_update_cb, bt, coba);
                uiItemR(row, &ptr, "color", 0, "", ICON_NONE);
        }
  
@@@ -2119,7 -2132,7 +2133,7 @@@ static void list_item_row(bContext *C, 
                uiBlockSetEmboss(block, UI_EMBOSS);
                uiDefButR(block, OPTION, 0, "", 0, 0, UI_UNIT_X, UI_UNIT_Y, ptr, "use_textures", i, 0, 0, 0, 0,  NULL);
        }
 -      else if(RNA_struct_is_a(itemptr->type, &RNA_SceneRenderLayer)) {
 +      else if(RNA_struct_is_a(itemptr->type, &RNA_SceneRenderLayer) || RNA_struct_is_a(itemptr->type, &RNA_FreestyleLineSet)) {
                uiItemL(sub, name, icon);
                uiBlockSetEmboss(block, UI_EMBOSS);
                uiDefButR(block, OPTION, 0, "", 0, 0, UI_UNIT_X, UI_UNIT_Y, itemptr, "use", 0, 0, 0, 0, 0,  NULL);
                Object *ob= (Object*)activeptr->data;
                Key *key= (Key*)itemptr->id.data;
  
-               split= uiLayoutSplit(sub, 0.75f, 0);
+               split= uiLayoutSplit(sub, 0.66f, 0);
  
                uiItemL(split, name, icon);
  
                row= uiLayoutRow(split, 1);
                if(i == 0 || (key->type != KEY_RELATIVE)) uiItemL(row, "", ICON_NONE);
                else uiItemR(row, itemptr, "value", 0, "", ICON_NONE);
+               uiItemR(row, itemptr, "mute", 0, "", 0);
  
-               if(ob->mode == OB_MODE_EDIT && !((ob->shapeflag & OB_SHAPE_EDIT_MODE) && ob->type == OB_MESH))
+               if( (key->flag & KEYBLOCK_MUTE) ||
+                   (ob->mode == OB_MODE_EDIT && !((ob->shapeflag & OB_SHAPE_EDIT_MODE) && ob->type == OB_MESH)) )
+               {
                        uiLayoutSetActive(row, 0);
-               //uiItemR(row, itemptr, "mute", 0, "", ICON_MUTE_IPO_OFF);
+               }
                uiBlockSetEmboss(block, UI_EMBOSS);
        }
        else if(itemptr->type == &RNA_VertexGroup) {
index 1b94c9152b884f4f4fe13e7d9991fe9706997478,e12efb72fcc3d0e056edb103b59d2a84c0ae1675..8fc2f17fae402714ab37bfc1f4497e41e61248b1
@@@ -149,7 -149,7 +149,7 @@@ typedef struct drawDMEdgesSel_userData 
  } drawDMEdgesSel_userData;
  
  typedef struct drawDMFacesSel_userData {
 -      unsigned char *cols[3];
 +      unsigned char *cols[4];
        EditFace *efa_act;
        int *orig_index;
  } drawDMFacesSel_userData;
@@@ -2421,17 -2421,6 +2421,17 @@@ static void draw_dm_edges_sharp(Derived
        dm->drawMappedEdges(dm, draw_dm_edges_sharp__setDrawOptions, NULL);
  }
  
 +      /* Draw only Freestyle feature edges */
 +static int draw_dm_edges_freestyle__setDrawOptions(void *UNUSED(userData), int index)
 +{
 +      EditEdge *eed = EM_get_edge_for_index(index);
 +
 +      return (eed->h==0 && eed->freestyle);
 +}
 +static void draw_dm_edges_freestyle(DerivedMesh *dm)
 +{
 +      dm->drawMappedEdges(dm, draw_dm_edges_freestyle__setDrawOptions, NULL);
 +}
  
        /* Draw faces with color set based on selection
         * return 2 for the active face so it renders with stipple enabled */
@@@ -2443,10 -2432,10 +2443,10 @@@ static int draw_dm_faces_sel__setDrawOp
        
        if (efa->h==0) {
                if (efa == data->efa_act) {
 -                      glColor4ubv(data->cols[2]);
 +                      glColor4ubv(data->cols[3]);
                        return 2; /* stipple */
                } else {
 -                      col = data->cols[(efa->f&SELECT)?1:0];
 +                      col = data->cols[(efa->f & SELECT) ? 1 : (efa->flag & ME_FREESTYLE_FACE) ? 2 : 0];
                        if (col[3]==0) return 0;
                        glColor4ubv(col);
                        return 1;
@@@ -2474,8 -2463,8 +2474,8 @@@ static int draw_dm_faces_sel__compareDr
        if(efa == data->efa_act || next_efa == data->efa_act)
                return 0;
  
 -      col = data->cols[(efa->f&SELECT)?1:0];
 -      next_col = data->cols[(next_efa->f&SELECT)?1:0];
 +      col = data->cols[(efa->f & SELECT) ? 1 : (efa->flag & ME_FREESTYLE_FACE) ? 2 : 0];
 +      next_col = data->cols[(next_efa->f & SELECT) ? 1 : (next_efa->flag & ME_FREESTYLE_FACE) ? 2 : 0];
  
        if(col[3]==0 || next_col[3]==0)
                return 0;
  }
  
  /* also draws the active face */
 -static void draw_dm_faces_sel(DerivedMesh *dm, unsigned char *baseCol, unsigned char *selCol, unsigned char *actCol, EditFace *efa_act) 
 +static void draw_dm_faces_sel(DerivedMesh *dm, unsigned char *baseCol, unsigned char *selCol, unsigned char *markCol, unsigned char *actCol, EditFace *efa_act) 
  {
        drawDMFacesSel_userData data;
        data.cols[0] = baseCol;
        data.cols[1] = selCol;
 -      data.cols[2] = actCol;
 +      data.cols[2] = markCol;
 +      data.cols[3] = actCol;
        data.efa_act = efa_act;
        data.orig_index = DM_get_face_data_layer(dm, CD_ORIGINDEX);
  
@@@ -2958,12 -2946,11 +2958,12 @@@ static void draw_em_fancy(Scene *scene
        }
        
        if(me->drawflag & ME_DRAWFACES) {       /* transp faces */
 -              unsigned char col1[4], col2[4], col3[4];
 +              unsigned char col1[4], col2[4], col3[4], col4[4];
                        
                UI_GetThemeColor4ubv(TH_FACE, col1);
                UI_GetThemeColor4ubv(TH_FACE_SELECT, col2);
 -              UI_GetThemeColor4ubv(TH_EDITMESH_ACTIVE, col3);
 +              UI_GetThemeColor4ubv(TH_FREESTYLE_FACE_MARK, col3);
 +              UI_GetThemeColor4ubv(TH_EDITMESH_ACTIVE, col4);
                
                glEnable(GL_BLEND);
                glDepthMask(0);         // disable write in zbuffer, needed for nice transp
                if CHECK_OB_DRAWTEXTURE(v3d, dt)
                        col1[3] = 0;
                
 -              draw_dm_faces_sel(cageDM, col1, col2, col3, efa_act);
 +              if (!(me->drawflag & ME_DRAW_FREESTYLE_FACE))
 +                      col3[3] = 0;
 +
 +              draw_dm_faces_sel(cageDM, col1, col2, col3, col4, efa_act);
  
                glDisable(GL_BLEND);
                glDepthMask(1);         // restore write in zbuffer
                /* even if draw faces is off it would be nice to draw the stipple face
                 * Make all other faces zero alpha except for the active
                 * */
 -              unsigned char col1[4], col2[4], col3[4];
 -              col1[3] = col2[3] = 0; /* dont draw */
 -              UI_GetThemeColor4ubv(TH_EDITMESH_ACTIVE, col3);
 +              unsigned char col1[4], col2[4], col3[4], col4[4];
 +              col1[3] = col2[3] = col3[3] = 0; /* dont draw */
 +              UI_GetThemeColor4ubv(TH_EDITMESH_ACTIVE, col4);
                
                glEnable(GL_BLEND);
                glDepthMask(0);         // disable write in zbuffer, needed for nice transp
                
 -              draw_dm_faces_sel(cageDM, col1, col2, col3, efa_act);
 +              draw_dm_faces_sel(cageDM, col1, col2, col3, col4, efa_act);
  
                glDisable(GL_BLEND);
                glDepthMask(1);         // restore write in zbuffer
                        glLineWidth(1);
                }
        
 +              if(me->drawflag & ME_DRAW_FREESTYLE_EDGE) {
 +                      UI_ThemeColor(TH_FREESTYLE_EDGE_MARK);
 +                      glLineWidth(2);
 +      
 +                      draw_dm_edges_freestyle(cageDM);
 +      
 +                      glColor3ub(0,0,0);
 +                      glLineWidth(1);
 +              }
 +      
                if(me->drawflag & ME_DRAWCREASES) {
                        draw_dm_creases(cageDM);
                }
@@@ -4068,7 -4042,7 +4068,7 @@@ static void draw_new_particle_system(Sc
        ParticleDrawData *pdd = psys->pdd;
        Material *ma;
        float vel[3], imat[4][4];
-       float timestep, pixsize=1.0, pa_size, r_tilt, r_length;
+       float timestep, pixsize_scale, pa_size, r_tilt, r_length;
        float pa_time, pa_birthtime, pa_dietime, pa_health, intensity;
        float cfra;
        float ma_col[3]= {0.0f, 0.0f, 0.0f};
                case PART_DRAW_CROSS:
                case PART_DRAW_AXIS:
                        /* lets calculate the scale: */
-                       pixsize= ED_view3d_pixel_size(rv3d, ob->obmat[3]);
                        
-                       if(part->draw_size==0.0)
-                               pixsize *= 2.0f;
+                       if (part->draw_size == 0.0)
+                               pixsize_scale = 2.0f;
                        else
-                               pixsize*=part->draw_size;
+                               pixsize_scale = part->draw_size;
  
                        if(draw_as==PART_DRAW_AXIS)
                                create_cdata = 1;
  
                                ct+=dt;
                                for(i=0; i < trail_count; i++, ct += dt) {
+                                       float pixsize;
                                        if(part->draw & PART_ABS_PATH_TIME) {
                                                if(ct < pa_birthtime || ct > pa_dietime)
                                                        continue;
                                                bb.time = ct;
                                        }
  
+                                       pixsize = ED_view3d_pixel_size(rv3d, state.co) * pixsize_scale;
                                        draw_particle(&state, draw_as, part->draw, pixsize, imat, part->draw_line, &bb, psys->pdd);
  
                                        totpoint++;
                        {
                                state.time=cfra;
                                if(psys_get_particle_state(&sim,a,&state,0)){
+                                       float pixsize;
                                        if(psys->parent)
                                                mul_m4_v3(psys->parent->obmat, state.co);
  
                                                bb.time = pa_time;
                                        }
  
+                                       pixsize = ED_view3d_pixel_size(rv3d, state.co) * pixsize_scale;
                                        draw_particle(&state, draw_as, part->draw, pixsize, imat, part->draw_line, &bb, pdd);
  
                                        totpoint++;
index 1e1f6e4279ea744486eae6b4283c53ce770eb968,9d368476f03ebb9d8cdd21d8fffa7ee78fb13eb5..15bd14ce94c8de4a7db21048366bc8ce46ab9e0c
@@@ -571,6 -571,9 +571,6 @@@ int transformEvent(TransInfo *t, wmEven
  
        if (event->type == MOUSEMOVE)
        {
 -              if (t->modifiers & MOD_CONSTRAINT_SELECT)
 -                      t->con.mode |= CON_SELECT;
 -
                copy_v2_v2_int(t->mval, event->mval);
  
                // t->redraw |= TREDRAW_SOFT; /* Use this for soft redraw. Might cause flicker in object mode */
@@@ -1766,9 -1769,6 +1766,9 @@@ void transformApply(bContext *C, TransI
  
        if ((t->redraw & TREDRAW_HARD) || (t->draw_handle_apply == NULL && (t->redraw & TREDRAW_SOFT)))
        {
 +              if (t->modifiers & MOD_CONSTRAINT_SELECT)
 +                      t->con.mode |= CON_SELECT;
 +
                selectConstraint(t);
                if (t->transform) {
                        t->transform(t, t->mval);  // calls recalcData()
@@@ -5566,9 -5566,9 +5566,9 @@@ static void headerTimeTranslate(TransIn
                /* apply snapping + frame->seconds conversions */
                if (autosnap == SACTSNAP_STEP) {
                        if (doTime)
-                               val= floor((double)val/secf + 0.5f);
+                               val= floorf((double)val/secf + 0.5f);
                        else
-                               val= floor(val + 0.5f);
+                               val= floorf(val + 0.5f);
                }
                else {
                        if (doTime)
index 4beda654ae80e80c30e70153a9a15a9a00389913,c2faf20749d0c9d6824da64333138e69ebf9886d..c91542bca2df3da69ee060ee14d1f61578e5d7ab
@@@ -27,6 -27,7 +27,7 @@@
  
  #include <stdlib.h>
  
+ #include "RNA_access.h"
  #include "RNA_define.h"
  
  #include "rna_internal.h"
@@@ -1132,22 -1133,25 +1133,25 @@@ static int rna_Mesh_tot_face_get(Pointe
        return me->edit_mesh ? me->edit_mesh->totfacesel : 0;
  }
  
- static CustomDataLayer *rna_Mesh_vertex_color_new(struct Mesh *me, struct bContext *C, const char *name)
+ static PointerRNA rna_Mesh_vertex_color_new(struct Mesh *me, struct bContext *C, const char *name)
  {
+       PointerRNA ptr;
        CustomData *fdata;
        CustomDataLayer *cdl= NULL;
-       int index;
+       int index= ED_mesh_color_add(C, NULL, NULL, me, name, FALSE);
  
-       if(ED_mesh_color_add(C, NULL, NULL, me, name, FALSE)) {
+       if(index != -1) {
                fdata= rna_mesh_fdata(me);
-               index= CustomData_get_named_layer_index(fdata, CD_MCOL, name);
-               cdl= (index == -1)? NULL: &fdata->layers[index];
+               cdl= &fdata->layers[CustomData_get_layer_index_n(fdata, CD_MCOL, index)];
        }
-       return cdl;
+       RNA_pointer_create(&me->id, &RNA_MeshColorLayer, cdl, &ptr);
+       return ptr;
  }
  
- static CustomDataLayer *rna_Mesh_int_property_new(struct Mesh *me, struct bContext *C, const char *name)
+ static PointerRNA rna_Mesh_int_property_new(struct Mesh *me, struct bContext *C, const char *name)
  {
+       PointerRNA ptr;
        CustomDataLayer *cdl = NULL;
        int index;
  
  
        cdl = (index == -1) ? NULL : &(me->fdata.layers[index]);
  
-       return cdl;
+       RNA_pointer_create(&me->id, &RNA_MeshIntPropertyLayer, cdl, &ptr);
+       return ptr;
  }
  
- static CustomDataLayer *rna_Mesh_float_property_new(struct Mesh *me, struct bContext *C, const char *name)
+ static PointerRNA rna_Mesh_float_property_new(struct Mesh *me, struct bContext *C, const char *name)
  {
+       PointerRNA ptr;
        CustomDataLayer *cdl = NULL;
        int index;
  
  
        cdl = (index == -1) ? NULL : &(me->fdata.layers[index]);
  
-       return cdl;
+       RNA_pointer_create(&me->id, &RNA_MeshFloatPropertyLayer, cdl, &ptr);
+       return ptr;
  }
  
- static CustomDataLayer *rna_Mesh_string_property_new(struct Mesh *me, struct bContext *C, const char *name)
+ static PointerRNA rna_Mesh_string_property_new(struct Mesh *me, struct bContext *C, const char *name)
  {
+       PointerRNA ptr;
        CustomDataLayer *cdl = NULL;
        int index;
  
  
        cdl = (index == -1) ? NULL : &(me->fdata.layers[index]);
  
-       return cdl;
+       RNA_pointer_create(&me->id, &RNA_MeshStringPropertyLayer, cdl, &ptr);
+       return ptr;
  }
  
- static CustomDataLayer *rna_Mesh_uv_texture_new(struct Mesh *me, struct bContext *C, const char *name)
+ static PointerRNA rna_Mesh_uv_texture_new(struct Mesh *me, struct bContext *C, const char *name)
  {
+       PointerRNA ptr;
        CustomData *fdata;
        CustomDataLayer *cdl= NULL;
-       int index;
+       int index= ED_mesh_uv_texture_add(C, me, name, FALSE);
  
-       if(ED_mesh_uv_texture_add(C, me, name, FALSE)) {
+       if(index != -1) {
                fdata= rna_mesh_fdata(me);
-               index= CustomData_get_named_layer_index(fdata, CD_MTFACE, name);
-               cdl= (index == -1)? NULL: &fdata->layers[index];
+               cdl= &fdata->layers[CustomData_get_layer_index_n(fdata, CD_MTFACE, index)];
        }
-       return cdl;
+       RNA_pointer_create(&me->id, &RNA_MeshTextureFaceLayer, cdl, &ptr);
+       return ptr;
  }
  
  #else
@@@ -1322,11 -1333,6 +1333,11 @@@ static void rna_def_medge(BlenderRNA *b
        RNA_def_property_ui_text(prop, "Sharp", "Sharp edge for the EdgeSplit modifier");
        RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
  
 +      prop= RNA_def_property(srna, "use_freestyle_edge_mark", PROP_BOOLEAN, PROP_NONE);
 +      RNA_def_property_boolean_sdna(prop, NULL, "flag", ME_FREESTYLE_EDGE);
 +      RNA_def_property_ui_text(prop, "Freestyle Edge Mark", "Edge mark for Freestyle feature edge detection");
 +      RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
 +
        prop= RNA_def_property(srna, "is_loose", PROP_BOOLEAN, PROP_NONE);
        RNA_def_property_boolean_sdna(prop, NULL, "flag", ME_LOOSEEDGE);
        RNA_def_property_ui_text(prop, "Loose", "Loose edge");
@@@ -1387,11 -1393,6 +1398,11 @@@ static void rna_def_mface(BlenderRNA *b
        RNA_def_property_ui_text(prop, "Smooth", "");
        RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
        
 +      prop= RNA_def_property(srna, "use_freestyle_face_mark", PROP_BOOLEAN, PROP_NONE);
 +      RNA_def_property_boolean_sdna(prop, NULL, "flag", ME_FREESTYLE_FACE);
 +      RNA_def_property_ui_text(prop, "Freestyle Face Mark", "Face mark for Freestyle feature edge detection");
 +      RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
 +
        prop= RNA_def_property(srna, "normal", PROP_FLOAT, PROP_DIRECTION);
        RNA_def_property_array(prop, 3);
        RNA_def_property_range(prop, -1.0f, 1.0f);
@@@ -1793,6 -1794,7 +1804,7 @@@ static void rna_def_vertex_colors(Blend
        RNA_def_function_ui_description(func, "Add a vertex color layer to Mesh");
        RNA_def_string(func, "name", "Col", 0, "", "Vertex color name");
        parm= RNA_def_pointer(func, "layer", "MeshColorLayer", "", "The newly created layer");
+       RNA_def_property_flag(parm, PROP_RNAPTR);
        RNA_def_function_return(func, parm);
        
  /*
@@@ -1833,6 -1835,7 +1845,7 @@@ static void rna_def_int_layers(BlenderR
        RNA_def_function_ui_description(func, "Add a integer property layer to Mesh");
        RNA_def_string(func, "name", "Int Prop", 0, "",  "Int property name");
        parm= RNA_def_pointer(func, "layer", "MeshIntPropertyLayer", "", "The newly created layer");
+       RNA_def_property_flag(parm, PROP_RNAPTR);
        RNA_def_function_return(func, parm);
  }
  
@@@ -1854,6 -1857,7 +1867,7 @@@ static void rna_def_float_layers(Blende
        RNA_def_function_ui_description(func, "Add a float property layer to Mesh");
        RNA_def_string(func, "name", "Float Prop", 0, "", "Float property name");
        parm= RNA_def_pointer(func, "layer", "MeshFloatPropertyLayer", "", "The newly created layer");
+       RNA_def_property_flag(parm, PROP_RNAPTR);
        RNA_def_function_return(func, parm);
  }
  
@@@ -1875,6 -1879,7 +1889,7 @@@ static void rna_def_string_layers(Blend
        RNA_def_function_ui_description(func, "Add a string property layer to Mesh");
        RNA_def_string(func, "name", "String Prop", 0, "", "String property name");
        parm= RNA_def_pointer(func, "layer", "MeshStringPropertyLayer", "", "The newly created layer");
+       RNA_def_property_flag(parm, PROP_RNAPTR);
        RNA_def_function_return(func, parm);
  }
  
@@@ -1897,6 -1902,7 +1912,7 @@@ static void rna_def_uv_textures(Blender
        RNA_def_function_ui_description(func, "Add a UV texture layer to Mesh");
        RNA_def_string(func, "name", "UVMap", 0, "", "UV map name");
        parm= RNA_def_pointer(func, "layer", "MeshTextureFaceLayer", "", "The newly created layer");
+       RNA_def_property_flag(parm, PROP_RNAPTR);
        RNA_def_function_return(func, parm);
  
  /*
@@@ -2138,16 -2144,6 +2154,16 @@@ static void rna_def_mesh(BlenderRNA *br
        RNA_def_property_ui_text(prop, "Draw Sharp", "Display sharp edges, used with the EdgeSplit modifier");
        RNA_def_property_update(prop, 0, "rna_Mesh_update_draw");
  
 +      prop= RNA_def_property(srna, "show_freestyle_edge_marks", PROP_BOOLEAN, PROP_NONE);
 +      RNA_def_property_boolean_sdna(prop, NULL, "drawflag", ME_DRAW_FREESTYLE_EDGE);
 +      RNA_def_property_ui_text(prop, "Draw Freestyle Edge Marks", "Display Freestyle edge marks, used with the Freestyle renderer");
 +      RNA_def_property_update(prop, 0, "rna_Mesh_update_draw");
 +
 +      prop= RNA_def_property(srna, "show_freestyle_face_marks", PROP_BOOLEAN, PROP_NONE);
 +      RNA_def_property_boolean_sdna(prop, NULL, "drawflag", ME_DRAW_FREESTYLE_FACE);
 +      RNA_def_property_ui_text(prop, "Draw Freestyle Face Marks", "Display Freestyle face marks, used with the Freestyle renderer");
 +      RNA_def_property_update(prop, 0, "rna_Mesh_update_draw");
 +
        prop= RNA_def_property(srna, "show_extra_edge_length", PROP_BOOLEAN, PROP_NONE);
        RNA_def_property_boolean_sdna(prop, NULL, "drawflag", ME_DRAWEXTRA_EDGELEN);
        RNA_def_property_ui_text(prop, "Edge Length",
index 03a304b253886edfe429012adfeab8583f967b92,290552d394f9a08d97a704874904ee0f01e892fa..3e9ab08c9d7522d21941f43513218260309fa4a6
@@@ -37,7 -37,6 +37,7 @@@
  #include "DNA_particle_types.h"
  #include "DNA_scene_types.h"
  #include "DNA_userdef_types.h"
 +#include "DNA_linestyle_types.h"
  #include "BLI_math.h"
  
  /* Include for Bake Options */
@@@ -284,8 -283,6 +284,8 @@@ EnumPropertyItem image_color_depth_item
  
  #include "RE_engine.h"
  
 +#include "FRS_freestyle.h"
 +
  static void rna_SpaceImageEditor_uv_sculpt_update(Main *bmain, Scene *scene, PointerRNA *UNUSED(ptr))
  {
        ED_space_image_uv_sculpt_update(bmain->wm.first, scene->toolsettings);
@@@ -1352,49 -1349,6 +1352,49 @@@ static void rna_SceneCamera_update(Mai
                DAG_id_tag_update(&camera->id, 0);
  }
  
 +static PointerRNA rna_FreestyleLineSet_linestyle_get(PointerRNA *ptr)
 +{
 +      FreestyleLineSet *lineset= (FreestyleLineSet *)ptr->data;
 +
 +      return rna_pointer_inherit_refine(ptr, &RNA_FreestyleLineStyle, lineset->linestyle);
 +}
 +
 +static void rna_FreestyleLineSet_linestyle_set(PointerRNA *ptr, PointerRNA value)
 +{
 +      FreestyleLineSet *lineset= (FreestyleLineSet*)ptr->data;
 +
 +      lineset->linestyle->id.us--;
 +      lineset->linestyle = (FreestyleLineStyle *)value.data;
 +      lineset->linestyle->id.us++;
 +}
 +
 +static PointerRNA rna_FreestyleSettings_active_lineset_get(PointerRNA *ptr)
 +{
 +      FreestyleConfig *config= (FreestyleConfig *)ptr->data;
 +      FreestyleLineSet *lineset= FRS_get_active_lineset(config);
 +      return rna_pointer_inherit_refine(ptr, &RNA_FreestyleLineSet, lineset);
 +}
 +
 +static void rna_FreestyleSettings_active_lineset_index_range(PointerRNA *ptr, int *min, int *max)
 +{
 +      FreestyleConfig *config= (FreestyleConfig *)ptr->data;
 +      *min= 0;
 +      *max= BLI_countlist(&config->linesets)-1;
 +      *max= MAX2(0, *max);
 +}
 +
 +static int rna_FreestyleSettings_active_lineset_index_get(PointerRNA *ptr)
 +{
 +      FreestyleConfig *config= (FreestyleConfig *)ptr->data;
 +      return FRS_get_active_lineset_index(config);
 +}
 +
 +static void rna_FreestyleSettings_active_lineset_index_set(PointerRNA *ptr, int value)
 +{
 +      FreestyleConfig *config= (FreestyleConfig *)ptr->data;
 +      FRS_set_active_lineset_index(config, value);
 +}
 +
  #else
  
  static void rna_def_transform_orientation(BlenderRNA *brna)
@@@ -1458,7 -1412,6 +1458,7 @@@ static void rna_def_tool_settings(Blend
                {EDGE_MODE_TAG_SHARP, "SHARP", 0, "Tag Sharp", ""},
                {EDGE_MODE_TAG_CREASE, "CREASE", 0, "Tag Crease", ""},
                {EDGE_MODE_TAG_BEVEL, "BEVEL", 0, "Tag Bevel", ""},
 +              {EDGE_MODE_TAG_FREESTYLE, "FREESTYLE", 0, "Tag Freestyle Edge Mark", ""},
                {0, NULL, 0, NULL, NULL}};
  
        srna= RNA_def_struct(brna, "ToolSettings", NULL);
                                 "Project individual elements on the surface of other objects");
        RNA_def_property_ui_icon(prop, ICON_RETOPO, 0);
        RNA_def_property_update(prop, NC_SCENE|ND_TOOLSETTINGS, NULL); /* header redraw */
 -
 +      
        prop= RNA_def_property(srna, "use_snap_self", PROP_BOOLEAN, PROP_NONE);
        RNA_def_property_boolean_negative_sdna(prop, NULL, "snap_flag", SCE_SNAP_NO_SELF);
        RNA_def_property_ui_text(prop, "Project to Self", "Snap onto itself (editmode)");
@@@ -1948,12 -1901,6 +1948,12 @@@ void rna_def_render_layer_common(Struct
        if(scene) RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL);
        else RNA_def_property_clear_flag(prop, PROP_EDITABLE);
  
 +      prop= RNA_def_property(srna, "use_freestyle", PROP_BOOLEAN, PROP_NONE);
 +      RNA_def_property_boolean_sdna(prop, NULL, "layflag", SCE_LAY_FRS);
 +      RNA_def_property_ui_text(prop, "Freestyle", "Render stylized strokes in this Layer");
 +      if(scene) RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL);
 +      else RNA_def_property_clear_flag(prop, PROP_EDITABLE);
 +
        /* passes */
        prop= RNA_def_property(srna, "use_pass_combined", PROP_BOOLEAN, PROP_NONE);
        RNA_def_property_boolean_sdna(prop, NULL, "passflag", SCE_PASS_COMBINED);
        else RNA_def_property_clear_flag(prop, PROP_EDITABLE);
  }
  
 +static void rna_def_freestyle_linesets(BlenderRNA *brna, PropertyRNA *cprop)
 +{
 +      StructRNA *srna;
 +      PropertyRNA *prop;
 +
 +      RNA_def_property_srna(cprop, "Linesets");
 +      srna= RNA_def_struct(brna, "Linesets", NULL);
 +      RNA_def_struct_sdna(srna, "FreestyleSettings");
 +      RNA_def_struct_ui_text(srna, "Line Sets", "Line sets for associating lines and style parameters");
 +
 +      prop= RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE);
 +      RNA_def_property_struct_type(prop, "FreestyleLineSet");
 +      RNA_def_property_pointer_funcs(prop, "rna_FreestyleSettings_active_lineset_get", NULL, NULL, NULL);
 +      RNA_def_property_ui_text(prop, "Active Line Set", "Active line set being displayed");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "active_index", PROP_INT, PROP_UNSIGNED);
 +      RNA_def_property_int_funcs(prop, "rna_FreestyleSettings_active_lineset_index_get", "rna_FreestyleSettings_active_lineset_index_set", "rna_FreestyleSettings_active_lineset_index_range");
 +      RNA_def_property_ui_text(prop, "Active Line Set Index", "Index of active line set slot");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +}
 +
 +static void rna_def_freestyle_settings(BlenderRNA *brna)
 +{
 +      StructRNA *srna;
 +      PropertyRNA *prop;
 +
 +      static EnumPropertyItem edge_type_negation_items[] = {
 +              {0, "INCLUSIVE", 0, "Inclusive", "Select feature edges satisfying the given edge type conditions"},
 +              {FREESTYLE_LINESET_FE_NOT, "EXCLUSIVE", 0, "Exclusive", "Select feature edges not satisfying the given edge type conditions"},
 +              {0, NULL, 0, NULL, NULL}};
 +
 +      static EnumPropertyItem edge_type_combination_items[] = {
 +              {0, "OR", 0, "Logical OR", "Combine feature edge type conditions by logical OR (logical disjunction)"},
 +              {FREESTYLE_LINESET_FE_AND, "AND", 0, "Logical AND", "Combine feature edge type conditions by logical AND (logical conjunction)"},
 +              {0, NULL, 0, NULL, NULL}};
 +
 +      static EnumPropertyItem group_negation_items[] = {
 +              {0, "INCLUSIVE", 0, "Inclusive", "Select feature edges belonging to some object in the group"},
 +              {FREESTYLE_LINESET_GR_NOT, "EXCLUSIVE", 0, "Exclusive", "Select feature edges not belonging to any object in the group"},
 +              {0, NULL, 0, NULL, NULL}};
 +
 +      static EnumPropertyItem face_mark_negation_items[] = {
 +              {0, "INCLUSIVE", 0, "Inclusive", "Select feature edges satisfying the given face mark conditions"},
 +              {FREESTYLE_LINESET_FM_NOT, "EXCLUSIVE", 0, "Exclusive", "Select feature edges not satisfying the given face mark conditions"},
 +              {0, NULL, 0, NULL, NULL}};
 +
 +      static EnumPropertyItem face_mark_condition_items[] = {
 +              {0, "ONE", 0, "One Face", "Select feature edges if one of faces on the right and left has a face mark"},
 +              {FREESTYLE_LINESET_FM_BOTH, "BOTH", 0, "Both Faces", "Select feature edges if both faces on the right and left faces have a face mark"},
 +              {0, NULL, 0, NULL, NULL}};
 +
 +      static EnumPropertyItem freestyle_ui_mode_items[] = {
 +              {FREESTYLE_CONTROL_SCRIPT_MODE, "SCRIPT", 0, "Python Scripting Mode", "Advanced mode for using style modules in Python"},
 +              {FREESTYLE_CONTROL_EDITOR_MODE, "EDITOR", 0, "Parameter Editor Mode", "Basic mode for interactive style parameter editing"},
 +              {0, NULL, 0, NULL, NULL}};
 +
 +      static EnumPropertyItem visibility_items[] ={
 +              {FREESTYLE_QI_VISIBLE, "VISIBLE", 0, "Visible", "Select visible feature edges"},
 +              {FREESTYLE_QI_HIDDEN, "HIDDEN", 0, "Hidden", "Select hidden feature edges"},
 +              {FREESTYLE_QI_RANGE, "RANGE", 0, "QI Range", "Select feature edges within a range of quantitative invisibility (QI) values"},
 +              {0, NULL, 0, NULL, NULL}};
 +
 +      static EnumPropertyItem freestyle_raycasting_algorithm_items[] = {
 +              {FREESTYLE_ALGO_REGULAR, "REGULAR", 0, "Normal Ray Casting", "Consider all FEdges in each ViewEdge"},
 +              {FREESTYLE_ALGO_FAST, "FAST", 0, "Fast Ray Casting", "Sample some FEdges in each ViewEdge"},
 +              {FREESTYLE_ALGO_VERYFAST, "VERYFAST", 0, "Very Fast Ray Casting", "Sample one FEdge in each ViewEdge; do not save list of occluders"},
 +              {FREESTYLE_ALGO_CULLED_ADAPTIVE_TRADITIONAL, "CULLEDADAPTIVETRADITIONAL", 0, "Culled Traditional Visibility Detection", "Culled adaptive grid with heuristic density and traditional QI calculation"},
 +              {FREESTYLE_ALGO_ADAPTIVE_TRADITIONAL, "ADAPTIVETRADITIONAL", 0, "Unculled Traditional Visibility Detection", "Adaptive grid with heuristic density and traditional QI calculation"},
 +              {FREESTYLE_ALGO_CULLED_ADAPTIVE_CUMULATIVE, "CULLEDADAPTIVECUMULATIVE", 0, "Culled Cumulative Visibility Detection", "Culled adaptive grid with heuristic density and cumulative QI calculation"},
 +              {FREESTYLE_ALGO_ADAPTIVE_CUMULATIVE, "ADAPTIVECUMULATIVE", 0, "Unculled Cumulative Visibility Detection", "Adaptive grid with heuristic density and cumulative QI calculation"},
 +              {0, NULL, 0, NULL, NULL}};
 +
 +
 +      /* FreestyleLineSet */
 +
 +      srna= RNA_def_struct(brna, "FreestyleLineSet", NULL);
 +      RNA_def_struct_ui_text(srna, "Freestyle Line Set", "Line set for associating lines and style parameters");
 +
 +      /* access to line style settings is redirected through functions */
 +      /* to allow proper id-buttons functionality */
 +      prop= RNA_def_property(srna, "linestyle", PROP_POINTER, PROP_NONE);
 +      RNA_def_property_struct_type(prop, "FreestyleLineStyle");
 +      RNA_def_property_flag(prop, PROP_EDITABLE|PROP_NEVER_NULL);
 +      RNA_def_property_pointer_funcs(prop, "rna_FreestyleLineSet_linestyle_get", "rna_FreestyleLineSet_linestyle_set", NULL, NULL);
 +      RNA_def_property_ui_text(prop, "Line Style", "Line style settings");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
 +      RNA_def_property_string_sdna(prop, NULL, "name");
 +      RNA_def_property_ui_text(prop, "Line Set Name", "Line set name");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +      RNA_def_struct_name_property(srna, prop);
 +
 +      prop= RNA_def_property(srna, "use", PROP_BOOLEAN, PROP_NONE);
 +      RNA_def_property_boolean_sdna(prop, NULL, "flags", FREESTYLE_LINESET_ENABLED);
 +      RNA_def_property_ui_text(prop, "Use", "Enable or disable this line set during stroke rendering");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "select_by_visibility", PROP_BOOLEAN, PROP_NONE);
 +      RNA_def_property_boolean_sdna(prop, NULL, "selection", FREESTYLE_SEL_VISIBILITY);
 +      RNA_def_property_ui_text(prop, "Selection by Visibility", "Select feature edges based on visibility");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "select_by_edge_types", PROP_BOOLEAN, PROP_NONE);
 +      RNA_def_property_boolean_sdna(prop, NULL, "selection", FREESTYLE_SEL_EDGE_TYPES);
 +      RNA_def_property_ui_text(prop, "Selection by Edge Types", "Select feature edges based on edge types");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "select_by_group", PROP_BOOLEAN, PROP_NONE);
 +      RNA_def_property_boolean_sdna(prop, NULL, "selection", FREESTYLE_SEL_GROUP);
 +      RNA_def_property_ui_text(prop, "Selection by Group", "Select feature edges based on a group of objects");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "select_by_image_border", PROP_BOOLEAN, PROP_NONE);
 +      RNA_def_property_boolean_sdna(prop, NULL, "selection", FREESTYLE_SEL_IMAGE_BORDER);
 +      RNA_def_property_ui_text(prop, "Selection by Image Border", "Select feature edges by image border (less memory consumption)");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "select_by_face_marks", PROP_BOOLEAN, PROP_NONE);
 +      RNA_def_property_boolean_sdna(prop, NULL, "selection", FREESTYLE_SEL_FACE_MARK);
 +      RNA_def_property_ui_text(prop, "Selection by Face Marks", "Select feature edges by face marks");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "edge_type_negation", PROP_ENUM, PROP_NONE);
 +      RNA_def_property_enum_bitflag_sdna(prop, NULL, "flags");
 +      RNA_def_property_enum_items(prop, edge_type_negation_items);
 +      RNA_def_property_ui_text(prop, "Edge Type Negation", "Set the negation operation for conditions on feature edge types");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "edge_type_combination", PROP_ENUM, PROP_NONE);
 +      RNA_def_property_enum_bitflag_sdna(prop, NULL, "flags");
 +      RNA_def_property_enum_items(prop, edge_type_combination_items);
 +      RNA_def_property_ui_text(prop, "Edge Type Combination", "Set the combination operation for conditions on feature edge types");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "group", PROP_POINTER, PROP_NONE);
 +      RNA_def_property_pointer_sdna(prop, NULL, "group");
 +      RNA_def_property_struct_type(prop, "Group");
 +      RNA_def_property_flag(prop, PROP_EDITABLE);
 +      RNA_def_property_ui_text(prop, "Group", "A group of objects based on which feature edges are selected");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "group_negation", PROP_ENUM, PROP_NONE);
 +      RNA_def_property_enum_bitflag_sdna(prop, NULL, "flags");
 +      RNA_def_property_enum_items(prop, group_negation_items);
 +      RNA_def_property_ui_text(prop, "Group Negation", "Set the negation operation for conditions on feature edge types");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "face_mark_negation", PROP_ENUM, PROP_NONE);
 +      RNA_def_property_enum_bitflag_sdna(prop, NULL, "flags");
 +      RNA_def_property_enum_items(prop, face_mark_negation_items);
 +      RNA_def_property_ui_text(prop, "Face Mark Negation", "Set the negation operation for the condition on face marks");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "face_mark_condition", PROP_ENUM, PROP_NONE);
 +      RNA_def_property_enum_bitflag_sdna(prop, NULL, "flags");
 +      RNA_def_property_enum_items(prop, face_mark_condition_items);
 +      RNA_def_property_ui_text(prop, "Face Mark Condition", "Set a feature edge selection condition on face marks");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "select_silhouette", PROP_BOOLEAN, PROP_NONE);
 +      RNA_def_property_boolean_sdna(prop, NULL, "edge_types", FREESTYLE_FE_SILHOUETTE);
 +      RNA_def_property_ui_text(prop, "Silhouette", "Select silhouette edges");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "select_border", PROP_BOOLEAN, PROP_NONE);
 +      RNA_def_property_boolean_sdna(prop, NULL, "edge_types", FREESTYLE_FE_BORDER);
 +      RNA_def_property_ui_text(prop, "Border", "Select border edges");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "select_crease", PROP_BOOLEAN, PROP_NONE);
 +      RNA_def_property_boolean_sdna(prop, NULL, "edge_types", FREESTYLE_FE_CREASE);
 +      RNA_def_property_ui_text(prop, "Crease", "Select crease edges");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "select_ridge", PROP_BOOLEAN, PROP_NONE);
 +      RNA_def_property_boolean_sdna(prop, NULL, "edge_types", FREESTYLE_FE_RIDGE);
 +      RNA_def_property_ui_text(prop, "Ridge", "Select ridges");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "select_valley", PROP_BOOLEAN, PROP_NONE);
 +      RNA_def_property_boolean_sdna(prop, NULL, "edge_types", FREESTYLE_FE_VALLEY);
 +      RNA_def_property_ui_text(prop, "Valley", "Select valleys");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "select_suggestive_contour", PROP_BOOLEAN, PROP_NONE);
 +      RNA_def_property_boolean_sdna(prop, NULL, "edge_types", FREESTYLE_FE_SUGGESTIVE_CONTOUR);
 +      RNA_def_property_ui_text(prop, "Suggestive Contour", "Select suggestive contours");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "select_material_boundary", PROP_BOOLEAN, PROP_NONE);
 +      RNA_def_property_boolean_sdna(prop, NULL, "edge_types", FREESTYLE_FE_MATERIAL_BOUNDARY);
 +      RNA_def_property_ui_text(prop, "Material Boundary", "Select edges at material boundaries");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "select_contour", PROP_BOOLEAN, PROP_NONE);
 +      RNA_def_property_boolean_sdna(prop, NULL, "edge_types", FREESTYLE_FE_CONTOUR);
 +      RNA_def_property_ui_text(prop, "Contour", "Select contours");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "select_external_contour", PROP_BOOLEAN, PROP_NONE);
 +      RNA_def_property_boolean_sdna(prop, NULL, "edge_types", FREESTYLE_FE_EXTERNAL_CONTOUR);
 +      RNA_def_property_ui_text(prop, "External Contour", "Select external contours");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "select_edge_mark", PROP_BOOLEAN, PROP_NONE);
 +      RNA_def_property_boolean_sdna(prop, NULL, "edge_types", FREESTYLE_FE_EDGE_MARK);
 +      RNA_def_property_ui_text(prop, "Edge Mark", "Select edge marks");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "exclude_silhouette", PROP_BOOLEAN, PROP_NONE);
 +      RNA_def_property_boolean_sdna(prop, NULL, "exclude_edge_types", FREESTYLE_FE_SILHOUETTE);
 +      RNA_def_property_ui_text(prop, "Silhouette", "Exclude silhouette edges");
 +      RNA_def_property_ui_icon(prop, ICON_X, 0);
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "exclude_border", PROP_BOOLEAN, PROP_NONE);
 +      RNA_def_property_boolean_sdna(prop, NULL, "exclude_edge_types", FREESTYLE_FE_BORDER);
 +      RNA_def_property_ui_text(prop, "Border", "Exclude border edges");
 +      RNA_def_property_ui_icon(prop, ICON_X, 0);
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "exclude_crease", PROP_BOOLEAN, PROP_NONE);
 +      RNA_def_property_boolean_sdna(prop, NULL, "exclude_edge_types", FREESTYLE_FE_CREASE);
 +      RNA_def_property_ui_text(prop, "Crease", "Exclude crease edges");
 +      RNA_def_property_ui_icon(prop, ICON_X, 0);
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "exclude_ridge", PROP_BOOLEAN, PROP_NONE);
 +      RNA_def_property_boolean_sdna(prop, NULL, "exclude_edge_types", FREESTYLE_FE_RIDGE);
 +      RNA_def_property_ui_text(prop, "Ridge", "Exclude ridges");
 +      RNA_def_property_ui_icon(prop, ICON_X, 0);
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "exclude_valley", PROP_BOOLEAN, PROP_NONE);
 +      RNA_def_property_boolean_sdna(prop, NULL, "exclude_edge_types", FREESTYLE_FE_VALLEY);
 +      RNA_def_property_ui_text(prop, "Valley", "Exclude valleys");
 +      RNA_def_property_ui_icon(prop, ICON_X, 0);
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "exclude_suggestive_contour", PROP_BOOLEAN, PROP_NONE);
 +      RNA_def_property_boolean_sdna(prop, NULL, "exclude_edge_types", FREESTYLE_FE_SUGGESTIVE_CONTOUR);
 +      RNA_def_property_ui_text(prop, "Suggestive Contour", "Exclude suggestive contours");
 +      RNA_def_property_ui_icon(prop, ICON_X, 0);
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "exclude_material_boundary", PROP_BOOLEAN, PROP_NONE);
 +      RNA_def_property_boolean_sdna(prop, NULL, "exclude_edge_types", FREESTYLE_FE_MATERIAL_BOUNDARY);
 +      RNA_def_property_ui_text(prop, "Material Boundary", "Exclude edges at material boundaries");
 +      RNA_def_property_ui_icon(prop, ICON_X, 0);
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "exclude_contour", PROP_BOOLEAN, PROP_NONE);
 +      RNA_def_property_boolean_sdna(prop, NULL, "exclude_edge_types", FREESTYLE_FE_CONTOUR);
 +      RNA_def_property_ui_text(prop, "Contour", "Exclude contours");
 +      RNA_def_property_ui_icon(prop, ICON_X, 0);
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "exclude_external_contour", PROP_BOOLEAN, PROP_NONE);
 +      RNA_def_property_boolean_sdna(prop, NULL, "exclude_edge_types", FREESTYLE_FE_EXTERNAL_CONTOUR);
 +      RNA_def_property_ui_text(prop, "External Contour", "Exclude external contours");
 +      RNA_def_property_ui_icon(prop, ICON_X, 0);
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "exclude_edge_mark", PROP_BOOLEAN, PROP_NONE);
 +      RNA_def_property_boolean_sdna(prop, NULL, "exclude_edge_types", FREESTYLE_FE_EDGE_MARK);
 +      RNA_def_property_ui_text(prop, "Edge Mark", "Exclude edge marks");
 +      RNA_def_property_ui_icon(prop, ICON_X, 0);
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "visibility", PROP_ENUM, PROP_NONE);
 +      RNA_def_property_enum_sdna(prop, NULL, "qi");
 +      RNA_def_property_enum_items(prop, visibility_items);
 +      RNA_def_property_ui_text(prop, "Visibility", "Determine how to use visibility for feature edge selection");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "qi_start", PROP_INT, PROP_UNSIGNED);
 +      RNA_def_property_int_sdna(prop, NULL, "qi_start");
 +      RNA_def_property_range(prop, 0, INT_MAX);
 +      RNA_def_property_ui_text(prop, "Start", "First QI value of the QI range");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "qi_end", PROP_INT, PROP_UNSIGNED);
 +      RNA_def_property_int_sdna(prop, NULL, "qi_end");
 +      RNA_def_property_range(prop, 0, INT_MAX);
 +      RNA_def_property_ui_text(prop, "End", "Last QI value of the QI range");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      /* FreestyleModuleSettings */
 +
 +      srna= RNA_def_struct(brna, "FreestyleModuleSettings", NULL);
 +      RNA_def_struct_sdna(srna, "FreestyleModuleConfig");
 +      RNA_def_struct_ui_text(srna, "Freestyle Module", "Style module configuration for specifying a style module");
 +
 +      prop= RNA_def_property(srna, "module_path", PROP_STRING, PROP_FILEPATH);
 +      RNA_def_property_string_sdna(prop, NULL, "module_path");
 +      RNA_def_property_ui_text(prop, "Module Path", "Path to a style module file");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "use", PROP_BOOLEAN, PROP_NONE);
 +      RNA_def_property_boolean_sdna(prop, NULL, "is_displayed", 1);
 +      RNA_def_property_ui_text(prop, "Use", "Enable or disable this style module during stroke rendering");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      /* FreestyleSettings */
 +
 +      srna= RNA_def_struct(brna, "FreestyleSettings", NULL);
 +      RNA_def_struct_sdna(srna, "FreestyleConfig");
 +      RNA_def_struct_nested(brna, srna, "SceneRenderLayer");
 +      RNA_def_struct_ui_text(srna, "Frestyle Settings", "Freestyle settings for a SceneRenderLayer datablock");
 +
 +      prop= RNA_def_property(srna, "modules", PROP_COLLECTION, PROP_NONE);
 +      RNA_def_property_collection_sdna(prop, NULL, "modules", NULL);
 +      RNA_def_property_struct_type(prop, "FreestyleModuleSettings");
 +      RNA_def_property_ui_text(prop, "Style modules", "A list of style modules (to be applied from top to bottom)");
 +
 +      prop= RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE);
 +      RNA_def_property_enum_sdna(prop, NULL, "mode");
 +      RNA_def_property_enum_items(prop, freestyle_ui_mode_items);
 +      RNA_def_property_ui_text(prop, "Control Mode", "Select the Freestyle control mode");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "raycasting_algorithm", PROP_ENUM, PROP_NONE);
 +      RNA_def_property_enum_sdna(prop, NULL, "raycasting_algorithm");
 +      RNA_def_property_enum_items(prop, freestyle_raycasting_algorithm_items);
 +      RNA_def_property_ui_text(prop, "Raycasting Algorithm", "Select the Freestyle raycasting algorithm");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "use_suggestive_contours", PROP_BOOLEAN, PROP_NONE);
 +      RNA_def_property_boolean_sdna(prop, NULL, "flags", FREESTYLE_SUGGESTIVE_CONTOURS_FLAG);
 +      RNA_def_property_ui_text(prop, "Suggestive Contours", "Enable suggestive contours");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "use_ridges_and_valleys", PROP_BOOLEAN, PROP_NONE);
 +      RNA_def_property_boolean_sdna(prop, NULL, "flags", FREESTYLE_RIDGES_AND_VALLEYS_FLAG);
 +      RNA_def_property_ui_text(prop, "Ridges and Valleys", "Enable ridges and valleys");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "use_material_boundaries", PROP_BOOLEAN, PROP_NONE);
 +      RNA_def_property_boolean_sdna(prop, NULL, "flags", FREESTYLE_MATERIAL_BOUNDARIES_FLAG);
 +      RNA_def_property_ui_text(prop, "Material Boundaries", "Enable material boundaries");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "use_smoothness", PROP_BOOLEAN, PROP_NONE);
 +      RNA_def_property_boolean_sdna(prop, NULL, "flags", FREESTYLE_FACE_SMOOTHNESS_FLAG);
 +      RNA_def_property_ui_text(prop, "Face Smoothness", "Take face smoothness into account in view map calculation");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "sphere_radius", PROP_FLOAT, PROP_NONE);
 +      RNA_def_property_float_sdna(prop, NULL, "sphere_radius");
 +      RNA_def_property_range(prop, 0.0, 1000.0);
 +      RNA_def_property_ui_text(prop, "Sphere Radius", "Sphere radius for computing curvatures");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "kr_derivative_epsilon", PROP_FLOAT, PROP_NONE);
 +      RNA_def_property_float_sdna(prop, NULL, "dkr_epsilon");
 +      RNA_def_property_range(prop, 0.0, 1000.0);
 +      RNA_def_property_ui_text(prop, "Kr Derivative Epsilon", "Kr derivative epsilon for computing suggestive contours");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "crease_angle", PROP_FLOAT, PROP_NONE);
 +      RNA_def_property_float_sdna(prop, NULL, "crease_angle");
 +      RNA_def_property_range(prop, 0.0, 180.0);
 +      RNA_def_property_ui_text(prop, "Crease Angle", "Angular threshold in degrees (between 0 and 180) for detecting crease edges");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "linesets", PROP_COLLECTION, PROP_NONE);
 +      RNA_def_property_collection_sdna(prop, NULL, "linesets", NULL);
 +      RNA_def_property_struct_type(prop, "FreestyleLineSet");
 +      RNA_def_property_ui_text(prop, "Line Sets", "");
 +      rna_def_freestyle_linesets(brna, prop);
 +}
 +
  static void rna_def_scene_game_recast_data(BlenderRNA *brna)
  {
        StructRNA *srna;
@@@ -3019,23 -2592,12 +3019,23 @@@ static void rna_def_scene_game_data(Ble
  static void rna_def_scene_render_layer(BlenderRNA *brna)
  {
        StructRNA *srna;
 +      PropertyRNA *prop;
  
        srna= RNA_def_struct(brna, "SceneRenderLayer", NULL);
        RNA_def_struct_ui_text(srna, "Scene Render Layer", "Render layer");
        RNA_def_struct_ui_icon(srna, ICON_RENDERLAYERS);
  
        rna_def_render_layer_common(srna, 1);
 +
 +      /* Freestyle */
 +
 +      rna_def_freestyle_settings(brna);
 +
 +      prop= RNA_def_property(srna, "freestyle_settings", PROP_POINTER, PROP_NONE);
 +      RNA_def_property_flag(prop, PROP_NEVER_NULL);
 +      RNA_def_property_pointer_sdna(prop, NULL, "freestyleConfig");
 +      RNA_def_property_struct_type(prop, "FreestyleSettings");
 +      RNA_def_property_ui_text(prop, "Freestyle Settings", "");
  }
  
  /* curve.splines */
@@@ -3810,11 -3372,6 +3810,11 @@@ static void rna_def_scene_render_data(B
        RNA_def_property_ui_text(prop, "Edge Color", "Edge color");
        RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL);
        
 +      prop= RNA_def_property(srna, "use_freestyle", PROP_BOOLEAN, PROP_NONE);
 +      RNA_def_property_boolean_sdna(prop, NULL, "mode", R_EDGE_FRS);
 +      RNA_def_property_ui_text(prop, "Edge", "Draw stylized strokes using Freestyle");
 +      RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL);
 +
        /* threads */
        prop= RNA_def_property(srna, "threads", PROP_INT, PROP_NONE);
        RNA_def_property_int_sdna(prop, NULL, "threads");
        prop= RNA_def_property(srna, "use_motion_blur", PROP_BOOLEAN, PROP_NONE);
        RNA_def_property_boolean_sdna(prop, NULL, "mode", R_MBLUR);
        RNA_def_property_ui_text(prop, "Motion Blur", "Use multi-sampled 3D scene motion blur");
+       RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
        RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL);
        
        prop= RNA_def_property(srna, "motion_blur_samples", PROP_INT, PROP_NONE);
        RNA_def_property_int_sdna(prop, NULL, "mblur_samples");
        RNA_def_property_range(prop, 1, 32);
        RNA_def_property_ui_text(prop, "Motion Samples", "Number of scene samples to take with motion blur");
+       RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
        RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL);
        
        prop= RNA_def_property(srna, "motion_blur_shutter", PROP_FLOAT, PROP_NONE);
index d2b71e92e22ba2e80e78d6960c26317376735b30,bc7f446d815848b20c35d7821bcb8f739807b15a..e6d04f04fefa01a7c1051f23123a6bcfb79c5af4
@@@ -377,10 -377,18 +377,18 @@@ static EnumPropertyItem *rna_userdef_co
                CCLDeviceInfo *devices = CCL_compute_device_list(opencl);
                int a;
  
-               for(a = 0; devices[a].name; a++) {
-                       tmp.value = devices[a].value;
-                       tmp.identifier = devices[a].identifier;
-                       tmp.name = devices[a].name;
+               if(devices) {
+                       for(a = 0; devices[a].name; a++) {
+                               tmp.value = devices[a].value;
+                               tmp.identifier = devices[a].identifier;
+                               tmp.name = devices[a].name;
+                               RNA_enum_item_add(&item, &totitem, &tmp);
+                       }
+               }
+               else {
+                       tmp.value = 0;
+                       tmp.name = "CPU";
+                       tmp.identifier = "CPU";
                        RNA_enum_item_add(&item, &totitem, &tmp);
                }
        }
@@@ -900,11 -908,6 +908,11 @@@ static void rna_def_userdef_theme_space
        RNA_def_property_array(prop, 3);
        RNA_def_property_ui_text(prop, "Edge UV Face Select", "");
        RNA_def_property_update(prop, 0, "rna_userdef_update");
 +
 +      prop= RNA_def_property(srna, "freestyle_edge_mark", PROP_FLOAT, PROP_COLOR_GAMMA);
 +      RNA_def_property_array(prop, 3);
 +      RNA_def_property_ui_text(prop, "Freestyle Edge Mark", "");
 +      RNA_def_property_update(prop, 0, "rna_userdef_update");
  }
  
  static void rna_def_userdef_theme_spaces_face(StructRNA *srna)
        RNA_def_property_range(prop, 1, 10);
        RNA_def_property_ui_text(prop, "Face Dot Size", "");
        RNA_def_property_update(prop, 0, "rna_userdef_update");
 +
 +      prop= RNA_def_property(srna, "freestyle_face_mark", PROP_FLOAT, PROP_COLOR_GAMMA);
 +      RNA_def_property_array(prop, 4);
 +      RNA_def_property_ui_text(prop, "Freestyle Face Mark", "");
 +      RNA_def_property_update(prop, 0, "rna_userdef_update");
  }
  
  static void rna_def_userdef_theme_spaces_curves(StructRNA *srna, short incl_nurbs)
index da33996fa99b74393f22b9170b7c0227e42d39d7,100b12aa1694b8a91aba48fe54678f28c20dc2e6..9ed2d845cf79597c38bdd8059c204506cbf8674e
@@@ -51,7 -51,6 +51,7 @@@
  #include "BKE_camera.h"
  #include "BKE_global.h"
  #include "BKE_image.h"
 +#include "BKE_library.h"
  #include "BKE_main.h"
  #include "BKE_node.h"
  #include "BKE_pointcache.h"
@@@ -76,8 -75,6 +76,8 @@@
  #include "RE_engine.h"
  #include "RE_pipeline.h"
  
 +#include "FRS_freestyle.h"
 +
  /* internal */
  #include "render_result.h"
  #include "render_types.h"
@@@ -701,7 -698,7 +701,7 @@@ static RenderPart *find_next_pano_slice
  
                R.panodxp= (re->winx - (best->disprect.xmin + best->disprect.xmax) )/2;
                R.panodxv= ((viewplane->xmax-viewplane->xmin)*R.panodxp)/(float)(re->winx);
 -
 +              
                /* shift viewplane */
                R.viewplane.xmin = viewplane->xmin + R.panodxv;
                R.viewplane.xmax = viewplane->xmax + R.panodxv;
@@@ -901,8 -898,6 +901,8 @@@ void RE_TileProcessor(Render *re
  
  /* ************  This part uses API, for rendering Blender scenes ********** */
  
 +static void add_freestyle(Render *re);
 +
  static void do_render_3d(Render *re)
  {
        /* try external */
                if(!re->test_break(re->tbh))
                        add_halo_flare(re);
        
 +      /* Freestyle  */
 +      if( re->r.mode & R_EDGE_FRS)
 +              if(!re->test_break(re->tbh))
 +                      add_freestyle(re);
 +              
        /* free all render verts etc */
        RE_Database_Free(re);
        
@@@ -1376,66 -1366,6 +1376,66 @@@ static void render_composit_stats(void 
  }
  
  
 +/* invokes Freestyle stroke rendering */
 +static void add_freestyle(Render *re)
 +{
 +      SceneRenderLayer *srl;
 +      LinkData *link;
 +
 +      FRS_init_stroke_rendering(re);
 +
 +      for(srl= (SceneRenderLayer *)re->scene->r.layers.first; srl; srl= srl->next) {
 +
 +              link = (LinkData *)MEM_callocN(sizeof(LinkData), "LinkData to Freestyle render");
 +              BLI_addtail(&re->freestyle_renders, link);
 +
 +              if( FRS_is_freestyle_enabled(srl) ) {
 +                      link->data = (void *)FRS_do_stroke_rendering(re, srl);
 +              }
 +      }
 +
 +      FRS_finish_stroke_rendering(re);
 +}
 +
 +/* merges the results of Freestyle stroke rendering into a given render result */
 +static void composite_freestyle_renders(Render *re, int sample)
 +{
 +      Render *freestyle_render;
 +      SceneRenderLayer *srl;
 +      LinkData *link;
 +
 +      link = (LinkData *)re->freestyle_renders.first;
 +      for(srl= (SceneRenderLayer *)re->scene->r.layers.first; srl; srl= srl->next) {
 +              if( FRS_is_freestyle_enabled(srl) ) {
 +                      freestyle_render = (Render *)link->data;
 +                      render_result_exr_file_read(freestyle_render, sample);
 +                      FRS_composite_result(re, srl, freestyle_render);
 +                      RE_FreeRenderResult(freestyle_render->result);
 +                      freestyle_render->result = NULL;
 +              }
 +              link = link->next;
 +      }
 +}
 +
 +/* releases temporary scenes and renders for Freestyle stroke rendering */
 +static void free_all_freestyle_renders(Scene *scene)
 +{
 +      Render *re1, *freestyle_render;
 +      LinkData *link;
 +
 +      for(re1= RenderGlobal.renderlist.first; re1; re1= re1->next) {
 +              for (link = (LinkData *)re1->freestyle_renders.first; link; link = link->next) {
 +                      if (link->data) {
 +                              freestyle_render = (Render *)link->data;
 +                              unlink_scene(G.main, freestyle_render->scene, scene);
 +                              RE_FreeRender(freestyle_render);
 +                      }
 +              }
 +              BLI_freelistN( &re1->freestyle_renders );
 +      }
 +}
 +
 +
  /* reads all buffers, calls optional composite, merges in first result->rectf */
  static void do_merge_fullsample(Render *re, bNodeTree *ntree)
  {
                                        if(sample) {
                                                BLI_rw_mutex_lock(&re->resultmutex, THREAD_LOCK_WRITE);
                                                render_result_exr_file_read(re1, sample);
 +                                              if( re1->r.mode & R_EDGE_FRS)
 +                                                      composite_freestyle_renders(re1, sample);
                                                BLI_rw_mutex_unlock(&re->resultmutex);
                                        }
                                        ntreeCompositTagRender(re1->scene); /* ensure node gets exec to put buffers on stack */
@@@ -1667,8 -1595,6 +1667,8 @@@ static void do_render_composite_fields_
                        do_merge_fullsample(re, NULL);
        }
  
 +      free_all_freestyle_renders(re->scene);
 +
        /* weak... the display callback wants an active renderlayer pointer... */
        re->result->renlay= render_get_active_layer(re, re->result);
        re->display_draw(re->ddh, re->result, NULL);
@@@ -1819,7 -1745,7 +1819,7 @@@ static int check_valid_camera(Scene *sc
                        check_comp= 0;
  
                        while(seq) {
-                               if(seq->type == SEQ_SCENE) {
+                               if(seq->type == SEQ_SCENE && seq->scene) {
                                        if(!seq->scene_camera) {
                                                if(!seq->scene->camera && !scene_find_camera(seq->scene)) {
                                                        if(seq->scene == scene) {
@@@ -2080,7 -2006,7 +2080,7 @@@ void RE_BlenderFrame(Render *re, Main *
                BLI_exec_cb(re->main, (ID *)scene, BLI_CB_EVT_RENDER_PRE);
  
                do_render_all_options(re);
 -
 +              
                if(write_still && !G.afbreek) {
                        if(BKE_imtype_is_movie(scene->r.im_format.imtype)) {
                                /* operator checks this but incase its called from elsewhere */
        G.rendering= 0;
  }
  
 +void RE_RenderFreestyleStrokes(Render *re, Main *bmain, Scene *scene)
 +{
 +      re->result_ok= 0;
 +      if(render_initialize_from_main(re, bmain, scene, NULL, NULL, scene->lay, 0, 0)) {
 +              do_render_fields_blur_3d(re);
 +      }
 +      re->result_ok= 1;
 +}
 +
  static int do_write_image_or_movie(Render *re, Main *bmain, Scene *scene, bMovieHandle *mh, const char *name_override)
  {
        char name[FILE_MAX];
index 619a16ae6b5dc7e925a8859d6a2456d0135ede99,0e9cfd11a68c721e036ae5a6b01fbfbec9368e8f..6b021d0be42a4ce8adec12df8f4c5da056967a6d
@@@ -1030,9 -1030,9 +1030,9 @@@ static void do_specular_ramp(ShadeInpu
  /* preprocess, textures were not done, don't use shi->amb for that reason */
  void ambient_occlusion(ShadeInput *shi)
  {
-       if((R.wrld.ao_gather_method == WO_AOGATHER_APPROX) && shi->mat->amb!=0.0f)
+       if(R.wrld.ao_gather_method == WO_AOGATHER_APPROX)
                sample_occ(&R, shi);
-       else if((R.r.mode & R_RAYTRACE) && shi->mat->amb!=0.0f)
+       else if(R.r.mode & R_RAYTRACE)
                ray_ao(shi, shi->ao, shi->env);
        else
                shi->ao[0]= shi->ao[1]= shi->ao[2]= 1.0f;
@@@ -1669,12 -1669,6 +1669,12 @@@ void shade_lamp_loop(ShadeInput *shi, S
                        if(ma->mode & (MA_FACETEXTURE_ALPHA))
                                shi->alpha= shi->vcol[3];
                }
 +              else if(ma->vcol_alpha) {
 +                      shi->r= shi->vcol[0];
 +                      shi->g= shi->vcol[1];
 +                      shi->b= shi->vcol[2];
 +                      shi->alpha= shi->vcol[3];
 +              }
                else if(ma->mode & (MA_VERTEXCOLP)) {
                        float neg_alpha = 1.0f - shi->vcol[3];
                        shi->r= shi->r*neg_alpha + shi->vcol[0]*shi->vcol[3];
index 89a6881a684896359d15134bdc6ac1ce6aef27ce,a4c90888b7411ab24f6fd980010d3cf7b8b815c4..1c8826f53216f0e2addc1068e4aa4b15b9ae6e54
  #include "BPY_extern.h"
  #endif
  
 +#include "FRS_freestyle.h"
 +
  #include "WM_api.h"
  #include "WM_types.h"
  #include "wm.h"
@@@ -279,7 -277,7 +279,7 @@@ static void wm_window_match_do(bContex
  static void wm_init_userdef(bContext *C)
  {
        UI_init_userdef();
-       MEM_CacheLimiter_set_maximum(U.memcachelimit * 1024 * 1024);
+       MEM_CacheLimiter_set_maximum(((size_t)U.memcachelimit) * 1024 * 1024);
        sound_init(CTX_data_main(C));
  
        /* needed so loading a file from the command line respects user-pref [#26156] */
@@@ -416,7 -414,6 +416,7 @@@ void WM_read_file(bContext *C, const ch
                BPY_app_handlers_reset(FALSE);
                BPY_modules_load_user(C);
  #endif
 +              FRS_read_file(C);
  
                /* important to do before NULL'ing the context */
                BLI_exec_cb(CTX_data_main(C), NULL, BLI_CB_EVT_LOAD_POST);