Merged changes in the trunk up to revision 52815.
authorTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>
Sat, 8 Dec 2012 12:35:14 +0000 (12:35 +0000)
committerTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>
Sat, 8 Dec 2012 12:35:14 +0000 (12:35 +0000)
15 files changed:
1  2 
build_files/scons/tools/Blender.py
doc/python_api/sphinx_doc_gen.py
source/blender/blenkernel/CMakeLists.txt
source/blender/blenkernel/intern/scene.c
source/blender/blenlib/CMakeLists.txt
source/blender/blenlib/intern/bpath.c
source/blender/blenloader/intern/readfile.c
source/blender/editors/interface/interface_templates.c
source/blender/editors/space_buttons/buttons_context.c
source/blender/editors/space_view3d/drawobject.c
source/blender/makesdna/DNA_scene_types.h
source/blender/makesrna/RNA_access.h
source/blender/makesrna/intern/rna_scene.c
source/blender/makesrna/intern/rna_space.c
source/blender/makesrna/intern/rna_userdef.c

index 6f6308867b681e6258d58b243939a2ae35dca217,94a9f1d9c244b3c1005bb43623cdfa8054512dc9..19c27d0c6bcc6b381c606d0484bf9157a086a13b
@@@ -364,7 -364,7 +364,7 @@@ def propose_priorities()
  def creator(env):
      sources = ['creator.c']# + Blender.buildinfo(env, "dynamic") + Blender.resources
  
 -    incs = ['#/intern/guardedalloc', '#/source/blender/blenlib', '#/source/blender/blenkernel', '#/source/blender/editors/include', '#/source/blender/blenloader', '#/source/blender/imbuf', '#/source/blender/renderconverter', '#/source/blender/render/extern/include', '#/source/blender/windowmanager', '#/source/blender/makesdna', '#/source/blender/makesrna', '#/source/gameengine/BlenderRoutines', '#/extern/glew/include', '#/source/blender/gpu', env['BF_OPENGL_INC']]
 +    incs = ['#/intern/guardedalloc', '#/source/blender/blenlib', '#/source/blender/blenkernel', '#/source/blender/editors/include', '#/source/blender/blenloader', '#/source/blender/imbuf', '#/source/blender/renderconverter', '#/source/blender/render/extern/include', '#/source/blender/windowmanager', '#/source/blender/makesdna', '#/source/blender/makesrna', '#/source/gameengine/BlenderRoutines', '#/extern/glew/include', '#/source/blender/gpu', '#/source/blender/freestyle', env['BF_OPENGL_INC']]
  
      defs = []
  
@@@ -651,7 -651,7 +651,7 @@@ def AppIt(target=None, source=None, env
              commands.getoutput(cmd)
              cmd = 'cp -R %s/kernel/*.h %s/kernel/*.cl %s/kernel/*.cu %s/kernel/' % (croot, croot, croot, cinstalldir)
              commands.getoutput(cmd)
-             cmd = 'cp -R %s/kernel/svm %s/util/util_color.h %s/util/util_math.h %s/util/util_transform.h %s/util/util_types.h %s/kernel/' % (croot, croot, croot, croot, croot, cinstalldir)
+             cmd = 'cp -R %s/kernel/svm %s/kernel/closure %s/util/util_color.h %s/util/util_math.h %s/util/util_transform.h %s/util/util_types.h %s/kernel/' % (croot, croot, croot, croot, croot, croot, cinstalldir)
              commands.getoutput(cmd)
              cmd = 'cp -R %s/../intern/cycles/kernel/*.cubin %s/lib/' % (builddir, cinstalldir)
              commands.getoutput(cmd)
index dd7019d43a317476ec2460baf1141344db979bb3,441a6c04efe795080a763c402bceb41209e153c9..d79c4e8fa9ad101eda5e39f579dd85421e970352
@@@ -262,7 -262,6 +262,7 @@@ else
          "mathutils",
          "mathutils.geometry",
          "mathutils.noise",
 +        "Freestyle",
          ]
  
      # ------
