Merged changes in the trunk up to revision 45133.
authorTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>
Sun, 25 Mar 2012 08:20:19 +0000 (08:20 +0000)
committerTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>
Sun, 25 Mar 2012 08:20:19 +0000 (08:20 +0000)
Conflicts resolved:
source/blender/blenloader/intern/readfile.c
source/blender/blenloader/intern/writefile.c
source/blender/bmesh/intern/bmesh_construct.c
source/blender/bmesh/intern/bmesh_mesh_conv.c
source/blender/bmesh/intern/bmesh_mesh_conv.h
source/blender/editors/interface/interface_templates.c
source/blender/editors/interface/resources.c
source/blender/editors/mesh/bmesh_select.c
source/blender/editors/mesh/bmesh_tools.c
source/blender/editors/space_view3d/drawobject.c
source/blender/render/intern/source/shadeoutput.c

67 files changed:
1  2 
build_files/scons/tools/Blender.py
doc/python_api/sphinx_doc_gen.py
release/scripts/startup/bl_ui/space_view3d.py
source/blender/blenkernel/CMakeLists.txt
source/blender/blenkernel/SConscript
source/blender/blenkernel/intern/anim_sys.c
source/blender/blenkernel/intern/group.c
source/blender/blenkernel/intern/library.c
source/blender/blenkernel/intern/material.c
source/blender/blenkernel/intern/object.c
source/blender/blenkernel/intern/scene.c
source/blender/blenkernel/intern/subsurf_ccg.c
source/blender/blenlib/CMakeLists.txt
source/blender/blenlib/intern/bpath.c
source/blender/blenloader/intern/readfile.c
source/blender/blenloader/intern/writefile.c
source/blender/bmesh/bmesh_class.h
source/blender/bmesh/intern/bmesh_construct.c
source/blender/bmesh/intern/bmesh_operators.h
source/blender/bmesh/operators/bmo_utils.c
source/blender/editors/animation/anim_channels_defines.c
source/blender/editors/animation/anim_channels_edit.c
source/blender/editors/animation/anim_filter.c
source/blender/editors/include/UI_resources.h
source/blender/editors/interface/interface_templates.c
source/blender/editors/interface/resources.c
source/blender/editors/mesh/editmesh_select.c
source/blender/editors/mesh/editmesh_tools.c
source/blender/editors/mesh/mesh_intern.h
source/blender/editors/mesh/mesh_ops.c
source/blender/editors/render/render_shading.c
source/blender/editors/space_buttons/space_buttons.c
source/blender/editors/space_file/filelist.c
source/blender/editors/space_nla/nla_buttons.c
source/blender/editors/space_nla/nla_channels.c
source/blender/editors/space_view3d/drawobject.c
source/blender/editors/transform/transform.c
source/blender/editors/transform/transform_orientations.c
source/blender/makesdna/DNA_action_types.h
source/blender/makesdna/DNA_material_types.h
source/blender/makesdna/DNA_mesh_types.h
source/blender/makesdna/DNA_meshdata_types.h
source/blender/makesdna/DNA_userdef_types.h
source/blender/makesdna/intern/makesdna.c
source/blender/makesrna/RNA_access.h
source/blender/makesrna/RNA_enum_types.h
source/blender/makesrna/intern/makesrna.c
source/blender/makesrna/intern/rna_ID.c
source/blender/makesrna/intern/rna_action.c
source/blender/makesrna/intern/rna_color.c
source/blender/makesrna/intern/rna_internal.h
source/blender/makesrna/intern/rna_main.c
source/blender/makesrna/intern/rna_main_api.c
source/blender/makesrna/intern/rna_mesh.c
source/blender/makesrna/intern/rna_scene.c
source/blender/makesrna/intern/rna_userdef.c
source/blender/python/intern/bpy.c
source/blender/render/intern/source/convertblender.c
source/blender/render/intern/source/pipeline.c
source/blender/render/intern/source/render_result.c
source/blender/render/intern/source/shadeoutput.c
source/blender/windowmanager/CMakeLists.txt
source/blender/windowmanager/SConscript
source/blender/windowmanager/WM_types.h
source/blender/windowmanager/intern/wm_files.c
source/creator/CMakeLists.txt
source/creator/creator.c

Simple merge
@@@ -212,9 -261,27 +261,28 @@@ else
          "mathutils",
          "mathutils.geometry",
          "mathutils.noise",
 +        "Freestyle",
      )
  
+     # ------
+     # Filter
+     #
+     # TODO, support bpy.ops and bpy.types filtering
+     import fnmatch
+     m = None
+     EXCLUDE_MODULES = tuple([m for m in EXCLUDE_MODULES if not fnmatch.fnmatchcase(m, ARGS.partial)])
+     EXCLUDE_INFO_DOCS = (not fnmatch.fnmatchcase("info", ARGS.partial))
+     del m
+     del fnmatch
+     BPY_LOGGER.debug("Partial Doc Build, Skipping: %s\n" % "\n                             ".join(sorted(EXCLUDE_MODULES)))
+     #
+     # done filtering
+     # --------------
  try:
      __import__("aud")
  except ImportError:
@@@ -1358,10 -1506,11 +1514,11 @@@ def write_rst_contents(basepath)
          # mathutils
          "mathutils", "mathutils.geometry", "mathutils.noise",
          # misc
 -        "bgl", "blf", "gpu", "aud", "bpy_extras",
 +        "Freestyle", "bgl", "blf", "gpu", "aud", "bpy_extras",
          # bmesh
-         "bmesh", "bmesh.types", "bmesh.utils"
-     ]
+         "bmesh", "bmesh.types", "bmesh.utils",
+         )
      for mod in standalone_modules:
          if mod not in EXCLUDE_MODULES:
              fw("   %s\n\n" % mod)
Simple merge
@@@ -80,15 -80,14 +80,15 @@@ void unlink_group(Group *group
        Object *ob;
        Scene *sce;
        SceneRenderLayer *srl;
 +      FreestyleLineSet *lineset;
        ParticleSystem *psys;
        
-       for(ma= bmain->mat.first; ma; ma= ma->id.next) {
-               if(ma->group==group)
+       for (ma= bmain->mat.first; ma; ma= ma->id.next) {
+               if (ma->group==group)
                        ma->group= NULL;
        }
-       for(ma= bmain->mat.first; ma; ma= ma->id.next) {
-               if(ma->group==group)
+       for (ma= bmain->mat.first; ma; ma= ma->id.next) {
+               if (ma->group==group)
                        ma->group= NULL;
        }
        for (sce= bmain->scene.first; sce; sce= sce->id.next) {
                        }
                }                       
                
-               for(srl= sce->r.layers.first; srl; srl= srl->next) {
+               for (srl= sce->r.layers.first; srl; srl= srl->next) {
                        if (srl->light_override==group)
                                srl->light_override= NULL;
 +
 +                      for(lineset= srl->freestyleConfig.linesets.first; lineset; lineset= lineset->next) {
 +                              if (lineset->group == group)
 +                                      lineset->group= NULL;
 +                      }
                }
        }
        
@@@ -895,8 -920,8 +920,8 @@@ static void ccgDM_getFinalEdge(DerivedM
                med->v2 = getEdgeIndex(ss, e, x+1, edgeSize);
  
                edgeFlag = (ccgdm->edgeFlags)? &ccgdm->edgeFlags[i]: NULL;
-               if(edgeFlag)
+               if (edgeFlag)
 -                      flags |= (*edgeFlag & (ME_SEAM | ME_SHARP))
 +                      flags |= (*edgeFlag & (ME_SEAM | ME_SHARP | ME_FREESTYLE_EDGE))
                                         | ME_EDGEDRAW | ME_EDGERENDER;
                else
                        flags |= ME_EDGEDRAW | ME_EDGERENDER;
@@@ -1077,14 -1140,15 +1140,15 @@@ static void ccgDM_copyFinalEdgeArray(De
                int x;
                int edgeIdx = GET_INT_FROM_POINTER(ccgSubSurf_getEdgeEdgeHandle(e));
  
-               if(!ccgSubSurf_getEdgeNumFaces(e)) flags |= ME_LOOSEEDGE;
+               if (!ccgSubSurf_getEdgeNumFaces(e)) flags |= ME_LOOSEEDGE;
  
-               if(edgeFlags) {
-                       if(edgeIdx != -1) {
+               if (edgeFlags) {
+                       if (edgeIdx != -1) {
 -                              flags |= (edgeFlags[index] & (ME_SEAM | ME_SHARP))
 +                              flags |= (edgeFlags[index] & (ME_SEAM | ME_SHARP | ME_FREESTYLE_EDGE))
                                                 | ME_EDGEDRAW | ME_EDGERENDER;
                        }
-               } else {
+               }
+               else {
                        flags |= ME_EDGEDRAW | ME_EDGERENDER;
                }
  
Simple merge
Simple merge
@@@ -4844,13 -4876,9 +4878,13 @@@ static void lib_link_scene(FileData *fd
                                composite_patch(sce->nodetree, sce);
                        }
                        
-                       for(srl= sce->r.layers.first; srl; srl= srl->next) {
+                       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);
@@@ -5060,15 -5092,8 +5099,15 @@@ static void direct_link_scene(FileData 
        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)
+       if (sce->nodetree)
                direct_link_nodetree(fd, sce->nodetree);
  }
  
@@@ -13438,28 -13330,18 +13519,40 @@@ static void do_versions(FileData *fd, L
                }
        }
  
+       {
+               /* Default for old files is to save particle rotations to pointcache */
+               ParticleSettings *part;
+               for (part = main->particle.first; part; part = part->id.next)
+                       part->flag |= PART_ROTATIONS;
+       }
+       /* put compatibility code here until next subversion bump */
+       {
+       }
 +      /* 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! */
  
@@@ -14389,9 -14270,8 +14482,9 @@@ static void expand_scene(FileData *fd, 
  {
        Base *base;
        SceneRenderLayer *srl;
 +      FreestyleLineSet *lineset;
  
-       for(base= sce->base.first; base; base= base->next) {
+       for (base= sce->base.first; base; base= base->next) {
                expand_doit(fd, mainvar, base->object);
        }
        expand_doit(fd, mainvar, sce->camera);
                expand_animdata(fd, mainvar, sce->adt);
        expand_keyingsets(fd, mainvar, &sce->keyingsets);
        
-       if(sce->set)
+       if (sce->set)
                expand_doit(fd, mainvar, sce->set);
        
-       if(sce->nodetree)
+       if (sce->nodetree)
                expand_nodetree(fd, mainvar, sce->nodetree);
        
-       for(srl= sce->r.layers.first; srl; srl= srl->next) {
+       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)
+       if (sce->r.dometext)
                expand_doit(fd, mainvar, sce->gm.dome.warptext);
                
-       if(sce->gpd)
+       if (sce->gpd)
                expand_doit(fd, mainvar, sce->gpd);
  
-       if(sce->ed) {
+       if (sce->ed) {
                Sequence *seq;
  
                SEQ_BEGIN(sce->ed, seq) {
@@@ -2182,23 -2184,13 +2187,23 @@@ static void write_scenes(WriteData *wd
                        writestruct(wd, DATA, "TimeMarker", 1, marker);
                
                /* writing dynamic list of TransformOrientations to the blend file */
-               for(ts = sce->transform_spaces.first; ts; ts = ts->next)
+               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)
++              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);
 +                      }
 +
 +              }
                
-               if(sce->nodetree) {
+               if (sce->nodetree) {
                        writestruct(wd, DATA, "bNodeTree", 1, sce->nodetree);
                        write_nodetree(wd, sce->nodetree);
                }
Simple merge
@@@ -759,8 -966,7 +968,8 @@@ short BM_edge_flag_to_mflag(BMEdge *eed
                 ((hflag & BM_ELEM_SEAM)         ? ME_SEAM   : 0) |
                 ((hflag & BM_ELEM_SMOOTH) == 0  ? ME_SHARP  : 0) |
                 ((hflag & BM_ELEM_HIDDEN)       ? ME_HIDE   : 0) |
-                ((BM_edge_is_wire(NULL, eed)) ? ME_LOOSEEDGE : 0) | /* not typical */
 +               ((hflag & BM_ELEM_FREESTYLE) ? ME_FREESTYLE_EDGE : 0) |
+                ((BM_edge_is_wire(eed)) ? ME_LOOSEEDGE : 0) | /* not typical */
                 (ME_EDGEDRAW | ME_EDGERENDER)
                 );
  }
@@@ -1985,83 -1981,6 +1982,83 @@@ static bAnimChannelType ACF_DSNTREE
        acf_dsntree_setting_ptr                                 /* pointer for setting */
  };
  
-                       GET_ACF_FLAG_PTR(linestyle->flag);
 +/* LineStyle Expander  ------------------------------------------- */
 +
 +// TODO: just get this from RNA?
 +static int acf_dslinestyle_icon(bAnimListElem *ale)
 +{
 +      return ICON_BRUSH_DATA; /* FIXME */
 +}
 +
 +/* get the appropriate flag(s) for the setting when it is valid  */
 +static int acf_dslinestyle_setting_flag(bAnimContext *ac, int setting, short *neg)
 +{
 +      /* clear extra return data first */
 +      *neg= 0;
 +      
 +      switch (setting) {
 +              case ACHANNEL_SETTING_EXPAND: /* expanded */
 +                      return LS_DS_EXPAND;
 +                      
 +              case ACHANNEL_SETTING_MUTE: /* mute (only in NLA) */
 +                      return ADT_NLA_EVAL_OFF;
 +                      
 +              case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */
 +                      *neg= 1;
 +                      return ADT_CURVES_NOT_VISIBLE;
 +                      
 +              case ACHANNEL_SETTING_SELECT: /* selected */
 +                      return ADT_UI_SELECTED;
 +                      
 +              default: /* unsupported */
 +                      return 0;
 +      }
 +}
 +
 +/* get pointer to the setting */
 +static void *acf_dslinestyle_setting_ptr(bAnimListElem *ale, int setting, short *type)
 +{
 +      FreestyleLineStyle *linestyle= (FreestyleLineStyle *)ale->data;
 +      
 +      /* clear extra return data first */
 +      *type= 0;
 +      
 +      switch (setting) {
 +              case ACHANNEL_SETTING_EXPAND: /* expanded */
-                               GET_ACF_FLAG_PTR(linestyle->adt->flag)
++                      return GET_ACF_FLAG_PTR(linestyle->flag, type);
 +                      
 +              case ACHANNEL_SETTING_SELECT: /* selected */
 +              case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */
 +              case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */
 +                      if (linestyle->adt)
++                              return GET_ACF_FLAG_PTR(linestyle->adt->flag, type);
 +                      else
 +                              return NULL;
 +                      
 +              default: /* unsupported */
 +                      return NULL;
 +      }
 +}
 +
 +/* node tree expander type define */
 +static bAnimChannelType ACF_DSLINESTYLE= 
 +{
 +      "Line Style Expander",                  /* type name */
 +      
 +      acf_generic_dataexpand_color,   /* backdrop color */
 +      acf_generic_dataexpand_backdrop,/* backdrop */
 +      acf_generic_indention_1,                /* indent level */
 +      acf_generic_basic_offset,               /* offset */
 +      
 +      acf_generic_idblock_name,               /* name */
 +      acf_generic_idblock_nameprop,   /* name prop */
 +      acf_dslinestyle_icon,                   /* icon */
 +      
 +      acf_generic_dataexpand_setting_valid,   /* has setting */
 +      acf_dslinestyle_setting_flag,                   /* flag for setting */
 +      acf_dslinestyle_setting_ptr                             /* pointer for setting */
 +};
 +
  /* Mesh Expander  ------------------------------------------- */
  
  // TODO: just get this from RNA?
@@@ -2134,7 -2134,7 +2135,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) || RNA_struct_is_a(itemptr->type, &RNA_FreestyleLineSet)) {
 -      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);
@@@ -627,50 -627,50 +631,52 @@@ void ui_theme_init_default(void
        ui_theme_init_new(btheme);
        
        /* space view3d */
-       SETCOLF(btheme->tv3d.back,       0.225, 0.225, 0.225, 1.0);
-       SETCOL(btheme->tv3d.text,       0, 0, 0, 255);
-       SETCOL(btheme->tv3d.text_hi, 255, 255, 255, 255);
+       rgba_char_args_set_fl(btheme->tv3d.back,       0.225, 0.225, 0.225, 1.0);
+       rgba_char_args_set(btheme->tv3d.text,       0, 0, 0, 255);
+       rgba_char_args_set(btheme->tv3d.text_hi, 255, 255, 255, 255);
        
-       SETCOLF(btheme->tv3d.header,    0.45, 0.45, 0.45, 1.0);
-       SETCOLF(btheme->tv3d.button,    0.45, 0.45, 0.45, 1.0);
-       SETCOL(btheme->tv3d.panel,      165, 165, 165, 127);
+       rgba_char_args_set_fl(btheme->tv3d.header,      0.45, 0.45, 0.45, 1.0);
+       rgba_char_args_set_fl(btheme->tv3d.button,      0.45, 0.45, 0.45, 1.0);
+       rgba_char_args_set(btheme->tv3d.panel,      165, 165, 165, 127);
        
-       SETCOL(btheme->tv3d.shade1,  160, 160, 160, 100);
-       SETCOL(btheme->tv3d.shade2,  0x7f, 0x70, 0x70, 100);
-       SETCOLF(btheme->tv3d.grid,     0.251, 0.251, 0.251, 1.0);
-       SETCOL(btheme->tv3d.wire,       0x0, 0x0, 0x0, 255);
-       SETCOL(btheme->tv3d.lamp,       0, 0, 0, 40);
-       SETCOL(btheme->tv3d.speaker,    0, 0, 0, 255);
-       SETCOL(btheme->tv3d.select, 241, 88, 0, 255);
-       SETCOL(btheme->tv3d.active, 255, 170, 64, 255);
-       SETCOL(btheme->tv3d.group,      8, 48, 8, 255);
-       SETCOL(btheme->tv3d.group_active, 85, 187, 85, 255);
-       SETCOL(btheme->tv3d.transform, 0xff, 0xff, 0xff, 255);
-       SETCOL(btheme->tv3d.vertex, 0, 0, 0, 255);
-       SETCOL(btheme->tv3d.vertex_select, 255, 133, 0, 255);
+       rgba_char_args_set(btheme->tv3d.shade1,  160, 160, 160, 100);
+       rgba_char_args_set(btheme->tv3d.shade2,  0x7f, 0x70, 0x70, 100);
+       rgba_char_args_set_fl(btheme->tv3d.grid,     0.251, 0.251, 0.251, 1.0);
+       rgba_char_args_set(btheme->tv3d.wire,       0x0, 0x0, 0x0, 255);
+       rgba_char_args_set(btheme->tv3d.lamp,       0, 0, 0, 40);
+       rgba_char_args_set(btheme->tv3d.speaker,    0, 0, 0, 255);
+       rgba_char_args_set(btheme->tv3d.camera,    0, 0, 0, 255);
+       rgba_char_args_set(btheme->tv3d.empty,    0, 0, 0, 255);
+       rgba_char_args_set(btheme->tv3d.select, 241, 88, 0, 255);
+       rgba_char_args_set(btheme->tv3d.active, 255, 170, 64, 255);
+       rgba_char_args_set(btheme->tv3d.group,      8, 48, 8, 255);
+       rgba_char_args_set(btheme->tv3d.group_active, 85, 187, 85, 255);
+       rgba_char_args_set(btheme->tv3d.transform, 0xff, 0xff, 0xff, 255);
+       rgba_char_args_set(btheme->tv3d.vertex, 0, 0, 0, 255);
+       rgba_char_args_set(btheme->tv3d.vertex_select, 255, 133, 0, 255);
        btheme->tv3d.vertex_size= 3;
        btheme->tv3d.outline_width= 1;
-       SETCOL(btheme->tv3d.edge,       0x0, 0x0, 0x0, 255);
-       SETCOL(btheme->tv3d.edge_select, 255, 160, 0, 255);
-       SETCOL(btheme->tv3d.edge_seam, 219, 37, 18, 255);
-       SETCOL(btheme->tv3d.edge_facesel, 75, 75, 75, 255);
-       SETCOL(btheme->tv3d.face,       0, 0, 0, 18);
-       SETCOL(btheme->tv3d.face_select, 255, 133, 0, 60);
-       SETCOL(btheme->tv3d.normal, 0x22, 0xDD, 0xDD, 255);
-       SETCOL(btheme->tv3d.vertex_normal, 0x23, 0x61, 0xDD, 255);
-       SETCOL(btheme->tv3d.face_dot, 255, 133, 0, 255);
-       SETCOL(btheme->tv3d.editmesh_active, 255, 255, 255, 128);
-       SETCOLF(btheme->tv3d.edge_crease, 0.8, 0, 0.6, 1.0);
-       SETCOL(btheme->tv3d.edge_sharp, 0, 255, 255, 255);
-       SETCOL(btheme->tv3d.header_text, 0, 0, 0, 255);
-       SETCOL(btheme->tv3d.header_text_hi, 255, 255, 255, 255);
-       SETCOL(btheme->tv3d.button_text, 0, 0, 0, 255);
-       SETCOL(btheme->tv3d.button_text_hi, 255, 255, 255, 255);
-       SETCOL(btheme->tv3d.button_title, 0, 0, 0, 255);
-       SETCOL(btheme->tv3d.title, 0, 0, 0, 255);
-       SETCOL(btheme->tv3d.freestyle_edge_mark, 0x7f, 0xff, 0x7f, 255);
-       SETCOL(btheme->tv3d.freestyle_face_mark, 0x7f, 0xff, 0x7f, 51);
+       rgba_char_args_set(btheme->tv3d.edge,       0x0, 0x0, 0x0, 255);
+       rgba_char_args_set(btheme->tv3d.edge_select, 255, 160, 0, 255);
+       rgba_char_args_set(btheme->tv3d.edge_seam, 219, 37, 18, 255);
+       rgba_char_args_set(btheme->tv3d.edge_facesel, 75, 75, 75, 255);
+       rgba_char_args_set(btheme->tv3d.face,       0, 0, 0, 18);
+       rgba_char_args_set(btheme->tv3d.face_select, 255, 133, 0, 60);
+       rgba_char_args_set(btheme->tv3d.normal, 0x22, 0xDD, 0xDD, 255);
+       rgba_char_args_set(btheme->tv3d.vertex_normal, 0x23, 0x61, 0xDD, 255);
+       rgba_char_args_set(btheme->tv3d.face_dot, 255, 133, 0, 255);
+       rgba_char_args_set(btheme->tv3d.editmesh_active, 255, 255, 255, 128);
+       rgba_char_args_set_fl(btheme->tv3d.edge_crease, 0.8, 0, 0.6, 1.0);
+       rgba_char_args_set(btheme->tv3d.edge_sharp, 0, 255, 255, 255);
+       rgba_char_args_set(btheme->tv3d.header_text, 0, 0, 0, 255);
+       rgba_char_args_set(btheme->tv3d.header_text_hi, 255, 255, 255, 255);
+       rgba_char_args_set(btheme->tv3d.button_text, 0, 0, 0, 255);
+       rgba_char_args_set(btheme->tv3d.button_text_hi, 255, 255, 255, 255);
+       rgba_char_args_set(btheme->tv3d.button_title, 0, 0, 0, 255);
+       rgba_char_args_set(btheme->tv3d.title, 0, 0, 0, 255);
++      rgba_char_args_set(btheme->tv3d.freestyle_edge_mark, 0x7f, 0xff, 0x7f, 255);
++      rgba_char_args_set(btheme->tv3d.freestyle_face_mark, 0x7f, 0xff, 0x7f, 51);
  
        btheme->tv3d.facedot_size= 4;
  
@@@ -1742,19 -1747,26 +1753,39 @@@ void init_userdef_do_versions(void
                U.use_16bit_textures = 1;
        }
  
-                               SETCOL(btheme->tv3d.freestyle_edge_mark, 0x7f, 0xff, 0x7f, 255);
-                               SETCOL(btheme->tv3d.freestyle_face_mark, 0x7f, 0xff, 0x7f, 51);
+       if (bmain->versionfile < 262 || (bmain->versionfile == 262 && bmain->subversionfile < 2)) {
+               bTheme *btheme;
+               for (btheme= U.themes.first; btheme; btheme= btheme->next) {
+                       if (btheme->tui.wcol_menu_item.item[3] == 255)
+                               rgba_char_args_set(btheme->tui.wcol_menu_item.item, 172, 172, 172, 128);
+               }
+       }
+       if (bmain->versionfile < 262 || (bmain->versionfile == 262 && bmain->subversionfile < 3)) {
+               bTheme *btheme;
+               for (btheme= U.themes.first; btheme; btheme= btheme->next) {
+                       if (btheme->tui.wcol_tooltip.inner[3] == 0) {
+                               btheme->tui.wcol_tooltip = btheme->tui.wcol_menu_back;
+                       }
+                       if (btheme->tui.wcol_tooltip.text[0] == 160) { /* hrmf */
+                               rgba_char_args_set(btheme->tui.wcol_tooltip.text, 255, 255, 255, 255);
+                       }
+               }
+       }
 +      /* Freestyle color settings */
 +      {
 +              bTheme *btheme;
 +
 +              for(btheme= U.themes.first; btheme; btheme= btheme->next) {
 +                      /* check for alpha==0 is safe, then color was never set */
 +                      if(btheme->tv3d.freestyle_edge_mark[3]==0) {
++                              rgba_char_args_set(btheme->tv3d.freestyle_edge_mark, 0x7f, 0xff, 0x7f, 255);
++                              rgba_char_args_set(btheme->tv3d.freestyle_face_mark, 0x7f, 0xff, 0x7f, 51);
 +                      }
 +              }
 +      }
 +
        /* GL Texture Garbage Collection (variable abused above!) */
        if (U.textimeout == 0) {
                U.texcollectrate = 60;
@@@ -4571,105 -4476,65 +4476,169 @@@ void MESH_OT_bridge_edge_loops(wmOperat
        RNA_def_boolean(ot->srna, "inside", 0, "Inside", "");
  }
  
- static int mark_freestyle_edge(bContext *C, wmOperator *op)
+ static int edbm_inset_exec(bContext *C, wmOperator *op)
+ {
+       Object *obedit = CTX_data_edit_object(C);
+       BMEditMesh *em = BMEdit_FromObject(obedit);
+       BMOperator bmop;
+       const int use_boundary        = FALSE; //RNA_boolean_get(op->ptr, "use_boundary");
+       const int use_even_offset     = RNA_boolean_get(op->ptr, "use_even_offset");
+       const int use_relative_offset = RNA_boolean_get(op->ptr, "use_relative_offset");
+       const float thickness         = RNA_float_get(op->ptr, "thickness");
+       const int use_outset          = RNA_boolean_get(op->ptr, "use_outset");
+       EDBM_InitOpf(em, &bmop, op,
+                    "inset faces=%hf use_boundary=%b use_even_offset=%b use_relative_offset=%b thickness=%f use_outset=%b",
+                    BM_ELEM_SELECT, use_boundary, use_even_offset, use_relative_offset, thickness, use_outset);
+       BMO_op_exec(em->bm, &bmop);
+       /* deselect original verts */
+       EDBM_flag_disable_all(em, BM_ELEM_SELECT);
+       BMO_slot_buffer_hflag_enable(em->bm, &bmop, "faceout", BM_FACE, BM_ELEM_SELECT, TRUE);
+       if (!EDBM_FinishOp(em, &bmop, op, TRUE)) {
+               return OPERATOR_CANCELLED;
+       }
+       else {
+               DAG_id_tag_update(obedit->data, 0);
+               WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data);
+               return OPERATOR_FINISHED;
+       }
+ }
+ void MESH_OT_inset(wmOperatorType *ot)
+ {
+       PropertyRNA *prop;
+       /* identifiers */
+       ot->name = "Inset Faces";
+       ot->idname = "MESH_OT_inset";
+       /* api callbacks */
+       ot->exec = edbm_inset_exec;
+       ot->poll = ED_operator_editmesh;
+       ot->description = "";
+       /* flags */
+       ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+       /* properties */
+       // RNA_def_boolean(ot->srna, "use_boundary",        TRUE, "Boundary",  "Inset face boundries");
+       RNA_def_boolean(ot->srna, "use_even_offset",     TRUE, "Offset Even",      "Scale the offset to give more even thickness");
+       RNA_def_boolean(ot->srna, "use_relative_offset", FALSE, "Offset Relative", "Scale the offset by surrounding geometry");
+       prop = RNA_def_float(ot->srna, "thickness", 0.01f, 0.0f, FLT_MAX, "thickness", "", 0.0f, 10.0f);
+       /* use 1 rather then 10 for max else dragging the button moves too far */
+       RNA_def_property_ui_range(prop, 0.0, 1.0, 0.01, 4);
+       RNA_def_boolean(ot->srna, "use_outset", FALSE, "Outset",  "outset rather then inset");
+ }
++
++static int edbm_mark_freestyle_edge(bContext *C, wmOperator *op)
 +{
 +      Object *obedit = CTX_data_edit_object(C);
 +      Mesh *me = ((Mesh *)obedit->data);
 +      BMEditMesh *em = ((Mesh *)obedit->data)->edit_btmesh;
 +      BMEdge *eed;
 +      BMIter iter;
 +      int clear = RNA_boolean_get(op->ptr, "clear");
 +
 +      if (em == NULL) return OPERATOR_FINISHED;
 +
 +      /* auto-enable seams drawing */
 +      if (clear == 0) {
 +              me->drawflag |= ME_DRAW_FREESTYLE_EDGE;
 +      }
 +
 +      if (clear) {
 +              BM_ITER(eed, &iter, em->bm, BM_EDGES_OF_MESH, NULL) {
 +                      if (BM_elem_flag_test(eed, BM_ELEM_SELECT) && !BM_elem_flag_test(eed, BM_ELEM_HIDDEN))
 +                              BM_elem_flag_disable(eed, BM_ELEM_FREESTYLE);
 +              }
 +      }
 +      else {
 +              BM_ITER(eed, &iter, em->bm, BM_EDGES_OF_MESH, NULL) {
 +                      if (BM_elem_flag_test(eed, BM_ELEM_SELECT) && !BM_elem_flag_test(eed, BM_ELEM_HIDDEN))
 +                              BM_elem_flag_enable(eed, BM_ELEM_FREESTYLE);
 +              }
 +      }
 +
 +      DAG_id_tag_update(obedit->data, OB_RECALC_DATA);
 +      WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data);
 +
 +      return OPERATOR_FINISHED;
 +}
 +
 +void MESH_OT_mark_freestyle_edge(wmOperatorType *ot)
 +{
 +      /* identifiers */
-       ot->name= "Mark Freestyle Edge";
-       ot->description= "(un)mark selected edges as Freestyle feature edges";
-       ot->idname= "MESH_OT_mark_freestyle_edge";
++      ot->name = "Mark Freestyle Edge";
++      ot->description = "(un)mark selected edges as Freestyle feature edges";
++      ot->idname = "MESH_OT_mark_freestyle_edge";
 +
 +      /* api callbacks */
-       ot->exec= mark_freestyle_edge;
-       ot->poll= ED_operator_editmesh;
++      ot->exec = edbm_mark_freestyle_edge;
++      ot->poll = ED_operator_editmesh;
 +
 +      /* flags */
-       ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
++      ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
 +
 +      RNA_def_boolean(ot->srna, "clear", 0, "Clear", "");
 +}
 +
- static int mark_freestyle_face_exec(bContext *C, wmOperator *op)
++static int edbm_mark_freestyle_face_exec(bContext *C, wmOperator *op)
 +{
 +      Object *obedit = CTX_data_edit_object(C);
 +      Mesh *me = ((Mesh *)obedit->data);
 +      BMEditMesh *em = ((Mesh *)obedit->data)->edit_btmesh;
 +      BMFace *efa;
 +      BMIter iter;
 +      int clear = RNA_boolean_get(op->ptr, "clear");
 +
 +      if (em == NULL) return OPERATOR_FINISHED;
 +
 +      /* auto-enable Freestyle face mark drawing */
 +      if(!clear) {
 +              me->drawflag |= ME_DRAW_FREESTYLE_FACE;
 +      }
 +
 +      if(clear) {
 +              BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) {
 +                      if (BM_elem_flag_test(efa, BM_ELEM_SELECT) && !BM_elem_flag_test(efa, BM_ELEM_HIDDEN))
 +                              BM_elem_flag_disable(efa, BM_ELEM_FREESTYLE);
 +              }
 +      } else {
 +              BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) {
 +                      if (BM_elem_flag_test(efa, BM_ELEM_SELECT) && !BM_elem_flag_test(efa, BM_ELEM_HIDDEN))
 +                              BM_elem_flag_enable(efa, BM_ELEM_FREESTYLE);
 +              }
 +      }
 +
 +      DAG_id_tag_update(obedit->data, OB_RECALC_DATA);
 +      WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data);
 +
 +      return OPERATOR_FINISHED;
 +}
 +
 +void MESH_OT_mark_freestyle_face(wmOperatorType *ot)
 +{
 +      /* identifiers */
-       ot->name= "Mark Freestyle Face";
-       ot->description= "(un)mark selected faces for exclusion from Freestyle feature edge detection";
-       ot->idname= "MESH_OT_mark_freestyle_face";
++      ot->name = "Mark Freestyle Face";
++      ot->description = "(un)mark selected faces for exclusion from Freestyle feature edge detection";
++      ot->idname = "MESH_OT_mark_freestyle_face";
 +
 +      /* api callbacks */
-       ot->exec= mark_freestyle_face_exec;
-       ot->poll= ED_operator_editmesh;
++      ot->exec = edbm_mark_freestyle_face_exec;
++      ot->poll = ED_operator_editmesh;
 +
 +      /* flags */
-       ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
++      ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
 +
 +      RNA_def_boolean(ot->srna, "clear", 0, "Clear", "");
 +}
++
@@@ -118,9 -119,10 +119,11 @@@ void ED_operatortypes_mesh(void
        WM_operatortype_append(MESH_OT_faces_shade_smooth);
        WM_operatortype_append(MESH_OT_faces_shade_flat);
        WM_operatortype_append(MESH_OT_sort_faces);
 +      WM_operatortype_append(MESH_OT_mark_freestyle_face);
  
        WM_operatortype_append(MESH_OT_delete);
+       WM_operatortype_append(MESH_OT_edge_collapse);
+       WM_operatortype_append(MESH_OT_edge_collapse_loop);
  
        WM_operatortype_append(MESH_OT_separate);
        WM_operatortype_append(MESH_OT_dupli_extrude_cursor);
@@@ -562,577 -558,17 +562,577 @@@ static int render_layer_remove_exec(bCo
  void SCENE_OT_render_layer_remove(wmOperatorType *ot)
  {
        /* identifiers */
-       ot->name= "Remove Render Layer";
-       ot->idname= "SCENE_OT_render_layer_remove";
-       ot->description="Remove the selected render layer";
+       ot->name = "Remove Render Layer";
+       ot->idname = "SCENE_OT_render_layer_remove";
+       ot->description = "Remove the selected render layer";
        
        /* api callbacks */
-       ot->exec= render_layer_remove_exec;
+       ot->exec = render_layer_remove_exec;
  
        /* flags */
-       ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+       ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
  }
  
 +static int freestyle_module_add_exec(bContext *C, wmOperator *UNUSED(op))
 +{
 +      Scene *scene= CTX_data_scene(C);
 +      SceneRenderLayer *srl = (SceneRenderLayer*) BLI_findlink(&scene->r.layers, scene->r.actlay);
 +
 +      FRS_add_module(&srl->freestyleConfig);
 +
 +      WM_event_add_notifier(C, NC_SCENE|ND_RENDER_OPTIONS, scene);
 +      
 +      return OPERATOR_FINISHED;
 +}
 +
 +void SCENE_OT_freestyle_module_add(wmOperatorType *ot)
 +{
 +      /* identifiers */
 +      ot->name= "Add Freestyle Module";
 +      ot->idname= "SCENE_OT_freestyle_module_add";
 +      ot->description="Add a style module into the list of modules";
 +      
 +      /* api callbacks */
 +      ot->exec= freestyle_module_add_exec;
 +
 +      /* flags */
 +      ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
 +}
 +
 +static int freestyle_module_remove_exec(bContext *C, wmOperator *UNUSED(op))
 +{
 +      Scene *scene= CTX_data_scene(C);
 +      SceneRenderLayer *srl = (SceneRenderLayer*) BLI_findlink(&scene->r.layers, scene->r.actlay);
 +      PointerRNA ptr= CTX_data_pointer_get_type(C, "freestyle_module", &RNA_FreestyleModuleSettings);
 +      FreestyleModuleConfig *module= ptr.data;
 +
 +      FRS_delete_module(&srl->freestyleConfig, module);
 +
 +      WM_event_add_notifier(C, NC_SCENE|ND_RENDER_OPTIONS, scene);
 +      
 +      return OPERATOR_FINISHED;
 +}
 +
 +void SCENE_OT_freestyle_module_remove(wmOperatorType *ot)
 +{
 +      /* identifiers */
 +      ot->name= "Remove Freestyle Module";
 +      ot->idname= "SCENE_OT_freestyle_module_remove";
 +      ot->description="Remove the style module from the stack";
 +      
 +      /* api callbacks */
 +      ot->exec= freestyle_module_remove_exec;
 +
 +      /* flags */
 +      ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
 +}
 +
 +static int freestyle_module_move_exec(bContext *C, wmOperator *op)
 +{
 +      Scene *scene= CTX_data_scene(C);
 +      SceneRenderLayer *srl = (SceneRenderLayer*) BLI_findlink(&scene->r.layers, scene->r.actlay);
 +      PointerRNA ptr= CTX_data_pointer_get_type(C, "freestyle_module", &RNA_FreestyleModuleSettings);
 +      FreestyleModuleConfig *module= ptr.data;
 +      int dir= RNA_enum_get(op->ptr, "direction");
 +
 +      if (dir == 1) {
 +              FRS_move_module_up(&srl->freestyleConfig, module);
 +      } else {
 +              FRS_move_module_down(&srl->freestyleConfig, module);
 +      }
 +      WM_event_add_notifier(C, NC_SCENE|ND_RENDER_OPTIONS, scene);
 +      
 +      return OPERATOR_FINISHED;
 +}
 +
 +void SCENE_OT_freestyle_module_move(wmOperatorType *ot)
 +{
 +      static EnumPropertyItem direction_items[] = {
 +              {1, "UP", 0, "Up", ""},
 +              {-1, "DOWN", 0, "Down", ""},
 +              {0, NULL, 0, NULL, NULL}
 +      };
 +
 +      /* identifiers */
 +      ot->name= "Move Freestyle Module";
 +      ot->idname= "SCENE_OT_freestyle_module_move";
 +      ot->description="Change the position of the style module within in the list of style modules";
 +      
 +      /* api callbacks */
 +      ot->exec= freestyle_module_move_exec;
 +
 +      /* flags */
 +      ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
 +
 +      /* props */
 +      RNA_def_enum(ot->srna, "direction", direction_items, 0, "Direction", "Direction to move, UP or DOWN");
 +}
 +
 +static int freestyle_lineset_add_exec(bContext *C, wmOperator *UNUSED(op))
 +{
 +      Scene *scene= CTX_data_scene(C);
 +      SceneRenderLayer *srl = (SceneRenderLayer*) BLI_findlink(&scene->r.layers, scene->r.actlay);
 +
 +      FRS_add_lineset(&srl->freestyleConfig);
 +
 +      WM_event_add_notifier(C, NC_SCENE|ND_RENDER_OPTIONS, scene);
 +      
 +      return OPERATOR_FINISHED;
 +}
 +
 +void SCENE_OT_freestyle_lineset_add(wmOperatorType *ot)
 +{
 +      /* identifiers */
 +      ot->name= "Add Line Set";
 +      ot->idname= "SCENE_OT_freestyle_lineset_add";
 +      ot->description="Add a line set into the list of line sets";
 +      
 +      /* api callbacks */
 +      ot->exec= freestyle_lineset_add_exec;
 +
 +      /* flags */
 +      ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
 +}
 +
 +static int freestyle_active_lineset_poll(bContext *C)
 +{
 +      Scene *scene= CTX_data_scene(C);
 +      SceneRenderLayer *srl = (SceneRenderLayer*) BLI_findlink(&scene->r.layers, scene->r.actlay);
 +
 +      return FRS_get_active_lineset(&srl->freestyleConfig) != NULL;
 +}
 +
 +static int freestyle_lineset_copy_exec(bContext *C, wmOperator *op)
 +{
 +      Scene *scene= CTX_data_scene(C);
 +      SceneRenderLayer *srl = (SceneRenderLayer*) BLI_findlink(&scene->r.layers, scene->r.actlay);
 +
 +      FRS_copy_active_lineset(&srl->freestyleConfig);
 +
 +      WM_event_add_notifier(C, NC_SCENE|ND_RENDER_OPTIONS, scene);
 +      
 +      return OPERATOR_FINISHED;
 +}
 +
 +void SCENE_OT_freestyle_lineset_copy(wmOperatorType *ot)
 +{
 +      /* identifiers */
 +      ot->name= "Copy Line Set";
 +      ot->idname= "SCENE_OT_freestyle_lineset_copy";
 +      ot->description="Copy the active line set to a buffer";
 +      
 +      /* api callbacks */
 +      ot->exec= freestyle_lineset_copy_exec;
 +      ot->poll= freestyle_active_lineset_poll;
 +
 +      /* flags */
 +      ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
 +}
 +
 +static int freestyle_lineset_paste_exec(bContext *C, wmOperator *op)
 +{
 +      Scene *scene= CTX_data_scene(C);
 +      SceneRenderLayer *srl = (SceneRenderLayer*) BLI_findlink(&scene->r.layers, scene->r.actlay);
 +
 +      FRS_paste_active_lineset(&srl->freestyleConfig);
 +
 +      WM_event_add_notifier(C, NC_SCENE|ND_RENDER_OPTIONS, scene);
 +      
 +      return OPERATOR_FINISHED;
 +}
 +
 +void SCENE_OT_freestyle_lineset_paste(wmOperatorType *ot)
 +{
 +      /* identifiers */
 +      ot->name= "Paste Line Set";
 +      ot->idname= "SCENE_OT_freestyle_lineset_paste";
 +      ot->description="Paste the buffer content to the active line set";
 +      
 +      /* api callbacks */
 +      ot->exec= freestyle_lineset_paste_exec;
 +      ot->poll= freestyle_active_lineset_poll;
 +
 +      /* flags */
 +      ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
 +}
 +
 +static int freestyle_lineset_remove_exec(bContext *C, wmOperator *UNUSED(op))
 +{
 +      Scene *scene= CTX_data_scene(C);
 +      SceneRenderLayer *srl = (SceneRenderLayer*) BLI_findlink(&scene->r.layers, scene->r.actlay);
 +
 +      FRS_delete_active_lineset(&srl->freestyleConfig);
 +
 +      WM_event_add_notifier(C, NC_SCENE|ND_RENDER_OPTIONS, scene);
 +      
 +      return OPERATOR_FINISHED;
 +}
 +
 +void SCENE_OT_freestyle_lineset_remove(wmOperatorType *ot)
 +{
 +      /* identifiers */
 +      ot->name= "Remove Line Set";
 +      ot->idname= "SCENE_OT_freestyle_lineset_remove";
 +      ot->description="Remove the active line set from the list of line sets";
 +      
 +      /* api callbacks */
 +      ot->exec= freestyle_lineset_remove_exec;
 +      ot->poll= freestyle_active_lineset_poll;
 +
 +      /* flags */
 +      ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
 +}
 +
 +static int freestyle_lineset_move_exec(bContext *C, wmOperator *op)
 +{
 +      Scene *scene= CTX_data_scene(C);
 +      SceneRenderLayer *srl = (SceneRenderLayer*) BLI_findlink(&scene->r.layers, scene->r.actlay);
 +      int dir= RNA_enum_get(op->ptr, "direction");
 +
 +      if (dir == 1) {
 +              FRS_move_active_lineset_up(&srl->freestyleConfig);
 +      } else {
 +              FRS_move_active_lineset_down(&srl->freestyleConfig);
 +      }
 +      WM_event_add_notifier(C, NC_SCENE|ND_RENDER_OPTIONS, scene);
 +      
 +      return OPERATOR_FINISHED;
 +}
 +
 +void SCENE_OT_freestyle_lineset_move(wmOperatorType *ot)
 +{
 +      static EnumPropertyItem direction_items[] = {
 +              {1, "UP", 0, "Up", ""},
 +              {-1, "DOWN", 0, "Down", ""},
 +              {0, NULL, 0, NULL, NULL}
 +      };
 +
 +      /* identifiers */
 +      ot->name= "Move Line Set";
 +      ot->idname= "SCENE_OT_freestyle_lineset_move";
 +      ot->description="Change the position of the active line set within the list of line sets";
 +      
 +      /* api callbacks */
 +      ot->exec= freestyle_lineset_move_exec;
 +      ot->poll= freestyle_active_lineset_poll;
 +
 +      /* flags */
 +      ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
 +
 +      /* props */
 +      RNA_def_enum(ot->srna, "direction", direction_items, 0, "Direction", "Direction to move, UP or DOWN");
 +}
 +
 +static int freestyle_linestyle_new_exec(bContext *C, wmOperator *op)
 +{
 +      Scene *scene= CTX_data_scene(C);
 +      SceneRenderLayer *srl = (SceneRenderLayer*) BLI_findlink(&scene->r.layers, scene->r.actlay);
 +      FreestyleLineSet *lineset = FRS_get_active_lineset(&srl->freestyleConfig);
 +
 +      if (!lineset) {
 +              BKE_report(op->reports, RPT_ERROR, "No active lineset to add a new line style to.");
 +              return OPERATOR_CANCELLED;
 +      }
 +      lineset->linestyle->id.us--;
 +      lineset->linestyle = FRS_copy_linestyle(lineset->linestyle);
 +
 +      WM_event_add_notifier(C, NC_SCENE|ND_RENDER_OPTIONS, scene);
 +      
 +      return OPERATOR_FINISHED;
 +}
 +
 +void SCENE_OT_freestyle_linestyle_new(wmOperatorType *ot)
 +{
 +      /* identifiers */
 +      ot->name= "New Line Style";
 +      ot->idname= "SCENE_OT_freestyle_linestyle_new";
 +      ot->description="Create a new line style, reusable by multiple line sets";
 +      
 +      /* api callbacks */
 +      ot->exec= freestyle_linestyle_new_exec;
 +      ot->poll= freestyle_active_lineset_poll;
 +
 +      /* flags */
 +      ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
 +}
 +
 +static int freestyle_color_modifier_add_exec(bContext *C, wmOperator *op)
 +{
 +      Scene *scene= CTX_data_scene(C);
 +      SceneRenderLayer *srl = (SceneRenderLayer*) BLI_findlink(&scene->r.layers, scene->r.actlay);
 +      FreestyleLineSet *lineset = FRS_get_active_lineset(&srl->freestyleConfig);
 +      int type= RNA_enum_get(op->ptr, "type");
 +
 +      if (!lineset) {
 +              BKE_report(op->reports, RPT_ERROR, "No active lineset and associated line style to add the modifier to.");
 +              return OPERATOR_CANCELLED;
 +      }
 +      if (FRS_add_linestyle_color_modifier(lineset->linestyle, type) < 0) {
 +              BKE_report(op->reports, RPT_ERROR, "Unknown line color modifier type.");
 +              return OPERATOR_CANCELLED;
 +      }
 +      WM_event_add_notifier(C, NC_SCENE|ND_RENDER_OPTIONS, scene);
 +      
 +      return OPERATOR_FINISHED;
 +}
 +
 +void SCENE_OT_freestyle_color_modifier_add(wmOperatorType *ot)
 +{
 +      /* identifiers */
 +      ot->name= "Add Line Color Modifier";
 +      ot->idname= "SCENE_OT_freestyle_color_modifier_add";
 +      ot->description = "Add a line color modifier to the line style associated with the active lineset";
 +      
 +      /* api callbacks */
 +      ot->invoke= WM_menu_invoke;
 +      ot->exec= freestyle_color_modifier_add_exec;
 +      ot->poll= freestyle_active_lineset_poll;
 +      
 +      /* flags */
 +      ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
 +      
 +      /* properties */
 +      ot->prop= RNA_def_enum(ot->srna, "type", linestyle_color_modifier_type_items, 0, "Type", "");
 +}
 +
 +static int freestyle_alpha_modifier_add_exec(bContext *C, wmOperator *op)
 +{
 +      Scene *scene= CTX_data_scene(C);
 +      SceneRenderLayer *srl = (SceneRenderLayer*) BLI_findlink(&scene->r.layers, scene->r.actlay);
 +      FreestyleLineSet *lineset = FRS_get_active_lineset(&srl->freestyleConfig);
 +      int type= RNA_enum_get(op->ptr, "type");
 +
 +      if (!lineset) {
 +              BKE_report(op->reports, RPT_ERROR, "No active lineset and associated line style to add the modifier to.");
 +              return OPERATOR_CANCELLED;
 +      }
 +      if (FRS_add_linestyle_alpha_modifier(lineset->linestyle, type) < 0) {
 +              BKE_report(op->reports, RPT_ERROR, "Unknown alpha transparency modifier type.");
 +              return OPERATOR_CANCELLED;
 +      }
 +      WM_event_add_notifier(C, NC_SCENE|ND_RENDER_OPTIONS, scene);
 +      
 +      return OPERATOR_FINISHED;
 +}
 +
 +void SCENE_OT_freestyle_alpha_modifier_add(wmOperatorType *ot)
 +{
 +      /* identifiers */
 +      ot->name= "Add Alpha Transparency Modifier";
 +      ot->idname= "SCENE_OT_freestyle_alpha_modifier_add";
 +      ot->description = "Add an alpha transparency modifier to the line style associated with the active lineset";
 +      
 +      /* api callbacks */
 +      ot->invoke= WM_menu_invoke;
 +      ot->exec= freestyle_alpha_modifier_add_exec;
 +      ot->poll= freestyle_active_lineset_poll;
 +      
 +      /* flags */
 +      ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
 +      
 +      /* properties */
 +      ot->prop= RNA_def_enum(ot->srna, "type", linestyle_alpha_modifier_type_items, 0, "Type", "");
 +}
 +
 +static int freestyle_thickness_modifier_add_exec(bContext *C, wmOperator *op)
 +{
 +      Scene *scene= CTX_data_scene(C);
 +      SceneRenderLayer *srl = (SceneRenderLayer*) BLI_findlink(&scene->r.layers, scene->r.actlay);
 +      FreestyleLineSet *lineset = FRS_get_active_lineset(&srl->freestyleConfig);
 +      int type= RNA_enum_get(op->ptr, "type");
 +
 +      if (!lineset) {
 +              BKE_report(op->reports, RPT_ERROR, "No active lineset and associated line style to add the modifier to.");
 +              return OPERATOR_CANCELLED;
 +      }
 +      if (FRS_add_linestyle_thickness_modifier(lineset->linestyle, type) < 0) {
 +              BKE_report(op->reports, RPT_ERROR, "Unknown line thickness modifier type.");
 +              return OPERATOR_CANCELLED;
 +      }
 +      WM_event_add_notifier(C, NC_SCENE|ND_RENDER_OPTIONS, scene);
 +      
 +      return OPERATOR_FINISHED;
 +}
 +
 +void SCENE_OT_freestyle_thickness_modifier_add(wmOperatorType *ot)
 +{
 +      /* identifiers */
 +      ot->name= "Add Line Thickness Modifier";
 +      ot->idname= "SCENE_OT_freestyle_thickness_modifier_add";
 +      ot->description = "Add a line thickness modifier to the line style associated with the active lineset";
 +      
 +      /* api callbacks */
 +      ot->invoke= WM_menu_invoke;
 +      ot->exec= freestyle_thickness_modifier_add_exec;
 +      ot->poll= freestyle_active_lineset_poll;
 +      
 +      /* flags */
 +      ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
 +      
 +      /* properties */
 +      ot->prop= RNA_def_enum(ot->srna, "type", linestyle_thickness_modifier_type_items, 0, "Type", "");
 +}
 +
 +static int freestyle_geometry_modifier_add_exec(bContext *C, wmOperator *op)
 +{
 +      Scene *scene= CTX_data_scene(C);
 +      SceneRenderLayer *srl = (SceneRenderLayer*) BLI_findlink(&scene->r.layers, scene->r.actlay);
 +      FreestyleLineSet *lineset = FRS_get_active_lineset(&srl->freestyleConfig);
 +      int type= RNA_enum_get(op->ptr, "type");
 +
 +      if (!lineset) {
 +              BKE_report(op->reports, RPT_ERROR, "No active lineset and associated line style to add the modifier to.");
 +              return OPERATOR_CANCELLED;
 +      }
 +      if (FRS_add_linestyle_geometry_modifier(lineset->linestyle, type) < 0) {
 +              BKE_report(op->reports, RPT_ERROR, "Unknown stroke geometry modifier type.");
 +              return OPERATOR_CANCELLED;
 +      }
 +      WM_event_add_notifier(C, NC_SCENE|ND_RENDER_OPTIONS, scene);
 +      
 +      return OPERATOR_FINISHED;
 +}
 +
 +void SCENE_OT_freestyle_geometry_modifier_add(wmOperatorType *ot)
 +{
 +      /* identifiers */
 +      ot->name= "Add Stroke Geometry Modifier";
 +      ot->idname= "SCENE_OT_freestyle_geometry_modifier_add";
 +      ot->description = "Add a stroke geometry modifier to the line style associated with the active lineset";
 +      
 +      /* api callbacks */
 +      ot->invoke= WM_menu_invoke;
 +      ot->exec= freestyle_geometry_modifier_add_exec;
 +      ot->poll= freestyle_active_lineset_poll;
 +      
 +      /* flags */
 +      ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
 +      
 +      /* properties */
 +      ot->prop= RNA_def_enum(ot->srna, "type", linestyle_geometry_modifier_type_items, 0, "Type", "");
 +}
 +
 +static int freestyle_get_modifier_type(PointerRNA *ptr)
 +{
 +      if (RNA_struct_is_a(ptr->type, &RNA_LineStyleColorModifier))
 +              return LS_MODIFIER_TYPE_COLOR;
 +      else if (RNA_struct_is_a(ptr->type, &RNA_LineStyleAlphaModifier))
 +              return LS_MODIFIER_TYPE_ALPHA;
 +      else if (RNA_struct_is_a(ptr->type, &RNA_LineStyleThicknessModifier))
 +              return LS_MODIFIER_TYPE_THICKNESS;
 +      else if (RNA_struct_is_a(ptr->type, &RNA_LineStyleGeometryModifier))
 +              return LS_MODIFIER_TYPE_GEOMETRY;
 +      return -1;
 +}
 +
 +static int freestyle_modifier_remove_exec(bContext *C, wmOperator *op)
 +{
 +      Scene *scene= CTX_data_scene(C);
 +      SceneRenderLayer *srl = (SceneRenderLayer*) BLI_findlink(&scene->r.layers, scene->r.actlay);
 +      FreestyleLineSet *lineset = FRS_get_active_lineset(&srl->freestyleConfig);
 +      PointerRNA ptr= CTX_data_pointer_get_type(C, "modifier", &RNA_LineStyleModifier);
 +      LineStyleModifier *modifier= ptr.data;
 +
 +      if (!lineset) {
 +              BKE_report(op->reports, RPT_ERROR, "No active lineset and associated line style the modifier belongs to.");
 +              return OPERATOR_CANCELLED;
 +      }
 +      switch (freestyle_get_modifier_type(&ptr)) {
 +      case LS_MODIFIER_TYPE_COLOR:
 +              FRS_remove_linestyle_color_modifier(lineset->linestyle, modifier);
 +              break;
 +      case LS_MODIFIER_TYPE_ALPHA:
 +              FRS_remove_linestyle_alpha_modifier(lineset->linestyle, modifier);
 +              break;
 +      case LS_MODIFIER_TYPE_THICKNESS:
 +              FRS_remove_linestyle_thickness_modifier(lineset->linestyle, modifier);
 +              break;
 +      case LS_MODIFIER_TYPE_GEOMETRY:
 +              FRS_remove_linestyle_geometry_modifier(lineset->linestyle, modifier);
 +              break;
 +      default:
 +              BKE_report(op->reports, RPT_ERROR, "The object the data pointer refers to is not a valid modifier.");
 +              return OPERATOR_CANCELLED;
 +      }
 +      WM_event_add_notifier(C, NC_SCENE|ND_RENDER_OPTIONS, scene);
 +      
 +      return OPERATOR_FINISHED;
 +}
 +
 +void SCENE_OT_freestyle_modifier_remove(wmOperatorType *ot)
 +{
 +      /* identifiers */
 +      ot->name= "Remove Modifier";
 +      ot->idname= "SCENE_OT_freestyle_modifier_remove";
 +      ot->description="Remove the modifier from the list of modifiers";
 +      
 +      /* api callbacks */
 +      ot->exec= freestyle_modifier_remove_exec;
 +      ot->poll= freestyle_active_lineset_poll;
 +
 +      /* flags */
 +      ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
 +}
 +
 +static int freestyle_modifier_move_exec(bContext *C, wmOperator *op)
 +{
 +      Scene *scene= CTX_data_scene(C);
 +      SceneRenderLayer *srl = (SceneRenderLayer*) BLI_findlink(&scene->r.layers, scene->r.actlay);
 +      FreestyleLineSet *lineset = FRS_get_active_lineset(&srl->freestyleConfig);
 +      PointerRNA ptr= CTX_data_pointer_get_type(C, "modifier", &RNA_LineStyleModifier);
 +      LineStyleModifier *modifier= ptr.data;
 +      int dir= RNA_enum_get(op->ptr, "direction");
 +
 +      if (!lineset) {
 +              BKE_report(op->reports, RPT_ERROR, "No active lineset and associated line style the modifier belongs to.");
 +              return OPERATOR_CANCELLED;
 +      }
 +      switch (freestyle_get_modifier_type(&ptr)) {
 +      case LS_MODIFIER_TYPE_COLOR:
 +              FRS_move_linestyle_color_modifier(lineset->linestyle, modifier, dir);
 +              break;
 +      case LS_MODIFIER_TYPE_ALPHA:
 +              FRS_move_linestyle_alpha_modifier(lineset->linestyle, modifier, dir);
 +              break;
 +      case LS_MODIFIER_TYPE_THICKNESS:
 +              FRS_move_linestyle_thickness_modifier(lineset->linestyle, modifier, dir);
 +              break;
 +      case LS_MODIFIER_TYPE_GEOMETRY:
 +              FRS_move_linestyle_geometry_modifier(lineset->linestyle, modifier, dir);
 +              break;
 +      default:
 +              BKE_report(op->reports, RPT_ERROR, "The object the data pointer refers to is not a valid modifier.");
 +              return OPERATOR_CANCELLED;
 +      }
 +      WM_event_add_notifier(C, NC_SCENE|ND_RENDER_OPTIONS, scene);
 +      
 +      return OPERATOR_FINISHED;
 +}
 +
 +void SCENE_OT_freestyle_modifier_move(wmOperatorType *ot)
 +{
 +      static EnumPropertyItem direction_items[] = {
 +              {1, "UP", 0, "Up", ""},
 +              {-1, "DOWN", 0, "Down", ""},
 +              {0, NULL, 0, NULL, NULL}
 +      };
 +
 +      /* identifiers */
 +      ot->name= "Move Modifier";
 +      ot->idname= "SCENE_OT_freestyle_modifier_move";
 +      ot->description="Move the modifier within the list of modifiers";
 +      
 +      /* api callbacks */
 +      ot->exec= freestyle_modifier_move_exec;
 +      ot->poll= freestyle_active_lineset_poll;
 +
 +      /* flags */
 +      ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
 +
 +      /* props */
 +      RNA_def_enum(ot->srna, "direction", direction_items, 0, "Direction", "Direction to move, UP or DOWN");
 +}
 +
  static int texture_slot_move(bContext *C, wmOperator *op)
  {
        ID *id= CTX_data_pointer_get_type(C, "texture_slot", &RNA_TextureSlot).id.data;
@@@ -369,13 -370,9 +370,13 @@@ static void buttons_area_listener(ScrAr
                        ED_area_tag_redraw(sa);
                        sbuts->preview= 1;
                        break;
 +              case NC_LINESTYLE:
 +                      ED_area_tag_redraw(sa);
 +                      sbuts->preview= 1;
 +                      break;
        }
  
-       if(wmn->data == ND_KEYS)
+       if (wmn->data == ND_KEYS)
                ED_area_tag_redraw(sa);
  }
  
@@@ -1092,20 -1126,20 +1126,20 @@@ void filelist_from_main(struct FileLis
        
        // filelist->type = FILE_MAIN; // XXXXX TODO: add modes to filebrowser
  
-       if(filelist->dir[0]=='/') filelist->dir[0]= 0;
+       if (filelist->dir[0]=='/') filelist->dir[0]= 0;
        
-       if(filelist->dir[0]) {
+       if (filelist->dir[0]) {
                idcode= groupname_to_code(filelist->dir);
-               if(idcode==0) filelist->dir[0]= 0;
+               if (idcode==0) filelist->dir[0]= 0;
        }
        
-       if( filelist->dir[0]==0) {
+       if ( filelist->dir[0]==0) {
                
                /* make directories */
 -              filelist->numfiles= 24;
 +              filelist->numfiles= 25;
                filelist->filelist= (struct direntry *)malloc(filelist->numfiles * sizeof(struct direntry));
                
-               for(a=0; a<filelist->numfiles; a++) {
+               for (a=0; a<filelist->numfiles; a++) {
                        memset( &(filelist->filelist[a]), 0 , sizeof(struct direntry));
                        filelist->filelist[a].type |= S_IFDIR;
                }
@@@ -2494,19 -2494,8 +2494,19 @@@ static void draw_dm_edges_sharp(BMEditM
        dm->drawMappedEdges(dm, draw_dm_edges_sharp__setDrawOptions, em);
  }
  
-       /* Draw only Freestyle feature edges */
++/* Draw only Freestyle feature edges */
 +static int draw_dm_edges_freestyle__setDrawOptions(void *userData, int index)
 +{
 +      BMEdge *eed = EDBM_get_edge_for_index(userData, index);
 +
 +      return !BM_elem_flag_test(eed, BM_ELEM_HIDDEN) && BM_elem_flag_test(eed, BM_ELEM_FREESTYLE);
 +}
 +static void draw_dm_edges_freestyle(BMEditMesh *em, DerivedMesh *dm)
 +{
 +      dm->drawMappedEdges(dm, draw_dm_edges_freestyle__setDrawOptions, em);
 +}
  
      /* Draw faces with color set based on selection
+ /* Draw faces with color set based on selection
         * return 2 for the active face so it renders with stipple enabled */
  static DMDrawOption draw_dm_faces_sel__setDrawOptions(void *userData, int index)
  {
@@@ -2565,7 -2554,7 +2565,7 @@@ static int draw_dm_faces_sel__compareDr
  
  /* also draws the active face */
  static void draw_dm_faces_sel(BMEditMesh *em, DerivedMesh *dm, unsigned char *baseCol, 
-                             unsigned char *selCol, unsigned char *markCol, unsigned char *actCol, BMFace *efa_act)
 -                              unsigned char *selCol, unsigned char *actCol, BMFace *efa_act)
++                              unsigned char *selCol, unsigned char *markCol, unsigned char *actCol, BMFace *efa_act)
  {
        drawDMFacesSel_userData data;
        data.dm= dm;
@@@ -3087,24 -3076,20 +3088,24 @@@ 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
                
-               /* dont draw unselected faces, only selected, this is MUCH nicer when texturing */
-               if CHECK_OB_DRAWTEXTURE(v3d, dt)
+               /* don't draw unselected faces, only selected, this is MUCH nicer when texturing */
+               if (CHECK_OB_DRAWTEXTURE(v3d, dt))
                        col1[3] = 0;
                
 -              draw_dm_faces_sel(em, cageDM, col1, col2, col3, efa_act);
 +              if (!(me->drawflag & ME_DRAW_FREESTYLE_FACE))
 +                      col3[3] = 0;
 +
 +              draw_dm_faces_sel(em, 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; /* don't 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 */
++              col1[3] = col2[3] = col3[3] = 0; /* don't draw */
 +              UI_GetThemeColor4ubv(TH_EDITMESH_ACTIVE, col4);
                
                glEnable(GL_BLEND);
                glDepthMask(0);         // disable write in zbuffer, needed for nice transp
                        glColor3ub(0,0,0);
                        glLineWidth(1);
                }
-       
 +              if(me->drawflag & ME_DRAW_FREESTYLE_EDGE) {
 +                      UI_ThemeColor(TH_FREESTYLE_EDGE_MARK);
 +                      glLineWidth(2);
 +      
 +                      draw_dm_edges_freestyle(em, cageDM);
 +      
 +                      glColor3ub(0,0,0);
 +                      glLineWidth(1);
 +              }
 +      
                if (me->drawflag & ME_DRAWCREASES && CustomData_has_layer(&em->bm->edata, CD_CREASE)) {
                        draw_dm_creases(em, cageDM);
                }
Simple merge
@@@ -317,12 -313,15 +319,16 @@@ void RNA_def_main(BlenderRNA *brna
                {"texts", "Text", "rna_Main_text_begin", "Texts", "Text datablocks", RNA_def_main_texts},
                {"speakers", "Speaker", "rna_Main_speaker_begin", "Speakers", "Speaker datablocks", RNA_def_main_speakers},
                {"sounds", "Sound", "rna_Main_sound_begin", "Sounds", "Sound datablocks", RNA_def_main_sounds},
-               {"armatures", "Armature", "rna_Main_armature_begin", "Armatures", "Armature datablocks", RNA_def_main_armatures},
+               {"armatures", "Armature", "rna_Main_armature_begin", "Armatures", "Armature datablocks",
+                             RNA_def_main_armatures},
                {"actions", "Action", "rna_Main_action_begin", "Actions", "Action datablocks", RNA_def_main_actions},
-               {"particles", "ParticleSettings", "rna_Main_particle_begin", "Particles", "Particle datablocks", RNA_def_main_particles},
-               {"grease_pencil", "GreasePencil", "rna_Main_gpencil_begin", "Grease Pencil", "Grease Pencil datablocks", RNA_def_main_gpencil},
-               {"movieclips", "MovieClip", "rna_Main_movieclips_begin", "Movie Clips", "Movie Clip datablocks", RNA_def_main_movieclips},
+               {"particles", "ParticleSettings", "rna_Main_particle_begin", "Particles", "Particle datablocks",
+                             RNA_def_main_particles},
+               {"grease_pencil", "GreasePencil", "rna_Main_gpencil_begin", "Grease Pencil", "Grease Pencil datablocks",
+                                 RNA_def_main_gpencil},
+               {"movieclips", "MovieClip", "rna_Main_movieclips_begin", "Movie Clips", "Movie Clip datablocks",
+                              RNA_def_main_movieclips},
 +              {"linestyles", "FreestyleLineStyle", "rna_Main_linestyle_begin", "Line Styles", "Line Style datablocks", RNA_def_main_linestyles},
                {NULL, NULL, NULL, NULL, NULL, NULL}};
  
        int i;
@@@ -1541,31 -1523,4 +1542,30 @@@ void RNA_def_main_movieclips(BlenderRN
        RNA_def_function_return(func, parm);
  }
  
 +void RNA_def_main_linestyles(BlenderRNA *brna, PropertyRNA *cprop)
 +{
 +      StructRNA *srna;
 +      FunctionRNA *func;
 +      PropertyRNA *parm;
 +
 +      RNA_def_property_srna(cprop, "BlendDataLineStyles");
 +      srna= RNA_def_struct(brna, "BlendDataLineStyles", NULL);
 +      RNA_def_struct_sdna(srna, "Main");
 +      RNA_def_struct_ui_text(srna, "Main Line Styles", "Collection of line styles");
 +
 +      func= RNA_def_function(srna, "new", "rna_Main_linestyles_new");
 +      RNA_def_function_ui_description(func, "Add a new line style instance to the main database");
 +      parm= RNA_def_string(func, "name", "FreestyleLineStyle", 0, "", "New name for the datablock");
 +      RNA_def_property_flag(parm, PROP_REQUIRED);
 +      /* return type */
 +      parm= RNA_def_pointer(func, "linestyle", "FreestyleLineStyle", "", "New line style datablock");
 +      RNA_def_function_return(func, parm);
 +
 +      func= RNA_def_function(srna, "remove", "rna_Main_linestyles_remove");
 +      RNA_def_function_flag(func, FUNC_USE_REPORTS);
 +      RNA_def_function_ui_description(func, "Remove a line style instance from the current blendfile");
 +      parm= RNA_def_pointer(func, "linestyle", "FreestyleLineStyle", "", "Line style to remove");
 +      RNA_def_property_flag(parm, PROP_REQUIRED);
 +}
 +
  #endif
Simple merge
@@@ -3387,16 -3374,7 +3393,16 @@@ static void init_render_mesh(Render *re
                        }
                }
                
-               if(!timeoffset) {
+               if (!timeoffset) {
 +                      EdgeHash *edge_hash;
 +                      MEdge *medge;
 +                      int totedge;
 +
 +                      /* create a hash table of Freestyle edge marks */
 +                      medge= dm->getEdgeArray(dm);
 +                      totedge= dm->getNumEdges(dm);
 +                      edge_hash= make_freestyle_edge_mark_hash(medge, totedge);
 +
                        /* store customdata names, because DerivedMesh is freed */
                        RE_set_customdata_names(obr, &dm->faceData);
  
                                        end= dm->getNumTessFaces(dm);
                                        mface= dm->getTessFaceArray(dm);
                                        
-                                       for(a=0; a<end; a++, mface++) {
+                                       for (a=0; a<end; a++, mface++) {
                                                int v1, v2, v3, v4, flag;
                                                
-                                               if( mface->mat_nr==a1 ) {
+                                               if ( mface->mat_nr==a1 ) {
                                                        float len;
 +                                                      int edge_mark= 0;
 +                                                              
                                                        int reverse_verts = negative_scale!=0 && do_autosmooth==0;
                                                        int rev_tab[] = {reverse_verts==0 ? 0 : 2, 1, reverse_verts==0 ? 2 : 0, 3};
                                                        v1= reverse_verts==0 ? mface->v1 : mface->v3;
                                                        vlr->v1= RE_findOrAddVert(obr, vertofs+v1);
                                                        vlr->v2= RE_findOrAddVert(obr, vertofs+v2);
                                                        vlr->v3= RE_findOrAddVert(obr, vertofs+v3);
-                                                       if(v4) vlr->v4= RE_findOrAddVert(obr, vertofs+v4);
+                                                       if (v4) vlr->v4= RE_findOrAddVert(obr, vertofs+v4);
                                                        else vlr->v4= 0;
  
 +                                                      /* Freestyle edge marks */
 +                                                      if(has_freestyle_edge_mark(edge_hash, v1, v2)) edge_mark |= R_EDGE_V1V2;
 +                                                      if(has_freestyle_edge_mark(edge_hash, v2, v3)) edge_mark |= R_EDGE_V2V3;
 +                                                      if (!v4) {
 +                                                              if(has_freestyle_edge_mark(edge_hash, v3, v1)) edge_mark |= R_EDGE_V3V1;
 +                                                      } else {
 +                                                              if(has_freestyle_edge_mark(edge_hash, v3, v4)) edge_mark |= R_EDGE_V3V4;
 +                                                              if(has_freestyle_edge_mark(edge_hash, v4, v1)) edge_mark |= R_EDGE_V4V1;
 +                                                      }
 +                                                      vlr->freestyle_edge_mark= edge_mark;
 +
                                                        /* render normals are inverted in render */
-                                                       if(use_original_normals) {
+                                                       if (use_original_normals) {
                                                                MFace *mf= me->mface+a;
                                                                MVert *mv= me->mvert;
                                                                
@@@ -929,15 -924,10 +929,15 @@@ static void do_render_3d(Render *re
        threaded_tile_processor(re);
        
        /* do left-over 3d post effects (flares) */
-       if(re->flag & R_HALO)
-               if(!re->test_break(re->tbh))
+       if (re->flag & R_HALO)
+               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);
        
@@@ -1468,14 -1398,12 +1468,14 @@@ static void do_merge_fullsample(Render 
                /* also function below assumes this */
                        
                tag_scenes_for_render(re);
-               for(re1= RenderGlobal.renderlist.first; re1; re1= re1->next) {
-                       if(re1->scene->id.flag & LIB_DOIT) {
-                               if(re1->r.scemode & R_FULL_SAMPLE) {
-                                       if(sample) {
+               for (re1= RenderGlobal.renderlist.first; re1; re1= re1->next) {
+                       if (re1->scene->id.flag & LIB_DOIT) {
+                               if (re1->r.scemode & R_FULL_SAMPLE) {
+                                       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 */
@@@ -2078,9 -2008,9 +2082,9 @@@ 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)) {
+               if (write_still && !G.afbreek) {
+                       if (BKE_imtype_is_movie(scene->r.im_format.imtype)) {
                                /* operator checks this but in case its called from elsewhere */
                                printf("Error: cant write single images with a movie format!\n");
                        }
@@@ -1671,16 -1672,10 +1672,16 @@@ void shade_lamp_loop(ShadeInput *shi, S
                        shi->r= shi->vcol[0];
                        shi->g= shi->vcol[1];
                        shi->b= shi->vcol[2];
-                       if(ma->mode & (MA_FACETEXTURE_ALPHA))
+                       if (ma->mode & (MA_FACETEXTURE_ALPHA))
                                shi->alpha= shi->vcol[3];
                }
-               else if(ma->vcol_alpha) {
++              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)) {
+               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];
                        shi->g= shi->g*neg_alpha + shi->vcol[1]*shi->vcol[3];
@@@ -799,10 -802,9 +803,10 @@@ endif(
                bf_python_ext
                bf_python_mathutils
                bf_python_bmesh
 +              bf_freestyle
                bf_ikplugin
-               bf_bmesh
                bf_modifiers
+               bf_bmesh
                bf_blenkernel
                bf_nodes
                bf_gpu
@@@ -1195,9 -1234,9 +1236,9 @@@ int main(int argc, const char **argv
        G.background= 1; /* python module mode ALWAYS runs in background mode (for now) */
  #else
        /* for all platforms, even windos has it! */
-       if(G.background) signal(SIGINT, blender_esc);   /* ctrl c out bg render */
+       if (G.background) signal(SIGINT, blender_esc);  /* ctrl c out bg render */
  #endif
 -
 +      
        /* background render uses this font too */
        BKE_font_register_builtin(datatoc_Bfont, datatoc_Bfont_size);