@@@ -317,6 -316,8 +317,8 @@@ RST_DIR = os.path.abspath(os.path.join(
  INFO_DOCS = (
      ("info_quickstart.rst", "Blender/Python Quickstart: new to blender/scripting and want to get your feet wet?"),
      ("info_overview.rst", "Blender/Python API Overview: a more complete explanation of python integration"),
+     ("info_tutorial_addon.rst", "Blender/Python Addon Tutorial: a step by step guide on how to write an addon from scratch"),
+     ("info_api_reference.rst", "Blender/Python API Reference Usage: examples of how to use the API reference docs"),
      ("info_best_practice.rst", "Best Practice: Conventions to follow for writing good scripts"),
      ("info_tips_and_tricks.rst", "Tips and Tricks: Hints to help you while writing scripts for blender"),
      ("info_gotcha.rst", "Gotcha's: some of the problems you may come up against when writing scripts"),
@@@ -448,7 -449,6 +450,7 @@@ if ARGS.sphinx_build_pdf
  ClassMethodDescriptorType = type(dict.__dict__['fromkeys'])
  MethodDescriptorType = type(dict.get)
  GetSetDescriptorType = type(int.real)
 +StaticMethodType = type(staticmethod(lambda: None))
  from types import MemberDescriptorType
  
  _BPY_STRUCT_FAKE = "bpy_struct"
@@@ -909,12 -909,6 +911,12 @@@ def pymodule2sphinx(basepath, module_na
              if type(descr) == GetSetDescriptorType:
                  py_descr2sphinx("   ", fw, descr, module_name, type_name, key)
  
 +        for key, descr in descr_items:
 +            if type(descr) == StaticMethodType:
 +                descr = getattr(value, key)
 +                write_indented_lines("   ", fw, descr.__doc__ or "Undocumented", False)
 +                fw("\n")
 +
          fw("\n\n")
  
      file.close()
@@@ -1545,9 -1539,9 +1547,9 @@@ 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.ops",
+         # bmesh, submodules are in own page
+         "bmesh",
          )
  
      for mod in standalone_modules:
@@@ -1693,7 -1687,6 +1695,7 @@@ def write_rst_importable_modules(basepa
          "mathutils"         : "Math Types & Utilities",
          "mathutils.geometry": "Geometry Utilities",
          "mathutils.noise"   : "Noise Utilities",
 +        "Freestyle"         : "Freestyle Data Types & Operators",
      }
      for mod_name, mod_descr in importable_modules.items():
          if mod_name not in EXCLUDE_MODULES:
@@@ -1733,6 -1726,11 +1735,11 @@@ def copy_handwritten_rsts(basepath)
      # changelog
      shutil.copy2(os.path.join(RST_DIR, "change_log.rst"), basepath)
  
+     # copy images, could be smarter but just glob for now.
+     for f in os.listdir(RST_DIR):
+         if f.endswith(".png"):
+             shutil.copy2(os.path.join(RST_DIR, f), basepath)
  
  def rna2sphinx(basepath):
  
index 11ff3930ffbf7b2b6c5fa044bfa81af2f776178b,2da9b402d59245f2f0ccddbc19df2a56e350b3a4..6208bb355b1a186d73509394a69241030425e134
@@@ -28,7 -28,6 +28,7 @@@ set(IN
        ../blenfont
        ../blenlib
        ../blenloader
 +      ../freestyle
        ../gpu
        ../ikplugin
        ../imbuf
@@@ -102,8 -101,8 +102,8 @@@ set(SR
        intern/lamp.c
        intern/lattice.c
        intern/library.c
 -      intern/mask_evaluate.c
 -      intern/mask_rasterize.c
 +      intern/linestyle.c
 +      intern/mask_evaluate.c  intern/mask_rasterize.c
        intern/mask.c
        intern/material.c
        intern/mball.c
        BKE_lamp.h
        BKE_lattice.h
        BKE_library.h
 +      BKE_linestyle.h
        BKE_main.h
        BKE_mask.h
        BKE_material.h
@@@ -257,13 -255,13 +257,13 @@@ if(WITH_BULLET
        add_definitions(-DUSE_BULLET)
  endif()
  
- if(WITH_MOD_CLOTH_ELTOPO)
      list(APPEND INC
              ../../../extern/eltopo
              ../../../extern/eltopo/eltopo3d
      )
      add_definitions(-DWITH_ELTOPO)
- endif()
#if(WITH_MOD_CLOTH_ELTOPO)
#     list(APPEND INC
#             ../../../extern/eltopo
#             ../../../extern/eltopo/eltopo3d
#     )
#     add_definitions(-DWITH_ELTOPO)
#endif()
  
  if(WITH_IMAGE_OPENEXR)
        add_definitions(-DWITH_OPENEXR)
index 2e57df844c8fd282b229d9333d152a7bea2fd1b7,9bb2fb2de5234970d06821fb731101da7d60d14d..d0af06d9f90d68c3125076fae1074a5a5cc95b63
@@@ -85,8 -85,6 +85,8 @@@
  //XXX #include "BIF_previewrender.h"
  //XXX #include "BIF_editseq.h"
  
 +#include "FRS_freestyle_config.h"
 +
  #ifdef WIN32
  #else
  #include <sys/time.h>
@@@ -287,8 -285,7 +287,8 @@@ Scene *BKE_scene_copy(Scene *sce, int t
  void BKE_scene_free(Scene *sce)
  {
        Base *base;
 -
 +      SceneRenderLayer *srl;
 +      
        base = sce->base.first;
        while (base) {
                base->object->id.us--;
                sce->r.ffcodecdata.properties = NULL;
        }
        
 +      for(srl= sce->r.layers.first; srl; srl= srl->next) {
 +              FRS_free_freestyle_config(srl);
 +      }
 +      
        BLI_freelistN(&sce->markers);
        BLI_freelistN(&sce->transform_spaces);
        BLI_freelistN(&sce->r.layers);
@@@ -408,6 -401,7 +408,7 @@@ Scene *BKE_scene_add(const char *name
        sce->r.im_format.planes = R_IMF_PLANES_RGB;
        sce->r.im_format.imtype = R_IMF_IMTYPE_PNG;
        sce->r.im_format.quality = 90;
+       sce->r.im_format.compress = 90;
  
        sce->r.displaymode = R_OUTPUT_AREA;
        sce->r.framapto = 100;
@@@ -1183,7 -1177,6 +1184,7 @@@ SceneRenderLayer *BKE_scene_add_render_
        srl->lay = (1 << 20) - 1;
        srl->layflag = 0x7FFF;   /* solid ztra halo edge strand */
        srl->passflag = SCE_PASS_COMBINED | SCE_PASS_Z;
 +      FRS_add_freestyle_config( srl );
  
        return srl;
  }
index 7be636fe150c86eb5e282de15b55009e38904790,8a3b1c9675b05c03cd7808fb881d8588dda4c87c..4a27036050ed8e737ea2c236a3b0933f719eacb7
@@@ -36,7 -36,6 +36,7 @@@ set(IN
  set(INC_SYS
        ${ZLIB_INCLUDE_DIRS}
        ${FREETYPE_INCLUDE_DIRS}
 +      ${ZLIB_INC}
  )
  
  set(SRC
        BLI_math_color.h
        BLI_math_geom.h
        BLI_math_inline.h
+       BLI_math_interp.h
        BLI_math_matrix.h
        BLI_math_rotation.h
        BLI_math_vector.h
index 8b63a94951dc181cf0493cd93e91aedf0d6c1705,c650438a31e0713ad7b242bf2e412c6fe2e34f4d..8924d03f736d8b802d976ab9ed2669a899199511
@@@ -70,7 -70,6 +70,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"
@@@ -431,43 -430,43 +431,43 @@@ void BLI_bpath_traverse_id(Main *bmain
                }                                                                      \
        } (void)0
  
 -                      /* do via modifiers instead */
 +                              /* do via modifiers instead */
  #if 0
 -                      if (ob->fluidsimSettings) {
 -                              rewrite_path_fixed(ob->fluidsimSettings->surfdataPath, visit_cb, absbase, bpath_user_data);
 -                      }
 +                              if (ob->fluidsimSettings) {
 +                                      rewrite_path_fixed(ob->fluidsimSettings->surfdataPath, visit_cb, absbase, bpath_user_data);
 +                              }
  #endif
  
 -                      for (md = ob->modifiers.first; md; md = md->next) {
 -                              if (md->type == eModifierType_Fluidsim) {
 -                                      FluidsimModifierData *fluidmd = (FluidsimModifierData *)md;
 -                                      if (fluidmd->fss) {
 -                                              rewrite_path_fixed(fluidmd->fss->surfdataPath, visit_cb, absbase, bpath_user_data);
 +                              for (md = ob->modifiers.first; md; md = md->next) {
 +                                      if (md->type == eModifierType_Fluidsim) {
 +                                              FluidsimModifierData *fluidmd = (FluidsimModifierData *)md;
 +                                              if (fluidmd->fss) {
 +                                                      rewrite_path_fixed(fluidmd->fss->surfdataPath, visit_cb, absbase, bpath_user_data);
 +                                              }
                                        }
 -                              }
 -                              else if (md->type == eModifierType_Smoke) {
 -                                      SmokeModifierData *smd = (SmokeModifierData *)md;
 -                                      if (smd->type & MOD_SMOKE_TYPE_DOMAIN) {
 -                                              BPATH_TRAVERSE_POINTCACHE(smd->domain->ptcaches[0]);
 +                                      else if (md->type == eModifierType_Smoke) {
 +                                              SmokeModifierData *smd = (SmokeModifierData *)md;
 +                                              if (smd->type & MOD_SMOKE_TYPE_DOMAIN) {
 +                                                      BPATH_TRAVERSE_POINTCACHE(smd->domain->ptcaches[0]);
 +                                              }
 +                                      }
 +                                      else if (md->type == eModifierType_Cloth) {
 +                                              ClothModifierData *clmd = (ClothModifierData *) md;
 +                                              BPATH_TRAVERSE_POINTCACHE(clmd->ptcaches);
 +                                      }
 +                                      else if (md->type == eModifierType_Ocean) {
 +                                              OceanModifierData *omd = (OceanModifierData *) md;
 +                                              rewrite_path_fixed(omd->cachepath, visit_cb, absbase, bpath_user_data);
                                        }
                                }
 -                              else if (md->type == eModifierType_Cloth) {
 -                                      ClothModifierData *clmd = (ClothModifierData *) md;
 -                                      BPATH_TRAVERSE_POINTCACHE(clmd->ptcaches);
 -                              }
 -                              else if (md->type == eModifierType_Ocean) {
 -                                      OceanModifierData *omd = (OceanModifierData *) md;
 -                                      rewrite_path_fixed(omd->cachepath, visit_cb, absbase, bpath_user_data);
 -                              }
 -                      }
  
 -                      if (ob->soft) {
 -                              BPATH_TRAVERSE_POINTCACHE(ob->soft->ptcaches);
 -                      }
 +                              if (ob->soft) {
 +                                      BPATH_TRAVERSE_POINTCACHE(ob->soft->ptcaches);
 +                              }
  
 -                      for (psys = ob->particlesystem.first; psys; psys = psys->next) {
 -                              BPATH_TRAVERSE_POINTCACHE(psys->ptcaches);
 -                      }
 +                              for (psys = ob->particlesystem.first; psys; psys = psys->next) {
 +                                      BPATH_TRAVERSE_POINTCACHE(psys->ptcaches);
 +                              }
  
  #undef BPATH_TRAVERSE_POINTCACHE
  
                        Material *ma = (Material *)id;
                        bNodeTree *ntree = ma->nodetree;
  
-                       if(ntree) {
+                       if (ntree) {
                                bNode *node;
  
                                for (node = ntree->nodes.first; node; node = node->next) {
                                        }
                                }
                        }
 -                      break;
 +              break;
                }
                case ID_NT:
                {
                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 b9e23f608817449ff4844106ec0d284cfad13ece,902d75ee67e99eedda17c29aa87e1332d233bf3e..55ae56ac4e82dd2432a9c0bf32694be0915569b3
@@@ -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"
@@@ -822,7 -821,7 +822,7 @@@ static void decode_blender_header(FileD
                        /* is the file saved in a different endian
                         * than we need ?
                         */
 -                      if (((((char *)&remove_this_endian_test)[0] == 1) ? L_ENDIAN : B_ENDIAN) != ((header[8] == 'v') ? L_ENDIAN : B_ENDIAN)) {
 +                      if (((((char*)&remove_this_endian_test)[0]==1)?L_ENDIAN:B_ENDIAN) != ((header[8]=='v')?L_ENDIAN:B_ENDIAN)) {
                                fd->flags |= FD_FLAGS_SWITCH_ENDIAN;
                        }
                        
@@@ -944,7 -943,7 +944,7 @@@ static int fd_read_from_memfile(FileDat
                        if (chunkoffset+readsize > chunk->size)
                                readsize= chunk->size-chunkoffset;
                        
 -                      memcpy((char *)buffer + totread, chunk->buf + chunkoffset, readsize);
 +                      memcpy((char*)buffer + totread, chunk->buf + chunkoffset, readsize);
                        totread += readsize;
                        filedata->seek += readsize;
                        seek += readsize;
@@@ -986,7 -985,7 +986,7 @@@ static FileData *blo_decode_and_check(F
                        blo_freefiledata(fd);
                        fd = NULL;
                }
 -      }
 +      } 
        else {
                BKE_reportf(reports, RPT_ERROR, "Failed to read blend file '%s', not a blend file", fd->relabase);
                blo_freefiledata(fd);
@@@ -1133,7 -1132,7 +1133,7 @@@ int BLO_is_a_library(const char *path, 
                /* the last part of the dir is a .blend file, no group follows */
                *fd = '/'; /* put back the removed slash separating the dir and the .blend file name */
        }
 -      else {
 +      else {          
                char *gp = fd + 1; // in case we have a .blend file, gp points to the group
                
                /* Find the last slash */
@@@ -1842,7 -1841,7 +1842,7 @@@ static void lib_link_fcurves(FileData *
                        
                        for (dvar= driver->variables.first; dvar; dvar= dvar->next) {
                                DRIVER_TARGETS_LOOPER(dvar)
 -                              {
 +                              {       
                                        /* only relink if still used */
                                        if (tarIndex < dvar->num_targets)
                                                dtar->id = newlibadr(fd, id->lib, dtar->id); 
@@@ -2410,6 -2409,8 +2410,8 @@@ static void direct_link_nodetree(FileDa
        ntree->adt = newdataadr(fd, ntree->adt);
        direct_link_animdata(fd, ntree->adt);
        
+       ntree->id.flag &= ~(LIB_ID_RECALC|LIB_ID_RECALC_DATA);
        link_list(fd, &ntree->nodes);
        for (node = ntree->nodes.first; node; node = node->next) {
                node->typeinfo = NULL;
                        /* could be handlerized at some point */
                        if (ntree->type==NTREE_SHADER) {
                                if (node->type==SH_NODE_CURVE_VEC || node->type==SH_NODE_CURVE_RGB) {
 -                                      direct_link_curvemapping(fd, node->storage);
 +                              direct_link_curvemapping(fd, node->storage);
                                }
                                else if (node->type==SH_NODE_SCRIPT) {
                                        NodeShaderScript *nss = (NodeShaderScript *) node->storage;
@@@ -2819,7 -2820,7 +2821,7 @@@ static void switch_endian_keyblock(Key 
                        
                        cp += 2;
                }
 -              data += elemsize;
 +              data+= elemsize;
        }
  }
  
@@@ -2854,7 -2855,7 +2856,7 @@@ static void lib_link_mball(FileData *fd
                        if (mb->adt) lib_link_animdata(fd, &mb->id, mb->adt);
                        
                        for (a = 0; a < mb->totcol; a++) 
 -                              mb->mat[a] = newlibadr_us(fd, mb->id.lib, mb->mat[a]);
 +                              mb->mat[a]= newlibadr_us(fd, mb->id.lib, mb->mat[a]);
                        
                        mb->ipo = newlibadr_us(fd, mb->id.lib, mb->ipo); // XXX deprecated - old animation system
                        
@@@ -3043,7 -3044,7 +3045,7 @@@ static void direct_link_image(FileData 
                link_ibuf_list(fd, &ima->ibufs);
        else
                ima->ibufs.first = ima->ibufs.last = NULL;
 -
 +      
        /* if not restored, we keep the binded opengl index */
        if (ima->ibufs.first == NULL) {
                ima->bindcode = 0;
@@@ -3091,7 -3092,7 +3093,7 @@@ static void lib_link_curve(FileData *fd
                        cu->taperobj = newlibadr(fd, cu->id.lib, cu->taperobj);
                        cu->textoncurve = newlibadr(fd, cu->id.lib, cu->textoncurve);
                        cu->vfont = newlibadr_us(fd, cu->id.lib, cu->vfont);
 -                      cu->vfontb = newlibadr_us(fd, cu->id.lib, cu->vfontb);
 +                      cu->vfontb = newlibadr_us(fd, cu->id.lib, cu->vfontb);                  
                        cu->vfonti = newlibadr_us(fd, cu->id.lib, cu->vfonti);
                        cu->vfontbi = newlibadr_us(fd, cu->id.lib, cu->vfontbi);
                        
@@@ -3125,7 -3126,7 +3127,7 @@@ static void direct_link_curve(FileData 
        cu->mat = newdataadr(fd, cu->mat);
        test_pointer_array(fd, (void **)&cu->mat);
        cu->str = newdataadr(fd, cu->str);
 -      cu->strinfo= newdataadr(fd, cu->strinfo);
 +      cu->strinfo= newdataadr(fd, cu->strinfo);       
        cu->tb = newdataadr(fd, cu->tb);
  
        if (cu->vfont == NULL) link_list(fd, &(cu->nurb));
                if (cu->tb) {
                        memcpy(tb, cu->tb, cu->totbox*sizeof(TextBox));
                        MEM_freeN(cu->tb);
 -                      cu->tb = tb;
 +                      cu->tb = tb;                    
                }
                else {
                        cu->totbox = 1;
                        cu->actbox = 1;
                        cu->tb = tb;
                        cu->tb[0].w = cu->linewidth;
 -              }
 +              }               
                if (cu->wordspace == 0.0f) cu->wordspace = 1.0f;
        }
  
@@@ -3312,7 -3313,7 +3314,7 @@@ static const char *ptcache_data_struct[
        "", // BPHYS_DATA_ROTATION
        "", // BPHYS_DATA_AVELOCITY / BPHYS_DATA_XCONST */
        "", // BPHYS_DATA_SIZE:
 -      "", // BPHYS_DATA_TIMES:
 +      "", // BPHYS_DATA_TIMES:        
        "BoidData" // case BPHYS_DATA_BOIDS:
  };
  static void direct_link_pointcache(FileData *fd, PointCache *cache)
@@@ -3421,7 -3422,7 +3423,7 @@@ static void lib_link_particlesettings(F
                                        /* special case for only one object in the group */
                                        index_ok = 1;
                                }
 -                              else {
 +                              else { 
                                        for (dw = part->dupliweights.first; dw; dw = dw->next) {
                                                if (dw->index > 0) {
                                                        index_ok = 1;
                                                }
                                        }
                                }
 -
 +                              
                                if (index_ok) {
                                        /* if we have indexes, let's use them */
                                        for (dw = part->dupliweights.first; dw; dw = dw->next) {
                                        /* otherwise try to get objects from own library (won't work on library linked groups) */
                                        for (dw = part->dupliweights.first; dw; dw = dw->next) {
                                                dw->ob = newlibadr(fd, part->id.lib, dw->ob);
 -                                      }
                                }
                        }
 +                      }
                        else {
                                part->dupliweights.first = part->dupliweights.last = NULL;
                        }
@@@ -3658,7 -3659,7 +3660,7 @@@ static void lib_link_mtface(FileData *f
  
  static void lib_link_customdata_mtface(FileData *fd, Mesh *me, CustomData *fdata, int totface)
  {
 -      int i;
 +      int i;  
        for (i = 0; i < fdata->totlayer; i++) {
                CustomDataLayer *layer = &fdata->layers[i];
                
@@@ -3683,11 -3684,11 +3685,11 @@@ static void lib_link_customdata_mtpoly(
                                tf->tpage = newlibadr(fd, me->id.lib, tf->tpage);
                                if (tf->tpage && tf->tpage->id.us == 0) {
                                        tf->tpage->id.us = 1;
 -                              }
                        }
                }
        }
  }
 +}
  
  static void lib_link_mesh(FileData *fd, Main *main)
  {
@@@ -4107,7 -4108,7 +4109,7 @@@ static void lib_link_object(FileData *f
                                if (paf->type == EFF_PARTICLE) {
                                        paf->group = newlibadr_us(fd, ob->id.lib, paf->group);
                                }
 -                      }
 +                      }                               
                        
                        for (sens = ob->sensors.first; sens; sens = sens->next) {
                                for (a = 0; a < sens->totlinks; a++)
@@@ -4639,7 -4640,7 +4641,7 @@@ static void direct_link_object(FileDat
        direct_link_partdeflect(ob->pd);
        ob->soft= newdataadr(fd, ob->soft);
        if (ob->soft) {
 -              SoftBody *sb = ob->soft;
 +              SoftBody *sb = ob->soft;                
                
                sb->bpoint = NULL;      // init pointers so it gets rebuilt nicely
                sb->bspring = NULL;
@@@ -4786,7 -4787,6 +4788,7 @@@ static void lib_link_scene(FileData *fd
        Base *base, *next;
        Sequence *seq;
        SceneRenderLayer *srl;
 +      FreestyleLineSet *fls;
        TimeMarker *marker;
        
        for (sce = main->scene.first; sce; sce = sce->id.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);
@@@ -4962,7 -4958,6 +4964,7 @@@ static void direct_link_scene(FileData 
        Editing *ed;
        Sequence *seq;
        MetaStack *ms;
 +      SceneRenderLayer *srl;
        
        sce->theDag = NULL;
        sce->dagisvalid = 0;
                                        ed->seqbasep = (ListBase *)(poin+offset);
                                else
                                        ed->seqbasep = &ed->seqbase;
 -                      }
 +                      }                       
                        /* stack */
                        link_list(fd, &(ed->metastack));
                        
        }
        if (sce->r.ffcodecdata.properties) {
                sce->r.ffcodecdata.properties = newdataadr(fd, sce->r.ffcodecdata.properties);
 -              if (sce->r.ffcodecdata.properties) {
 +              if (sce->r.ffcodecdata.properties) { 
                        IDP_DirectLinkProperty(sce->r.ffcodecdata.properties, 
                                (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd);
                }
        link_list(fd, &(sce->markers));
        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) {
@@@ -6401,177 -6389,6 +6403,177 @@@ static void lib_link_mask(FileData *fd
        }
  }
  
 +/* ************ READ LINE STYLE ***************** */
 +
 +static void lib_link_linestyle(FileData *fd, Main *main)
 +{
 +      FreestyleLineStyle *linestyle;
 +      LineStyleModifier *m;
 +
 +      linestyle = main->linestyle.first;
 +      while (linestyle) {
 +              if (linestyle->id.flag & LIB_NEED_LINK) {
 +                      linestyle->id.flag -= LIB_NEED_LINK;
 +
 +                      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 ******************** */
  
  
@@@ -6606,7 -6423,6 +6608,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";
        
@@@ -6783,9 -6599,6 +6785,9 @@@ static BHead *read_libblock(FileData *f
                case ID_MSK:
                        direct_link_mask(fd, (Mask *)id);
                        break;
 +              case ID_LS:
 +                      direct_link_linestyle(fd, (FreestyleLineStyle *)id);
 +                      break;
        }
        
        oldnewmap_free_unused(fd->datamap);
@@@ -7338,7 -7151,7 +7340,7 @@@ static void do_version_node_fix_interna
                }
        }
  }
 -      
 +
  static void do_version_logic_264(ListBase *regionbase)
  {
        ARegion *ar;
@@@ -7586,10 -7399,10 +7588,10 @@@ static void do_versions(FileData *fd, L
                                        if ( (ob->dsize[i] == 0.0f) || /* simple case, user never touched dsize */
                                             (ob->size[i]  == 0.0f))   /* cant scale the dsize to give a non zero result, so fallback to 1.0f */
                                        {
 -                                              ob->dscale[i] = 1.0f;
 +                                              ob->dscale[i]= 1.0f;
                                        }
                                        else {
 -                                              ob->dscale[i] = (ob->size[i] + ob->dsize[i]) / ob->size[i];
 +                                              ob->dscale[i]= (ob->size[i] + ob->dsize[i]) / ob->size[i];
                                        }
                                }
                        }
                        do_version_node_fix_internal_links_264(NULL, NULL, ntree);
                
        }
 -      
 +
        if (main->versionfile < 264 || (main->versionfile == 264 && main->subversionfile < 6)) {
                bScreen *sc;
                
  
                        for (clip = main->movieclip.first; clip; clip = clip->id.next) {
                                if (clip->tracking.settings.reconstruction_success_threshold == 0.0f) {
-                                       clip->tracking.settings.reconstruction_success_threshold = 1e-3;
+                                       clip->tracking.settings.reconstruction_success_threshold = 1e-3f;
                                }
                        }
                }
                }
        }
  
 +      /* default values in Freestyle settings */
 +      {
 +              Scene *sce;
 +              SceneRenderLayer *srl;
 +              FreestyleLineStyle *linestyle;
 +
 +              for(sce = main->scene.first; sce; sce = sce->id.next) {
 +                      if (sce->r.line_thickness_mode == 0) {
 +                              sce->r.line_thickness_mode= R_LINE_THICKNESS_ABSOLUTE;
 +                              sce->r.unit_line_thickness= 1.f;
 +                      }
 +                      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 == FREESTYLE_ALGO_CULLED_ADAPTIVE_CUMULATIVE ||
 +                                      srl->freestyleConfig.raycasting_algorithm == FREESTYLE_ALGO_CULLED_ADAPTIVE_TRADITIONAL) {
 +                                      srl->freestyleConfig.raycasting_algorithm= 0; /* deprecated */
 +                                      srl->freestyleConfig.flags |= FREESTYLE_CULLING;
 +                              }
 +                      }
 +              }
 +              for(linestyle = main->linestyle.first; linestyle; linestyle = linestyle->id.next) {
 +                      if (linestyle->thickness_position == 0) {
 +                              linestyle->thickness_position= LS_THICKNESS_CENTER;
 +                              linestyle->thickness_ratio= 0.5f;
 +                      }
 +                      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! */
  
@@@ -8648,7 -8428,6 +8650,7 @@@ static void lib_link_all(FileData *fd, 
        lib_link_particlesettings(fd, main);
        lib_link_movieclip(fd, main);
        lib_link_mask(fd, main);
 +      lib_link_linestyle(fd, main);
  
        lib_link_mesh(fd, main);                /* as last: tpage images with users at zero */
        
@@@ -9259,7 -9038,7 +9261,7 @@@ static void expand_curve(FileData *fd, 
        }
        
        expand_doit(fd, mainvar, cu->vfont);
 -      expand_doit(fd, mainvar, cu->vfontb);
 +      expand_doit(fd, mainvar, cu->vfontb);   
        expand_doit(fd, mainvar, cu->vfonti);
        expand_doit(fd, mainvar, cu->vfontbi);
        expand_doit(fd, mainvar, cu->key);
@@@ -9563,7 -9342,6 +9565,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)
@@@ -9683,26 -9455,6 +9685,26 @@@ static void expand_mask(FileData *fd, M
        }
  }
  
 +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)
  {
        ListBase *lbarray[MAX_LIBARRAY];
                                        case ID_MSK:
                                                expand_mask(fd, mainvar, (Mask *)id);
                                                break;
 +                                      case ID_LS:
 +                                              expand_linestyle(fd, mainvar, (FreestyleLineStyle *)id);
 +                                              break;
                                        }
                                        
                                        do_it = TRUE;
@@@ -10111,7 -9860,7 +10113,7 @@@ static void library_append_end(const bC
        if ((*fd)->flags & FD_FLAGS_SWITCH_ENDIAN) {
                blo_freefiledata(*fd);
                *fd = NULL;
 -      }
 +      }       
  }
  
  void BLO_library_append_end(const bContext *C, struct Main *mainl, BlendHandle** bh, int idcode, short flag)
index e90fc1d4695df5dc26780fa8334f6db58d85ff6e,f7a53c6bab23f633681cdf8650f4c10f1efac634..84ee0ffebe112ac2056b914361d4153a563cd8f6
@@@ -325,7 -325,6 +325,7 @@@ static const char *template_id_browse_t
                        case ID_MA:  return N_("Browse Material to be linked");
                        case ID_TE:  return N_("Browse Texture to be linked");
                        case ID_IM:  return N_("Browse Image to be linked");
 +                      case ID_LS:  return N_("Browse Line Style Data to be linked");
                        case ID_LT:  return N_("Browse Lattice Data to be linked");
                        case ID_LA:  return N_("Browse Lamp Data to be linked");
                        case ID_CA:  return N_("Browse Camera Data to be linked");
@@@ -360,7 -359,6 +360,7 @@@ static const char *template_id_context(
                        case ID_MA:  return BLF_I18NCONTEXT_ID_MATERIAL;
                        case ID_TE:  return BLF_I18NCONTEXT_ID_TEXTURE;
                        case ID_IM:  return BLF_I18NCONTEXT_ID_IMAGE;
 +                      case ID_LS:  return BLF_I18NCONTEXT_ID_FREESTYLELINESTYLE;
                        case ID_LT:  return BLF_I18NCONTEXT_ID_LATTICE;
                        case ID_LA:  return BLF_I18NCONTEXT_ID_LAMP;
                        case ID_CA:  return BLF_I18NCONTEXT_ID_CAMERA;
@@@ -516,8 -514,7 +516,8 @@@ static void template_ID(bContext *C, ui
                                                 BLF_I18NCONTEXT_ID_NODETREE,
                                                 BLF_I18NCONTEXT_ID_BRUSH,
                                                 BLF_I18NCONTEXT_ID_PARTICLESETTINGS,
 -                                               BLF_I18NCONTEXT_ID_GPENCIL);
 +                                               BLF_I18NCONTEXT_ID_GPENCIL,
 +                                                                               BLF_I18NCONTEXT_ID_FREESTYLELINESTYLE);
                
                if (newop) {
                        but = uiDefIconTextButO(block, BUT, newop, WM_OP_INVOKE_DEFAULT, ICON_ZOOMIN,
@@@ -2024,10 -2021,16 +2024,16 @@@ static void curvemap_buttons_layout(uiL
        }
  
        if (cmp) {
+               const float range_clamp[2]   = {0.0f, 1.0f};
+               const float range_unclamp[2] = {-1000.0f, 1000.0f};  /* arbitrary limits here */
+               const float *range = (cumap->flag & CUMA_DO_CLIP) ? range_clamp : range_unclamp;
                uiLayoutRow(layout, TRUE);
                uiBlockSetNFunc(block, curvemap_buttons_update, MEM_dupallocN(cb), cumap);
-               bt = uiDefButF(block, NUM, 0, "X", 0, 2 * UI_UNIT_Y, UI_UNIT_X * 10, UI_UNIT_Y, &cmp->x, 0.0f, 1.0f, 1, 5, "");
-               bt = uiDefButF(block, NUM, 0, "Y", 0, 1 * UI_UNIT_Y, UI_UNIT_X * 10, UI_UNIT_Y, &cmp->y, 0.0f, 1.0f, 1, 5, "");
+               bt = uiDefButF(block, NUM, 0, "X", 0, 2 * UI_UNIT_Y, UI_UNIT_X * 10, UI_UNIT_Y,
+                              &cmp->x, range[0], range[1], 1, 5, "");
+               bt = uiDefButF(block, NUM, 0, "Y", 0, 1 * UI_UNIT_Y, UI_UNIT_X * 10, UI_UNIT_Y,
+                              &cmp->y, range[0], range[1], 1, 5, "");
        }
  
        /* black/white levels */
@@@ -2087,19 -2090,19 +2093,19 @@@ void uiTemplateColorPicker(uiLayout *la
        PropertyRNA *prop = RNA_struct_find_property(ptr, propname);
        uiBlock *block = uiLayoutGetBlock(layout);
        uiLayout *col, *row;
-       uiBut *but;
+       uiBut *but = NULL;
        float softmin, softmax, step, precision;
-       
        if (!prop) {
                RNA_warning("property not found: %s.%s", RNA_struct_identifier(ptr->type), propname);
                return;
        }
  
        RNA_property_float_ui_range(ptr, prop, &softmin, &softmax, &step, &precision);
-       
        col = uiLayoutColumn(layout, TRUE);
        row = uiLayoutRow(col, TRUE);
-       
        switch (U.color_picker_type) {
                case USER_CP_CIRCLE:
                        but = uiDefButR_prop(block, HSVCIRCLE, 0, "", 0, 0, WHEEL_SIZE, WHEEL_SIZE, ptr, prop,
                                             -1, 0.0, 0.0, UI_GRAD_HV, 0, "");
                        break;
        }
-       
  
        if (lock) {
                but->flag |= UI_BUT_COLOR_LOCK;
  
        
        if (value_slider) {
-               
                switch (U.color_picker_type) {
                        case USER_CP_CIRCLE:
                                uiItemS(row);
                                               -1, softmin, softmax, UI_GRAD_HV + 3, 0, "");
                                break;
                }
-               
        }
  }
  
@@@ -2409,7 -2409,7 +2412,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);
@@@ -2785,6 -2785,9 +2788,9 @@@ static void operator_search_cb(const bC
        for (; !BLI_ghashIterator_isDone(iter); BLI_ghashIterator_step(iter)) {
                wmOperatorType *ot = BLI_ghashIterator_getValue(iter);
  
+               if ((ot->flag & OPTYPE_INTERNAL) && (G.debug & G_DEBUG_WM) == 0)
+                       continue;
                if (BLI_strcasestr(ot->name, str)) {
                        if (WM_operator_poll((bContext *)C, ot)) {
                                char name[256];
        BLI_ghashIterator_free(iter);
  }
  
+ void uiOperatorSearch_But(uiBut *but)
+ {
+       uiButSetSearchFunc(but, operator_search_cb, NULL, operator_call_cb, NULL);
+ }
  void uiTemplateOperatorSearch(uiLayout *layout)
  {
        uiBlock *block;
        uiBlockSetCurLayout(block, layout);
  
        but = uiDefSearchBut(block, search, 0, ICON_VIEWZOOM, sizeof(search), 0, 0, UI_UNIT_X * 6, UI_UNIT_Y, 0, 0, "");
-       uiButSetSearchFunc(but, operator_search_cb, NULL, operator_call_cb, NULL);
+       uiOperatorSearch_But(but);
  }
  
  /************************* Running Jobs Template **************************/
index a7f18c9de5322a59100c1f2ffadac94724ac1577,2a5b64cd6ed30334f1852c45bb631fb1fdc69953..91f069d16de16ccd02d728f78142e2972e944302
@@@ -538,7 -538,6 +538,7 @@@ static int buttons_context_path(const b
        switch (mainb) {
                case BCONTEXT_SCENE:
                case BCONTEXT_RENDER:
 +              case BCONTEXT_RENDER_LAYER:
                        found = buttons_context_path_scene(path);
                        break;
                case BCONTEXT_WORLD:
@@@ -823,12 -822,12 +823,12 @@@ int buttons_context(const bContext *C, 
                ButsContextTexture *ct = sbuts->texuser;
                PointerRNA *ptr;
  
-               if (ct)
-                       return 0;  /* new shading system */
                if ((ptr = get_pointer_type(path, &RNA_Material))) {
                        Material *ma = ptr->data;
  
+                       if (ct)
+                               return 0;  /* new shading system */
                        /* if we have a node material, get slot from material in material node */
                        if (ma && ma->use_nodes && ma->nodetree) {
                                /* if there's an active texture node in the node tree,
                else if ((ptr = get_pointer_type(path, &RNA_Lamp))) {
                        Lamp *la = ptr->data;
  
+                       if (ct)
+                               return 0;  /* new shading system */
                        if (la)
                                CTX_data_pointer_set(result, &la->id, &RNA_LampTextureSlot, la->mtex[(int)la->texact]);
                }
                else if ((ptr = get_pointer_type(path, &RNA_World))) {
                        World *wo = ptr->data;
  
+                       if (ct)
+                               return 0;  /* new shading system */
                        if (wo)
                                CTX_data_pointer_set(result, &wo->id, &RNA_WorldTextureSlot, wo->mtex[(int)wo->texact]);
                }
@@@ -1038,7 -1043,7 +1044,7 @@@ void buttons_context_draw(const bContex
                        name = RNA_struct_name_get_alloc(ptr, namebuf, sizeof(namebuf), NULL);
  
                        if (name) {
 -                              if (!ELEM(sbuts->mainb, BCONTEXT_RENDER, BCONTEXT_SCENE) && ptr->type == &RNA_Scene)
 +                              if (!ELEM3(sbuts->mainb, BCONTEXT_RENDER, BCONTEXT_SCENE, BCONTEXT_RENDER_LAYER) && ptr->type == &RNA_Scene)
                                        uiItemLDrag(row, ptr, "", icon);  /* save some space */
                                else
                                        uiItemLDrag(row, ptr, name, icon);
index 79c34f93a10654659ee09aa60d311d45c4f1658b,5ac7327b93b09d42d1ef41e64d15d12707edd98e..f272cb61c26b4af92ff801a156d24d1c551e4e75
@@@ -126,7 -126,7 +126,7 @@@ typedef struct drawDMEdgesSel_userData 
  } drawDMEdgesSel_userData;
  
  typedef struct drawDMFacesSel_userData {
 -      unsigned char *cols[3];
 +      unsigned char *cols[4];
  
        DerivedMesh *dm; /* BMESH BRANCH ONLY */
        BMEditMesh *em;  /* BMESH BRANCH ONLY */
@@@ -229,7 -229,10 +229,10 @@@ static int check_alpha_pass(Base *base
  
        if (G.f & G_PICKSEL)
                return 0;
-       
+       if (base->object->mode & OB_MODE_ALL_PAINT)
+               return 0;
        return (base->object->dtx & OB_DRAWTRANSP);
  }
  
@@@ -2277,21 -2280,6 +2280,21 @@@ static void draw_dm_edges_sharp(BMEditM
        dm->drawMappedEdges(dm, draw_dm_edges_sharp__setDrawOptions, em);
  }
  
 +/* Draw only Freestyle feature edges */
 +static DMDrawOption draw_dm_edges_freestyle__setDrawOptions(void *userData, int index)
 +{
 +      BMEdge *eed = EDBM_edge_at_index(userData, index);
 +
 +      if (!BM_elem_flag_test(eed, BM_ELEM_HIDDEN) && BM_elem_flag_test(eed, BM_ELEM_FREESTYLE))
 +              return DM_DRAW_OPTION_NORMAL;
 +      else
 +              return DM_DRAW_OPTION_SKIP;
 +}
 +
 +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
   * return 2 for the active face so it renders with stipple enabled */
@@@ -2306,11 -2294,11 +2309,11 @@@ static DMDrawOption draw_dm_faces_sel__
        
        if (!BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) {
                if (efa == data->efa_act) {
 -                      glColor4ubv(data->cols[2]);
 +                      glColor4ubv(data->cols[3]);
                        return DM_DRAW_OPTION_STIPPLE;
                }
                else {
 -                      col = data->cols[BM_elem_flag_test(efa, BM_ELEM_SELECT) ? 1 : 0];
 +                      col = data->cols[BM_elem_flag_test(efa, BM_ELEM_SELECT) ? 1 : BM_elem_flag_test(efa, BM_ELEM_FREESTYLE) ? 2 : 0];
                        if (col[3] == 0)
                                return DM_DRAW_OPTION_SKIP;
                        glColor4ubv(col);
@@@ -2341,8 -2329,8 +2344,8 @@@ static int draw_dm_faces_sel__compareDr
        if (efa == data->efa_act || next_efa == data->efa_act)
                return 0;
  
 -      col = data->cols[BM_elem_flag_test(efa, BM_ELEM_SELECT) ? 1 : 0];
 -      next_col = data->cols[BM_elem_flag_test(next_efa, BM_ELEM_SELECT) ? 1 : 0];
 +      col = data->cols[BM_elem_flag_test(efa, BM_ELEM_SELECT) ? 1 : BM_elem_flag_test(efa, BM_ELEM_FREESTYLE) ? 2 : 0];
 +      next_col = data->cols[BM_elem_flag_test(next_efa, BM_ELEM_SELECT) ? 1 : BM_elem_flag_test(next_efa, BM_ELEM_FREESTYLE) ? 2 : 0];
  
        if (col[3] == 0 || next_col[3] == 0)
                return 0;
  
  /* also draws the active face */
  static void draw_dm_faces_sel(BMEditMesh *em, DerivedMesh *dm, unsigned char *baseCol,
 -                              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;
        data.cols[0] = baseCol;
        data.em = em;
        data.cols[1] = selCol;
 -      data.cols[2] = actCol;
 +      data.cols[2] = markCol;
 +      data.cols[3] = actCol;
        data.efa_act = efa_act;
        /* double lookup */
        data.orig_index_mf_to_mpoly = DM_get_tessface_data_layer(dm, CD_ORIGINDEX);
@@@ -2595,7 -2582,7 +2598,7 @@@ static void draw_em_measure_stats(View3
        BMIter iter;
        int i;
  
-       /* make the precision of the pronted value proportionate to the gridsize */
+       /* make the precision of the display value proportionate to the gridsize */
  
        if (grid < 0.01f) conv_float = "%.6g";
        else if (grid < 0.1f) conv_float = "%.5g";
@@@ -2897,12 -2884,11 +2900,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_object_draw_texture(scene, 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; /* don't draw */
 +              UI_GetThemeColor4ubv(TH_EDITMESH_ACTIVE, col4);
  
                glEnable(GL_BLEND);
                glDepthMask(0);  /* disable write in zbuffer, needed for nice transp */
  
 -              draw_dm_faces_sel(em, cageDM, col1, col2, col3, efa_act);
 +              draw_dm_faces_sel(em, 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(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);
                }
index 3e22613574188becdfda1fc723390caec1843ed2,8e0a36a8a43e86099fa6c4c27e47b9cb5317a42e..8af971b9b65b5a37facb4b8b9ecd361a4381c5a4
@@@ -45,7 -45,6 +45,7 @@@ extern "C" 
  #include "DNA_vec_types.h"
  #include "DNA_listBase.h"
  #include "DNA_ID.h"
 +#include "DNA_freestyle_types.h"
  
  struct Object;
  struct Brush;
@@@ -188,9 -187,6 +188,9 @@@ typedef struct SceneRenderLayer 
  
        int samples;
        int pad;
 +      
 +      struct FreestyleConfig freestyleConfig;
 +      
  } SceneRenderLayer;
  
  /* srl->layflag */
  #define SCE_LAY_EDGE  8
  #define SCE_LAY_SKY           16
  #define SCE_LAY_STRAND        32
 -      /* flags between 32 and 0x8000 are set to 1 already, for future options */
 +#define SCE_LAY_FRS           64
 +      /* flags between 64 and 0x8000 are set to 1 already, for future options */
  
  #define SCE_LAY_ALL_Z         0x8000
  #define SCE_LAY_XOR                   0x10000
@@@ -540,10 -535,6 +540,10 @@@ typedef struct RenderData 
        float pad2;
        struct Text *dometext  DNA_DEPRECATED;  //  XXX deprecated since 2.5
  
 +      /* Freestyle line thickness options */
 +      int line_thickness_mode;
 +      float unit_line_thickness; /* in pixels */
 +
        /* render engine */
        char engine[32];
  } RenderData;
@@@ -1018,7 -1009,7 +1018,7 @@@ typedef struct ToolSettings 
  
        /* Transform */
        char snap_mode, snap_node_mode;
-       char pad3;
+       char snap_uv_mode;
        short snap_flag, snap_target;
        short proportional, prop_mode;
        char proportional_objects; /* proportional edit, object mode */
@@@ -1317,10 -1308,6 +1317,10 @@@ typedef struct Scene 
  /* simplify_flag */
  #define R_SIMPLE_NO_TRIANGULATE               1
  
 +/* line_thickness_mode */
 +#define R_LINE_THICKNESS_ABSOLUTE 1
 +#define R_LINE_THICKNESS_RELATIVE 2
 +
  /* sequencer seq_prev_type seq_rend_type */
  
  
  
  /* Paint.flags */
  typedef enum {
 -      PAINT_SHOW_BRUSH = (1 << 0),
 -      PAINT_FAST_NAVIGATE = (1 << 1),
 -      PAINT_SHOW_BRUSH_ON_SURFACE = (1 << 2),
 +      PAINT_SHOW_BRUSH = (1<<0),
 +      PAINT_FAST_NAVIGATE = (1<<1),
 +      PAINT_SHOW_BRUSH_ON_SURFACE = (1<<2),
  } PaintFlags;
  
  /* Sculpt.flags */
@@@ -1515,7 -1502,6 +1515,7 @@@ typedef enum SculptFlags 
  #define EDGE_MODE_TAG_SHARP                           2
  #define EDGE_MODE_TAG_CREASE                  3
  #define EDGE_MODE_TAG_BEVEL                           4
 +#define EDGE_MODE_TAG_FREESTYLE                       5
  
  /* toolsettings->gpencil_flags */
  #define GP_TOOL_FLAG_PAINTSESSIONS_ON (1<<0)
index 0df6fc41269fc5068ff5edbb88268010dbb6e834,0e5f9c5fa5fd8fe68260b2dbffcfa5fffb2ce113..e22bffd7db7e6d57523f3797fe78d85f9466e116
@@@ -240,10 -240,6 +240,10 @@@ extern StructRNA RNA_FluidFluidSettings
  extern StructRNA RNA_FluidSettings;
  extern StructRNA RNA_FluidSimulationModifier;
  extern StructRNA RNA_FollowPathConstraint;
 +extern StructRNA RNA_FreestyleLineStyle;
 +extern StructRNA RNA_FreestyleLineSet;
 +extern StructRNA RNA_FreestyleModuleSettings;
 +extern StructRNA RNA_FreestyleSettings;
  extern StructRNA RNA_Function;
  extern StructRNA RNA_GPencilFrame;
  extern StructRNA RNA_GPencilLayer;
@@@ -300,37 -296,6 +300,37 @@@ extern StructRNA RNA_LimitDistanceConst
  extern StructRNA RNA_LimitLocationConstraint;
  extern StructRNA RNA_LimitRotationConstraint;
  extern StructRNA RNA_LimitScaleConstraint;
 +extern StructRNA RNA_LineStyleAlphaModifier;
 +extern StructRNA RNA_LineStyleAlphaModifier_AlongStroke;
 +extern StructRNA RNA_LineStyleAlphaModifier_DistanceFromCamera;
 +extern StructRNA RNA_LineStyleAlphaModifier_DistanceFromObject;
 +extern StructRNA RNA_LineStyleAlphaModifier_Material;
 +extern StructRNA RNA_LineStyleColorModifier;
 +extern StructRNA RNA_LineStyleColorModifier_AlongStroke;
 +extern StructRNA RNA_LineStyleColorModifier_DistanceFromCamera;
 +extern StructRNA RNA_LineStyleColorModifier_DistanceFromObject;
 +extern StructRNA RNA_LineStyleColorModifier_Material;
 +extern StructRNA RNA_LineStyleGeometryModifier;
 +extern StructRNA RNA_LineStyleGeometryModifier_2DOffset;
 +extern StructRNA RNA_LineStyleGeometryModifier_2DTransform;
 +extern StructRNA RNA_LineStyleGeometryModifier_BackboneStretcher;
 +extern StructRNA RNA_LineStyleGeometryModifier_BezierCurve;
 +extern StructRNA RNA_LineStyleGeometryModifier_Blueprint;
 +extern StructRNA RNA_LineStyleGeometryModifier_GuidingLines;
 +extern StructRNA RNA_LineStyleGeometryModifier_PerlinNoise1D;
 +extern StructRNA RNA_LineStyleGeometryModifier_PerlinNoise2D;
 +extern StructRNA RNA_LineStyleGeometryModifier_Polygonalization;
 +extern StructRNA RNA_LineStyleGeometryModifier_Sampling;
 +extern StructRNA RNA_LineStyleGeometryModifier_SinusDisplacement;
 +extern StructRNA RNA_LineStyleGeometryModifier_SpatialNoise;
 +extern StructRNA RNA_LineStyleGeometryModifier_TipRemover;
 +extern StructRNA RNA_LineStyleModifier;
 +extern StructRNA RNA_LineStyleThicknessModifier;
 +extern StructRNA RNA_LineStyleThicknessModifier_AlongStroke;
 +extern StructRNA RNA_LineStyleThicknessModifier_Calligraphy;
 +extern StructRNA RNA_LineStyleThicknessModifier_DistanceFromCamera;
 +extern StructRNA RNA_LineStyleThicknessModifier_DistanceFromObject;
 +extern StructRNA RNA_LineStyleThicknessModifier_Material;
  extern StructRNA RNA_LockedTrackConstraint;
  extern StructRNA RNA_Macro;
  extern StructRNA RNA_MagicTexture;
@@@ -897,6 -862,7 +897,7 @@@ int RNA_path_resolve_full(PointerRNA *p
  
  char *RNA_path_from_ID_to_struct(PointerRNA *ptr);
  char *RNA_path_from_ID_to_property(PointerRNA *ptr, PropertyRNA *prop);
+ char *RNA_path_from_ID_python(struct ID *id);
  
  /* Quick name based property access
   *
index ffcca772764dfd0538583db08f531d9005ba1ec0,6f3a483cf7e5f3538f26d7855c844f013ef003c8..6527fe29263878dc2ea81ae32d42b8b6879fd35f
@@@ -38,7 -38,6 +38,7 @@@
  #include "DNA_scene_types.h"
  #include "DNA_userdef_types.h"
  #include "DNA_world_types.h"
 +#include "DNA_linestyle_types.h"
  
  #include "BLI_math.h"
  
@@@ -146,6 -145,11 +146,11 @@@ EnumPropertyItem snap_node_element_item
        {0, NULL, 0, NULL, NULL}
  };
  
+ EnumPropertyItem snap_uv_element_items[] = {
+       {SCE_SNAP_MODE_INCREMENT, "INCREMENT", ICON_SNAP_INCREMENT, "Increment", "Snap to increments of grid"},
+       {SCE_SNAP_MODE_VERTEX, "VERTEX", ICON_SNAP_VERTEX, "Vertex", "Snap to vertices"},
+       {0, NULL, 0, NULL, NULL}
+ };
  
  /* workaround for duplicate enums,
   * have each enum line as a defne then conditionally set it or not
@@@ -325,8 -329,6 +330,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);
@@@ -1438,49 -1440,6 +1443,49 @@@ static void rna_SceneSequencer_update(M
        BKE_sequencer_preprocessed_cache_cleanup();
  }
  
 +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)
@@@ -1548,7 -1507,6 +1553,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}
        };
  
        RNA_def_property_enum_items(prop, snap_node_element_items);
        RNA_def_property_ui_text(prop, "Snap Node Element", "Type of element to snap to");
        RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); /* header redraw */
+       
+       /* image editor uses own set of snap modes */
+       prop = RNA_def_property(srna, "snap_uv_element", PROP_ENUM, PROP_NONE);
+       RNA_def_property_enum_sdna(prop, NULL, "snap_uv_mode");
+       RNA_def_property_enum_items(prop, snap_uv_element_items);
+       RNA_def_property_ui_text(prop, "Snap UV Element", "Type of element to snap to");
+       RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); /* header redraw */
  
        prop = RNA_def_property(srna, "snap_target", PROP_ENUM, PROP_NONE);
        RNA_def_property_enum_sdna(prop, NULL, "snap_target");
                                 "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)");
@@@ -2090,12 -2055,6 +2102,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_valley", PROP_BOOLEAN, PROP_NONE);
 +      RNA_def_property_boolean_sdna(prop, NULL, "edge_types", FREESTYLE_FE_RIDGE_VALLEY);
 +      RNA_def_property_ui_text(prop, "Ridge & Valley", "Select ridges and 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_valley", PROP_BOOLEAN, PROP_NONE);
 +      RNA_def_property_boolean_sdna(prop, NULL, "exclude_edge_types", FREESTYLE_FE_RIDGE_VALLEY);
 +      RNA_def_property_ui_text(prop, "Ridge & Valley", "Exclude ridges and 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_culling", PROP_BOOLEAN, PROP_NONE);
 +      RNA_def_property_boolean_sdna(prop, NULL, "flags", FREESTYLE_CULLING);
 +      RNA_def_property_ui_text(prop, "Culling", "If enabled, out-of-view edges are ignored");
 +      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, "use_advanced_options", PROP_BOOLEAN, PROP_NONE);
 +      RNA_def_property_boolean_sdna(prop, NULL, "flags", FREESTYLE_ADVANCED_OPTIONS_FLAG);
 +      RNA_def_property_ui_text(prop, "Advanced Edge Detection Options", "Enable advanced edge detection options (sphere radius and Kr derivative epsilon)");
 +      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, -1000.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;
@@@ -3203,7 -2789,6 +3215,7 @@@ 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_path_func(srna, "rna_SceneRenderLayer_path");
  
        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 */
@@@ -3804,11 -3379,6 +3816,11 @@@ static void rna_def_scene_render_data(B
                {0, NULL, 0, NULL, NULL}
        };
  
 +      static EnumPropertyItem freestyle_thickness_items[] = {
 +              {R_LINE_THICKNESS_ABSOLUTE, "ABSOLUTE", 0, "Absolute", "Specify unit line thickness in pixels"},
 +              {R_LINE_THICKNESS_RELATIVE, "RELATIVE", 0, "Relative", "Unit line thickness is scaled by the proportion of the present vertical image resolution to 480 pixels"},
 +              {0, NULL, 0, NULL, NULL}};
 +
        rna_def_scene_ffmpeg_settings(brna);
  #ifdef WITH_QUICKTIME
        rna_def_scene_quicktime_settings(brna);
        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");
        RNA_def_property_ui_text(prop, "Persistent Data", "Keep render data around for faster re-renders");
        RNA_def_property_update(prop, 0, "rna_Scene_use_persistent_data_update");
  
 +      /* Freestyle line thickness options */
 +      prop = RNA_def_property(srna, "line_thickness_mode", PROP_ENUM, PROP_NONE);
 +      RNA_def_property_enum_sdna(prop, NULL, "line_thickness_mode");
 +      RNA_def_property_enum_items(prop, freestyle_thickness_items);
 +      RNA_def_property_ui_text(prop, "Line Thickness Mode", "Line thickness mode for Freestyle line drawing");
 +
 +      prop = RNA_def_property(srna, "unit_line_thickness", PROP_FLOAT, PROP_NONE);
 +      RNA_def_property_float_sdna(prop, NULL, "unit_line_thickness");
 +      RNA_def_property_range(prop, 0.f, 10000.f);
 +      RNA_def_property_ui_text(prop, "Unit Line Thickness", "Unit line thickness in pixels");
 +
        /* Scene API */
        RNA_api_scene_render(srna);
  }
index 2aa907b72f2725d5c9cb645ebf4ebabeea7e879f,2b2e8d97499be49302c0dbe8186eda1f3ab86175..c928e91ea1f27c82106a85434b6900bf66a879a5
@@@ -1914,7 -1914,6 +1914,7 @@@ static void rna_def_space_buttons(Blend
        static EnumPropertyItem buttons_context_items[] = {
                {BCONTEXT_SCENE, "SCENE", ICON_SCENE, "Scene", "Scene"},
                {BCONTEXT_RENDER, "RENDER", ICON_SCENE_DATA, "Render", "Render"},
 +              {BCONTEXT_RENDER_LAYER, "RENDER_LAYER", ICON_RENDERLAYERS, "Render Layers", "Render Layers"},
                {BCONTEXT_WORLD, "WORLD", ICON_WORLD, "World", "World"},
                {BCONTEXT_OBJECT, "OBJECT", ICON_OBJECT_DATA, "Object", "Object"},
                {BCONTEXT_CONSTRAINT, "CONSTRAINT", ICON_CONSTRAINT, "Constraints", "Constraints"},
@@@ -2977,10 -2976,9 +2977,9 @@@ static void rna_def_space_node(BlenderR
                {SNODE_USE_ALPHA, "COLOR_ALPHA", ICON_IMAGE_RGB_ALPHA, "Color and Alpha",
                                  "Draw image with RGB colors and alpha transparency"},
                {SNODE_SHOW_ALPHA, "ALPHA", ICON_IMAGE_ALPHA, "Alpha", "Draw alpha transparency channel"},
-                                       /* XXX, we could use better icons here  */
-               {SNODE_SHOW_R, "RED",   ICON_COLOR, "Red", ""},
-               {SNODE_SHOW_G, "GREEN", ICON_COLOR, "Green", ""},
-               {SNODE_SHOW_B, "BLUE",  ICON_COLOR, "Blue", ""},
+               {SNODE_SHOW_R, "RED",   ICON_COLOR_RED, "Red", ""},
+               {SNODE_SHOW_G, "GREEN", ICON_COLOR_GREEN, "Green", ""},
+               {SNODE_SHOW_B, "BLUE",  ICON_COLOR_BLUE, "Blue", ""},
                {0, NULL, 0, NULL, NULL}
        };
  
index 50341c84b8f56099ceca395b7f7dcb19a6671576,7be34c398aefbc8d792034293a10f9f604468bf2..59a3a8c2522a5e50bffa000b823d06cea5ff7e4c
@@@ -144,6 -144,12 +144,12 @@@ static void rna_userdef_anisotropic_upd
        rna_userdef_update(bmain, scene, ptr);
  }
  
+ static void rna_userdef_gl_gpu_mipmaps(Main *bmain, Scene *scene, PointerRNA *ptr)
+ {
+       GPU_set_gpu_mipmapping(U.use_gpu_mipmap);
+       rna_userdef_update(bmain, scene, ptr);
+ }
  static void rna_userdef_gl_texture_limit_update(Main *bmain, Scene *scene, PointerRNA *ptr)
  {
        GPU_free_images();
@@@ -956,11 -962,6 +962,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)
@@@ -3228,6 -3224,11 +3234,11 @@@ static void rna_def_userdef_system(Blen
        RNA_def_property_ui_text(prop, "16 Bit Float Textures", "Use 16 bit per component texture for float images");
        RNA_def_property_update(prop, 0, "rna_userdef_gl_use_16bit_textures");
  
+       prop = RNA_def_property(srna, "use_gpu_mipmap", PROP_BOOLEAN, PROP_NONE);
+       RNA_def_property_boolean_sdna(prop, NULL, "use_gpu_mipmap", 1);
+       RNA_def_property_ui_text(prop, "GPU Mipmap Generation", "Generate Image Mipmaps on the GPU");
+       RNA_def_property_update(prop, 0, "rna_userdef_gl_gpu_mipmaps");
        prop = RNA_def_property(srna, "use_vertex_buffer_objects", PROP_BOOLEAN, PROP_NONE);
        RNA_def_property_boolean_negative_sdna(prop, NULL, "gameflags", USER_DISABLE_VBO);
        RNA_def_property_ui_text(prop, "VBOs",