Merged changes in the trunk up to revision 41768.
authorTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>
Sat, 12 Nov 2011 23:12:30 +0000 (23:12 +0000)
committerTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>
Sat, 12 Nov 2011 23:12:30 +0000 (23:12 +0000)
Conflicts resolved:
source/blender/makesdna/intern/makesdna.c
source/blender/makesrna/RNA_enum_types.h
source/blender/render/intern/source/shadeinput.c
source/blenderplayer/bad_level_call_stubs/stubs.c

Additional changes:

* source/blender/makesrna/intern/rna_linestyle.c: Fixed white
space issues that generated a number of compiler errors.  The
problem was that two string literals for enumerating MA_RAMP_SOFT
and MA_RAMP_LINEAR contained a space.  The string literals are
supposed to represent a valid C identifier because of their use
for automatic code generation.

* Stroke transparency has been temporarily disabled due to a
functionality conflict with some merged changes.  A fix of this
issue is planned.

39 files changed:
1  2 
build_files/scons/tools/Blender.py
release/scripts/startup/bl_ui/space_view3d.py
source/blender/CMakeLists.txt
source/blender/SConscript
source/blender/blenkernel/CMakeLists.txt
source/blender/blenkernel/intern/DerivedMesh.c
source/blender/blenkernel/intern/cdderivedmesh.c
source/blender/blenkernel/intern/library.c
source/blender/blenkernel/intern/object.c
source/blender/blenkernel/intern/subsurf_ccg.c
source/blender/blenloader/intern/readfile.c
source/blender/blenloader/intern/writefile.c
source/blender/editors/interface/interface_templates.c
source/blender/editors/interface/resources.c
source/blender/editors/mesh/editmesh_mods.c
source/blender/editors/mesh/editmesh_tools.c
source/blender/editors/space_view3d/drawobject.c
source/blender/editors/transform/transform.c
source/blender/editors/transform/transform_orientations.c
source/blender/makesdna/DNA_ID.h
source/blender/makesdna/intern/makesdna.c
source/blender/makesrna/RNA_access.h
source/blender/makesrna/RNA_enum_types.h
source/blender/makesrna/SConscript
source/blender/makesrna/intern/CMakeLists.txt
source/blender/makesrna/intern/makesrna.c
source/blender/makesrna/intern/rna_internal.h
source/blender/makesrna/intern/rna_linestyle.c
source/blender/makesrna/intern/rna_mesh.c
source/blender/makesrna/intern/rna_scene.c
source/blender/makesrna/intern/rna_userdef.c
source/blender/python/SConscript
source/blender/python/intern/CMakeLists.txt
source/blender/render/extern/include/RE_pipeline.h
source/blender/render/intern/source/convertblender.c
source/blender/render/intern/source/pipeline.c
source/blender/render/intern/source/shadeoutput.c
source/blenderplayer/bad_level_call_stubs/stubs.c
source/creator/CMakeLists.txt

index ae2d5298298e60cb6407b94353803b58888d0a24,71a4af1dc36c5366040f08858180bbe68c8b9e38..9e967ac5a4da08da349890d541ba0fa651c80796
@@@ -195,8 -195,13 +195,13 @@@ def setup_staticlibs(lenv)
              
      if lenv['WITH_BF_OIIO']:
          libincs += Split(lenv['BF_OIIO_LIBPATH'])
+         if lenv['WITH_BF_STATICOIIO']:
+             statlibs += Split(lenv['BF_OIIO_LIB_STATIC'])
      if lenv['WITH_BF_BOOST']:
          libincs += Split(lenv['BF_BOOST_LIBPATH'])
+         if lenv['WITH_BF_STATICBOOST']:
+             statlibs += Split(lenv['BF_BOOST_LIB_STATIC'])
  
      # setting this last so any overriding of manually libs could be handled
      if lenv['OURPLATFORM'] not in ('win32-vc', 'win32-mingw', 'win64-vc', 'linuxcross'):
      return statlibs, libincs
  
  def setup_syslibs(lenv):
-     syslibs = [
-         
-         lenv['BF_JPEG_LIB'],
-         lenv['BF_PNG_LIB'],
-         ]
+     syslibs = []
  
      if not lenv['WITH_BF_FREETYPE_STATIC']:
          syslibs += Split(lenv['BF_FREETYPE_LIB'])
              syslibs += ['gomp']
      if lenv['WITH_BF_ICONV']:
          syslibs += Split(lenv['BF_ICONV_LIB'])
+     if lenv['WITH_BF_OIIO']:
+         if not lenv['WITH_BF_STATICOIIO']:
+             syslibs += Split(lenv['BF_OIIO_LIB'])
      if lenv['WITH_BF_OPENEXR'] and not lenv['WITH_BF_STATICOPENEXR']:
          syslibs += Split(lenv['BF_OPENEXR_LIB'])
      if lenv['WITH_BF_TIFF'] and not lenv['WITH_BF_STATICTIFF']:
          if lenv['WITH_BF_3DMOUSE']:
              if not lenv['WITH_BF_STATIC3DMOUSE']:
                  syslibs += Split(lenv['BF_3DMOUSE_LIB'])
-     if lenv['WITH_BF_OIIO']:
-         syslibs += Split(lenv['BF_OIIO_LIB'])
-     if lenv['WITH_BF_BOOST']:
+                 
+     if lenv['WITH_BF_BOOST'] and not lenv['WITH_BF_STATICBOOST']:
          syslibs += Split(lenv['BF_BOOST_LIB'])
  
+     syslibs += Split(lenv['BF_JPEG_LIB'])
+     syslibs += Split(lenv['BF_PNG_LIB'])
+       
      syslibs += lenv['LLIBS']
  
      return syslibs
@@@ -309,7 -315,7 +315,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 = []
      if env['WITH_BF_QUICKTIME']:
@@@ -550,10 -556,6 +556,6 @@@ def AppIt(target=None, source=None, env
      bldroot = env.Dir('.').abspath
      binary = env['BINARYKIND']
       
-     if b=='verse':
-         print bc.OKBLUE+"no bundle for verse"+bc.ENDC 
-         return 0
-     
      sourcedir = bldroot + '/source/darwin/%s.app'%binary
      sourceinfo = bldroot + "/source/darwin/%s.app/Contents/Info.plist"%binary
      targetinfo = installdir +'/' + "%s.app/Contents/Info.plist"%binary
          commands.getoutput(cmd)
          cmd = 'cp -R %s/release/scripts %s/%s.app/Contents/MacOS/%s/'%(bldroot,installdir,binary,VERSION)
          commands.getoutput(cmd)
+         if env['WITH_BF_CYCLES']:
+             croot = '%s/intern/cycles' % (bldroot)
+             cinstalldir = '%s/%s.app/Contents/MacOS/%s/scripts/addons/cycles' % (installdir,binary,VERSION)
+             cmd = 'mkdir %s' % (cinstalldir)
+             commands.getoutput(cmd)
+             cmd = 'mkdir %s/kernel' % (cinstalldir)
+             commands.getoutput(cmd)
+             cmd = 'cp -R %s/blender/addon/*.py %s/' % (croot, cinstalldir)
+             commands.getoutput(cmd)
+             cmd = 'cp -R %s/doc/license %s/license' % (croot, cinstalldir)
+             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)
+             commands.getoutput(cmd)
  
      if env['WITH_OSX_STATICPYTHON']:
          cmd = 'mkdir %s/%s.app/Contents/MacOS/%s/python/'%(installdir,binary, VERSION)
index e5eccb4d9408e73ae9f9797b2510e759c1a82567,9ca542103ad952a91662e869c264818643fff084..1314401a1ef4b5d8ed0a1d80743d894143e30912
@@@ -1537,10 -1537,10 +1537,10 @@@ class VIEW3D_MT_edit_mesh_extrude(Menu)
      bl_label = "Extrude"
  
      _extrude_funcs = {
-         "VERT": lambda layout: layout.operator("mesh.extrude_vertices_move", text="Vertices Only"),
-         "EDGE": lambda layout: layout.operator("mesh.extrude_edges_move", text="Edges Only"),
-         "FACE": lambda layout: layout.operator("mesh.extrude_faces_move", text="Individual Faces"),
-         "REGION": lambda layout: layout.operator("view3d.edit_mesh_extrude_move_normal", text="Region"),
+         'VERT': lambda layout: layout.operator("mesh.extrude_vertices_move", text="Vertices Only"),
+         'EDGE': lambda layout: layout.operator("mesh.extrude_edges_move", text="Edges Only"),
+         'FACE': lambda layout: layout.operator("mesh.extrude_faces_move", text="Individual Faces"),
+         'REGION': lambda layout: layout.operator("view3d.edit_mesh_extrude_move_normal", text="Region"),
      }
  
      @staticmethod
  
          menu = []
          if mesh.total_face_sel:
-             menu += ["REGION", "FACE"]
+             menu += ['REGION', 'FACE']
          if mesh.total_edge_sel and (select_mode[0] or select_mode[1]):
-             menu += ["EDGE"]
+             menu += ['EDGE']
          if mesh.total_vert_sel and select_mode[0]:
-             menu += ["VERT"]
+             menu += ['VERT']
  
          # should never get here
          return menu
@@@ -1621,11 -1621,6 +1621,11 @@@ class VIEW3D_MT_edit_mesh_edges(Menu)
  
          layout.separator()
  
 +        layout.operator("mesh.mark_freestyle_edge")
 +        layout.operator("mesh.mark_freestyle_edge", text="Clear Freestyle Edge").clear = True
 +
 +        layout.separator()
 +
          layout.operator("mesh.edge_rotate", text="Rotate Edge CW").direction = 'CW'
          layout.operator("mesh.edge_rotate", text="Rotate Edge CCW").direction = 'CCW'
  
@@@ -1668,11 -1663,6 +1668,11 @@@ class VIEW3D_MT_edit_mesh_faces(Menu)
  
          layout.separator()
  
 +        layout.operator("mesh.mark_freestyle_face")
 +        layout.operator("mesh.mark_freestyle_face", text="Clear Freestyle Face").clear = True
 +
 +        layout.separator()
 +
          layout.operator("mesh.quads_convert_to_tris")
          layout.operator("mesh.tris_convert_to_quads")
          layout.operator("mesh.edge_flip")
@@@ -2222,8 -2212,6 +2222,8 @@@ class VIEW3D_PT_view3d_meshdisplay(Pane
          col.prop(mesh, "show_edge_bevel_weight", text="Bevel Weights")
          col.prop(mesh, "show_edge_seams", text="Seams")
          col.prop(mesh, "show_edge_sharp", text="Sharp")
 +        col.prop(mesh, "show_freestyle_edge_marks", text="Freestyle Edge Marks")
 +        col.prop(mesh, "show_freestyle_face_marks", text="Freestyle Face Marks")
  
          col.separator()
          col.label(text="Normals:")
index df293ecbf41476043f0a1c86ddbdb3d5197ea7b1,e52b5b89aa016c39535f9fe53ad4d1d0cc75a83e..6a6e71eac227395de7c844d25c4861bc64019016
@@@ -39,6 -39,7 +39,7 @@@ set(SRC_DNA_IN
        ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_curve_types.h
        ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_customdata_types.h
        ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_documentation.h
+       ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_dynamicpaint_types.h
        ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_effect_types.h
        ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_fileglobal_types.h
        ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_genfile.h
@@@ -49,7 -50,6 +50,7 @@@
        ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_key_types.h
        ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_lamp_types.h
        ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_lattice_types.h
 +      ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_linestyle_types.h
        ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_listBase.h
        ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_material_types.h
        ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_mesh_types.h
@@@ -103,7 -103,6 +104,7 @@@ add_subdirectory(nodes
  add_subdirectory(modifiers)
  add_subdirectory(makesdna)
  add_subdirectory(makesrna)
 +ADD_SUBDIRECTORY(freestyle)
  
  if(WITH_IMAGE_OPENEXR)
        add_subdirectory(imbuf/intern/openexr)
index ed69c9e57e9b238ce6ba2708f50364411c11d8ce,ea5101f811110ff08d48cff99a450243e8efe895..1fe815849dbcf5d88b27074999019962003aa306
@@@ -9,10 -9,8 +9,9 @@@ SConscript(['avi/SConscript'
              'blenpluginapi/SConscript',
              'gpu/SConscript',
              'editors/SConscript',
 +                      'freestyle/SConscript',
              'imbuf/SConscript',
              'makesdna/SConscript',
-             'makesrna/SConscript',
              'render/SConscript',
              'nodes/SConscript',
              'modifiers/SConscript',
@@@ -20,7 -18,7 +19,7 @@@
              'windowmanager/SConscript',
              'blenfont/SConscript'])
  
+ makesrna = SConscript('makesrna/SConscript')
  
  if env['WITH_BF_PYTHON']:
      SConscript(['python/SConscript'])
index ffa3555e40bdf98140d471754382faef18c3bc58,1fc851bfa72a5f88343b345a46036d70162256c8..4f909a59e8e42e8bc689d28c3577b3c7797f4264
@@@ -29,7 -29,6 +29,7 @@@ set(IN
        ../blenfont
        ../blenlib
        ../blenloader
 +      ../freestyle
        ../gpu
        ../ikplugin
        ../imbuf
@@@ -90,6 -89,7 +90,7 @@@ set(SR
        intern/deform.c
        intern/depsgraph.c
        intern/displist.c
+       intern/dynamicpaint.c
        intern/effect.c
        intern/fcurve.c
        intern/fluidsim.c
        intern/lamp.c
        intern/lattice.c
        intern/library.c
 +      intern/linestyle.c
        intern/material.c
        intern/mball.c
        intern/mesh.c
        BKE_deform.h
        BKE_depsgraph.h
        BKE_displist.h
+       BKE_dynamicpaint.h
        BKE_effect.h
        BKE_fcurve.h
        BKE_fluidsim.h
        BKE_lamp.h
        BKE_lattice.h
        BKE_library.h
 +      BKE_linestyle.h
        BKE_main.h
        BKE_material.h
        BKE_mball.h
index 964ba18ca4059fbdfb142644fc172bcee21a04a2,4400c895b78a2d98996b00a48e27e861e7b1f866..a76ea1852ded4f636c20712ff65c2bc05e86d3ba
@@@ -1123,6 -1123,140 +1123,140 @@@ static void emDM_drawFacesGLSL(DerivedM
        dm->drawMappedFacesGLSL(dm, setMaterial, NULL, NULL);
  }
  
+ static void emDM_drawMappedFacesMat(DerivedMesh *dm,
+                          void (*setMaterial)(void *userData, int, void *attribs),
+                          int (*setFace)(void *userData, int index), void *userData) 
+ {
+       EditMeshDerivedMesh *emdm= (EditMeshDerivedMesh*) dm;
+       EditMesh *em= emdm->em;
+       float (*vertexCos)[3]= emdm->vertexCos;
+       float (*vertexNos)[3]= emdm->vertexNos;
+       EditVert *eve;
+       EditFace *efa;
+       DMVertexAttribs attribs= {{{0}}};
+       GPUVertexAttribs gattribs;
+       int i, b, matnr, new_matnr;
+       matnr = -1;
+       /* always use smooth shading even for flat faces, else vertex colors wont interpolate */
+       glShadeModel(GL_SMOOTH);
+       for (i=0,eve=em->verts.first; eve; eve= eve->next)
+               eve->tmp.l = (intptr_t) i++;
+ #define PASSATTRIB(efa, eve, vert) {                                                                                  \
+       if(attribs.totorco) {                                                                                                           \
+               float *orco = attribs.orco.array[eve->tmp.l];                                                   \
+               if(attribs.orco.glTexco)                                                                                                \
+                       glTexCoord3fv(orco);                                                                                            \
+               else                                                                                                                                    \
+                       glVertexAttrib3fvARB(attribs.orco.glIndex, orco);                                       \
+       }                                                                                                                                                       \
+       for(b = 0; b < attribs.tottface; b++) {                                                                         \
+               MTFace *_tf = (MTFace*)((char*)efa->data + attribs.tface[b].emOffset);  \
+               if(attribs.tface[b].glTexco)                                                                                    \
+                       glTexCoord2fv(_tf->uv[vert]);                                                                           \
+               else                                                                                                                                    \
+                       glVertexAttrib2fvARB(attribs.tface[b].glIndex, _tf->uv[vert]);          \
+       }                                                                                                                                                       \
+       for(b = 0; b < attribs.totmcol; b++) {                                                                          \
+               MCol *cp = (MCol*)((char*)efa->data + attribs.mcol[b].emOffset);                \
+               GLubyte col[4];                                                                                                                 \
+               col[0]= cp->b; col[1]= cp->g; col[2]= cp->r; col[3]= cp->a;                             \
+               glVertexAttrib4ubvARB(attribs.mcol[b].glIndex, col);                                    \
+       }                                                                                                                                                       \
+       if(attribs.tottang) {                                                                                                           \
+               float *tang = attribs.tang.array[i*4 + vert];                                                   \
+               glVertexAttrib4fvARB(attribs.tang.glIndex, tang);                                               \
+       }                                                                                                                                                       \
+ }
+       for (i=0,efa= em->faces.first; efa; i++,efa= efa->next) {
+               int drawSmooth= (efa->flag & ME_SMOOTH);
+               /* face hiding */
+               if(setFace && !setFace(userData, i))
+                       continue;
+               /* material */
+               new_matnr = efa->mat_nr + 1;
+               if(new_matnr != matnr) {
+                       setMaterial(userData, matnr = new_matnr, &gattribs);
+                       DM_vertex_attributes_from_gpu(dm, &gattribs, &attribs);
+               }
+               /* face */
+               glBegin(efa->v4?GL_QUADS:GL_TRIANGLES);
+               if (!drawSmooth) {
+                       if(vertexCos) glNormal3fv(emdm->faceNos[i]);
+                       else glNormal3fv(efa->n);
+                       PASSATTRIB(efa, efa->v1, 0);
+                       if(vertexCos) glVertex3fv(vertexCos[(int) efa->v1->tmp.l]);
+                       else glVertex3fv(efa->v1->co);
+                       PASSATTRIB(efa, efa->v2, 1);
+                       if(vertexCos) glVertex3fv(vertexCos[(int) efa->v2->tmp.l]);
+                       else glVertex3fv(efa->v2->co);
+                       PASSATTRIB(efa, efa->v3, 2);
+                       if(vertexCos) glVertex3fv(vertexCos[(int) efa->v3->tmp.l]);
+                       else glVertex3fv(efa->v3->co);
+                       if(efa->v4) {
+                               PASSATTRIB(efa, efa->v4, 3);
+                               if(vertexCos) glVertex3fv(vertexCos[(int) efa->v4->tmp.l]);
+                               else glVertex3fv(efa->v4->co);
+                       }
+               } else {
+                       PASSATTRIB(efa, efa->v1, 0);
+                       if(vertexCos) {
+                               glNormal3fv(vertexNos[(int) efa->v1->tmp.l]);
+                               glVertex3fv(vertexCos[(int) efa->v1->tmp.l]);
+                       }
+                       else {
+                               glNormal3fv(efa->v1->no);
+                               glVertex3fv(efa->v1->co);
+                       }
+                       PASSATTRIB(efa, efa->v2, 1);
+                       if(vertexCos) {
+                               glNormal3fv(vertexNos[(int) efa->v2->tmp.l]);
+                               glVertex3fv(vertexCos[(int) efa->v2->tmp.l]);
+                       }
+                       else {
+                               glNormal3fv(efa->v2->no);
+                               glVertex3fv(efa->v2->co);
+                       }
+                       PASSATTRIB(efa, efa->v3, 2);
+                       if(vertexCos) {
+                               glNormal3fv(vertexNos[(int) efa->v3->tmp.l]);
+                               glVertex3fv(vertexCos[(int) efa->v3->tmp.l]);
+                       }
+                       else {
+                               glNormal3fv(efa->v3->no);
+                               glVertex3fv(efa->v3->co);
+                       }
+                       if(efa->v4) {
+                               PASSATTRIB(efa, efa->v4, 3);
+                               if(vertexCos) {
+                                       glNormal3fv(vertexNos[(int) efa->v4->tmp.l]);
+                                       glVertex3fv(vertexCos[(int) efa->v4->tmp.l]);
+                               }
+                               else {
+                                       glNormal3fv(efa->v4->no);
+                                       glVertex3fv(efa->v4->co);
+                               }
+                       }
+               }
+               glEnd();
+       }
+ #undef PASSATTRIB
+ }
  static void emDM_getMinMax(DerivedMesh *dm, float min_r[3], float max_r[3])
  {
        EditMeshDerivedMesh *emdm= (EditMeshDerivedMesh*) dm;
@@@ -1207,7 -1341,6 +1341,7 @@@ static void emDM_getEdge(DerivedMesh *d
        edge_r->flag = ME_EDGEDRAW|ME_EDGERENDER;
        if (ee->seam) edge_r->flag |= ME_SEAM;
        if (ee->sharp) edge_r->flag |= ME_SHARP;
 +      if (ee->freestyle) edge_r->flag |= ME_FREESTYLE_EDGE;
  #if 0
        /* this needs setup of f2 field */
        if (!ee->f2) edge_r->flag |= ME_LOOSEEDGE;
@@@ -1308,7 -1441,6 +1442,7 @@@ static void emDM_copyEdgeArray(DerivedM
                edge_r->flag = ME_EDGEDRAW|ME_EDGERENDER;
                if (ee->seam) edge_r->flag |= ME_SEAM;
                if (ee->sharp) edge_r->flag |= ME_SHARP;
 +              if (ee->freestyle) edge_r->flag |= ME_FREESTYLE_EDGE;
  #if 0
                /* this needs setup of f2 field */
                if (!ee->f2) edge_r->flag |= ME_LOOSEEDGE;
@@@ -1431,6 -1563,7 +1565,7 @@@ DerivedMesh *editmesh_get_derived(EditM
        emdm->dm.drawMappedFacesGLSL = emDM_drawMappedFacesGLSL;
        emdm->dm.drawFacesTex = emDM_drawFacesTex;
        emdm->dm.drawFacesGLSL = emDM_drawFacesGLSL;
+       emdm->dm.drawMappedFacesMat = emDM_drawMappedFacesMat;
        emdm->dm.drawUVEdges = emDM_drawUVEdges;
  
        emdm->dm.release = emDM_release;
@@@ -1788,7 -1921,7 +1923,7 @@@ static void mesh_calc_modifiers(Scene *
        Mesh *me = ob->data;
        ModifierData *firstmd, *md;
        LinkNode *datamasks, *curr;
-       CustomDataMask mask, nextmask;
+       CustomDataMask mask, nextmask, append_mask = 0;
        float (*deformedVerts)[3] = NULL;
        DerivedMesh *dm, *orcodm, *clothorcodm, *finaldm;
        int numVerts = me->totvert;
                        mask= (CustomDataMask)GET_INT_FROM_POINTER(curr->link);
                        /* needMapping check here fixes bug [#28112], otherwise its
                         * possible that it wont be copied */
+                       mask |= append_mask;
                        DM_set_only_copy(dm, mask | (needMapping ? CD_MASK_ORIGINDEX : 0));
                        
                        /* add cloth rest shape key if need */
                                        clothorcodm = ndm;
                                }
                        }
+                       /* in case of dynamic paint, make sure preview mask remains for following modifiers */
+                       if (md->type == eModifierType_DynamicPaint)
+                               append_mask |= CD_MASK_WEIGHT_MCOL;
                }
  
                isPrevDeform= (mti->type == eModifierTypeType_OnlyDeform);
index e758f5a048761fbb796d9b11edc86787ba48ed26,1e38f666da790dc6e45a00873b3e373fe7145ce5..eaf2afdcfb652292ffadfb943d2e7ec9fda8036a
@@@ -231,7 -231,7 +231,7 @@@ static struct PBVH *cdDM_getPBVH(Objec
                cddm->pbvh = BLI_pbvh_new();
                cddm->pbvh_draw = can_pbvh_draw(ob, dm);
                BLI_pbvh_build_mesh(cddm->pbvh, me->mface, me->mvert,
-                                  me->totface, me->totvert);
+                                   me->totface, me->totvert);
  
                if(ss->modifiers_active && ob->derivedDeform) {
                        DerivedMesh *deformdm= ob->derivedDeform;
@@@ -878,7 -878,9 +878,9 @@@ static void cdDM_drawMappedFaces(Derive
                                if(useColors && mc)
                                        cp = (unsigned char *)&mc[i * 4];
  
-                               glShadeModel(drawSmooth?GL_SMOOTH:GL_FLAT);
+                               /* no need to set shading mode to flat because
+                               *  normals are already used to change shading */
+                               glShadeModel(GL_SMOOTH);
                                glBegin(mf->v4?GL_QUADS:GL_TRIANGLES);
  
                                if (!drawSmooth) {
@@@ -1351,6 -1353,85 +1353,85 @@@ static void cdDM_drawFacesGLSL(DerivedM
        dm->drawMappedFacesGLSL(dm, setMaterial, NULL, NULL);
  }
  
+ static void cdDM_drawMappedFacesMat(DerivedMesh *dm,
+       void (*setMaterial)(void *userData, int, void *attribs),
+       int (*setFace)(void *userData, int index), void *userData)
+ {
+       CDDerivedMesh *cddm = (CDDerivedMesh*) dm;
+       GPUVertexAttribs gattribs;
+       DMVertexAttribs attribs;
+       MVert *mvert = cddm->mvert;
+       MFace *mf = cddm->mface;
+       float (*nors)[3] = dm->getFaceDataArray(dm, CD_NORMAL);
+       int a, matnr, new_matnr;
+       int orig, *index = dm->getFaceDataArray(dm, CD_ORIGINDEX);
+       cdDM_update_normals_from_pbvh(dm);
+       matnr = -1;
+       glShadeModel(GL_SMOOTH);
+       memset(&attribs, 0, sizeof(attribs));
+       glBegin(GL_QUADS);
+       for(a = 0; a < dm->numFaceData; a++, mf++) {
+               const int smoothnormal = (mf->flag & ME_SMOOTH);
+               /* material */
+               new_matnr = mf->mat_nr + 1;
+               if(new_matnr != matnr) {
+                       glEnd();
+                       setMaterial(userData, matnr = new_matnr, &gattribs);
+                       DM_vertex_attributes_from_gpu(dm, &gattribs, &attribs);
+                       glBegin(GL_QUADS);
+               }
+               /* skipping faces */
+               if(setFace) {
+                       orig = (index)? index[a]: a;
+                       if(orig != ORIGINDEX_NONE && !setFace(userData, orig))
+                               continue;
+               }
+               /* smooth normal */
+               if(!smoothnormal) {
+                       if(nors) {
+                               glNormal3fv(nors[a]);
+                       }
+                       else {
+                               /* TODO ideally a normal layer should always be available */
+                               float nor[3];
+                               if(mf->v4)
+                                       normal_quad_v3( nor,mvert[mf->v1].co, mvert[mf->v2].co, mvert[mf->v3].co, mvert[mf->v4].co);
+                               else
+                                       normal_tri_v3( nor,mvert[mf->v1].co, mvert[mf->v2].co, mvert[mf->v3].co);
+                               glNormal3fv(nor);
+                       }
+               }
+               /* vertices */
+               cddm_draw_attrib_vertex(&attribs, mvert, a, mf->v1, 0, smoothnormal);
+               cddm_draw_attrib_vertex(&attribs, mvert, a, mf->v2, 1, smoothnormal);
+               cddm_draw_attrib_vertex(&attribs, mvert, a, mf->v3, 2, smoothnormal);
+               if(mf->v4)
+                       cddm_draw_attrib_vertex(&attribs, mvert, a, mf->v4, 3, smoothnormal);
+               else
+                       cddm_draw_attrib_vertex(&attribs, mvert, a, mf->v3, 2, smoothnormal);
+       }
+       glEnd();
+       glShadeModel(GL_FLAT);
+ }
  static void cdDM_drawMappedEdges(DerivedMesh *dm, int (*setDrawOptions)(void *userData, int index), void *userData)
  {
        CDDerivedMesh *cddm = (CDDerivedMesh*) dm;
@@@ -1521,6 -1602,7 +1602,7 @@@ static CDDerivedMesh *cdDM_create(cons
        dm->drawMappedFaces = cdDM_drawMappedFaces;
        dm->drawMappedFacesTex = cdDM_drawMappedFacesTex;
        dm->drawMappedFacesGLSL = cdDM_drawMappedFacesGLSL;
+       dm->drawMappedFacesMat = cdDM_drawMappedFacesMat;
  
        dm->foreachMappedVert = cdDM_foreachMappedVert;
        dm->foreachMappedEdge = cdDM_foreachMappedEdge;
@@@ -1650,7 -1732,6 +1732,7 @@@ DerivedMesh *CDDM_from_editmesh(EditMes
                
                if(eed->seam) med->flag |= ME_SEAM;
                if(eed->sharp) med->flag |= ME_SHARP;
 +              if(eed->freestyle) med->flag |= ME_FREESTYLE_EDGE;
                if(!eed->f2) med->flag |= ME_LOOSEEDGE;
  
                *index = i;
index fe9678ee1fcec2afa81ffeeda01e39dbf31ee4ad,7332b89f629aaf384e6bfbe7bd9dac3ca0eaf057..f57bb1bfd5199845922df533b4991960fa9f97d9
  #include "BKE_speaker.h"
  #include "BKE_utildefines.h"
  #include "BKE_movieclip.h"
 +#include "BKE_linestyle.h"
  
  #include "RNA_access.h"
  
@@@ -270,8 -269,6 +270,8 @@@ int id_make_local(ID *id, int test
                        return 0; /* can't be linked */
                case ID_GD:
                        return 0; /* not implemented */
 +              case ID_LS:
 +                      return 0; /* not implemented */
        }
  
        return 0;
@@@ -363,8 -360,6 +363,8 @@@ int id_copy(ID *id, ID **newid, int tes
                        return 0; /* can't be copied from here */
                case ID_GD:
                        return 0; /* not implemented */
 +              case ID_LS:
 +                      return 0; /* not implemented */
        }
        
        return 0;
@@@ -493,8 -488,6 +493,8 @@@ ListBase *which_libbase(Main *mainlib, 
                        return &(mainlib->gpencil);
                case ID_MC:
                        return &(mainlib->movieclip);
 +              case ID_LS:
 +                      return &(mainlib->linestyle);
        }
        return NULL;
  }
@@@ -577,7 -570,6 +577,7 @@@ int set_listbasepointers(Main *main, Li
        lb[a++]= &(main->library);
        lb[a++]= &(main->wm);
        lb[a++]= &(main->movieclip);
 +      lb[a++]= &(main->linestyle);
        
        lb[a]= NULL;
  
@@@ -679,19 -671,16 +679,19 @@@ static ID *alloc_libblock_notest(short 
                        break;
                case ID_PA:
                        id = MEM_callocN(sizeof(ParticleSettings), "ParticleSettings");
-                         break;
+                       break;
                case ID_WM:
                        id = MEM_callocN(sizeof(wmWindowManager), "Window manager");
-                         break;
+                       break;
                case ID_GD:
                        id = MEM_callocN(sizeof(bGPdata), "Grease Pencil");
                        break;
                case ID_MC:
                        id = MEM_callocN(sizeof(MovieClip), "Movie Clip");
                        break;
 +              case ID_LS:
 +                      id = MEM_callocN(sizeof(FreestyleLineStyle), "Freestyle Line Style");
 +                      break;
        }
        return id;
  }
@@@ -900,9 -889,6 +900,9 @@@ void free_libblock(ListBase *lb, void *
                case ID_MC:
                        free_movieclip((MovieClip *)id);
                        break;
 +              case ID_LS:
 +                      FRS_free_linestyle((FreestyleLineStyle *)id);
 +                      break;
        }
  
        if (id->properties) {
index 57b6cb6f02edb5b55d98c45aba83ae34de4490ad,4e6bc4eee8951525cb049a8ca92d93912c775575..f3486360d08ea050aa56b2f08c51b6403a832e5d
  
  #include "GPU_material.h"
  
 +#include "FRS_freestyle.h"
 +
  /* Local function protos */
  static void solve_parenting (Scene *scene, Object *ob, Object *par, float obmat[][4], float slowmat[][4], int simul);
  
@@@ -603,14 -601,6 +603,14 @@@ void unlink_object(Object *ob
                                        }
                                SEQ_END
                        }
 +
 +                      {
 +                              SceneRenderLayer *srl;
 +
 +                              for (srl= sce->r.layers.first; srl; srl= srl->next) {
 +                                      FRS_unlink_target_object(&srl->freestyleConfig, ob);
 +                              }
 +                      }
                }
  
                sce= sce->id.next;
@@@ -1508,6 -1498,71 +1508,71 @@@ void object_mat3_to_rot(Object *ob, flo
        }
  }
  
+ void object_tfm_protected_backup(const Object *ob,
+                                  ObjectTfmProtectedChannels *obtfm)
+ {
+ #define TFMCPY(   _v) (obtfm->_v = ob->_v)
+ #define TFMCPY3D( _v) copy_v3_v3(obtfm->_v, ob->_v)
+ #define TFMCPY4D( _v) copy_v4_v4(obtfm->_v, ob->_v)
+       TFMCPY3D(loc);
+       TFMCPY3D(dloc);
+       TFMCPY3D(size);
+       TFMCPY3D(dsize);
+       TFMCPY3D(rot);
+       TFMCPY3D(drot);
+       TFMCPY4D(quat);
+       TFMCPY4D(dquat);
+       TFMCPY3D(rotAxis);
+       TFMCPY3D(drotAxis);
+       TFMCPY(rotAngle);
+       TFMCPY(drotAngle);
+ #undef TFMCPY
+ #undef TFMCPY3D
+ #undef TFMCPY4D
+ }
+ void object_tfm_protected_restore(Object *ob,
+                                   const ObjectTfmProtectedChannels *obtfm,
+                                   const short protectflag)
+ {
+       unsigned int i;
+       for (i= 0; i < 3; i++) {
+               if (protectflag & (OB_LOCK_LOCX<<i)) {
+                       ob->loc[i]=  obtfm->loc[i];
+                       ob->dloc[i]= obtfm->dloc[i];
+               }
+               if (protectflag & (OB_LOCK_SCALEX<<i)) {
+                       ob->size[i]=  obtfm->size[i];
+                       ob->dsize[i]= obtfm->dsize[i];
+               }
+               if (protectflag & (OB_LOCK_ROTX<<i)) {
+                       ob->rot[i]=  obtfm->rot[i];
+                       ob->drot[i]= obtfm->drot[i];
+                       ob->quat[i + 1]=  obtfm->quat[i + 1];
+                       ob->dquat[i + 1]= obtfm->dquat[i + 1];
+                       ob->rotAxis[i]=  obtfm->rotAxis[i];
+                       ob->drotAxis[i]= obtfm->drotAxis[i];
+               }
+       }
+       if ((protectflag & OB_LOCK_ROT4D) && (protectflag & OB_LOCK_ROTW)) {
+               ob->quat[0]=  obtfm->quat[0];
+               ob->dquat[0]= obtfm->dquat[0];
+               ob->rotAngle=  obtfm->rotAngle;
+               ob->drotAngle= obtfm->drotAngle;
+       }
+ }
  /* see pchan_apply_mat4() for the equivalent 'pchan' function */
  void object_apply_mat4(Object *ob, float mat[][4], const short use_compat, const short use_parent)
  {
index a66178a935c16bd1613376ad94e281084b30cc52,61dea5773e9e4c4f93e2f84e6777a35821916726..001d2abab01108e7fca993d0e55ba9915e8580b7
@@@ -749,7 -749,7 +749,7 @@@ static void ccgDM_getFinalEdge(DerivedM
  
                edgeFlag = (ccgdm->edgeFlags)? &ccgdm->edgeFlags[i]: NULL;
                if(edgeFlag)
 -                      flags |= (*edgeFlag & (ME_SEAM | ME_SHARP))
 +                      flags |= (*edgeFlag & (ME_SEAM | ME_SHARP | ME_FREESTYLE_EDGE))
                                         | ME_EDGEDRAW | ME_EDGERENDER;
                else
                        flags |= ME_EDGEDRAW | ME_EDGERENDER;
@@@ -934,7 -934,7 +934,7 @@@ static void ccgDM_copyFinalEdgeArray(De
  
                if(edgeFlags) {
                        if(edgeIdx != -1) {
 -                              flags |= (edgeFlags[index] & (ME_SEAM | ME_SHARP))
 +                              flags |= (edgeFlags[index] & (ME_SEAM | ME_SHARP | ME_FREESTYLE_EDGE))
                                                 | ME_EDGEDRAW | ME_EDGERENDER;
                        }
                } else {
@@@ -1511,6 -1511,155 +1511,155 @@@ static void ccgDM_drawFacesGLSL(Derived
        dm->drawMappedFacesGLSL(dm, setMaterial, NULL, NULL);
  }
  
+       /* Only used by non-editmesh types */
+ static void ccgDM_drawMappedFacesMat(DerivedMesh *dm, void (*setMaterial)(void *userData, int, void *attribs), int (*setFace)(void *userData, int index), void *userData) {
+       CCGDerivedMesh *ccgdm = (CCGDerivedMesh*) dm;
+       CCGSubSurf *ss = ccgdm->ss;
+       CCGFaceIterator *fi = ccgSubSurf_getFaceIterator(ss);
+       GPUVertexAttribs gattribs;
+       DMVertexAttribs attribs= {{{NULL}}};
+       int gridSize = ccgSubSurf_getGridSize(ss);
+       int gridFaces = gridSize - 1;
+       int edgeSize = ccgSubSurf_getEdgeSize(ss);
+       char *faceFlags = ccgdm->faceFlags;
+       int a, b, i, numVerts, matnr, new_matnr, totface;
+       ccgdm_pbvh_update(ccgdm);
+       matnr = -1;
+ #define PASSATTRIB(dx, dy, vert) {                                                                                            \
+       if(attribs.totorco) {                                                                                                           \
+               index = getFaceIndex(ss, f, S, x+dx, y+dy, edgeSize, gridSize);                 \
+               if(attribs.orco.glTexco)                                                                                                \
+                       glTexCoord3fv(attribs.orco.array[index]);                                                       \
+               else                                                                                                                                    \
+                       glVertexAttrib3fvARB(attribs.orco.glIndex, attribs.orco.array[index]);  \
+       }                                                                                                                                                       \
+       for(b = 0; b < attribs.tottface; b++) {                                                                         \
+               MTFace *tf = &attribs.tface[b].array[a];                                                                \
+               if(attribs.tface[b].glTexco)                                                                                    \
+                       glTexCoord2fv(tf->uv[vert]);                                                                            \
+               else                                                                                                                                    \
+                       glVertexAttrib2fvARB(attribs.tface[b].glIndex, tf->uv[vert]);           \
+       }                                                                                                                                                       \
+       for(b = 0; b < attribs.totmcol; b++) {                                                                          \
+               MCol *cp = &attribs.mcol[b].array[a*4 + vert];                                                  \
+               GLubyte col[4];                                                                                                                 \
+               col[0]= cp->b; col[1]= cp->g; col[2]= cp->r; col[3]= cp->a;                             \
+               glVertexAttrib4ubvARB(attribs.mcol[b].glIndex, col);                                    \
+       }                                                                                                                                                       \
+       if(attribs.tottang) {                                                                                                           \
+               float *tang = attribs.tang.array[a*4 + vert];                                                   \
+               glVertexAttrib4fvARB(attribs.tang.glIndex, tang);                                               \
+       }                                                                                                                                                       \
+ }
+       totface = ccgSubSurf_getNumFaces(ss);
+       for(a = 0, i = 0; i < totface; i++) {
+               CCGFace *f = ccgdm->faceMap[i].face;
+               int S, x, y, drawSmooth;
+               int index = GET_INT_FROM_POINTER(ccgSubSurf_getFaceFaceHandle(ss, f));
+               int origIndex = ccgDM_getFaceMapIndex(ss, f);
+               
+               numVerts = ccgSubSurf_getFaceNumVerts(f);
+               /* get flags */
+               if(faceFlags) {
+                       drawSmooth = (faceFlags[index*2] & ME_SMOOTH);
+                       new_matnr= faceFlags[index*2 + 1] + 1;
+               }
+               else {
+                       drawSmooth = 1;
+                       new_matnr= 1;
+               }
+               /* material */
+               if(new_matnr != matnr) {
+                       setMaterial(userData, matnr = new_matnr, &gattribs);
+                       DM_vertex_attributes_from_gpu(dm, &gattribs, &attribs);
+               }
+               /* face hiding */
+               if((setFace && (origIndex != ORIGINDEX_NONE) && !setFace(userData, origIndex))) {
+                       a += gridFaces*gridFaces*numVerts;
+                       continue;
+               }
+               /* draw face*/
+               glShadeModel(drawSmooth? GL_SMOOTH: GL_FLAT);
+               for (S=0; S<numVerts; S++) {
+                       DMGridData *faceGridData = ccgSubSurf_getFaceGridDataArray(ss, f, S);
+                       DMGridData *vda, *vdb;
+                       if (drawSmooth) {
+                               for (y=0; y<gridFaces; y++) {
+                                       glBegin(GL_QUAD_STRIP);
+                                       for (x=0; x<gridFaces; x++) {
+                                               vda = &faceGridData[(y+0)*gridSize + x];
+                                               vdb = &faceGridData[(y+1)*gridSize + x];
+                                               
+                                               PASSATTRIB(0, 0, 0);
+                                               glNormal3fv(vda->no);
+                                               glVertex3fv(vda->co);
+                                               PASSATTRIB(0, 1, 1);
+                                               glNormal3fv(vdb->no);
+                                               glVertex3fv(vdb->co);
+                                               if(x != gridFaces-1)
+                                                       a++;
+                                       }
+                                       vda = &faceGridData[(y+0)*gridSize + x];
+                                       vdb = &faceGridData[(y+1)*gridSize + x];
+                                       PASSATTRIB(0, 0, 3);
+                                       glNormal3fv(vda->no);
+                                       glVertex3fv(vda->co);
+                                       PASSATTRIB(0, 1, 2);
+                                       glNormal3fv(vdb->no);
+                                       glVertex3fv(vdb->co);
+                                       glEnd();
+                                       a++;
+                               }
+                       } else {
+                               glBegin(GL_QUADS);
+                               for (y=0; y<gridFaces; y++) {
+                                       for (x=0; x<gridFaces; x++) {
+                                               float *aco = faceGridData[(y+0)*gridSize + x].co;
+                                               float *bco = faceGridData[(y+0)*gridSize + x + 1].co;
+                                               float *cco = faceGridData[(y+1)*gridSize + x + 1].co;
+                                               float *dco = faceGridData[(y+1)*gridSize + x].co;
+                                               ccgDM_glNormalFast(aco, bco, cco, dco);
+                                               PASSATTRIB(0, 1, 1);
+                                               glVertex3fv(dco);
+                                               PASSATTRIB(1, 1, 2);
+                                               glVertex3fv(cco);
+                                               PASSATTRIB(1, 0, 3);
+                                               glVertex3fv(bco);
+                                               PASSATTRIB(0, 0, 0);
+                                               glVertex3fv(aco);
+                                               
+                                               a++;
+                                       }
+                               }
+                               glEnd();
+                       }
+               }
+       }
+ #undef PASSATTRIB
+       ccgFaceIterator_free(fi);
+ }
  static void ccgDM_drawFacesColored(DerivedMesh *dm, int UNUSED(useTwoSided), unsigned char *col1, unsigned char *col2) {
        CCGDerivedMesh *ccgdm = (CCGDerivedMesh*) dm;
        CCGSubSurf *ss = ccgdm->ss;
@@@ -1815,11 -1964,14 +1964,14 @@@ static void ccgDM_drawMappedFaces(Deriv
                                          glEnable(GL_POLYGON_STIPPLE);
                                          glPolygonStipple(stipple_quarttone);
                                }
+                               /* no need to set shading mode to flat because
+                               *  normals are already used to change shading */
+                               glShadeModel(GL_SMOOTH);
                                
                                for (S=0; S<numVerts; S++) {
                                        DMGridData *faceGridData = ccgSubSurf_getFaceGridDataArray(ss, f, S);
                                        if (drawSmooth) {
-                                               glShadeModel(GL_SMOOTH);
                                                for (y=0; y<gridFaces; y++) {
                                                        DMGridData *a, *b;
                                                        glBegin(GL_QUAD_STRIP);
                                                        glEnd();
                                                }
                                        } else {
-                                               glShadeModel(GL_FLAT);
                                                glBegin(GL_QUADS);
                                                for (y=0; y<gridFaces; y++) {
                                                        for (x=0; x<gridFaces; x++) {
@@@ -2382,6 -2533,7 +2533,7 @@@ static CCGDerivedMesh *getCCGDerivedMes
        ccgdm->dm.drawMappedFaces = ccgDM_drawMappedFaces;
        ccgdm->dm.drawMappedFacesTex = ccgDM_drawMappedFacesTex;
        ccgdm->dm.drawMappedFacesGLSL = ccgDM_drawMappedFacesGLSL;
+       ccgdm->dm.drawMappedFacesMat = ccgDM_drawMappedFacesMat;
        ccgdm->dm.drawUVEdges = ccgDM_drawUVEdges;
  
        ccgdm->dm.drawMappedEdgesInterp = ccgDM_drawMappedEdgesInterp;
index 304d302328acf112fe824c8c6cc3ba672bf75261,3fd661a52dae058c639f7c8e6a42defa81b2e8a7..1fc790803108273bc5f41652ea5f072ad0aec569
@@@ -56,6 -56,7 +56,7 @@@
  #include "DNA_cloth_types.h"
  #include "DNA_controller_types.h"
  #include "DNA_constraint_types.h"
+ #include "DNA_dynamicpaint_types.h"
  #include "DNA_effect_types.h"
  #include "DNA_fileglobal_types.h"
  #include "DNA_genfile.h"
@@@ -65,7 -66,6 +66,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"
@@@ -1554,14 -1554,14 +1555,14 @@@ static void IDP_DirectLinkProperty(IDPr
                        IDP_DirectLinkIDPArray(prop, switch_endian, fd);
                        break;
                case IDP_DOUBLE:
-                       /*erg, stupid doubles.  since I'm storing them
-                        in the same field as int val; val2 in the
-                        IDPropertyData struct, they have to deal with
-                        endianness specifically
-                        
-                        in theory, val and val2 would've already been swapped
-                        if switch_endian is true, so we have to first unswap
-                        them then reswap them as a single 64-bit entity.
+                       /* erg, stupid doubles.  since I'm storing them
+                        in the same field as int val; val2 in the
+                        IDPropertyData struct, they have to deal with
+                        endianness specifically
+                        in theory, val and val2 would've already been swapped
+                        if switch_endian is true, so we have to first unswap
+                        them then reswap them as a single 64-bit entity.
                         */
                        
                        if (switch_endian) {
@@@ -2123,11 -2123,61 +2124,61 @@@ static void lib_link_nodetree(FileData 
        }
  }
  
+ static void do_versions_socket_default_value(bNodeSocket *sock)
+ {
+       bNodeSocketValueFloat *valfloat;
+       bNodeSocketValueVector *valvector;
+       bNodeSocketValueRGBA *valrgba;
+       
+       if (sock->default_value)
+               return;
+       
+       switch (sock->type) {
+       case SOCK_FLOAT:
+               valfloat = sock->default_value = MEM_callocN(sizeof(bNodeSocketValueFloat), "default socket value");
+               valfloat->value = sock->ns.vec[0];
+               valfloat->min = sock->ns.min;
+               valfloat->max = sock->ns.max;
+               valfloat->subtype = PROP_NONE;
+               break;
+       case SOCK_VECTOR:
+               valvector = sock->default_value = MEM_callocN(sizeof(bNodeSocketValueVector), "default socket value");
+               copy_v3_v3(valvector->value, sock->ns.vec);
+               valvector->min = sock->ns.min;
+               valvector->max = sock->ns.max;
+               valvector->subtype = PROP_NONE;
+               break;
+       case SOCK_RGBA:
+               valrgba = sock->default_value = MEM_callocN(sizeof(bNodeSocketValueRGBA), "default socket value");
+               copy_v4_v4(valrgba->value, sock->ns.vec);
+               break;
+       }
+ }
+ static void do_versions_nodetree_default_value(bNodeTree *ntree)
+ {
+       bNode *node;
+       bNodeSocket *sock;
+       for (node=ntree->nodes.first; node; node=node->next) {
+               for (sock=node->inputs.first; sock; sock=sock->next)
+                       do_versions_socket_default_value(sock);
+               for (sock=node->outputs.first; sock; sock=sock->next)
+                       do_versions_socket_default_value(sock);
+       }
+       for (sock=ntree->inputs.first; sock; sock=sock->next)
+               do_versions_socket_default_value(sock);
+       for (sock=ntree->outputs.first; sock; sock=sock->next)
+               do_versions_socket_default_value(sock);
+ }
  static void lib_nodetree_init_types_cb(void *UNUSED(data), ID *UNUSED(id), bNodeTree *ntree)
  {
        bNode *node;
        
        ntreeInitTypes(ntree);
+       /* need to do this here instead of in do_versions, otherwise next function can crash */
+       do_versions_nodetree_default_value(ntree);
        
        /* XXX could be replaced by do_versions for new nodes */
        for (node=ntree->nodes.first; node; node=node->next)
@@@ -3517,8 -3567,8 +3568,8 @@@ static void lib_link_mtface(FileData *f
        int i;
  
        /* Add pseudo-references (not fake users!) to images used by texface. A
-          little bogus; it would be better if each mesh consistently added one ref
-          to each image it used. - z0r */
+        * little bogus; it would be better if each mesh consistently added one ref
+        * to each image it used. - z0r */
        for (i=0; i<totface; i++, tf++) {
                tf->tpage= newlibadr(fd, me->id.lib, tf->tpage);
                if(tf->tpage && tf->tpage->id.us==0)
@@@ -3719,7 -3769,7 +3770,7 @@@ static void direct_link_mesh(FileData *
        }
  
        /* if multires is present but has no valid vertex data,
-          there's no way to recover it; silently remove multires */
+        * there's no way to recover it; silently remove multires */
        if(mesh->mr && !mesh->mr->verts) {
                multires_free(mesh->mr);
                mesh->mr = NULL;
@@@ -4193,6 -4243,40 +4244,40 @@@ static void direct_link_modifiers(FileD
  
                        }
                }
+               else if (md->type==eModifierType_DynamicPaint) {
+                       DynamicPaintModifierData *pmd = (DynamicPaintModifierData*) md;
+                       if(pmd->canvas)
+                       {
+                               pmd->canvas = newdataadr(fd, pmd->canvas);
+                               pmd->canvas->pmd = pmd;
+                               pmd->canvas->dm = NULL;
+                               pmd->canvas->flags &= ~MOD_DPAINT_BAKING; /* just in case */
+                               if (pmd->canvas->surfaces.first) {
+                                       DynamicPaintSurface *surface;
+                                       link_list(fd, &pmd->canvas->surfaces);
+                                       for (surface=pmd->canvas->surfaces.first; surface; surface=surface->next) {
+                                               surface->canvas = pmd->canvas;
+                                               surface->data = NULL;
+                                               direct_link_pointcache_list(fd, &(surface->ptcaches), &(surface->pointcache), 1);
+                                               if(!(surface->effector_weights = newdataadr(fd, surface->effector_weights)))
+                                                       surface->effector_weights = BKE_add_effector_weights(NULL);
+                                       }
+                               }
+                       }
+                       if(pmd->brush)
+                       {
+                               pmd->brush = newdataadr(fd, pmd->brush);
+                               pmd->brush->pmd = pmd;
+                               pmd->brush->psys = newdataadr(fd, pmd->brush->psys);
+                               pmd->brush->paint_ramp = newdataadr(fd, pmd->brush->paint_ramp);
+                               pmd->brush->vel_ramp = newdataadr(fd, pmd->brush->vel_ramp);
+                               pmd->brush->dm = NULL;
+                       }
+               }
                else if (md->type==eModifierType_Collision) {
                        
                        CollisionModifierData *collmd = (CollisionModifierData*) md;
@@@ -4542,7 -4626,6 +4627,7 @@@ static void lib_link_scene(FileData *fd
        Base *base, *next;
        Sequence *seq;
        SceneRenderLayer *srl;
 +      FreestyleLineSet *fls;
        TimeMarker *marker;
        
        sce= main->scene.first;
                        for(srl= sce->r.layers.first; srl; srl= srl->next) {
                                srl->mat_override= newlibadr_us(fd, sce->id.lib, srl->mat_override);
                                srl->light_override= newlibadr_us(fd, sce->id.lib, srl->light_override);
 +                              for(fls=srl->freestyleConfig.linesets.first; fls; fls= fls->next) {
 +                                      fls->linestyle= newlibadr_us(fd, sce->id.lib, fls->linestyle);
 +                                      fls->group= newlibadr_us(fd, sce->id.lib, fls->group);
 +                              }
                        }
                        /*Game Settings: Dome Warp Text*/
                        sce->gm.dome.warptext= newlibadr(fd, sce->id.lib, sce->gm.dome.warptext);
@@@ -4665,7 -4744,6 +4750,7 @@@ static void direct_link_scene(FileData 
        Editing *ed;
        Sequence *seq;
        MetaStack *ms;
 +      SceneRenderLayer *srl;
  
        sce->theDag = NULL;
        sce->dagisvalid = 0;
        link_list(fd, &(sce->transform_spaces));
        link_list(fd, &(sce->r.layers));
  
 +      for(srl= sce->r.layers.first; srl; srl= srl->next) {
 +              link_list(fd, &(srl->freestyleConfig.modules));
 +      }
 +      for(srl= sce->r.layers.first; srl; srl= srl->next) {
 +              link_list(fd, &(srl->freestyleConfig.linesets));
 +      }
 +      
        sce->nodetree= newdataadr(fd, sce->nodetree);
        if(sce->nodetree)
                direct_link_nodetree(fd, sce->nodetree);
@@@ -5625,6 -5696,7 +5710,7 @@@ static void direct_link_screen(FileDat
                        else if(sl->spacetype==SPACE_BUTS) {
                                SpaceButs *sbuts= (SpaceButs *)sl;
                                sbuts->path= NULL;
+                               sbuts->texuser= NULL;
                        }
                        else if(sl->spacetype==SPACE_CONSOLE) {
                                SpaceConsole *sconsole= (SpaceConsole *)sl;
@@@ -5903,177 -5975,6 +5989,177 @@@ static void lib_link_movieclip(FileDat
        }
  }
  
 +/* ************ READ LINE STYLE ***************** */
 +
 +static void lib_link_linestyle(FileData *fd, Main *main)
 +{
 +      FreestyleLineStyle *linestyle;
 +      LineStyleModifier *m;
 +
 +      linestyle = main->linestyle.first;
 +      while (linestyle) {
 +              if (linestyle->id.flag & LIB_NEEDLINK) {
 +                      linestyle->id.flag -= LIB_NEEDLINK;
 +
 +                      if (linestyle->id.properties) IDP_LibLinkProperty(linestyle->id.properties, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd);
 +                      if (linestyle->adt) lib_link_animdata(fd, &linestyle->id, linestyle->adt);
 +                      for (m = linestyle->color_modifiers.first; m; m = m->next) {
 +                              switch (m->type) {
 +                              case LS_MODIFIER_DISTANCE_FROM_OBJECT:
 +                                      {
 +                                              LineStyleColorModifier_DistanceFromObject *cm = (LineStyleColorModifier_DistanceFromObject *)m;
 +                                              cm->target = newlibadr(fd, linestyle->id.lib, cm->target);
 +                                      }
 +                                      break;
 +                              }
 +                      }
 +                      for (m = linestyle->alpha_modifiers.first; m; m = m->next){
 +                              switch (m->type) {
 +                              case LS_MODIFIER_DISTANCE_FROM_OBJECT:
 +                                      {
 +                                              LineStyleAlphaModifier_DistanceFromObject *am = (LineStyleAlphaModifier_DistanceFromObject *)m;
 +                                              am->target = newlibadr(fd, linestyle->id.lib, am->target);
 +                                      }
 +                                      break;
 +                              }
 +                      }
 +                      for (m = linestyle->thickness_modifiers.first; m; m = m->next){
 +                              switch (m->type) {
 +                              case LS_MODIFIER_DISTANCE_FROM_OBJECT:
 +                                      {
 +                                              LineStyleThicknessModifier_DistanceFromObject *tm = (LineStyleThicknessModifier_DistanceFromObject *)m;
 +                                              tm->target = newlibadr(fd, linestyle->id.lib, tm->target);
 +                                      }
 +                                      break;
 +                              }
 +                      }
 +              }
 +              linestyle = linestyle->id.next;
 +      }
 +}
 +
 +static void direct_link_linestyle_color_modifier(FileData *fd, LineStyleModifier *modifier)
 +{
 +      switch (modifier->type) {
 +      case LS_MODIFIER_ALONG_STROKE:
 +              {
 +                      LineStyleColorModifier_AlongStroke *m = (LineStyleColorModifier_AlongStroke *)modifier;
 +                      m->color_ramp = newdataadr(fd, m->color_ramp);
 +              }
 +              break;
 +      case LS_MODIFIER_DISTANCE_FROM_CAMERA:
 +              {
 +                      LineStyleColorModifier_DistanceFromCamera *m = (LineStyleColorModifier_DistanceFromCamera *)modifier;
 +                      m->color_ramp = newdataadr(fd, m->color_ramp);
 +              }
 +              break;
 +      case LS_MODIFIER_DISTANCE_FROM_OBJECT:
 +              {
 +                      LineStyleColorModifier_DistanceFromObject *m = (LineStyleColorModifier_DistanceFromObject *)modifier;
 +                      m->color_ramp = newdataadr(fd, m->color_ramp);
 +              }
 +              break;
 +      case LS_MODIFIER_MATERIAL:
 +              {
 +                      LineStyleColorModifier_Material *m = (LineStyleColorModifier_Material *)modifier;
 +                      m->color_ramp = newdataadr(fd, m->color_ramp);
 +              }
 +              break;
 +      }
 +}
 +
 +static void direct_link_linestyle_alpha_modifier(FileData *fd, LineStyleModifier *modifier)
 +{
 +      switch (modifier->type) {
 +      case LS_MODIFIER_ALONG_STROKE:
 +              {
 +                      LineStyleAlphaModifier_AlongStroke *m = (LineStyleAlphaModifier_AlongStroke *)modifier;
 +                      m->curve = newdataadr(fd, m->curve);
 +                      direct_link_curvemapping(fd, m->curve);
 +              }
 +              break;
 +      case LS_MODIFIER_DISTANCE_FROM_CAMERA:
 +              {
 +                      LineStyleAlphaModifier_DistanceFromCamera *m = (LineStyleAlphaModifier_DistanceFromCamera *)modifier;
 +                      m->curve = newdataadr(fd, m->curve);
 +                      direct_link_curvemapping(fd, m->curve);
 +              }
 +              break;
 +      case LS_MODIFIER_DISTANCE_FROM_OBJECT:
 +              {
 +                      LineStyleAlphaModifier_DistanceFromObject *m = (LineStyleAlphaModifier_DistanceFromObject *)modifier;
 +                      m->curve = newdataadr(fd, m->curve);
 +                      direct_link_curvemapping(fd, m->curve);
 +              }
 +              break;
 +      case LS_MODIFIER_MATERIAL:
 +              {
 +                      LineStyleAlphaModifier_Material *m = (LineStyleAlphaModifier_Material *)modifier;
 +                      m->curve = newdataadr(fd, m->curve);
 +                      direct_link_curvemapping(fd, m->curve);
 +              }
 +              break;
 +      }
 +}
 +
 +static void direct_link_linestyle_thickness_modifier(FileData *fd, LineStyleModifier *modifier)
 +{
 +      switch (modifier->type) {
 +      case LS_MODIFIER_ALONG_STROKE:
 +              {
 +                      LineStyleThicknessModifier_AlongStroke *m = (LineStyleThicknessModifier_AlongStroke *)modifier;
 +                      m->curve = newdataadr(fd, m->curve);
 +                      direct_link_curvemapping(fd, m->curve);
 +              }
 +              break;
 +      case LS_MODIFIER_DISTANCE_FROM_CAMERA:
 +              {
 +                      LineStyleThicknessModifier_DistanceFromCamera *m = (LineStyleThicknessModifier_DistanceFromCamera *)modifier;
 +                      m->curve = newdataadr(fd, m->curve);
 +                      direct_link_curvemapping(fd, m->curve);
 +              }
 +              break;
 +      case LS_MODIFIER_DISTANCE_FROM_OBJECT:
 +              {
 +                      LineStyleThicknessModifier_DistanceFromObject *m = (LineStyleThicknessModifier_DistanceFromObject *)modifier;
 +                      m->curve = newdataadr(fd, m->curve);
 +                      direct_link_curvemapping(fd, m->curve);
 +              }
 +              break;
 +      case LS_MODIFIER_MATERIAL:
 +              {
 +                      LineStyleThicknessModifier_Material *m = (LineStyleThicknessModifier_Material *)modifier;
 +                      m->curve = newdataadr(fd, m->curve);
 +                      direct_link_curvemapping(fd, m->curve);
 +              }
 +              break;
 +      }
 +}
 +
 +static void direct_link_linestyle_geometry_modifier(FileData *fd, LineStyleModifier *modifier)
 +{
 +}
 +
 +static void direct_link_linestyle(FileData *fd, FreestyleLineStyle *linestyle)
 +{
 +      LineStyleModifier *modifier;
 +
 +      linestyle->adt= newdataadr(fd, linestyle->adt);
 +      direct_link_animdata(fd, linestyle->adt);
 +      link_list(fd, &linestyle->color_modifiers);
 +      for(modifier=linestyle->color_modifiers.first; modifier; modifier= modifier->next)
 +              direct_link_linestyle_color_modifier(fd, modifier);
 +      link_list(fd, &linestyle->alpha_modifiers);
 +      for(modifier=linestyle->alpha_modifiers.first; modifier; modifier= modifier->next)
 +              direct_link_linestyle_alpha_modifier(fd, modifier);
 +      link_list(fd, &linestyle->thickness_modifiers);
 +      for(modifier=linestyle->thickness_modifiers.first; modifier; modifier= modifier->next)
 +              direct_link_linestyle_thickness_modifier(fd, modifier);
 +      link_list(fd, &linestyle->geometry_modifiers);
 +      for(modifier=linestyle->geometry_modifiers.first; modifier; modifier= modifier->next)
 +              direct_link_linestyle_geometry_modifier(fd, modifier);
 +}
 +
  /* ************** GENERAL & MAIN ******************** */
  
  
@@@ -6109,7 -6010,6 +6195,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";
        
@@@ -6282,9 -6182,6 +6368,9 @@@ static BHead *read_libblock(FileData *f
                case ID_MC:
                        direct_link_movieclip(fd, (MovieClip *)id);
                        break;
 +              case ID_LS:
 +                      direct_link_linestyle(fd, (FreestyleLineStyle *)id);
 +                      break;
        }
        
        /*link direct data of ID properties*/
@@@ -7334,53 -7231,6 +7420,6 @@@ static void do_version_bone_roll_256(Bo
                do_version_bone_roll_256(child);
  }
  
- static void do_versions_socket_default_value(bNodeSocket *sock)
- {
-       bNodeSocketValueFloat *valfloat;
-       bNodeSocketValueVector *valvector;
-       bNodeSocketValueRGBA *valrgba;
-       
-       if (sock->default_value)
-               return;
-       
-       switch (sock->type) {
-       case SOCK_FLOAT:
-               valfloat = sock->default_value = MEM_callocN(sizeof(bNodeSocketValueFloat), "default socket value");
-               valfloat->value = sock->ns.vec[0];
-               valfloat->min = sock->ns.min;
-               valfloat->max = sock->ns.max;
-               valfloat->subtype = PROP_NONE;
-               break;
-       case SOCK_VECTOR:
-               valvector = sock->default_value = MEM_callocN(sizeof(bNodeSocketValueVector), "default socket value");
-               copy_v3_v3(valvector->value, sock->ns.vec);
-               valvector->min = sock->ns.min;
-               valvector->max = sock->ns.max;
-               valvector->subtype = PROP_NONE;
-               break;
-       case SOCK_RGBA:
-               valrgba = sock->default_value = MEM_callocN(sizeof(bNodeSocketValueRGBA), "default socket value");
-               copy_v4_v4(valrgba->value, sock->ns.vec);
-               break;
-       }
- }
- static void do_versions_nodetree_default_value(bNodeTree *ntree)
- {
-       bNode *node;
-       bNodeSocket *sock;
-       for (node=ntree->nodes.first; node; node=node->next) {
-               for (sock=node->inputs.first; sock; sock=sock->next)
-                       do_versions_socket_default_value(sock);
-               for (sock=node->outputs.first; sock; sock=sock->next)
-                       do_versions_socket_default_value(sock);
-       }
-       for (sock=ntree->inputs.first; sock; sock=sock->next)
-               do_versions_socket_default_value(sock);
-       for (sock=ntree->outputs.first; sock; sock=sock->next)
-               do_versions_socket_default_value(sock);
- }
  static void do_versions_nodetree_dynamic_sockets(bNodeTree *ntree)
  {
        bNodeSocket *sock;
@@@ -8994,7 -8844,7 +9033,7 @@@ static void do_versions(FileData *fd, L
                        
                        /* make sure old cameras have title safe on */
                        if (!(cam->flag & CAM_SHOWTITLESAFE))
-                        cam->flag |= CAM_SHOWTITLESAFE;
+                               cam->flag |= CAM_SHOWTITLESAFE;
                        
                        /* set an appropriate camera passepartout alpha */
                        if (!(cam->passepartalpha)) cam->passepartalpha = 0.2f;
                
                for(group= main->group.first; group; group= group->id.next)
                        if(group->layer==0)
-                          group->layer= (1<<20)-1;
+                               group->layer= (1<<20)-1;
                
                /* History fix (python?), shape key adrcode numbers have to be sorted */
                sort_shape_fix(main);
                                                /* enable all cache display */
                                                stime->cache_display |= TIME_CACHE_DISPLAY;
                                                stime->cache_display |= (TIME_CACHE_SOFTBODY|TIME_CACHE_PARTICLES);
-                                               stime->cache_display |= (TIME_CACHE_CLOTH|TIME_CACHE_SMOKE);
+                                               stime->cache_display |= (TIME_CACHE_CLOTH|TIME_CACHE_SMOKE|TIME_CACHE_DYNAMICPAINT);
                                        }
                                }
                        }
                {
                        Camera *cam;
                        for(cam= main->camera.first; cam; cam= cam->id.next) {
-                               if (cam->sensor_x < 0.01)
+                               if (cam->sensor_x < 0.01f)
                                        cam->sensor_x = DEFAULT_SENSOR_WIDTH;
  
-                               if (cam->sensor_y < 0.01)
+                               if (cam->sensor_y < 0.01f)
                                        cam->sensor_y = DEFAULT_SENSOR_HEIGHT;
                        }
                }
                }
        }
  
 +      /* default values in Freestyle settings */
 +      {
 +              Scene *sce;
 +              SceneRenderLayer *srl;
 +              FreestyleLineStyle *linestyle;
 +
 +              for(sce = main->scene.first; sce; sce = sce->id.next) {
 +                      for(srl= sce->r.layers.first; srl; srl= srl->next) {
 +                              if (srl->freestyleConfig.mode == 0)
 +                                      srl->freestyleConfig.mode= FREESTYLE_CONTROL_EDITOR_MODE;
 +                              if (srl->freestyleConfig.raycasting_algorithm == 0)
 +                                      srl->freestyleConfig.raycasting_algorithm= FREESTYLE_ALGO_CULLED_ADAPTIVE_CUMULATIVE;
 +                      }
 +              }
 +              for(linestyle = main->linestyle.first; linestyle; linestyle = linestyle->id.next) {
 +                      if (linestyle->chaining == 0)
 +                              linestyle->chaining= LS_CHAINING_PLAIN;
 +                      if (linestyle->rounds == 0)
 +                              linestyle->rounds= 3;
 +              }
 +      }
 +      
        /* WATCH IT!!!: pointers from libdata have not been converted yet here! */
        /* WATCH IT 2!: Userdef struct init has to be in editors/interface/resources.c! */
  
@@@ -12662,7 -12490,6 +12701,7 @@@ static void lib_link_all(FileData *fd, 
        lib_link_brush(fd, main);
        lib_link_particlesettings(fd, main);
        lib_link_movieclip(fd, main);
 +      lib_link_linestyle(fd, main);
  
        lib_link_mesh(fd, main);                /* as last: tpage images with users at zero */
  
@@@ -13546,7 -13373,6 +13585,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)
@@@ -13626,25 -13446,6 +13665,25 @@@ static void expand_sound(FileData *fd, 
        expand_doit(fd, mainvar, snd->ipo); // XXX depreceated - old animation system
  }
  
 +static void expand_linestyle(FileData *fd, Main *mainvar, FreestyleLineStyle *linestyle)
 +{
 +      LineStyleModifier *m;
 +
 +      if (linestyle->adt)
 +              expand_animdata(fd, mainvar, linestyle->adt);
 +      for (m = linestyle->color_modifiers.first; m; m = m->next) {
 +              if (m->type == LS_MODIFIER_DISTANCE_FROM_OBJECT)
 +                      expand_doit(fd, mainvar, ((LineStyleColorModifier_DistanceFromObject *)m)->target);
 +      }
 +      for (m = linestyle->alpha_modifiers.first; m; m = m->next){
 +              if (m->type == LS_MODIFIER_DISTANCE_FROM_OBJECT)
 +                      expand_doit(fd, mainvar, ((LineStyleAlphaModifier_DistanceFromObject *)m)->target);
 +      }
 +      for (m = linestyle->thickness_modifiers.first; m; m = m->next){
 +              if (m->type == LS_MODIFIER_DISTANCE_FROM_OBJECT)
 +                      expand_doit(fd, mainvar, ((LineStyleThicknessModifier_DistanceFromObject *)m)->target);
 +      }
 +}
  
  static void expand_main(FileData *fd, Main *mainvar)
  {
                                                break;
                                        case ID_PA:
                                                expand_particlesettings(fd, mainvar, (ParticleSettings *)id);
 +                                              break;
 +                                      case ID_LS:
 +                                              expand_linestyle(fd, mainvar, (FreestyleLineStyle *)id);
 +                                              break;
                                        }
  
                                        doit= 1;
index 3accc8715486f8c487c14775a8b7c48412a919a9,11a80d0d41a6b4763ae8c80899e4c72368a30546..086b83d09625d081dbb6e8af87a600338b8427df
@@@ -97,6 -97,7 +97,7 @@@ Any case: direct data is ALWAYS after t
  #include "DNA_cloth_types.h"
  #include "DNA_constraint_types.h"
  #include "DNA_controller_types.h"
+ #include "DNA_dynamicpaint_types.h"
  #include "DNA_genfile.h"
  #include "DNA_group_types.h"
  #include "DNA_gpencil_types.h"
  #include "DNA_key_types.h"
  #include "DNA_lattice_types.h"
  #include "DNA_lamp_types.h"
 +#include "DNA_linestyle_types.h"
  #include "DNA_meta_types.h"
  #include "DNA_mesh_types.h"
  #include "DNA_meshdata_types.h"
@@@ -1327,6 -1327,31 +1328,31 @@@ static void write_modifiers(WriteData *
                        FluidsimModifierData *fluidmd = (FluidsimModifierData*) md;
                        
                        writestruct(wd, DATA, "FluidsimSettings", 1, fluidmd->fss);
+               }
+               else if(md->type==eModifierType_DynamicPaint) {
+                       DynamicPaintModifierData *pmd = (DynamicPaintModifierData*) md;
+                       
+                       if(pmd->canvas)
+                       {
+                               DynamicPaintSurface *surface;
+                               writestruct(wd, DATA, "DynamicPaintCanvasSettings", 1, pmd->canvas);
+                               
+                               /* write surfaces */
+                               for (surface=pmd->canvas->surfaces.first; surface; surface=surface->next)
+                                       writestruct(wd, DATA, "DynamicPaintSurface", 1, surface);
+                               /* write caches and effector weights */
+                               for (surface=pmd->canvas->surfaces.first; surface; surface=surface->next) {
+                                       write_pointcaches(wd, &(surface->ptcaches));
+                                       writestruct(wd, DATA, "EffectorWeights", 1, surface->effector_weights);
+                               }
+                       }
+                       if(pmd->brush)
+                       {
+                               writestruct(wd, DATA, "DynamicPaintBrushSettings", 1, pmd->brush);
+                               writestruct(wd, DATA, "ColorBand", 1, pmd->brush->paint_ramp);
+                               writestruct(wd, DATA, "ColorBand", 1, pmd->brush->vel_ramp);
+                       }
                } 
                else if (md->type==eModifierType_Collision) {
                        
@@@ -1921,8 -1946,6 +1947,8 @@@ static void write_scenes(WriteData *wd
        TimeMarker *marker;
        TransformOrientation *ts;
        SceneRenderLayer *srl;
 +      FreestyleModuleConfig *fmc;
 +      FreestyleLineSet *fls;
        ToolSettings *tos;
        
        sce= scebase->first;
                for(ts = sce->transform_spaces.first; ts; ts = ts->next)
                        writestruct(wd, DATA, "TransformOrientation", 1, ts);
                
 -              for(srl= sce->r.layers.first; srl; srl= srl->next)
 +              for(srl= sce->r.layers.first; srl; srl= srl->next) {
                        writestruct(wd, DATA, "SceneRenderLayer", 1, srl);
 +                      
 +                      for(fmc= srl->freestyleConfig.modules.first; fmc; fmc = fmc->next) {
 +                              writestruct(wd, DATA, "FreestyleModuleConfig", 1, fmc);
 +                      }
 +                      
 +                      for(fls= srl->freestyleConfig.linesets.first; fls; fls = fls->next) {
 +                              writestruct(wd, DATA, "FreestyleLineSet", 1, fls);
 +                      }
 +
 +              }
                
                if(sce->nodetree) {
                        writestruct(wd, DATA, "bNodeTree", 1, sce->nodetree);
@@@ -2557,199 -2570,6 +2583,199 @@@ static void write_movieclips(WriteData 
        mywrite(wd, MYWRITE_FLUSH, 0);
  }
  
 +static void write_linestyle_color_modifiers(WriteData *wd, ListBase *modifiers)
 +{
 +      LineStyleModifier *m;
 +      char *struct_name;
 +
 +      for (m = modifiers->first; m; m = m->next) {
 +              switch (m->type) {
 +              case LS_MODIFIER_ALONG_STROKE:
 +                      struct_name = "LineStyleColorModifier_AlongStroke";
 +                      break;
 +              case LS_MODIFIER_DISTANCE_FROM_CAMERA:
 +                      struct_name = "LineStyleColorModifier_DistanceFromCamera";
 +                      break;
 +              case LS_MODIFIER_DISTANCE_FROM_OBJECT:
 +                      struct_name = "LineStyleColorModifier_DistanceFromObject";
 +                      break;
 +              case LS_MODIFIER_MATERIAL:
 +                      struct_name = "LineStyleColorModifier_Material";
 +                      break;
 +              default:
 +                      struct_name = "LineStyleColorModifier"; // this should not happen
 +              }
 +              writestruct(wd, DATA, struct_name, 1, m);
 +      }
 +      for (m = modifiers->first; m; m = m->next) {
 +              switch (m->type) {
 +              case LS_MODIFIER_ALONG_STROKE:
 +                      writestruct(wd, DATA, "ColorBand", 1, ((LineStyleColorModifier_AlongStroke *)m)->color_ramp);
 +                      break;
 +              case LS_MODIFIER_DISTANCE_FROM_CAMERA:
 +                      writestruct(wd, DATA, "ColorBand", 1, ((LineStyleColorModifier_DistanceFromCamera *)m)->color_ramp);
 +                      break;
 +              case LS_MODIFIER_DISTANCE_FROM_OBJECT:
 +                      writestruct(wd, DATA, "ColorBand", 1, ((LineStyleColorModifier_DistanceFromObject *)m)->color_ramp);
 +                      break;
 +              case LS_MODIFIER_MATERIAL:
 +                      writestruct(wd, DATA, "ColorBand", 1, ((LineStyleColorModifier_Material *)m)->color_ramp);
 +                      break;
 +              }
 +      }
 +}
 +
 +static void write_linestyle_alpha_modifiers(WriteData *wd, ListBase *modifiers)
 +{
 +      LineStyleModifier *m;
 +      char *struct_name;
 +
 +      for (m = modifiers->first; m; m = m->next) {
 +              switch (m->type) {
 +              case LS_MODIFIER_ALONG_STROKE:
 +                      struct_name = "LineStyleAlphaModifier_AlongStroke";
 +                      break;
 +              case LS_MODIFIER_DISTANCE_FROM_CAMERA:
 +                      struct_name = "LineStyleAlphaModifier_DistanceFromCamera";
 +                      break;
 +              case LS_MODIFIER_DISTANCE_FROM_OBJECT:
 +                      struct_name = "LineStyleAlphaModifier_DistanceFromObject";
 +                      break;
 +              case LS_MODIFIER_MATERIAL:
 +                      struct_name = "LineStyleAlphaModifier_Material";
 +                      break;
 +              default:
 +                      struct_name = "LineStyleAlphaModifier"; // this should not happen
 +              }
 +              writestruct(wd, DATA, struct_name, 1, m);
 +      }
 +      for (m = modifiers->first; m; m = m->next) {
 +              switch (m->type) {
 +              case LS_MODIFIER_ALONG_STROKE:
 +                      write_curvemapping(wd, ((LineStyleAlphaModifier_AlongStroke *)m)->curve);
 +                      break;
 +              case LS_MODIFIER_DISTANCE_FROM_CAMERA:
 +                      write_curvemapping(wd, ((LineStyleAlphaModifier_DistanceFromCamera *)m)->curve);
 +                      break;
 +              case LS_MODIFIER_DISTANCE_FROM_OBJECT:
 +                      write_curvemapping(wd, ((LineStyleAlphaModifier_DistanceFromObject *)m)->curve);
 +                      break;
 +              case LS_MODIFIER_MATERIAL:
 +                      write_curvemapping(wd, ((LineStyleAlphaModifier_Material *)m)->curve);
 +                      break;
 +              }
 +      }
 +}
 +
 +static void write_linestyle_thickness_modifiers(WriteData *wd, ListBase *modifiers)
 +{
 +      LineStyleModifier *m;
 +      char *struct_name;
 +
 +      for (m = modifiers->first; m; m = m->next) {
 +              switch (m->type) {
 +              case LS_MODIFIER_ALONG_STROKE:
 +                      struct_name = "LineStyleThicknessModifier_AlongStroke";
 +                      break;
 +              case LS_MODIFIER_DISTANCE_FROM_CAMERA:
 +                      struct_name = "LineStyleThicknessModifier_DistanceFromCamera";
 +                      break;
 +              case LS_MODIFIER_DISTANCE_FROM_OBJECT:
 +                      struct_name = "LineStyleThicknessModifier_DistanceFromObject";
 +                      break;
 +              case LS_MODIFIER_MATERIAL:
 +                      struct_name = "LineStyleThicknessModifier_Material";
 +                      break;
 +              case LS_MODIFIER_CALLIGRAPHY:
 +                      struct_name = "LineStyleThicknessModifier_Calligraphy";
 +                      break;
 +              default:
 +                      struct_name = "LineStyleThicknessModifier"; // this should not happen
 +              }
 +              writestruct(wd, DATA, struct_name, 1, m);
 +      }
 +      for (m = modifiers->first; m; m = m->next) {
 +              switch (m->type) {
 +              case LS_MODIFIER_ALONG_STROKE:
 +                      write_curvemapping(wd, ((LineStyleThicknessModifier_AlongStroke *)m)->curve);
 +                      break;
 +              case LS_MODIFIER_DISTANCE_FROM_CAMERA:
 +                      write_curvemapping(wd, ((LineStyleThicknessModifier_DistanceFromCamera *)m)->curve);
 +                      break;
 +              case LS_MODIFIER_DISTANCE_FROM_OBJECT:
 +                      write_curvemapping(wd, ((LineStyleThicknessModifier_DistanceFromObject *)m)->curve);
 +                      break;
 +              case LS_MODIFIER_MATERIAL:
 +                      write_curvemapping(wd, ((LineStyleThicknessModifier_Material *)m)->curve);
 +                      break;
 +              }
 +      }
 +}
 +
 +static void write_linestyle_geometry_modifiers(WriteData *wd, ListBase *modifiers)
 +{
 +      LineStyleModifier *m;
 +      char *struct_name;
 +
 +      for (m = modifiers->first; m; m = m->next) {
 +              switch (m->type) {
 +              case LS_MODIFIER_SAMPLING:
 +                      struct_name = "LineStyleGeometryModifier_Sampling";
 +                      break;
 +              case LS_MODIFIER_BEZIER_CURVE:
 +                      struct_name = "LineStyleGeometryModifier_BezierCurve";
 +                      break;
 +              case LS_MODIFIER_SINUS_DISPLACEMENT:
 +                      struct_name = "LineStyleGeometryModifier_SinusDisplacement";
 +                      break;
 +              case LS_MODIFIER_SPATIAL_NOISE:
 +                      struct_name = "LineStyleGeometryModifier_SpatialNoise";
 +                      break;
 +              case LS_MODIFIER_PERLIN_NOISE_1D:
 +                      struct_name = "LineStyleGeometryModifier_PerlinNoise1D";
 +                      break;
 +              case LS_MODIFIER_PERLIN_NOISE_2D:
 +                      struct_name = "LineStyleGeometryModifier_PerlinNoise2D";
 +                      break;
 +              case LS_MODIFIER_BACKBONE_STRETCHER:
 +                      struct_name = "LineStyleGeometryModifier_BackboneStretcher";
 +                      break;
 +              case LS_MODIFIER_TIP_REMOVER:
 +                      struct_name = "LineStyleGeometryModifier_TipRemover";
 +                      break;
 +              case LS_MODIFIER_POLYGONIZATION:
 +                      struct_name = "LineStyleGeometryModifier_Polygonalization";
 +                      break;
 +              case LS_MODIFIER_GUIDING_LINES:
 +                      struct_name = "LineStyleGeometryModifier_GuidingLines";
 +                      break;
 +              case LS_MODIFIER_BLUEPRINT:
 +                      struct_name = "LineStyleGeometryModifier_Blueprint";
 +                      break;
 +              default:
 +                      struct_name = "LineStyleGeometryModifier"; // this should not happen
 +              }
 +              writestruct(wd, DATA, struct_name, 1, m);
 +      }
 +}
 +
 +static void write_linestyles(WriteData *wd, ListBase *idbase)
 +{
 +      FreestyleLineStyle *linestyle;
 +
 +      for(linestyle=idbase->first; linestyle; linestyle= linestyle->id.next) {
 +              if(linestyle->id.us>0 || wd->current) {
 +                      writestruct(wd, ID_LS, "FreestyleLineStyle", 1, linestyle);
 +                      if (linestyle->id.properties) IDP_WriteProperty(linestyle->id.properties, wd);
 +                      if (linestyle->adt) write_animdata(wd, linestyle->adt);
 +                      write_linestyle_color_modifiers(wd, &linestyle->color_modifiers);
 +                      write_linestyle_alpha_modifiers(wd, &linestyle->alpha_modifiers);
 +                      write_linestyle_thickness_modifiers(wd, &linestyle->thickness_modifiers);
 +                      write_linestyle_geometry_modifiers(wd, &linestyle->geometry_modifiers);
 +              }
 +      }
 +}
 +
  /* context is usually defined by WM, two cases where no WM is available:
   * - for forward compatibility, curscreen has to be saved
   * - for undofile, curscene needs to be saved */
@@@ -2852,7 -2672,6 +2878,7 @@@ static int write_file_handle(Main *main
        write_brushes  (wd, &mainvar->brush);
        write_scripts  (wd, &mainvar->script);
        write_gpencils (wd, &mainvar->gpencil);
 +      write_linestyles(wd, &mainvar->linestyle);
        write_libraries(wd,  mainvar->next);
  
        if (write_user_block) {
index 8334986a76f4c2d08d87823079bda568ea5d5614,795446e76efa18bc907a197d0e8f61da2a84e19b..6e51443fc8debacc801c36a0460e1c4297114c87
@@@ -32,6 -32,7 +32,7 @@@
  #include "MEM_guardedalloc.h"
  
  #include "DNA_anim_types.h"
+ #include "DNA_dynamicpaint_types.h"
  #include "DNA_key_types.h"
  #include "DNA_scene_types.h"
  #include "DNA_userdef_types.h"
  #include "BLI_string.h"
  #include "BLI_ghash.h"
  
+ #include "BLF_translation.h"
  #include "BKE_animsys.h"
  #include "BKE_colortools.h"
  #include "BKE_context.h"
+ #include "BKE_dynamicpaint.h"
  #include "BKE_global.h"
  #include "BKE_library.h"
  #include "BKE_main.h"
@@@ -332,7 -336,7 +336,7 @@@ static const char *template_id_browse_t
        return N_("Browse ID data to be linked");
  }
  
- static void template_ID(bContext *C, uiLayout *layout, TemplateID *template, StructRNA *type, int flag, const char *newop, const char *openop, const char *unlinkop)
+ static void template_ID(bContext *C, uiLayout *layout, TemplateID *template, StructRNA *type, short idcode, int flag, const char *newop, const char *openop, const char *unlinkop)
  {
        uiBut *but;
        uiBlock *block;
                if((idfrom && idfrom->lib) || !editable)
                        uiButSetFlag(but, UI_BUT_DISABLED);
        }
+       if(idcode == ID_TE)
+               uiTemplateTextureShow(layout, C, &template->ptr, template->prop);
        
        uiBlockEndAlign(block);
  }
@@@ -487,6 -494,7 +494,7 @@@ static void ui_template_id(uiLayout *la
        TemplateID *template;
        PropertyRNA *prop;
        StructRNA *type;
+       short idcode;
  
        prop= RNA_struct_find_property(ptr, propname);
  
                flag |= UI_ID_OPEN;
  
        type= RNA_property_pointer_type(ptr, prop);
-       template->idlb= which_libbase(CTX_data_main(C), RNA_type_to_ID_code(type));
+       idcode= RNA_type_to_ID_code(type);
+       template->idlb= which_libbase(CTX_data_main(C), idcode);
        
        /* create UI elements for this template
         *      - template_ID makes a copy of the template data and assigns it to the relevant buttons
         */
        if(template->idlb) {
                uiLayoutRow(layout, 1);
-               template_ID(C, layout, template, type, flag, newop, openop, unlinkop);
+               template_ID(C, layout, template, type, idcode, flag, newop, openop, unlinkop);
        }
  
        MEM_freeN(template);
@@@ -684,7 -693,7 +693,7 @@@ static int modifier_can_delete(Modifier
  static int modifier_is_simulation(ModifierData *md)
  {
        // Physic Tab
-       if(ELEM6(md->type, eModifierType_Cloth, eModifierType_Collision, eModifierType_Fluidsim, eModifierType_Smoke, eModifierType_Softbody, eModifierType_Surface)) {
+       if(ELEM7(md->type, eModifierType_Cloth, eModifierType_Collision, eModifierType_Fluidsim, eModifierType_Smoke, eModifierType_Softbody, eModifierType_Surface, eModifierType_DynamicPaint)) {
                return 1;
        }
        // Particle Tab
@@@ -2047,6 -2056,13 +2056,13 @@@ static int list_item_icon_get(bContext 
        else if(RNA_struct_is_a(itemptr->type, &RNA_TextureSlot)) {
                id= RNA_pointer_get(itemptr, "texture").data;
        }
+       else if(RNA_struct_is_a(itemptr->type, &RNA_DynamicPaintSurface)) {
+               DynamicPaintSurface *surface= (DynamicPaintSurface*)itemptr->data;
+               if (surface->format == MOD_DPAINT_SURFACE_F_PTEX) return ICON_TEXTURE_SHADED;
+               else if (surface->format == MOD_DPAINT_SURFACE_F_VERTEX) return ICON_OUTLINER_DATA_MESH;
+               else if (surface->format == MOD_DPAINT_SURFACE_F_IMAGESEQ) return ICON_FILE_IMAGE;
+       }
  
        /* get icon from ID */
        if(id) {
@@@ -2098,7 -2114,7 +2114,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);
                /* nothing else special to do... */
                uiItemL(sub, name, icon); /* fails, backdrop LISTROW... */
        }
+       else if(itemptr->type == &RNA_DynamicPaintSurface) {
+               char name_final[96];
+               const char *enum_name;
+               PropertyRNA *prop = RNA_struct_find_property(itemptr, "surface_type");
+               DynamicPaintSurface *surface= (DynamicPaintSurface*)itemptr->data;
+               RNA_property_enum_name(C, itemptr, prop, RNA_property_enum_get(itemptr, prop), &enum_name);
+               BLI_snprintf(name_final, sizeof(name_final), "%s (%s)",name,enum_name);
+               uiItemL(sub, name_final, icon);
+               if (dynamicPaint_surfaceHasColorPreview(surface)) {
+                       uiBlockSetEmboss(block, UI_EMBOSSN);
+                       uiDefIconButR(block, OPTION, 0, (surface->flags & MOD_DPAINT_PREVIEW) ? ICON_RESTRICT_VIEW_OFF : ICON_RESTRICT_VIEW_ON,
+                               0, 0, UI_UNIT_X, UI_UNIT_Y, itemptr, "show_preview", 0, 0, 0, 0, 0, NULL);
+                       uiBlockSetEmboss(block, UI_EMBOSS);
+               }
+               uiDefButR(block, OPTION, 0, "", 0, 0, UI_UNIT_X, UI_UNIT_Y, itemptr, "is_active", i, 0, 0, 0, 0,  NULL);
+       }
        /* There is a last chance to display custom controls (in addition to the name/label):
         * If the given item property group features a string property named as prop_list,
         * this tries to add controls for all properties of the item listed in that string property.
index 90002611fbdc9848e1b48d4a105b5d4b9660f566,738531e3badd29882466bc29c0d263676f75a5ce..4581721a77649d580d1d1d06c20f6ab6cb2ae000
@@@ -339,10 -339,6 +339,10 @@@ const unsigned char *UI_ThemeGetColorPt
                                cp= ts->handle_sel_vect; break;
                        case TH_HANDLE_SEL_ALIGN:
                                cp= ts->handle_sel_align; break;
 +                      case TH_FREESTYLE_EDGE_MARK:
 +                              cp= ts->freestyle_edge_mark; break;
 +                      case TH_FREESTYLE_FACE_MARK:
 +                              cp= ts->freestyle_face_mark; break;
                
                        case TH_SYNTAX_B:
                                cp= ts->syntaxb; break;
@@@ -640,8 -636,6 +640,8 @@@ void ui_theme_init_default(void
        SETCOL(btheme->tv3d.button_text_hi, 255, 255, 255, 255);
        SETCOL(btheme->tv3d.button_title, 0, 0, 0, 255);
        SETCOL(btheme->tv3d.title, 0, 0, 0, 255);
 +      SETCOL(btheme->tv3d.freestyle_edge_mark, 0x7f, 0xff, 0x7f, 255);
 +      SETCOL(btheme->tv3d.freestyle_face_mark, 0x7f, 0xff, 0x7f, 51);
  
        btheme->tv3d.facedot_size= 4;
  
@@@ -1617,41 -1611,33 +1617,33 @@@ void init_userdef_do_versions(void
                }
        }
  
-       if (bmain->versionfile < 258 || (bmain->versionfile == 258 && bmain->subversionfile < 1)) {
-               bTheme *btheme;
-               
-               /* if new keyframes handle default is stuff "auto", make it "auto-clamped" instead */
-               if (U.keyhandles_new == HD_AUTO) 
-                       U.keyhandles_new = HD_AUTO_ANIM;
-                       
-               /* theme color additions */
-               for (btheme= U.themes.first; btheme; btheme= btheme->next) {
-                       /* auto-clamped handles -> based on auto */
-                       SETCOL(btheme->tipo.handle_auto_clamped, 0x99, 0x40, 0x30, 255);
-                       SETCOL(btheme->tipo.handle_sel_auto_clamped, 0xf0, 0xaf, 0x90, 255);
-               }
-       }
-       
        if (bmain->versionfile < 259 || (bmain->versionfile == 259 && bmain->subversionfile < 1)) {
                bTheme *btheme;
+               
                for(btheme= U.themes.first; btheme; btheme= btheme->next) {
                        btheme->tv3d.speaker[3] = 255;
                }
        }
  
-       {
+       if (bmain->versionfile < 260 || (bmain->versionfile == 260 && bmain->subversionfile < 3)) {
                bTheme *btheme;
-               for(btheme= U.themes.first; btheme; btheme= btheme->next) {
+               
+               /* if new keyframes handle default is stuff "auto", make it "auto-clamped" instead 
+                * was changed in 260 as part of GSoC11, but version patch was wrong
+                */
+               if (U.keyhandles_new == HD_AUTO) 
+                       U.keyhandles_new = HD_AUTO_ANIM;
+               
+               for(btheme= U.themes.first; btheme; btheme= btheme->next) {             
                        if(btheme->tv3d.bundle_solid[3] == 0)
                                SETCOL(btheme->tv3d.bundle_solid, 200, 200, 200, 255);
+                       
                        if(btheme->tv3d.camera_path[3] == 0)
                                SETCOL(btheme->tv3d.camera_path, 0x00, 0x00, 0x00, 255);
+                               
                        if((btheme->tclip.back[3]) == 0) {
                                btheme->tclip= btheme->tv3d;
+                               
                                SETCOL(btheme->tclip.marker_outline, 0x00, 0x00, 0x00, 255);
                                SETCOL(btheme->tclip.marker, 0x7f, 0x7f, 0x00, 255);
                                SETCOL(btheme->tclip.act_marker, 0xff, 0xff, 0xff, 255);
                                SETCOL(btheme->tclip.handle_vertex_select, 0xff, 0xff, 0, 0xff);
                                btheme->tclip.handle_vertex_size= 4;
                        }
+                       
+                       /* auto-clamped handles -> based on auto */
+                       if(btheme->tipo.handle_auto_clamped[3] == 0)
+                               SETCOL(btheme->tipo.handle_auto_clamped, 0x99, 0x40, 0x30, 255);
+                       if(btheme->tipo.handle_sel_auto_clamped[3] == 0)
+                               SETCOL(btheme->tipo.handle_sel_auto_clamped, 0xf0, 0xaf, 0x90, 255);
+               }
+               
+               /* enable (Cycles) addon by default */
+               if(!BLI_findstring(&U.addons, "cycles", offsetof(bAddon, module))) {
+                       bAddon *baddon= MEM_callocN(sizeof(bAddon), "bAddon");
+                       BLI_strncpy(baddon->module, "cycles", sizeof(baddon->module));
+                       BLI_addtail(&U.addons, baddon);
                }
        }
  
 +      /* Freestyle color settings */
 +      {
 +              bTheme *btheme;
 +
 +              for(btheme= U.themes.first; btheme; btheme= btheme->next) {
 +                      /* check for alpha==0 is safe, then color was never set */
 +                      if(btheme->tv3d.freestyle_edge_mark[3]==0) {
 +                              SETCOL(btheme->tv3d.freestyle_edge_mark, 0x7f, 0xff, 0x7f, 255);
 +                              SETCOL(btheme->tv3d.freestyle_face_mark, 0x7f, 0xff, 0x7f, 51);
 +                      }
 +              }
 +      }
 +
        /* GL Texture Garbage Collection (variable abused above!) */
        if (U.textimeout == 0) {
                U.texcollectrate = 60;
index 04fe5ed36e34d453c763184d9141a6850b68924a,3e4051cc751105d953f40f8b7319663195a849a8..1965e8e16132d5f0ab1503f2e5935ef4b4f7a6c6
@@@ -700,7 -700,6 +700,7 @@@ static int unified_findnearest(ViewCont
  #define SIMEDGE_SEAM          106
  #define SIMEDGE_SHARP         107
  #define SIMEDGE_TOT                   108
 +#define SIMEDGE_FREESTYLE     109
  
  /* FACE GROUP */
  
@@@ -723,7 -722,6 +723,7 @@@ static EnumPropertyItem prop_similar_ty
        {SIMEDGE_CREASE, "CREASE", 0, "Crease", ""},
        {SIMEDGE_SEAM, "SEAM", 0, "Seam", ""},
        {SIMEDGE_SHARP, "SHARP", 0, "Sharpness", ""},
 +      {SIMEDGE_FREESTYLE, "FREESTYLE", 0, "Freestyle Edge Mark", ""},
        {SIMFACE_MATERIAL, "MATERIAL", 0, "Material", ""},
        {SIMFACE_IMAGE, "IMAGE", 0, "Image", ""},
        {SIMFACE_AREA, "AREA", 0, "Area", ""},
@@@ -1076,20 -1074,6 +1076,20 @@@ static int similar_edge_select__interna
                                                        return selcount;
                                        }
                                }
 +                      } else if (mode==SIMEDGE_FREESTYLE) { /* Freestyle edge mark */
 +                              for(eed= em->edges.first; eed; eed= eed->next) {
 +                                      if (
 +                                              !(eed->f & SELECT) &&
 +                                              !eed->h &&
 +                                              (eed->freestyle == base_eed->freestyle)
 +                                      ) {
 +                                              EM_select_edge(eed, 1);
 +                                              selcount++;
 +                                              deselcount--;
 +                                              if (!deselcount) /*have we selected all posible faces?, if so return*/
 +                                                      return selcount;
 +                                      }
 +                              }
                        }
                }
        }       
@@@ -1328,7 -1312,7 +1328,7 @@@ void MESH_OT_select_similar(wmOperatorT
  
  int mesh_layers_menu_charlen(CustomData *data, int type)
  {
-        int i, len = 0;
+       int i, len = 0;
        /* see if there is a duplicate */
        for(i=0; i<data->totlayer; i++) {
                if((&data->layers[i])->type == type) {
@@@ -2234,9 -2218,6 +2234,9 @@@ static void mouse_mesh_shortest_path(bC
                        case EDGE_MODE_TAG_BEVEL:
                                me->drawflag |= ME_DRAWBWEIGHTS;
                                break;
 +                      case EDGE_MODE_TAG_FREESTYLE:
 +                              me->drawflag |= ME_DRAW_FREESTYLE_EDGE;
 +                              break;
                }
  
                /* live unwrap while tagging */
@@@ -3878,58 -3859,6 +3878,58 @@@ void MESH_OT_mark_sharp(wmOperatorType 
        RNA_def_boolean(ot->srna, "clear", 0, "Clear", "");
  }
  
 +static int editmesh_mark_freestyle_edge(bContext *C, wmOperator *op)
 +{
 +      Object *obedit= CTX_data_edit_object(C);
 +      EditMesh *em= BKE_mesh_get_editmesh(((Mesh *)obedit->data));
 +      Mesh *me= ((Mesh *)obedit->data);
 +      int clear = RNA_boolean_get(op->ptr, "clear");
 +      EditEdge *eed;
 +
 +      /* auto-enable Freestyle edge mark drawing */
 +      if(!clear) {
 +              me->drawflag |= ME_DRAW_FREESTYLE_EDGE;
 +      }
 +
 +      if(!clear) {
 +              eed= em->edges.first;
 +              while(eed) {
 +                      if(!eed->h && (eed->f & SELECT)) eed->freestyle = 1;
 +                      eed = eed->next;
 +              }
 +      } else {
 +              eed= em->edges.first;
 +              while(eed) {
 +                      if(!eed->h && (eed->f & SELECT)) eed->freestyle = 0;
 +                      eed = eed->next;
 +              }
 +      }
 +
 +      BKE_mesh_end_editmesh(obedit->data, em);
 +
 +      DAG_id_tag_update(obedit->data, 0);
 +      WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data);
 +
 +      return OPERATOR_FINISHED;
 +}
 +
 +void MESH_OT_mark_freestyle_edge(wmOperatorType *ot)
 +{
 +      /* identifiers */
 +      ot->name= "Mark Freestyle Edge";
 +      ot->description= "(un)mark selected edges as Freestyle feature edges";
 +      ot->idname= "MESH_OT_mark_freestyle_edge";
 +
 +      /* api callbacks */
 +      ot->exec= editmesh_mark_freestyle_edge;
 +      ot->poll= ED_operator_editmesh;
 +
 +      /* flags */
 +      ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
 +
 +      RNA_def_boolean(ot->srna, "clear", 0, "Clear", "");
 +}
 +
  /* **************** NORMALS ************** */
  
  void EM_recalc_normal_direction(EditMesh *em, int inside, int select) /* makes faces righthand turning */
index eb60a32afce12eb320d4c5b7ae54b4338d11f100,4ac418fdd9ac835d6397d228ec0b661d1f34a705..fb2c7c154fc8b649cfe95394cea4241cac1de966
@@@ -1651,7 -1651,7 +1651,7 @@@ static void fill_quad_single(EditMesh *
                facecopy(em, efa,hold);
                if(i+1 != (vertsize-1)/2) {
                        if(seltype == SUBDIV_SELECT_INNER) {
-                                hold->e3->f2 |= EDGEINNER;
+                               hold->e3->f2 |= EDGEINNER;
                        }
                }
        }
@@@ -1720,7 -1720,7 +1720,7 @@@ static void fill_tri_single(EditMesh *e
                hold = addfacelist(em, verts[i],verts[i+1],v[op],NULL,NULL,NULL);
                if(i+1 != vertsize-1) {
                        if(seltype == SUBDIV_SELECT_INNER) {
-                                hold->e2->f2 |= EDGEINNER;
+                               hold->e2->f2 |= EDGEINNER;
                        }
                }
                facecopy(em, efa,hold);
@@@ -2369,7 -2369,7 +2369,7 @@@ static void fill_quad_quadruple(EditMes
        }
        // Clean up our dynamic multi-dim array
        for(i=0;i<numcuts+2;i++) {
-          MEM_freeN(innerverts[i]);
+               MEM_freeN(innerverts[i]);
        }
        MEM_freeN(innerverts);
  }
@@@ -3760,7 -3760,6 +3760,7 @@@ static void edge_rotate(EditMesh *em, w
                        srchedge->h = eed->h;
                        srchedge->dir = eed->dir;
                        srchedge->seam = eed->seam;
 +                      srchedge->freestyle = eed->freestyle;
                        srchedge->crease = eed->crease;
                        srchedge->bweight = eed->bweight;
                }
@@@ -7589,54 -7588,3 +7589,54 @@@ void MESH_OT_select_axis(wmOperatorTyp
        RNA_def_enum(ot->srna, "axis", axis_items_xyz, 0, "Axis", "Select the axis to compare each vertex on");
  }
  
 +/********************** Freestyle Face Mark Operator *************************/
 +
 +static int mesh_mark_freestyle_face_exec(bContext *C, wmOperator *op)
 +{
 +      Object *obedit= CTX_data_edit_object(C);
 +      EditMesh *em= BKE_mesh_get_editmesh((Mesh *)obedit->data);
 +      Mesh *me= ((Mesh *)obedit->data);
 +      int clear = RNA_boolean_get(op->ptr, "clear");
 +      EditFace *efa;
 +
 +      /* auto-enable Freestyle face mark drawing */
 +      if(!clear) {
 +              me->drawflag |= ME_DRAW_FREESTYLE_FACE;
 +      }
 +
 +      if(!clear) {
 +              for(efa= em->faces.first; efa; efa=efa->next) {
 +                      if(efa->f & SELECT)
 +                              efa->flag |= ME_FREESTYLE_FACE;
 +              }
 +      } else {
 +              for(efa= em->faces.first; efa; efa=efa->next) {
 +                      if(efa->f & SELECT)
 +                              efa->flag &= ~ME_FREESTYLE_FACE;
 +              }
 +      }
 +
 +      BKE_mesh_end_editmesh(obedit->data, em);
 +
 +      DAG_id_tag_update(obedit->data, 0);
 +      WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data);
 +
 +      return OPERATOR_FINISHED;
 +}
 +
 +void MESH_OT_mark_freestyle_face(wmOperatorType *ot)
 +{
 +      /* identifiers */
 +      ot->name= "Mark Freestyle Face";
 +      ot->description= "(un)mark selected faces for exclusion from Freestyle feature edge detection";
 +      ot->idname= "MESH_OT_mark_freestyle_face";
 +
 +      /* api callbacks */
 +      ot->exec= mesh_mark_freestyle_face_exec;
 +      ot->poll= ED_operator_editmesh;
 +
 +      /* flags */
 +      ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
 +
 +      RNA_def_boolean(ot->srna, "clear", 0, "Clear", "");
 +}
index e5797e1a14a46ec7f48ab5e10d317ef25dbb8a0f,21fcc0677649b979037f3558e14c17b2ab6a07f8..70cdefddc7265500c2f1d8a2165ef914766be8b7
@@@ -36,6 -36,7 +36,7 @@@
  #include "DNA_camera_types.h"
  #include "DNA_curve_types.h"
  #include "DNA_constraint_types.h" // for drawing constraint
+ #include "DNA_dynamicpaint_types.h"
  #include "DNA_lamp_types.h"
  #include "DNA_lattice_types.h"
  #include "DNA_material_types.h"
  
  /* this condition has been made more complex since editmode can draw textures */
  #define CHECK_OB_DRAWTEXTURE(vd, dt)                                          \
-       ((vd->drawtype==OB_TEXTURE && dt>OB_SOLID) ||                             \
+       ((ELEM(vd->drawtype, OB_TEXTURE, OB_MATERIAL) && dt>OB_SOLID) ||          \
        (vd->drawtype==OB_SOLID && vd->flag2 & V3D_SOLID_TEX))
  
  static void draw_bounding_volume(Scene *scene, Object *ob, char type);
@@@ -252,6 -253,8 +253,8 @@@ int draw_glsl_material(Scene *scene, Ob
                return 0;
        if(ob==OBACT && (ob && ob->mode & OB_MODE_WEIGHT_PAINT))
                return 0;
+       if(scene_use_new_shading_nodes(scene))
+               return 0;
        
        return (scene->gm.matmode == GAME_MAT_GLSL) && (dt > OB_SOLID);
  }
@@@ -1476,7 -1479,7 +1479,7 @@@ static void draw_viewport_reconstructio
  
                glPushMatrix();
                        glTranslatef(track->bundle_pos[0], track->bundle_pos[1], track->bundle_pos[2]);
-                       glScalef(v3d->bundle_size/0.05, v3d->bundle_size/0.05, v3d->bundle_size/0.05);
+                       glScalef(v3d->bundle_size/0.05f, v3d->bundle_size/0.05f, v3d->bundle_size/0.05f);
  
                        if(v3d->drawtype==OB_WIRE) {
                                glDisable(GL_LIGHTING);
@@@ -1717,8 -1720,8 +1720,8 @@@ static void drawspeaker(Scene *UNUSED(s
  
                glBegin(GL_LINE_LOOP);
                for(i = 0; i < 16; i++) {
-                       vec[0] = cosf(M_PI * i / 8.0f) * (j == 0 ? 0.5f : 0.25f);
-                       vec[1] = sinf(M_PI * i / 8.0f) * (j == 0 ? 0.5f : 0.25f);
+                       vec[0] = cosf((float)M_PI * i / 8.0f) * (j == 0 ? 0.5f : 0.25f);
+                       vec[1] = sinf((float)M_PI * i / 8.0f) * (j == 0 ? 0.5f : 0.25f);
                        glVertex3fv(vec);
                }
                glEnd();
@@@ -2287,32 -2290,21 +2290,32 @@@ static void draw_dm_edges_sharp(Derived
        dm->drawMappedEdges(dm, draw_dm_edges_sharp__setDrawOptions, NULL);
  }
  
 +      /* Draw only Freestyle feature edges */
 +static int draw_dm_edges_freestyle__setDrawOptions(void *UNUSED(userData), int index)
 +{
 +      EditEdge *eed = EM_get_edge_for_index(index);
 +
 +      return (eed->h==0 && eed->freestyle);
 +}
 +static void draw_dm_edges_freestyle(DerivedMesh *dm)
 +{
 +      dm->drawMappedEdges(dm, draw_dm_edges_freestyle__setDrawOptions, NULL);
 +}
  
        /* Draw faces with color set based on selection
         * return 2 for the active face so it renders with stipple enabled */
  static int draw_dm_faces_sel__setDrawOptions(void *userData, int index, int *UNUSED(drawSmooth_r))
  {
 -      struct { unsigned char *cols[3]; EditFace *efa_act; } * data = userData;
 +      struct { unsigned char *cols[4]; EditFace *efa_act; } * data = userData;
        EditFace *efa = EM_get_face_for_index(index);
        unsigned char *col;
        
        if (efa->h==0) {
                if (efa == data->efa_act) {
 -                      glColor4ubv(data->cols[2]);
 +                      glColor4ubv(data->cols[3]);
                        return 2; /* stipple */
                } else {
 -                      col = data->cols[(efa->f&SELECT)?1:0];
 +                      col = data->cols[(efa->f & SELECT) ? 1 : (efa->flag & ME_FREESTYLE_FACE) ? 2 : 0];
                        if (col[3]==0) return 0;
                        glColor4ubv(col);
                        return 1;
  
  static int draw_dm_faces_sel__compareDrawOptions(void *userData, int index, int next_index)
  {
 -      struct { unsigned char *cols[3]; EditFace *efa_act; } * data = userData;
 +      struct { unsigned char *cols[4]; EditFace *efa_act; } * data = userData;
        EditFace *efa = EM_get_face_for_index(index);
        EditFace *next_efa = EM_get_face_for_index(next_index);
        unsigned char *col, *next_col;
        if(efa == data->efa_act || next_efa == data->efa_act)
                return 0;
  
 -      col = data->cols[(efa->f&SELECT)?1:0];
 -      next_col = data->cols[(next_efa->f&SELECT)?1:0];
 +      col = data->cols[(efa->f & SELECT) ? 1 : (efa->flag & ME_FREESTYLE_FACE) ? 2 : 0];
 +      next_col = data->cols[(next_efa->f & SELECT) ? 1 : (next_efa->flag & ME_FREESTYLE_FACE) ? 2 : 0];
  
        if(col[3]==0 || next_col[3]==0)
                return 0;
  }
  
  /* also draws the active face */
 -static void draw_dm_faces_sel(DerivedMesh *dm, unsigned char *baseCol, unsigned char *selCol, unsigned char *actCol, EditFace *efa_act) 
 +static void draw_dm_faces_sel(DerivedMesh *dm, unsigned char *baseCol, unsigned char *selCol, unsigned char *markCol, unsigned char *actCol, EditFace *efa_act) 
  {
 -      struct { unsigned char *cols[3]; EditFace *efa_act; } data;
 +      struct { unsigned char *cols[4]; EditFace *efa_act; } data;
        data.cols[0] = baseCol;
        data.cols[1] = selCol;
 -      data.cols[2] = actCol;
 +      data.cols[2] = markCol;
 +      data.cols[3] = actCol;
        data.efa_act = efa_act;
  
        dm->drawMappedFaces(dm, draw_dm_faces_sel__setDrawOptions, &data, 0, GPU_enable_material, draw_dm_faces_sel__compareDrawOptions);
@@@ -2573,7 -2564,7 +2576,7 @@@ static void draw_em_measure_stats(View3
                                copy_v3_v3(v1, eed->v1->co);
                                copy_v3_v3(v2, eed->v2->co);
  
-                               interp_v3_v3v3(vmid, v1, v2, 0.5f);
+                               mid_v3_v3v3(vmid, v1, v2);
  
                                if(do_global) {
                                        mul_mat3_m4_v3(ob->obmat, v1);
@@@ -2784,12 -2775,11 +2787,12 @@@ static void draw_em_fancy(Scene *scene
        }
        
        if(me->drawflag & ME_DRAWFACES) {       /* transp faces */
 -              unsigned char col1[4], col2[4], col3[4];
 +              unsigned char col1[4], col2[4], col3[4], col4[4];
                        
                UI_GetThemeColor4ubv(TH_FACE, col1);
                UI_GetThemeColor4ubv(TH_FACE_SELECT, col2);
 -              UI_GetThemeColor4ubv(TH_EDITMESH_ACTIVE, col3);
 +              UI_GetThemeColor4ubv(TH_FREESTYLE_FACE_MARK, col3);
 +              UI_GetThemeColor4ubv(TH_EDITMESH_ACTIVE, col4);
                
                glEnable(GL_BLEND);
                glDepthMask(0);         // disable write in zbuffer, needed for nice transp
                if CHECK_OB_DRAWTEXTURE(v3d, dt)
                        col1[3] = 0;
                
 -              draw_dm_faces_sel(cageDM, col1, col2, col3, efa_act);
 +              if (!(me->drawflag & ME_DRAW_FREESTYLE_FACE))
 +                      col3[3] = 0;
 +
 +              draw_dm_faces_sel(cageDM, col1, col2, col3, col4, efa_act);
  
                glDisable(GL_BLEND);
                glDepthMask(1);         // restore write in zbuffer
                /* even if draw faces is off it would be nice to draw the stipple face
                 * Make all other faces zero alpha except for the active
                 * */
 -              unsigned char col1[4], col2[4], col3[4];
 -              col1[3] = col2[3] = 0; /* dont draw */
 -              UI_GetThemeColor4ubv(TH_EDITMESH_ACTIVE, col3);
 +              unsigned char col1[4], col2[4], col3[4], col4[4];
 +              col1[3] = col2[3] = col3[3] = 0; /* dont draw */
 +              UI_GetThemeColor4ubv(TH_EDITMESH_ACTIVE, col4);
                
                glEnable(GL_BLEND);
                glDepthMask(0);         // disable write in zbuffer, needed for nice transp
                
 -              draw_dm_faces_sel(cageDM, col1, col2, col3, efa_act);
 +              draw_dm_faces_sel(cageDM, col1, col2, col3, col4, efa_act);
  
                glDisable(GL_BLEND);
                glDepthMask(1);         // restore write in zbuffer
                        draw_dm_edges_sharp(cageDM);
        
                        glColor3ub(0,0,0);
 +                      glLineWidth(1);
 +              }
 +      
 +              if(me->drawflag & ME_DRAW_FREESTYLE_EDGE) {
 +                      UI_ThemeColor(TH_FREESTYLE_EDGE_MARK);
 +                      glLineWidth(2);
 +      
 +                      draw_dm_edges_freestyle(cageDM);
 +      
 +                      glColor3ub(0,0,0);
                        glLineWidth(1);
                }
        
@@@ -2935,13 -2912,29 +2938,29 @@@ static void draw_mesh_fancy(Scene *scen
        Mesh *me = ob->data;
        Material *ma= give_current_material(ob, 1);
        const short hasHaloMat = (ma && (ma->material_type == MA_TYPE_HALO));
-       const short is_paint_sel= (ob==OBACT && paint_facesel_test(ob));
        int draw_wire = 0;
        int /* totvert,*/ totedge, totface;
        DerivedMesh *dm= mesh_get_derived_final(scene, ob, scene->customdata_mask);
+       ModifierData *md = NULL;
+       int draw_flags = (ob==OBACT && paint_facesel_test(ob)) ? DRAW_FACE_SELECT : 0;
  
        if(!dm)
                return;
+       /* check to draw dynamic paint colors */
+       if ((md = modifiers_findByType(ob, eModifierType_DynamicPaint)))
+       {
+               /* check if target has an active dpaint modifier        */
+               if(md && (md->mode & eModifierMode_Realtime))                                   
+               {
+                       DynamicPaintModifierData *pmd = (DynamicPaintModifierData *)md;
+                       /* if canvas is ready to preview vertex colors */
+                       if (pmd->canvas && pmd->canvas->flags & MOD_DPAINT_PREVIEW_READY &&
+                               DM_get_face_data_layer(dm, CD_WEIGHT_MCOL)) {
+                               draw_flags |= DRAW_DYNAMIC_PAINT_PREVIEW;
+                       }
+               }
+       }
        
        if (ob->dtx&OB_DRAWWIRE) {
                draw_wire = 2; /* draw wire after solid using zoffset and depth buffer adjusment */
        glFrontFace((ob->transflag&OB_NEG_SCALE)?GL_CW:GL_CCW);
  
                // Unwanted combination.
-       if (is_paint_sel) draw_wire = 0;
+       if (draw_flags & DRAW_FACE_SELECT) draw_wire = 0;
  
        if(dt==OB_BOUNDBOX) {
                if((v3d->flag2 & V3D_RENDER_OVERRIDE && v3d->drawtype >= OB_WIRE)==0)
        else if(dt==OB_WIRE || totface==0) {
                draw_wire = 1; /* draw wire only, no depth buffer stuff  */
        }
-       else if(        (is_paint_sel || (ob==OBACT && ob->mode & OB_MODE_TEXTURE_PAINT)) ||
+       else if(        (draw_flags & DRAW_FACE_SELECT || (ob==OBACT && ob->mode & OB_MODE_TEXTURE_PAINT)) ||
                                CHECK_OB_DRAWTEXTURE(v3d, dt))
        {
-               if ((v3d->flag&V3D_SELECT_OUTLINE) && ((v3d->flag2 & V3D_RENDER_OVERRIDE)==0) && (base->flag&SELECT) && !(G.f&G_PICKSEL || is_paint_sel) && !draw_wire) {
+               if ((v3d->flag&V3D_SELECT_OUTLINE) && ((v3d->flag2 & V3D_RENDER_OVERRIDE)==0) && (base->flag&SELECT) && !(G.f&G_PICKSEL || (draw_flags & DRAW_FACE_SELECT)) && !draw_wire) {
                        draw_mesh_object_outline(v3d, ob, dm);
                }
  
-               if(draw_glsl_material(scene, ob, v3d, dt)) {
+               if(draw_glsl_material(scene, ob, v3d, dt) && !(draw_flags & DRAW_DYNAMIC_PAINT_PREVIEW)) {
                        glFrontFace((ob->transflag&OB_NEG_SCALE)?GL_CW:GL_CCW);
  
                        dm->drawFacesGLSL(dm, GPU_enable_material);
                        glFrontFace(GL_CCW);
                }
                else {
-                       draw_mesh_textured(scene, v3d, rv3d, ob, dm, is_paint_sel);
+                       draw_mesh_textured(scene, v3d, rv3d, ob, dm, draw_flags);
                }
  
-               if(!is_paint_sel) {
+               if(!(draw_flags & DRAW_FACE_SELECT)) {
                        if(base->flag & SELECT)
                                UI_ThemeColor((ob==OBACT)?TH_ACTIVE:TH_SELECT);
                        else
                        /* since we already draw wire as wp guide, dont draw over the top */
                        draw_wire= 0;
                }
+               else if (draw_flags & DRAW_DYNAMIC_PAINT_PREVIEW) {
+                       /* for object selection draws no shade */
+                       if (flag & (DRAW_PICKING|DRAW_CONSTCOLOR)) {
+                               dm->drawFacesSolid(dm, NULL, 0, GPU_enable_material);
+                       }
+                       else {
+                               /* draw outline */
+                               if((v3d->flag&V3D_SELECT_OUTLINE) && ((v3d->flag2 & V3D_RENDER_OVERRIDE)==0) && (base->flag&SELECT) && !draw_wire && !ob->sculpt)
+                                       draw_mesh_object_outline(v3d, ob, dm);
+                               /* materials arent compatible with vertex colors */
+                               GPU_end_object_materials();
+                               GPU_enable_material(0, NULL);
+                               
+                               /* set default spec */
+                               glColorMaterial(GL_FRONT_AND_BACK, GL_SPECULAR);
+                               glEnable(GL_COLOR_MATERIAL);    /* according manpages needed */
+                               glColor3ub(120, 120, 120);
+                               glDisable(GL_COLOR_MATERIAL);
+                               /* diffuse */
+                               glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE);
+                               glEnable(GL_LIGHTING);
+                               glEnable(GL_COLOR_MATERIAL);
+                               dm->drawMappedFaces(dm, NULL, NULL, 1, GPU_enable_material, NULL);
+                               glDisable(GL_COLOR_MATERIAL);
+                               glDisable(GL_LIGHTING);
+                               GPU_disable_material();
+                       }
+               }
                else {
                        Paint *p;
  
index 1014c6f8b4095ccdcfddd61b7a916e7f97cd4a84,5060f55c533506c492c2fd3d6b3dfbc9ba20fae7..a50a1a6910ee3b435e2dfb0d329800a1e3177265
@@@ -513,7 -513,7 +513,7 @@@ wmKeyMap* transform_modal_keymap(wmKeyC
        {NUM_MODAL_INCREMENT_UP, "INCREMENT_UP", 0, "Numinput Increment Up", ""},
        {NUM_MODAL_INCREMENT_DOWN, "INCREMENT_DOWN", 0, "Numinput Increment Down", ""},
        {TFM_MODAL_PROPSIZE_UP, "PROPORTIONAL_SIZE_UP", 0, "Increase Proportional Influence", ""},
-       {TFM_MODAL_PROPSIZE_DOWN, "PROPORTIONAL_SIZE_DOWN", 0, "Decrease Poportional Influence", ""},
+       {TFM_MODAL_PROPSIZE_DOWN, "PROPORTIONAL_SIZE_DOWN", 0, "Decrease Proportional Influence", ""},
        {TFM_MODAL_AUTOIK_LEN_INC, "AUTOIK_CHAIN_LEN_UP", 0, "Increase Max AutoIK Chain Length", ""},
        {TFM_MODAL_AUTOIK_LEN_DEC, "AUTOIK_CHAIN_LEN_DOWN", 0, "Decrease Max AutoIK Chain Length", ""},
        {0, NULL, 0, NULL, NULL}};
@@@ -570,6 -570,9 +570,6 @@@ int transformEvent(TransInfo *t, wmEven
  
        if (event->type == MOUSEMOVE)
        {
 -              if (t->modifiers & MOD_CONSTRAINT_SELECT)
 -                      t->con.mode |= CON_SELECT;
 -
                copy_v2_v2_int(t->mval, event->mval);
  
                // t->redraw |= TREDRAW_SOFT; /* Use this for soft redraw. Might cause flicker in object mode */
@@@ -1755,9 -1758,6 +1755,9 @@@ void transformApply(bContext *C, TransI
  
        if ((t->redraw & TREDRAW_HARD) || (t->draw_handle_apply == NULL && (t->redraw & TREDRAW_SOFT)))
        {
 +              if (t->modifiers & MOD_CONSTRAINT_SELECT)
 +                      t->con.mode |= CON_SELECT;
 +
                selectConstraint(t);
                if (t->transform) {
                        t->transform(t, t->mval);  // calls recalcData()
@@@ -4691,7 -4691,7 +4691,7 @@@ static int createSlideVerts(TransInfo *
                                                        uv_new = tf->uv[k];
  
                                                        if (ev->tmp.l) {
-                                                               if (fabsf(suv->origuv[0]-uv_new[0]) > 0.0001f || fabs(suv->origuv[1]-uv_new[1]) > 0.0001f) {
+                                                               if (fabsf(suv->origuv[0]-uv_new[0]) > 0.0001f || fabsf(suv->origuv[1]-uv_new[1]) > 0.0001f) {
                                                                        ev->tmp.l = -1; /* Tag as invalid */
                                                                        BLI_linklist_free(suv->fuv_list,NULL);
                                                                        suv->fuv_list = NULL;
@@@ -5462,7 -5462,7 +5462,7 @@@ static void doAnimEdit_SnapFrame(TransI
                else
  #endif
                {
-                       val= (float)( floor(val+0.5f) );
+                       val= floorf(val+0.5f);
                }
                
                /* convert frame out of nla-action time */
@@@ -5548,13 -5548,13 +5548,13 @@@ static void headerTimeTranslate(TransIn
                /* apply snapping + frame->seconds conversions */
                if (autosnap == SACTSNAP_STEP) {
                        if (doTime)
-                               val= floor(val/secf + 0.5f);
+                               val= floor((double)val/secf + 0.5f);
                        else
                                val= floor(val + 0.5f);
                }
                else {
                        if (doTime)
-                               val= val / secf;
+                               val= (float)((double)val / secf);
                }
                
                if (autosnap == SACTSNAP_FRAME)
index 88a2163164a7705eb9232fb4ffa9c67228745b26,442ad662813d90eb26273801910e032e055a70da..9367826e102e5f0cd77ae9891af55ffb6bc33cd6
@@@ -493,6 -493,7 +493,6 @@@ void initTransformOrientation(bContext 
  
        switch(t->current_orientation) {
        case V3D_MANIP_GLOBAL:
 -              unit_m3(t->spacemtx);
                strcpy(t->spacename, "global");
                break;
  
@@@ -791,7 -792,7 +791,7 @@@ int getTransformOrientation(const bCont
                                float mat[4][4];
  
                                /* Rotation of MetaElem is stored in quat */
-                                quat_to_mat4( mat,ml_sel->quat);
+                               quat_to_mat4( mat,ml_sel->quat);
  
                                copy_v3_v3(normal, mat[2]);
  
index b4aa2f6da25992011458f0db76d9e8affe787834,c135254b11b7501a6dc480f2e628deed49541bc8..67171c35ca31b734a483055948a413989c9dc48b
@@@ -58,8 -58,8 +58,8 @@@ typedef struct IDProperty 
        IDPropertyData data;    /* note, alignment for 64 bits */
        int len; /* array length, also (this is important!) string length + 1.
                                the idea is to be able to reuse array realloc functions on strings.*/
-       /*totallen is total length of allocated array/string, including a buffer.
-         Note that the buffering is mild; the code comes from python's list implementation.*/
+       /* totallen is total length of allocated array/string, including a buffer.
+        * Note that the buffering is mild; the code comes from python's list implementation.*/
        int totallen; /*strings and arrays are both buffered, though the buffer isn't
                                        saved.*/
  } IDProperty;
@@@ -195,7 -195,6 +195,7 @@@ typedef struct PreviewImage 
  #define ID_GD         MAKE_ID2('G', 'D') /* GreasePencil */
  #define ID_WM         MAKE_ID2('W', 'M') /* WindowManager */
  #define ID_MC         MAKE_ID2('M', 'C') /* MovieClip */
 +#define ID_LS         MAKE_ID2('L', 'S') /* FreestyleLineStyle */
  
        /* NOTE! Fake IDs, needed for g.sipo->blocktype or outliner */
  #define ID_SEQ                MAKE_ID2('S', 'Q')
index 0cfe9763267bc4dc8f2ffa7c3293b0ddc9596fab,c060eb186c9c1066529cddcc5a84704f052ae1d2..781fe805812fdf1ecc19d8dc37c3d1d331e0c832
@@@ -133,8 -133,7 +133,9 @@@ const char *includefiles[] = 
        "DNA_speaker_types.h",
        "DNA_movieclip_types.h",
        "DNA_tracking_types.h",
+       "DNA_dynamicpaint_types.h",
 +      "DNA_freestyle_types.h",
 +      "DNA_linestyle_types.h",
  
        // empty string to indicate end of includefiles
        ""
@@@ -1202,6 -1201,5 +1203,7 @@@ int main(int argc, char ** argv
  #include "DNA_speaker_types.h"
  #include "DNA_movieclip_types.h"
  #include "DNA_tracking_types.h"
+ #include "DNA_dynamicpaint_types.h"
 +#include "DNA_freestyle_types.h"
 +#include "DNA_linestyle_types.h"
  /* end of list */
index 1e0231fd4a6280c887351a47a274b7d6d63ad425,c9dadce0a5edec0151637ea6ef5cf40ac92d5c06..c34f319b0a15dcd81ddf673c42e47b385ae99dd0
@@@ -197,6 -197,10 +197,10 @@@ extern StructRNA RNA_Driver
  extern StructRNA RNA_DriverTarget;
  extern StructRNA RNA_DriverVariable;
  extern StructRNA RNA_DupliObject;
+ extern StructRNA RNA_DynamicPaintBrushSettings;
+ extern StructRNA RNA_DynamicPaintCanvasSettings;
+ extern StructRNA RNA_DynamicPaintModifier;
+ extern StructRNA RNA_DynamicPaintSurface;
  extern StructRNA RNA_EdgeSplitModifier;
  extern StructRNA RNA_EditBone;
  extern StructRNA RNA_EffectSequence;
@@@ -228,10 -232,6 +232,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;
@@@ -286,35 -286,6 +290,35 @@@ 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_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;
@@@ -656,6 -627,8 +660,8 @@@ StructRNA *RNA_struct_base(StructRNA *t
  int RNA_struct_is_ID(StructRNA *type);
  int RNA_struct_is_a(StructRNA *type, StructRNA *srna);
  
+ int RNA_struct_undo_check(StructRNA *type);
  StructRegisterFunc RNA_struct_register(StructRNA *type);
  StructUnregisterFunc RNA_struct_unregister(StructRNA *type);
  void **RNA_struct_instance(PointerRNA *ptr);
index 41483213bd45b9b84e00ae5972ca9c6ca0a8736e,a4866238caa8f8b3a3b9d34faeb01e8c775115bb..509db622b703d43a2c9296c63a64dfba424681f5
@@@ -114,11 -114,8 +114,13 @@@ extern EnumPropertyItem node_filter_ite
  
  extern EnumPropertyItem ramp_blend_items[];
  
+ extern EnumPropertyItem prop_dynamicpaint_type_items[];
 +extern EnumPropertyItem linestyle_color_modifier_type_items[];
 +extern EnumPropertyItem linestyle_alpha_modifier_type_items[];
 +extern EnumPropertyItem linestyle_thickness_modifier_type_items[];
 +extern EnumPropertyItem linestyle_geometry_modifier_type_items[];
 +
  struct bContext;
  struct PointerRNA;
  struct PropertyRNA;
index 9f248f973a1eee175993dd2712fba8d918590f84,769ec880a65178a97c5ebe8c3cc03abc7d1b2e0c..c4b3f204b23e596dc2c5bf9501ae2633d067284c
@@@ -11,7 -11,6 +11,7 @@@ incs += ' ../windowmanager ../editors/i
  incs += ' ../render/extern/include'
  incs += ' ../nodes'
  incs += ' #/extern/glew/include'
 +incs += ' ../freestyle'
  
  defs = []
  
@@@ -66,4 -65,6 +66,6 @@@ if env['OURPLATFORM'] in ('win32-vc', '
  if env['WITH_BF_INTERNATIONAL']:
      defs.append('WITH_INTERNATIONAL')
  
- env.BlenderLib ( 'bf_rna', objs, Split(incs), defines=defs, libtype=['core','player'], priority = [165,20] )
+ rnalib = env.BlenderLib ( 'bf_rna', objs, Split(incs), defines=defs, libtype=['core','player'], priority = [165,20] )
+ Return ('rnalib')
index 8038dc2b04a64edeba23a3648257eac884729584,9bc532afa11c76ee8ae5f73affc769dfbae0e2d3..f61db894263c3bfb3fd4e10f3c2c13afe35601bf
@@@ -46,6 -46,7 +46,7 @@@ set(DEFSR
        rna_context.c
        rna_controller.c
        rna_curve.c
+       rna_dynamicpaint.c
        rna_fcurve.c
        rna_fluidsim.c
        rna_gpencil.c
@@@ -54,7 -55,6 +55,7 @@@
        rna_key.c
        rna_lamp.c
        rna_lattice.c
 +      rna_linestyle.c
        rna_main.c
        rna_material.c
        rna_mesh.c
@@@ -241,7 -241,6 +242,7 @@@ blender_include_dirs
        ../../windowmanager
        ../../editors/include
        ../../render/extern/include
 +      ../../freestyle
        ../../../../intern/audaspace/intern
        ../../../../intern/guardedalloc
        ../../../../intern/memutil
index 9cb2706886a99559a64561d36564c119987e2974,1eaeaf8278fd2ae3c716d9a3f3454173e07d0d2a..b6ddfe39e9dbad441f6817e67ed37ae88c872f66
@@@ -2440,6 -2440,7 +2440,7 @@@ static RNAProcessItem PROCESS_ITEMS[]= 
        {"rna_context.c", NULL, RNA_def_context},
        {"rna_controller.c", "rna_controller_api.c", RNA_def_controller},
        {"rna_curve.c", NULL, RNA_def_curve},
+       {"rna_dynamicpaint.c", NULL, RNA_def_dynamic_paint},
        {"rna_fcurve.c", "rna_fcurve_api.c", RNA_def_fcurve},
        {"rna_fluidsim.c", NULL, RNA_def_fluidsim},
        {"rna_gpencil.c", NULL, RNA_def_gpencil},
        {"rna_key.c", NULL, RNA_def_key},
        {"rna_lamp.c", NULL, RNA_def_lamp},
        {"rna_lattice.c", NULL, RNA_def_lattice},
 +      {"rna_linestyle.c", NULL, RNA_def_linestyle},
        {"rna_main.c", "rna_main_api.c", RNA_def_main},
        {"rna_material.c", "rna_material_api.c", RNA_def_material},
        {"rna_mesh.c", "rna_mesh_api.c", RNA_def_mesh},
index 35513e1287233756e76d25fc1ea0bd0d82dd8ba5,e9f8ecd1ef234e2db7acdc098ddf5f4b63ff9edc..809127258c5c026deb17125eb4ccb053b8b22ce4
@@@ -136,6 -136,7 +136,7 @@@ void RNA_def_constraint(struct BlenderR
  void RNA_def_context(struct BlenderRNA *brna);
  void RNA_def_controller(struct BlenderRNA *brna);
  void RNA_def_curve(struct BlenderRNA *brna);
+ void RNA_def_dynamic_paint(struct BlenderRNA *brna);
  void RNA_def_fluidsim(struct BlenderRNA *brna);
  void RNA_def_fcurve(struct BlenderRNA *brna);
  void RNA_def_gameproperty(struct BlenderRNA *brna);
@@@ -145,7 -146,6 +146,7 @@@ void RNA_def_image(struct BlenderRNA *b
  void RNA_def_key(struct BlenderRNA *brna);
  void RNA_def_lamp(struct BlenderRNA *brna);
  void RNA_def_lattice(struct BlenderRNA *brna);
 +void RNA_def_linestyle(struct BlenderRNA *brna);
  void RNA_def_main(struct BlenderRNA *brna);
  void RNA_def_material(struct BlenderRNA *brna);
  void RNA_def_mesh(struct BlenderRNA *brna);
@@@ -294,7 -294,6 +295,7 @@@ void RNA_def_main_actions(BlenderRNA *b
  void RNA_def_main_particles(BlenderRNA *brna, PropertyRNA *cprop);
  void RNA_def_main_gpencil(BlenderRNA *brna, PropertyRNA *cprop);
  void RNA_def_main_movieclips(BlenderRNA *brna, PropertyRNA *cprop);
 +void RNA_def_main_linestyles(BlenderRNA *brna, PropertyRNA *cprop);
  
  /* ID Properties */
  
index 58be8fc62c481d04c9643ea0505dc075f16a1d17,0000000000000000000000000000000000000000..736bc67a6ab8f8b7f92ba0bd3551e876a9b3f348
mode 100644,000000..100644
--- /dev/null
@@@ -1,908 -1,0 +1,908 @@@
-               {MA_RAMP_SOFT, "SOFT LIGHT", 0, "Soft Light", ""}, 
-               {MA_RAMP_LINEAR, "LINEAR LIGHT", 0, "Linear Light", ""}, 
 +/**
 + * $Id$
 + *
 + * ***** BEGIN GPL LICENSE BLOCK *****
 + *
 + * This program is free software; you can redistribute it and/or
 + * modify it under the terms of the GNU General Public License
 + * as published by the Free Software Foundation; either version 2
 + * of the License, or (at your option) any later version.
 + *
 + * This program is distributed in the hope that it will be useful,
 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 + * GNU General Public License for more details.
 + *
 + * You should have received a copy of the GNU General Public License
 + * along with this program; if not, write to the Free Software Foundation,
 + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 + *
 + * Contributor(s): Blender Foundation (2008).
 + *
 + * ***** END GPL LICENSE BLOCK *****
 + */
 +
 +#include <stdio.h>
 +#include <stdlib.h>
 +
 +#include "RNA_define.h"
 +
 +#include "rna_internal.h"
 +
 +#include "DNA_linestyle_types.h"
 +#include "DNA_material_types.h"
 +#include "DNA_texture_types.h"
 +
 +#include "WM_types.h"
 +#include "WM_api.h"
 +
 +EnumPropertyItem linestyle_color_modifier_type_items[] ={
 +      {LS_MODIFIER_ALONG_STROKE, "ALONG_STROKE", ICON_MODIFIER, "Along Stroke", ""},
 +      {LS_MODIFIER_DISTANCE_FROM_CAMERA, "DISTANCE_FROM_CAMERA", ICON_MODIFIER, "Distance from Camera", ""},
 +      {LS_MODIFIER_DISTANCE_FROM_OBJECT, "DISTANCE_FROM_OBJECT", ICON_MODIFIER, "Distance from Object", ""},
 +      {LS_MODIFIER_MATERIAL, "MATERIAL", ICON_MODIFIER, "Material", ""},
 +      {0, NULL, 0, NULL, NULL}};
 +
 +EnumPropertyItem linestyle_alpha_modifier_type_items[] ={
 +      {LS_MODIFIER_ALONG_STROKE, "ALONG_STROKE", ICON_MODIFIER, "Along Stroke", ""},
 +      {LS_MODIFIER_DISTANCE_FROM_CAMERA, "DISTANCE_FROM_CAMERA", ICON_MODIFIER, "Distance from Camera", ""},
 +      {LS_MODIFIER_DISTANCE_FROM_OBJECT, "DISTANCE_FROM_OBJECT", ICON_MODIFIER, "Distance from Object", ""},
 +      {LS_MODIFIER_MATERIAL, "MATERIAL", ICON_MODIFIER, "Material", ""},
 +      {0, NULL, 0, NULL, NULL}};
 +
 +EnumPropertyItem linestyle_thickness_modifier_type_items[] ={
 +      {LS_MODIFIER_ALONG_STROKE, "ALONG_STROKE", ICON_MODIFIER, "Along Stroke", ""},
 +      {LS_MODIFIER_CALLIGRAPHY, "CALLIGRAPHY", ICON_MODIFIER, "Calligraphy", ""},
 +      {LS_MODIFIER_DISTANCE_FROM_CAMERA, "DISTANCE_FROM_CAMERA", ICON_MODIFIER, "Distance from Camera", ""},
 +      {LS_MODIFIER_DISTANCE_FROM_OBJECT, "DISTANCE_FROM_OBJECT", ICON_MODIFIER, "Distance from Object", ""},
 +      {LS_MODIFIER_MATERIAL, "MATERIAL", ICON_MODIFIER, "Material", ""},
 +      {0, NULL, 0, NULL, NULL}};
 +
 +EnumPropertyItem linestyle_geometry_modifier_type_items[] ={
 +      {LS_MODIFIER_BACKBONE_STRETCHER, "BACKBONE_STRETCHER", ICON_MODIFIER, "Backbone Stretcher", ""},
 +      {LS_MODIFIER_BEZIER_CURVE, "BEZIER_CURVE", ICON_MODIFIER, "Bezier Curve", ""},
 +      {LS_MODIFIER_BLUEPRINT, "BLUEPRINT", ICON_MODIFIER, "Blueprint", ""},
 +      {LS_MODIFIER_GUIDING_LINES, "GUIDING_LINES", ICON_MODIFIER, "Guiding Lines", ""},
 +      {LS_MODIFIER_PERLIN_NOISE_1D, "PERLIN_NOISE_1D", ICON_MODIFIER, "Perlin Noise 1D", ""},
 +      {LS_MODIFIER_PERLIN_NOISE_2D, "PERLIN_NOISE_2D", ICON_MODIFIER, "Perlin Noise 2D", ""},
 +      {LS_MODIFIER_POLYGONIZATION, "POLYGONIZATION", ICON_MODIFIER, "Polygonization", ""},
 +      {LS_MODIFIER_SAMPLING, "SAMPLING", ICON_MODIFIER, "Sampling", ""},
 +      {LS_MODIFIER_SINUS_DISPLACEMENT, "SINUS_DISPLACEMENT", ICON_MODIFIER, "Sinus Displacement", ""},
 +      {LS_MODIFIER_SPATIAL_NOISE, "SPATIAL_NOISE", ICON_MODIFIER, "Spatial Noise", ""},
 +      {LS_MODIFIER_TIP_REMOVER, "TIP_REMOVER", ICON_MODIFIER, "Tip Remover", ""},
 +      {0, NULL, 0, NULL, NULL}};
 +
 +#ifdef RNA_RUNTIME
 +
 +static StructRNA *rna_LineStyle_color_modifier_refine(struct PointerRNA *ptr)
 +{
 +      LineStyleModifier *m = (LineStyleModifier *)ptr->data;
 +
 +      switch(m->type) {
 +              case LS_MODIFIER_ALONG_STROKE:
 +                      return &RNA_LineStyleColorModifier_AlongStroke;
 +              case LS_MODIFIER_DISTANCE_FROM_CAMERA:
 +                      return &RNA_LineStyleColorModifier_DistanceFromCamera;
 +              case LS_MODIFIER_DISTANCE_FROM_OBJECT:
 +                      return &RNA_LineStyleColorModifier_DistanceFromObject;
 +              case LS_MODIFIER_MATERIAL:
 +                      return &RNA_LineStyleColorModifier_Material;
 +              default:
 +                      return &RNA_LineStyleColorModifier;
 +      }
 +}
 +
 +static StructRNA *rna_LineStyle_alpha_modifier_refine(struct PointerRNA *ptr)
 +{
 +      LineStyleModifier *m = (LineStyleModifier *)ptr->data;
 +
 +      switch(m->type) {
 +              case LS_MODIFIER_ALONG_STROKE:
 +                      return &RNA_LineStyleAlphaModifier_AlongStroke;
 +              case LS_MODIFIER_DISTANCE_FROM_CAMERA:
 +                      return &RNA_LineStyleAlphaModifier_DistanceFromCamera;
 +              case LS_MODIFIER_DISTANCE_FROM_OBJECT:
 +                      return &RNA_LineStyleAlphaModifier_DistanceFromObject;
 +              case LS_MODIFIER_MATERIAL:
 +                      return &RNA_LineStyleAlphaModifier_Material;
 +              default:
 +                      return &RNA_LineStyleAlphaModifier;
 +      }
 +}
 +
 +static StructRNA *rna_LineStyle_thickness_modifier_refine(struct PointerRNA *ptr)
 +{
 +      LineStyleModifier *m = (LineStyleModifier *)ptr->data;
 +
 +      switch(m->type) {
 +              case LS_MODIFIER_ALONG_STROKE:
 +                      return &RNA_LineStyleThicknessModifier_AlongStroke;
 +              case LS_MODIFIER_DISTANCE_FROM_CAMERA:
 +                      return &RNA_LineStyleThicknessModifier_DistanceFromCamera;
 +              case LS_MODIFIER_DISTANCE_FROM_OBJECT:
 +                      return &RNA_LineStyleThicknessModifier_DistanceFromObject;
 +              case LS_MODIFIER_MATERIAL:
 +                      return &RNA_LineStyleThicknessModifier_Material;
 +              case LS_MODIFIER_CALLIGRAPHY:
 +                      return &RNA_LineStyleThicknessModifier_Calligraphy;
 +              default:
 +                      return &RNA_LineStyleThicknessModifier;
 +      }
 +}
 +
 +static StructRNA *rna_LineStyle_geometry_modifier_refine(struct PointerRNA *ptr)
 +{
 +      LineStyleModifier *m = (LineStyleModifier *)ptr->data;
 +
 +      switch(m->type) {
 +              case LS_MODIFIER_SAMPLING:
 +                      return &RNA_LineStyleGeometryModifier_Sampling;
 +              case LS_MODIFIER_BEZIER_CURVE:
 +                      return &RNA_LineStyleGeometryModifier_BezierCurve;
 +              case LS_MODIFIER_SINUS_DISPLACEMENT:
 +                      return &RNA_LineStyleGeometryModifier_SinusDisplacement;
 +              case LS_MODIFIER_SPATIAL_NOISE:
 +                      return &RNA_LineStyleGeometryModifier_SpatialNoise;
 +              case LS_MODIFIER_PERLIN_NOISE_1D:
 +                      return &RNA_LineStyleGeometryModifier_PerlinNoise1D;
 +              case LS_MODIFIER_PERLIN_NOISE_2D:
 +                      return &RNA_LineStyleGeometryModifier_PerlinNoise2D;
 +              case LS_MODIFIER_BACKBONE_STRETCHER:
 +                      return &RNA_LineStyleGeometryModifier_BackboneStretcher;
 +              case LS_MODIFIER_TIP_REMOVER:
 +                      return &RNA_LineStyleGeometryModifier_TipRemover;
 +              case LS_MODIFIER_POLYGONIZATION:
 +                      return &RNA_LineStyleGeometryModifier_Polygonalization;
 +              case LS_MODIFIER_GUIDING_LINES:
 +                      return &RNA_LineStyleGeometryModifier_GuidingLines;
 +              case LS_MODIFIER_BLUEPRINT:
 +                      return &RNA_LineStyleGeometryModifier_Blueprint;
 +              default:
 +                      return &RNA_LineStyleGeometryModifier;
 +      }
 +}
 +
 +static char *rna_LineStyle_color_modifier_path(PointerRNA *ptr)
 +{
 +      return BLI_sprintfN("color_modifiers[\"%s\"]", ((LineStyleModifier*)ptr->data)->name);
 +}
 +
 +static char *rna_LineStyle_alpha_modifier_path(PointerRNA *ptr)
 +{
 +      return BLI_sprintfN("alpha_modifiers[\"%s\"]", ((LineStyleModifier*)ptr->data)->name);
 +}
 +
 +static char *rna_LineStyle_thickness_modifier_path(PointerRNA *ptr)
 +{
 +      return BLI_sprintfN("thickness_modifiers[\"%s\"]", ((LineStyleModifier*)ptr->data)->name);
 +}
 +
 +static char *rna_LineStyle_geometry_modifier_path(PointerRNA *ptr)
 +{
 +      return BLI_sprintfN("geometry_modifiers[\"%s\"]", ((LineStyleModifier*)ptr->data)->name);
 +}
 +
 +#else
 +
 +#include "DNA_material_types.h"
 +
 +static void rna_def_modifier_type_common(StructRNA *srna, EnumPropertyItem *modifier_type_items, int blend, int color)
 +{
 +      PropertyRNA *prop;
 +
 +      static EnumPropertyItem color_blend_items[] = {
 +              {MA_RAMP_BLEND, "MIX", 0, "Mix", ""},
 +              {MA_RAMP_ADD, "ADD", 0, "Add", ""},
 +              {MA_RAMP_MULT, "MULTIPLY", 0, "Multiply", ""},
 +              {MA_RAMP_SUB, "SUBTRACT", 0, "Subtract", ""},
 +              {MA_RAMP_SCREEN, "SCREEN", 0, "Screen", ""},
 +              {MA_RAMP_DIV, "DIVIDE", 0, "Divide", ""},
 +              {MA_RAMP_DIFF, "DIFFERENCE", 0, "Difference", ""},
 +              {MA_RAMP_DARK, "DARKEN", 0, "Darken", ""},
 +              {MA_RAMP_LIGHT, "LIGHTEN", 0, "Lighten", ""},
 +              {MA_RAMP_OVERLAY, "OVERLAY", 0, "Overlay", ""},
 +              {MA_RAMP_DODGE, "DODGE", 0, "Dodge", ""},
 +              {MA_RAMP_BURN, "BURN", 0, "Burn", ""},
 +              {MA_RAMP_HUE, "HUE", 0, "Hue", ""},
 +              {MA_RAMP_SAT, "SATURATION", 0, "Saturation", ""},
 +              {MA_RAMP_VAL, "VALUE", 0, "Value", ""},
 +              {MA_RAMP_COLOR, "COLOR", 0, "Color", ""},
++              {MA_RAMP_SOFT, "SOFT_LIGHT", 0, "Soft Light", ""}, 
++              {MA_RAMP_LINEAR, "LINEAR_LIGHT", 0, "Linear Light", ""}, 
 +              {0, NULL, 0, NULL, NULL}};
 +
 +      static EnumPropertyItem value_blend_items[] = {
 +              {LS_VALUE_BLEND, "MIX", 0, "Mix", ""},
 +              {LS_VALUE_ADD, "ADD", 0, "Add", ""},
 +              {LS_VALUE_SUB, "SUBTRACT", 0, "Subtract", ""},
 +              {LS_VALUE_MULT, "MULTIPLY", 0, "Multiply", ""},
 +              {LS_VALUE_DIV, "DIVIDE", 0, "Divide", ""},
 +              {LS_VALUE_DIFF, "DIFFERENCE", 0, "Divide", ""},
 +              {LS_VALUE_MIN, "MININUM", 0, "Minimum", ""}, 
 +              {LS_VALUE_MAX, "MAXIMUM", 0, "Maximum", ""}, 
 +              {0, NULL, 0, NULL, NULL}};
 +
 +      prop= RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
 +      RNA_def_property_enum_sdna(prop, NULL, "modifier.type");
 +      RNA_def_property_enum_items(prop, modifier_type_items);
 +      RNA_def_property_clear_flag(prop, PROP_EDITABLE);
 +      RNA_def_property_ui_text(prop, "Modifier Type", "Type of the modifier");
 +
 +      prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
 +      RNA_def_property_string_sdna(prop, NULL, "modifier.name");
 +      RNA_def_property_ui_text(prop, "Modifier Name", "Name of the modifier");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +      RNA_def_struct_name_property(srna, prop);
 +
 +      if (blend) {
 +              prop= RNA_def_property(srna, "blend", PROP_ENUM, PROP_NONE);
 +              RNA_def_property_enum_sdna(prop, NULL, "modifier.blend");
 +              RNA_def_property_enum_items(prop, (color) ? color_blend_items : value_blend_items);
 +              RNA_def_property_ui_text(prop, "Blend", "Specify how the modifier value is blended into the base value");
 +              RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +              prop= RNA_def_property(srna, "influence", PROP_FLOAT, PROP_FACTOR);
 +              RNA_def_property_float_sdna(prop, NULL, "modifier.influence");
 +              RNA_def_property_range(prop, 0.0f, 1.0f);
 +              RNA_def_property_ui_text(prop, "Influence", "Influence factor by which the modifier changes the property");
 +              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, "modifier.flags", LS_MODIFIER_ENABLED);
 +      RNA_def_property_ui_text(prop, "Use", "Enable or disable this modifier during stroke rendering");
 +
 +      prop= RNA_def_property(srna, "expanded", PROP_BOOLEAN, PROP_NONE);
 +      RNA_def_property_boolean_sdna(prop, NULL, "modifier.flags", LS_MODIFIER_EXPANDED);
 +      RNA_def_property_ui_text(prop, "Expanded", "True if the modifier tab is expanded");
 +}
 +
 +static void rna_def_color_modifier(StructRNA *srna)
 +{
 +      rna_def_modifier_type_common(srna, linestyle_color_modifier_type_items, 1, 1);
 +}
 +
 +static void rna_def_alpha_modifier(StructRNA *srna)
 +{
 +      rna_def_modifier_type_common(srna, linestyle_alpha_modifier_type_items, 1, 0);
 +}
 +
 +static void rna_def_thickness_modifier(StructRNA *srna)
 +{
 +      rna_def_modifier_type_common(srna, linestyle_thickness_modifier_type_items, 1, 0);
 +}
 +
 +static void rna_def_geometry_modifier(StructRNA *srna)
 +{
 +      rna_def_modifier_type_common(srna, linestyle_geometry_modifier_type_items, 0, 0);
 +}
 +
 +static void rna_def_modifier_color_ramp_common(StructRNA *srna, int range)
 +{
 +      PropertyRNA *prop;
 +
 +      prop= RNA_def_property(srna, "color_ramp", PROP_POINTER, PROP_NONE);
 +      RNA_def_property_pointer_sdna(prop, NULL, "color_ramp");
 +      RNA_def_property_struct_type(prop, "ColorRamp");
 +      RNA_def_property_ui_text(prop, "Color Ramp", "Color ramp used to change line color");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      if (range) {
 +              prop= RNA_def_property(srna, "range_min", PROP_FLOAT, PROP_NONE);
 +              RNA_def_property_float_sdna(prop, NULL, "range_min");
 +              RNA_def_property_ui_text(prop, "Range Min", "Lower bound of the input range the mapping is applied");
 +              RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +              prop= RNA_def_property(srna, "range_max", PROP_FLOAT, PROP_NONE);
 +              RNA_def_property_float_sdna(prop, NULL, "range_max");
 +              RNA_def_property_ui_text(prop, "Range Max", "Upper bound of the input range the mapping is applied");
 +              RNA_def_property_update(prop, NC_SCENE, NULL);
 +      }
 +}
 +
 +static void rna_def_modifier_curve_common(StructRNA *srna, int range, int value)
 +{
 +      PropertyRNA *prop;
 +
 +      static EnumPropertyItem mapping_items[] = {
 +              {0, "LINEAR", 0, "Linear", "Use linear mapping"},
 +              {LS_MODIFIER_USE_CURVE, "CURVE", 0, "Curve", "Use curve mapping"},
 +              {0, NULL, 0, NULL, NULL}};
 +
 +      prop= RNA_def_property(srna, "mapping", PROP_ENUM, PROP_NONE);
 +      RNA_def_property_enum_bitflag_sdna(prop, NULL, "flags");
 +      RNA_def_property_enum_items(prop, mapping_items);
 +      RNA_def_property_ui_text(prop, "Mapping", "Select the mapping type");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "invert", PROP_BOOLEAN, PROP_NONE);
 +      RNA_def_property_boolean_sdna(prop, NULL, "flags", LS_MODIFIER_INVERT);
 +      RNA_def_property_ui_text(prop, "Invert", "Invert the fade-out direction of the linear mapping");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop = RNA_def_property(srna, "curve", PROP_POINTER, PROP_NONE);
 +      RNA_def_property_pointer_sdna(prop, NULL, "curve");
 +      RNA_def_property_struct_type(prop, "CurveMapping");
 +      RNA_def_property_ui_text(prop, "Curve", "Curve used for the curve mapping");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      if (range) {
 +              prop= RNA_def_property(srna, "range_min", PROP_FLOAT, PROP_NONE);
 +              RNA_def_property_float_sdna(prop, NULL, "range_min");
 +              RNA_def_property_ui_text(prop, "Range Min", "Lower bound of the input range the mapping is applied");
 +              RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +              prop= RNA_def_property(srna, "range_max", PROP_FLOAT, PROP_NONE);
 +              RNA_def_property_float_sdna(prop, NULL, "range_max");
 +              RNA_def_property_ui_text(prop, "Range Max", "Upper bound of the input range the mapping is applied");
 +              RNA_def_property_update(prop, NC_SCENE, NULL);
 +      }
 +
 +      if (value) {
 +              prop= RNA_def_property(srna, "value_min", PROP_FLOAT, PROP_NONE);
 +              RNA_def_property_float_sdna(prop, NULL, "value_min");
 +              RNA_def_property_ui_text(prop, "Value Min", "Minimum output value of the mapping");
 +              RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +              prop= RNA_def_property(srna, "value_max", PROP_FLOAT, PROP_NONE);
 +              RNA_def_property_float_sdna(prop, NULL, "value_max");
 +              RNA_def_property_ui_text(prop, "Value Max", "Maximum output value of the mapping");
 +              RNA_def_property_update(prop, NC_SCENE, NULL);
 +      }
 +}
 +
 +static void rna_def_modifier_material_common(StructRNA *srna)
 +{
 +      PropertyRNA *prop;
 +
 +      static EnumPropertyItem mat_attr_items[] = {
 +              {LS_MODIFIER_MATERIAL_DIFF, "DIFF", 0, "Diffuse", ""},
 +              {LS_MODIFIER_MATERIAL_DIFF_R, "DIFF_R", 0, "Diffuse Red", ""},
 +              {LS_MODIFIER_MATERIAL_DIFF_G, "DIFF_G", 0, "Diffuse Green", ""},
 +              {LS_MODIFIER_MATERIAL_DIFF_B, "DIFF_B", 0, "Diffuse Blue", ""},
 +              {LS_MODIFIER_MATERIAL_SPEC, "SPEC", 0, "Specular", ""},
 +              {LS_MODIFIER_MATERIAL_SPEC_R, "SPEC_R", 0, "Specular Red", ""},
 +              {LS_MODIFIER_MATERIAL_SPEC_G, "SPEC_G", 0, "Specular Green", ""},
 +              {LS_MODIFIER_MATERIAL_SPEC_B, "SPEC_B", 0, "Specular Blue", ""},
 +              {LS_MODIFIER_MATERIAL_SPEC_HARD, "SPEC_HARD", 0, "Specular Hardness", ""},
 +              {LS_MODIFIER_MATERIAL_ALPHA, "ALPHA", 0, "Alpha", ""},
 +              {0, NULL, 0, NULL, NULL}};
 +
 +      prop= RNA_def_property(srna, "material_attr", PROP_ENUM, PROP_NONE);
 +      RNA_def_property_enum_sdna(prop, NULL, "mat_attr");
 +      RNA_def_property_enum_items(prop, mat_attr_items);
 +      RNA_def_property_ui_text(prop, "Material Attribute", "Specify which material attribute is used");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +}
 +
 +static void rna_def_linestyle_modifiers(BlenderRNA *brna)
 +{
 +      StructRNA *srna;
 +      PropertyRNA *prop;
 +
 +      static EnumPropertyItem blueprint_shape_items[] = {
 +              {LS_MODIFIER_BLUEPRINT_CIRCLES, "CIRCLES", 0, "Circles", "Draw a blueprint using circular contour strokes"},
 +              {LS_MODIFIER_BLUEPRINT_ELLIPSES, "ELLIPSES", 0, "Ellipses", "Draw a blueprint using elliptic contour strokes"},
 +              {LS_MODIFIER_BLUEPRINT_SQUARES, "SQUARES", 0, "Squares", "Draw a blueprint using square contour strokes"},
 +              {0, NULL, 0, NULL, NULL}};
 +
 +      srna= RNA_def_struct(brna, "LineStyleModifier", NULL);
 +      RNA_def_struct_ui_text(srna, "Line Style Modifier", "Base type to define modifiers");
 +
 +      /* line color modifiers */
 +
 +      srna= RNA_def_struct(brna, "LineStyleColorModifier", "LineStyleModifier");
 +      RNA_def_struct_sdna(srna, "LineStyleModifier");
 +      RNA_def_struct_refine_func(srna, "rna_LineStyle_color_modifier_refine");
 +      RNA_def_struct_path_func(srna, "rna_LineStyle_color_modifier_path");
 +      RNA_def_struct_ui_text(srna, "Line Style Color Modifier", "Base type to define line color modifiers");
 +
 +      srna= RNA_def_struct(brna, "LineStyleColorModifier_AlongStroke", "LineStyleColorModifier");
 +      RNA_def_struct_ui_text(srna, "Along Stroke", "Change line color along stroke");
 +      rna_def_color_modifier(srna);
 +      rna_def_modifier_color_ramp_common(srna, 0);
 +
 +      srna= RNA_def_struct(brna, "LineStyleColorModifier_DistanceFromCamera", "LineStyleColorModifier");
 +      RNA_def_struct_ui_text(srna, "Distance from Camera", "Change line color based on the distance from the camera");
 +      rna_def_color_modifier(srna);
 +      rna_def_modifier_color_ramp_common(srna, 1);
 +
 +      srna= RNA_def_struct(brna, "LineStyleColorModifier_DistanceFromObject", "LineStyleColorModifier");
 +      RNA_def_struct_ui_text(srna, "Distance from Object", "Change line color based on the distance from an object");
 +      rna_def_color_modifier(srna);
 +      rna_def_modifier_color_ramp_common(srna, 1);
 +
 +      prop= RNA_def_property(srna, "target", PROP_POINTER, PROP_NONE);
 +      RNA_def_property_pointer_sdna(prop, NULL, "target");
 +      RNA_def_property_struct_type(prop, "Object");
 +      RNA_def_property_flag(prop, PROP_EDITABLE);
 +      RNA_def_property_ui_text(prop, "Target", "Target object from which the distance is measured");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      srna= RNA_def_struct(brna, "LineStyleColorModifier_Material", "LineStyleColorModifier");
 +      RNA_def_struct_ui_text(srna, "Material", "Change line color based on a material attribute");
 +      rna_def_color_modifier(srna);
 +      rna_def_modifier_material_common(srna);
 +      rna_def_modifier_color_ramp_common(srna, 0);
 +
 +      prop= RNA_def_property(srna, "use_ramp", PROP_BOOLEAN, PROP_NONE);
 +      RNA_def_property_boolean_sdna(prop, NULL, "flags", LS_MODIFIER_USE_RAMP);
 +      RNA_def_property_ui_text(prop, "Ramp", "Use color ramp to map the BW average into an RGB color");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      /* alpha transparency modifiers */
 +
 +      srna= RNA_def_struct(brna, "LineStyleAlphaModifier", "LineStyleModifier");
 +      RNA_def_struct_sdna(srna, "LineStyleModifier");
 +      RNA_def_struct_refine_func(srna, "rna_LineStyle_alpha_modifier_refine");
 +      RNA_def_struct_path_func(srna, "rna_LineStyle_alpha_modifier_path");
 +      RNA_def_struct_ui_text(srna, "Line Style Alpha Modifier", "Base type to define alpha transparency modifiers");
 +
 +      srna= RNA_def_struct(brna, "LineStyleAlphaModifier_AlongStroke", "LineStyleAlphaModifier");
 +      RNA_def_struct_ui_text(srna, "Along Stroke", "Change alpha transparency along stroke");
 +      rna_def_alpha_modifier(srna);
 +      rna_def_modifier_curve_common(srna, 0, 0);
 +
 +      srna= RNA_def_struct(brna, "LineStyleAlphaModifier_DistanceFromCamera", "LineStyleAlphaModifier");
 +      RNA_def_struct_ui_text(srna, "Distance from Camera", "Change alpha transparency based on the distance from the camera");
 +      rna_def_alpha_modifier(srna);
 +      rna_def_modifier_curve_common(srna, 1, 0);
 +
 +      srna= RNA_def_struct(brna, "LineStyleAlphaModifier_DistanceFromObject", "LineStyleAlphaModifier");
 +      RNA_def_struct_ui_text(srna, "Distance from Object", "Change alpha transparency based on the distance from an object");
 +      rna_def_alpha_modifier(srna);
 +      rna_def_modifier_curve_common(srna, 1, 0);
 +
 +      prop= RNA_def_property(srna, "target", PROP_POINTER, PROP_NONE);
 +      RNA_def_property_pointer_sdna(prop, NULL, "target");
 +      RNA_def_property_struct_type(prop, "Object");
 +      RNA_def_property_flag(prop, PROP_EDITABLE);
 +      RNA_def_property_ui_text(prop, "Target", "Target object from which the distance is measured");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      srna= RNA_def_struct(brna, "LineStyleAlphaModifier_Material", "LineStyleAlphaModifier");
 +      RNA_def_struct_ui_text(srna, "Material", "Change alpha transparency based on a material attribute");
 +      rna_def_alpha_modifier(srna);
 +      rna_def_modifier_material_common(srna);
 +      rna_def_modifier_curve_common(srna, 0, 0);
 +
 +      /* line thickness modifiers */
 +
 +      srna= RNA_def_struct(brna, "LineStyleThicknessModifier", "LineStyleModifier");
 +      RNA_def_struct_sdna(srna, "LineStyleModifier");
 +      RNA_def_struct_refine_func(srna, "rna_LineStyle_thickness_modifier_refine");
 +      RNA_def_struct_path_func(srna, "rna_LineStyle_thickness_modifier_path");
 +      RNA_def_struct_ui_text(srna, "Line Style Thickness Modifier", "Base type to define line thickness modifiers");
 +
 +      srna= RNA_def_struct(brna, "LineStyleThicknessModifier_AlongStroke", "LineStyleThicknessModifier");
 +      RNA_def_struct_ui_text(srna, "Along Stroke", "Change line thickness along stroke");
 +      rna_def_thickness_modifier(srna);
 +      rna_def_modifier_curve_common(srna, 0, 1);
 +
 +      srna= RNA_def_struct(brna, "LineStyleThicknessModifier_DistanceFromCamera", "LineStyleThicknessModifier");
 +      RNA_def_struct_ui_text(srna, "Distance from Camera", "Change line thickness based on the distance from the camera");
 +      rna_def_thickness_modifier(srna);
 +      rna_def_modifier_curve_common(srna, 1, 1);
 +
 +      srna= RNA_def_struct(brna, "LineStyleThicknessModifier_DistanceFromObject", "LineStyleThicknessModifier");
 +      RNA_def_struct_ui_text(srna, "Distance from Object", "Change line thickness based on the distance from an object");
 +      rna_def_thickness_modifier(srna);
 +      rna_def_modifier_curve_common(srna, 1, 1);
 +
 +      prop= RNA_def_property(srna, "target", PROP_POINTER, PROP_NONE);
 +      RNA_def_property_pointer_sdna(prop, NULL, "target");
 +      RNA_def_property_struct_type(prop, "Object");
 +      RNA_def_property_flag(prop, PROP_EDITABLE);
 +      RNA_def_property_ui_text(prop, "Target", "Target object from which the distance is measured");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      srna= RNA_def_struct(brna, "LineStyleThicknessModifier_Material", "LineStyleThicknessModifier");
 +      RNA_def_struct_ui_text(srna, "Material", "Change line thickness based on a material attribute");
 +      rna_def_thickness_modifier(srna);
 +      rna_def_modifier_material_common(srna);
 +      rna_def_modifier_curve_common(srna, 0, 1);
 +
 +      srna= RNA_def_struct(brna, "LineStyleThicknessModifier_Calligraphy", "LineStyleThicknessModifier");
 +      RNA_def_struct_ui_text(srna, "Calligraphy", "Change line thickness so that stroke looks like made with a calligraphic pen");
 +      rna_def_thickness_modifier(srna);
 +
 +      prop= RNA_def_property(srna, "orientation", PROP_FLOAT, PROP_NONE);
 +      RNA_def_property_float_sdna(prop, NULL, "orientation");
 +      RNA_def_property_ui_text(prop, "Orientation", "Angle of the main direction");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "min_thickness", PROP_FLOAT, PROP_NONE);
 +      RNA_def_property_float_sdna(prop, NULL, "min_thickness");
 +      RNA_def_property_range(prop, 0.0f, 10000.0f);
 +      RNA_def_property_ui_text(prop, "Min Thickness", "Minimum thickness in the direction perpendicular to the main direction");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "max_thickness", PROP_FLOAT, PROP_NONE);
 +      RNA_def_property_float_sdna(prop, NULL, "max_thickness");
 +      RNA_def_property_range(prop, 0.0f, 10000.0f);
 +      RNA_def_property_ui_text(prop, "Max Thickness", "Maximum thickness in the main direction");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      /* geometry modifiers */
 +
 +      srna= RNA_def_struct(brna, "LineStyleGeometryModifier", "LineStyleModifier");
 +      RNA_def_struct_sdna(srna, "LineStyleModifier");
 +      RNA_def_struct_refine_func(srna, "rna_LineStyle_geometry_modifier_refine");
 +      RNA_def_struct_path_func(srna, "rna_LineStyle_geometry_modifier_path");
 +      RNA_def_struct_ui_text(srna, "Line Style Geometry Modifier", "Base type to define stroke geometry modifiers");
 +
 +      srna= RNA_def_struct(brna, "LineStyleGeometryModifier_Sampling", "LineStyleGeometryModifier");
 +      RNA_def_struct_ui_text(srna, "Sampling", "Specify a new sampling value that determines the resolution of stroke polylines");
 +      rna_def_geometry_modifier(srna);
 +
 +      prop= RNA_def_property(srna, "sampling", PROP_FLOAT, PROP_NONE);
 +      RNA_def_property_float_sdna(prop, NULL, "sampling");
 +      RNA_def_property_ui_text(prop, "Sampling", "New sampling value to be used for subsequent modifiers");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      srna= RNA_def_struct(brna, "LineStyleGeometryModifier_BezierCurve", "LineStyleGeometryModifier");
 +      RNA_def_struct_ui_text(srna, "Bezier Curve", "Replace stroke backbone geometry by a Bezier curve approximation of the original backbone geometry");
 +      rna_def_geometry_modifier(srna);
 +
 +      prop= RNA_def_property(srna, "error", PROP_FLOAT, PROP_NONE);
 +      RNA_def_property_float_sdna(prop, NULL, "error");
 +      RNA_def_property_ui_text(prop, "Error", "Maximum distance allowed between the new Bezier curve and the original backbone geometry)");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      srna= RNA_def_struct(brna, "LineStyleGeometryModifier_SinusDisplacement", "LineStyleGeometryModifier");
 +      RNA_def_struct_ui_text(srna, "Sinus Displacement", "Add sinus displacement to stroke backbone geometry");
 +      rna_def_geometry_modifier(srna);
 +
 +      prop= RNA_def_property(srna, "wavelength", PROP_FLOAT, PROP_NONE);
 +      RNA_def_property_float_sdna(prop, NULL, "wavelength");
 +      RNA_def_property_ui_text(prop, "Wavelength", "Wavelength of the sinus displacement");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "amplitude", PROP_FLOAT, PROP_NONE);
 +      RNA_def_property_float_sdna(prop, NULL, "amplitude");
 +      RNA_def_property_ui_text(prop, "Amplitude", "Amplitude of the sinus displacement");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "phase", PROP_FLOAT, PROP_NONE);
 +      RNA_def_property_float_sdna(prop, NULL, "phase");
 +      RNA_def_property_ui_text(prop, "Phase", "Phase of the sinus displacement");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      srna= RNA_def_struct(brna, "LineStyleGeometryModifier_SpatialNoise", "LineStyleGeometryModifier");
 +      RNA_def_struct_ui_text(srna, "Spatial Noise", "Add spatial noise to stroke backbone geometry");
 +      rna_def_geometry_modifier(srna);
 +
 +      prop= RNA_def_property(srna, "amplitude", PROP_FLOAT, PROP_NONE);
 +      RNA_def_property_float_sdna(prop, NULL, "amplitude");
 +      RNA_def_property_ui_text(prop, "Amplitude", "Amplitude of the spatial noise");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "scale", PROP_FLOAT, PROP_NONE);
 +      RNA_def_property_float_sdna(prop, NULL, "scale");
 +      RNA_def_property_ui_text(prop, "Scale", "Scale of the spatial noise");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "octaves", PROP_INT, PROP_UNSIGNED);
 +      RNA_def_property_int_sdna(prop, NULL, "octaves");
 +      RNA_def_property_ui_text(prop, "Octaves", "Number of octaves (i.e., the amount of detail of the spatial noise)");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "smooth", PROP_BOOLEAN, PROP_NONE);
 +      RNA_def_property_boolean_sdna(prop, NULL, "flags", LS_MODIFIER_SPATIAL_NOISE_SMOOTH);
 +      RNA_def_property_ui_text(prop, "Smooth", "If true, the spatial noise is smooth");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "pure_random", PROP_BOOLEAN, PROP_NONE);
 +      RNA_def_property_boolean_sdna(prop, NULL, "flags", LS_MODIFIER_SPATIAL_NOISE_PURERANDOM);
 +      RNA_def_property_ui_text(prop, "Pure Random", "If true, the spatial noise does not show any coherence");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      srna= RNA_def_struct(brna, "LineStyleGeometryModifier_PerlinNoise1D", "LineStyleGeometryModifier");
 +      RNA_def_struct_ui_text(srna, "Perlin Noise 1D", "Add one-dimensional Perlin noise to stroke backbone geometry");
 +      rna_def_geometry_modifier(srna);
 +
 +      prop= RNA_def_property(srna, "frequency", PROP_FLOAT, PROP_NONE);
 +      RNA_def_property_float_sdna(prop, NULL, "frequency");
 +      RNA_def_property_ui_text(prop, "Frequency", "Frequency of the Perlin noise");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "amplitude", PROP_FLOAT, PROP_NONE);
 +      RNA_def_property_float_sdna(prop, NULL, "amplitude");
 +      RNA_def_property_ui_text(prop, "Amplitude", "Amplitude of the Perlin noise");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "octaves", PROP_INT, PROP_UNSIGNED);
 +      RNA_def_property_int_sdna(prop, NULL, "octaves");
 +      RNA_def_property_ui_text(prop, "Octaves", "Number of octaves (i.e., the amount of detail of the Perlin noise)");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "angle", PROP_FLOAT, PROP_NONE);
 +      RNA_def_property_float_sdna(prop, NULL, "angle");
 +      RNA_def_property_ui_text(prop, "Angle", "Displacement direction in degrees");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "seed", PROP_INT, PROP_NONE);
 +      RNA_def_property_int_sdna(prop, NULL, "seed");
 +      RNA_def_property_ui_text(prop, "Seed", "Seed for random number generation.  If negative, time is used as a seed instead");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      srna= RNA_def_struct(brna, "LineStyleGeometryModifier_PerlinNoise2D", "LineStyleGeometryModifier");
 +      RNA_def_struct_ui_text(srna, "Perlin Noise 2D", "Add two-dimensional Perlin noise to stroke backbone geometry");
 +      rna_def_geometry_modifier(srna);
 +
 +      prop= RNA_def_property(srna, "frequency", PROP_FLOAT, PROP_NONE);
 +      RNA_def_property_float_sdna(prop, NULL, "frequency");
 +      RNA_def_property_ui_text(prop, "Frequency", "Frequency of the Perlin noise");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "amplitude", PROP_FLOAT, PROP_NONE);
 +      RNA_def_property_float_sdna(prop, NULL, "amplitude");
 +      RNA_def_property_ui_text(prop, "Amplitude", "Amplitude of the Perlin noise");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "octaves", PROP_INT, PROP_UNSIGNED);
 +      RNA_def_property_int_sdna(prop, NULL, "octaves");
 +      RNA_def_property_ui_text(prop, "Octaves", "Number of octaves (i.e., the amount of detail of the Perlin noise)");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "angle", PROP_FLOAT, PROP_NONE);
 +      RNA_def_property_float_sdna(prop, NULL, "angle");
 +      RNA_def_property_ui_text(prop, "Angle", "Displacement direction in degrees");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "seed", PROP_INT, PROP_NONE);
 +      RNA_def_property_int_sdna(prop, NULL, "seed");
 +      RNA_def_property_ui_text(prop, "Seed", "Seed for random number generation.  If negative, time is used as a seed instead");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      srna= RNA_def_struct(brna, "LineStyleGeometryModifier_BackboneStretcher", "LineStyleGeometryModifier");
 +      RNA_def_struct_ui_text(srna, "Backbone Stretcher", "Stretch the beginning and the end of stroke backbone");
 +      rna_def_geometry_modifier(srna);
 +
 +      prop= RNA_def_property(srna, "backbone_length", PROP_FLOAT, PROP_NONE);
 +      RNA_def_property_float_sdna(prop, NULL, "backbone_length");
 +      RNA_def_property_ui_text(prop, "Backbone Length", "Amount of backbone stretching");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      srna= RNA_def_struct(brna, "LineStyleGeometryModifier_TipRemover", "LineStyleGeometryModifier");
 +      RNA_def_struct_ui_text(srna, "Tip Remover", "Remove a piece of stroke at the beginning and the end of stroke backbone");
 +      rna_def_geometry_modifier(srna);
 +
 +      prop= RNA_def_property(srna, "tip_length", PROP_FLOAT, PROP_NONE);
 +      RNA_def_property_float_sdna(prop, NULL, "tip_length");
 +      RNA_def_property_ui_text(prop, "Tip Length", "Length of tips to be removed");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      srna= RNA_def_struct(brna, "LineStyleGeometryModifier_Polygonalization", "LineStyleGeometryModifier");
 +      RNA_def_struct_ui_text(srna, "Polygonalization", "Modify the stroke geometry so that it looks more \"polygonal\"");
 +      rna_def_geometry_modifier(srna);
 +
 +      prop= RNA_def_property(srna, "error", PROP_FLOAT, PROP_NONE);
 +      RNA_def_property_float_sdna(prop, NULL, "error");
 +      RNA_def_property_ui_text(prop, "Error", "Maximum distance between the original stroke and its polygonal approximation");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      srna= RNA_def_struct(brna, "LineStyleGeometryModifier_GuidingLines", "LineStyleGeometryModifier");
 +      RNA_def_struct_ui_text(srna, "Guiding Lines", "Modify the stroke geometry so that it corresponds to its main direction line");
 +      rna_def_geometry_modifier(srna);
 +
 +      prop= RNA_def_property(srna, "offset", PROP_FLOAT, PROP_NONE);
 +      RNA_def_property_float_sdna(prop, NULL, "offset");
 +      RNA_def_property_ui_text(prop, "Offset", "Displacement that is applied to the main direction line along its normal");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      srna= RNA_def_struct(brna, "LineStyleGeometryModifier_Blueprint", "LineStyleGeometryModifier");
 +      RNA_def_struct_ui_text(srna, "Blueprint", "Produce a blueprint using circular, elliptic, and square contour strokes");
 +      rna_def_geometry_modifier(srna);
 +
 +      prop= RNA_def_property(srna, "shape", PROP_ENUM, PROP_NONE);
 +      RNA_def_property_enum_bitflag_sdna(prop, NULL, "flags");
 +      RNA_def_property_enum_items(prop, blueprint_shape_items);
 +      RNA_def_property_ui_text(prop, "Shape", "Select the shape of blueprint contour strokes");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "rounds", PROP_INT, PROP_UNSIGNED);
 +      RNA_def_property_int_sdna(prop, NULL, "rounds");
 +      RNA_def_property_range(prop, 1, 1000);
 +      RNA_def_property_ui_text(prop, "Rounds", "Number of rounds in contour strokes");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "backbone_length", PROP_FLOAT, PROP_NONE);
 +      RNA_def_property_float_sdna(prop, NULL, "backbone_length");
 +      RNA_def_property_ui_text(prop, "Backbone Length", "Amount of backbone stretching");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "random_radius", PROP_INT, PROP_UNSIGNED);
 +      RNA_def_property_int_sdna(prop, NULL, "random_radius");
 +      RNA_def_property_ui_text(prop, "Random Radius", "Randomness of the radius");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "random_center", PROP_INT, PROP_UNSIGNED);
 +      RNA_def_property_int_sdna(prop, NULL, "random_center");
 +      RNA_def_property_ui_text(prop, "Random Center", "Randomness of the center");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "random_backbone", PROP_INT, PROP_UNSIGNED);
 +      RNA_def_property_int_sdna(prop, NULL, "random_backbone");
 +      RNA_def_property_ui_text(prop, "Random Backbone", "Randomness of the backbone stretching");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +}
 +
 +static void rna_def_linestyle(BlenderRNA *brna)
 +{
 +      StructRNA *srna;
 +      PropertyRNA *prop;
 +
 +      static EnumPropertyItem panel_items[] = {
 +              {LS_PANEL_STROKES, "STROKES", 0, "Strokes", "Show the panel for stroke construction"},
 +              {LS_PANEL_COLOR, "COLOR", 0, "Color", "Show the panel for line color options"},
 +              {LS_PANEL_ALPHA, "ALPHA", 0, "Alpha", "Show the panel for alpha transparency options"},
 +              {LS_PANEL_THICKNESS, "THICKNESS", 0, "Thickness", "Show the panel for line thickness options"},
 +              {LS_PANEL_GEOMETRY, "GEOMETRY", 0, "Geometry", "Show the panel for stroke geometry options"},
 +              {LS_PANEL_MISC, "MISC", 0, "Misc", "Show the panel for miscellaneous options"},
 +              {0, NULL, 0, NULL, NULL}};
 +      static EnumPropertyItem chaining_items[] = {
 +              {LS_CHAINING_PLAIN, "PLAIN", 0, "Plain", "Plain chaining"},
 +              {LS_CHAINING_SKETCHY, "SKETCHY", 0, "Sketchy", "Sketchy chaining with a multiple touch"},
 +              {0, NULL, 0, NULL, NULL}};
 +      static EnumPropertyItem cap_items[] = {
 +              {LS_CAPS_BUTT, "BUTT", 0, "Butt", "Butt cap (flat)"},
 +              {LS_CAPS_ROUND, "ROUND", 0, "Round", "Round cap (half-circle)"},
 +              {LS_CAPS_SQUARE, "SQUARE", 0, "Square", "Square cap (flat and extended)"},
 +              {0, NULL, 0, NULL, NULL}};
 +
 +      srna= RNA_def_struct(brna, "FreestyleLineStyle", "ID");
 +      RNA_def_struct_ui_text(srna, "Freestyle Line Style", "Freestyle line style, reusable by multiple line sets");
 +      RNA_def_struct_ui_icon(srna, ICON_BRUSH_DATA); /* FIXME: use a proper icon */
 +
 +      prop= RNA_def_property(srna, "panel", PROP_ENUM, PROP_NONE);
 +      RNA_def_property_enum_bitflag_sdna(prop, NULL, "panel");
 +      RNA_def_property_enum_items(prop, panel_items);
 +      RNA_def_property_ui_text(prop, "Panel", "Select the property panel to be shown");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR);
 +      RNA_def_property_float_sdna(prop, NULL, "r");
 +      RNA_def_property_array(prop, 3);
 +      RNA_def_property_ui_text(prop, "Color", "Base line color, possibly modified by line color modifiers");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "alpha", PROP_FLOAT, PROP_FACTOR);
 +      RNA_def_property_float_sdna(prop, NULL, "alpha");
 +      RNA_def_property_range(prop, 0.0f, 1.0f);
 +      RNA_def_property_ui_text(prop, "Alpha", "Base alpha transparency, possibly modified by alpha transparency modifiers");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "thickness", PROP_FLOAT, PROP_NONE);
 +      RNA_def_property_float_sdna(prop, NULL, "thickness");
 +      RNA_def_property_range(prop, 0.0f, 10000.0f);
 +      RNA_def_property_ui_text(prop, "Thickness", "Base line thickness, possibly modified by line thickness modifiers");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "color_modifiers", PROP_COLLECTION, PROP_NONE);
 +      RNA_def_property_collection_sdna(prop, NULL, "color_modifiers", NULL);
 +      RNA_def_property_struct_type(prop, "LineStyleColorModifier");
 +      RNA_def_property_ui_text(prop, "Color Modifiers", "List of line color modifiers");
 +
 +      prop= RNA_def_property(srna, "alpha_modifiers", PROP_COLLECTION, PROP_NONE);
 +      RNA_def_property_collection_sdna(prop, NULL, "alpha_modifiers", NULL);
 +      RNA_def_property_struct_type(prop, "LineStyleAlphaModifier");
 +      RNA_def_property_ui_text(prop, "Alpha Modifiers", "List of alpha trancparency modifiers");
 +
 +      prop= RNA_def_property(srna, "thickness_modifiers", PROP_COLLECTION, PROP_NONE);
 +      RNA_def_property_collection_sdna(prop, NULL, "thickness_modifiers", NULL);
 +      RNA_def_property_struct_type(prop, "LineStyleThicknessModifier");
 +      RNA_def_property_ui_text(prop, "Thickness Modifiers", "List of line thickness modifiers");
 +
 +      prop= RNA_def_property(srna, "use_chaining", PROP_BOOLEAN, PROP_NONE);
 +      RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", LS_NO_CHAINING);
 +      RNA_def_property_ui_text(prop, "Chaining", "Enable chaining of feature edges");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "chaining", PROP_ENUM, PROP_NONE);
 +      RNA_def_property_enum_sdna(prop, NULL, "chaining");
 +      RNA_def_property_enum_items(prop, chaining_items);
 +      RNA_def_property_ui_text(prop, "Chaining", "Select the way how feature edges are jointed to form chains");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "rounds", PROP_INT, PROP_UNSIGNED);
 +      RNA_def_property_int_sdna(prop, NULL, "rounds");
 +      RNA_def_property_range(prop, 1, 1000);
 +      RNA_def_property_ui_text(prop, "Rounds", "Number of rounds in a sketchy multiple touch");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "geometry_modifiers", PROP_COLLECTION, PROP_NONE);
 +      RNA_def_property_collection_sdna(prop, NULL, "geometry_modifiers", NULL);
 +      RNA_def_property_struct_type(prop, "LineStyleGeometryModifier");
 +      RNA_def_property_ui_text(prop, "Geometry Modifiers", "List of stroke geometry modifiers");
 +
 +      prop= RNA_def_property(srna, "same_object", PROP_BOOLEAN, PROP_NONE);
 +      RNA_def_property_boolean_sdna(prop, NULL, "flag", LS_SAME_OBJECT);
 +      RNA_def_property_ui_text(prop, "Same Object", "If true, only feature edges of the same object are joined");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "use_min_length", PROP_BOOLEAN, PROP_NONE);
 +      RNA_def_property_boolean_sdna(prop, NULL, "flag", LS_MIN_2D_LENGTH);
 +      RNA_def_property_ui_text(prop, "Use Min 2D Length", "Enable the selection of chains by a minimum 2D length");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "min_length", PROP_FLOAT, PROP_NONE);
 +      RNA_def_property_float_sdna(prop, NULL, "min_length");
 +      RNA_def_property_range(prop, 0.0f, 10000.0f);
 +      RNA_def_property_ui_text(prop, "Min 2D Length", "Minimum 2D length for the selection of chains");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "use_max_length", PROP_BOOLEAN, PROP_NONE);
 +      RNA_def_property_boolean_sdna(prop, NULL, "flag", LS_MAX_2D_LENGTH);
 +      RNA_def_property_ui_text(prop, "Use Max 2D Length", "Enable the selection of chains by a maximum 2D length");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "max_length", PROP_FLOAT, PROP_NONE);
 +      RNA_def_property_float_sdna(prop, NULL, "max_length");
 +      RNA_def_property_range(prop, 0.0f, 10000.0f);
 +      RNA_def_property_ui_text(prop, "Max 2D Length", "Maximum 2D length for the selection of chains");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "material_boundary", PROP_BOOLEAN, PROP_NONE);
 +      RNA_def_property_boolean_sdna(prop, NULL, "flag", LS_MATERIAL_BOUNDARY);
 +      RNA_def_property_ui_text(prop, "Material Boundary", "If true, chains of feature edges are split at material boundaries");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "use_dashed_line", PROP_BOOLEAN, PROP_NONE);
 +      RNA_def_property_boolean_sdna(prop, NULL, "flag", LS_DASHED_LINE);
 +      RNA_def_property_ui_text(prop, "Dashed Line", "Enable or disable dashed line");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "caps", PROP_ENUM, PROP_NONE);
 +      RNA_def_property_enum_bitflag_sdna(prop, NULL, "caps");
 +      RNA_def_property_enum_items(prop, cap_items);
 +      RNA_def_property_ui_text(prop, "Cap", "Select the shape of both ends of strokes");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "dash1", PROP_INT, PROP_UNSIGNED);
 +      RNA_def_property_int_sdna(prop, NULL, "dash1");
 +      RNA_def_property_range(prop, 0, USHRT_MAX);
 +      RNA_def_property_ui_text(prop, "Dash #1", "Length of the 1st dash");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "gap1", PROP_INT, PROP_UNSIGNED);
 +      RNA_def_property_int_sdna(prop, NULL, "gap1");
 +      RNA_def_property_range(prop, 0, USHRT_MAX);
 +      RNA_def_property_ui_text(prop, "Gap #1", "Length of the 1st gap");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "dash2", PROP_INT, PROP_UNSIGNED);
 +      RNA_def_property_int_sdna(prop, NULL, "dash2");
 +      RNA_def_property_range(prop, 0, USHRT_MAX);
 +      RNA_def_property_ui_text(prop, "Dash #2", "Length of the 2nd dash");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "gap2", PROP_INT, PROP_UNSIGNED);
 +      RNA_def_property_int_sdna(prop, NULL, "gap2");
 +      RNA_def_property_range(prop, 0, USHRT_MAX);
 +      RNA_def_property_ui_text(prop, "Gap #2", "Length of the 2nd gap");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "dash3", PROP_INT, PROP_UNSIGNED);
 +      RNA_def_property_int_sdna(prop, NULL, "dash3");
 +      RNA_def_property_range(prop, 0, USHRT_MAX);
 +      RNA_def_property_ui_text(prop, "Dash #3", "Length of the 3rd dash");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "gap3", PROP_INT, PROP_UNSIGNED);
 +      RNA_def_property_int_sdna(prop, NULL, "gap3");
 +      RNA_def_property_range(prop, 0, USHRT_MAX);
 +      RNA_def_property_ui_text(prop, "Gap #3", "Length of the 3rd gap");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +}
 +
 +void RNA_def_linestyle(BlenderRNA *brna)
 +{
 +      rna_def_linestyle_modifiers(brna);
 +      rna_def_linestyle(brna);
 +}
 +
 +#endif
index 462156d4acc6458b3c67cfd2b8d46e3c5d70131c,48a4d055520909cf09c16ca2363d14da9038bd56..fe2cfbd3bc0b19706a43be85e1081abc696edc5a
@@@ -1283,11 -1283,6 +1283,11 @@@ static void rna_def_medge(BlenderRNA *b
        RNA_def_property_ui_text(prop, "Sharp", "Sharp edge for the EdgeSplit modifier");
        RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
  
 +      prop= RNA_def_property(srna, "use_freestyle_edge_mark", PROP_BOOLEAN, PROP_NONE);
 +      RNA_def_property_boolean_sdna(prop, NULL, "flag", ME_FREESTYLE_EDGE);
 +      RNA_def_property_ui_text(prop, "Freestyle Edge Mark", "Edge mark for Freestyle feature edge detection");
 +      RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
 +
        prop= RNA_def_property(srna, "is_loose", PROP_BOOLEAN, PROP_NONE);
        RNA_def_property_boolean_sdna(prop, NULL, "flag", ME_LOOSEEDGE);
        RNA_def_property_ui_text(prop, "Loose", "Loose edge");
@@@ -1348,11 -1343,6 +1348,11 @@@ static void rna_def_mface(BlenderRNA *b
        RNA_def_property_ui_text(prop, "Smooth", "");
        RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
        
 +      prop= RNA_def_property(srna, "use_freestyle_face_mark", PROP_BOOLEAN, PROP_NONE);
 +      RNA_def_property_boolean_sdna(prop, NULL, "flag", ME_FREESTYLE_FACE);
 +      RNA_def_property_ui_text(prop, "Freestyle Face Mark", "Face mark for Freestyle feature edge detection");
 +      RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
 +
        prop= RNA_def_property(srna, "normal", PROP_FLOAT, PROP_DIRECTION);
        RNA_def_property_array(prop, 3);
        RNA_def_property_range(prop, -1.0f, 1.0f);
@@@ -1955,11 -1945,12 +1955,12 @@@ static void rna_def_mesh(BlenderRNA *br
        RNA_def_property_update(prop, 0, "rna_Mesh_update_draw");
        
        /* not supported yet
-        prop= RNA_def_property(srna, "texspace_rot", PROP_FLOAT, PROP_EULER);
-        RNA_def_property_float(prop, NULL, "rot");
-        RNA_def_property_ui_text(prop, "Texture Space Rotation", "Texture space rotation");
-        RNA_def_property_editable_func(prop, texspace_editable);
-        RNA_def_property_update(prop, 0, "rna_Mesh_update_draw");*/
+       prop= RNA_def_property(srna, "texspace_rot", PROP_FLOAT, PROP_EULER);
+       RNA_def_property_float(prop, NULL, "rot");
+       RNA_def_property_ui_text(prop, "Texture Space Rotation", "Texture space rotation");
+       RNA_def_property_editable_func(prop, texspace_editable);
+       RNA_def_property_update(prop, 0, "rna_Mesh_update_draw");
+       */
        
        /* materials */
        prop= RNA_def_property(srna, "materials", PROP_COLLECTION, PROP_NONE);
        RNA_def_property_ui_text(prop, "Draw Sharp", "Display sharp edges, used with the EdgeSplit modifier");
        RNA_def_property_update(prop, 0, "rna_Mesh_update_draw");
  
 +      prop= RNA_def_property(srna, "show_freestyle_edge_marks", PROP_BOOLEAN, PROP_NONE);
 +      RNA_def_property_boolean_sdna(prop, NULL, "drawflag", ME_DRAW_FREESTYLE_EDGE);
 +      RNA_def_property_ui_text(prop, "Draw Freestyle Edge Marks", "Display Freestyle edge marks, used with the Freestyle renderer");
 +      RNA_def_property_update(prop, 0, "rna_Mesh_update_draw");
 +
 +      prop= RNA_def_property(srna, "show_freestyle_face_marks", PROP_BOOLEAN, PROP_NONE);
 +      RNA_def_property_boolean_sdna(prop, NULL, "drawflag", ME_DRAW_FREESTYLE_FACE);
 +      RNA_def_property_ui_text(prop, "Draw Freestyle Face Marks", "Display Freestyle face marks, used with the Freestyle renderer");
 +      RNA_def_property_update(prop, 0, "rna_Mesh_update_draw");
 +
        prop= RNA_def_property(srna, "show_extra_edge_length", PROP_BOOLEAN, PROP_NONE);
        RNA_def_property_boolean_sdna(prop, NULL, "drawflag", ME_DRAWEXTRA_EDGELEN);
        RNA_def_property_ui_text(prop, "Edge Length",
index 24b704464682bbf5fbf81a69f29bf856cbb5dceb,2d3944a5b074f7cd76cad47e55cc58ebac0f28a8..9c4a09845966ea6b3530ede53011958e9f1d9b0f
@@@ -37,7 -37,6 +37,7 @@@
  #include "DNA_particle_types.h"
  #include "DNA_scene_types.h"
  #include "DNA_userdef_types.h"
 +#include "DNA_linestyle_types.h"
  #include "BLI_math.h"
  
  /* Include for Bake Options */
@@@ -203,8 -202,6 +203,8 @@@ EnumPropertyItem image_color_mode_items
  
  #include "RE_engine.h"
  
 +#include "FRS_freestyle.h"
 +
  static int rna_Scene_object_bases_lookup_string(PointerRNA *ptr, const char *key, PointerRNA *r_ptr)
  {
        Scene *scene= (Scene*)ptr->data;
@@@ -576,6 -573,7 +576,7 @@@ static int rna_SceneRender_file_ext_len
  static void rna_SceneRender_file_ext_get(PointerRNA *ptr, char *str)
  {
        RenderData *rd= (RenderData*)ptr->data;
+       str[0]= '\0';
        BKE_add_image_extension(str, rd->imtype);
  }
  
@@@ -1086,49 -1084,6 +1087,49 @@@ static void rna_SceneCamera_update(Mai
                DAG_id_tag_update(&camera->id, 0);
  }
  
 +static PointerRNA rna_FreestyleLineSet_linestyle_get(PointerRNA *ptr)
 +{
 +      FreestyleLineSet *lineset= (FreestyleLineSet *)ptr->data;
 +
 +      return rna_pointer_inherit_refine(ptr, &RNA_FreestyleLineStyle, lineset->linestyle);
 +}
 +
 +static void rna_FreestyleLineSet_linestyle_set(PointerRNA *ptr, PointerRNA value)
 +{
 +      FreestyleLineSet *lineset= (FreestyleLineSet*)ptr->data;
 +
 +      lineset->linestyle->id.us--;
 +      lineset->linestyle = (FreestyleLineStyle *)value.data;
 +      lineset->linestyle->id.us++;
 +}
 +
 +static PointerRNA rna_FreestyleSettings_active_lineset_get(PointerRNA *ptr)
 +{
 +      FreestyleConfig *config= (FreestyleConfig *)ptr->data;
 +      FreestyleLineSet *lineset= FRS_get_active_lineset(config);
 +      return rna_pointer_inherit_refine(ptr, &RNA_FreestyleLineSet, lineset);
 +}
 +
 +static void rna_FreestyleSettings_active_lineset_index_range(PointerRNA *ptr, int *min, int *max)
 +{
 +      FreestyleConfig *config= (FreestyleConfig *)ptr->data;
 +      *min= 0;
 +      *max= BLI_countlist(&config->linesets)-1;
 +      *max= MAX2(0, *max);
 +}
 +
 +static int rna_FreestyleSettings_active_lineset_index_get(PointerRNA *ptr)
 +{
 +      FreestyleConfig *config= (FreestyleConfig *)ptr->data;
 +      return FRS_get_active_lineset_index(config);
 +}
 +
 +static void rna_FreestyleSettings_active_lineset_index_set(PointerRNA *ptr, int value)
 +{
 +      FreestyleConfig *config= (FreestyleConfig *)ptr->data;
 +      FRS_set_active_lineset_index(config, value);
 +}
 +
  #else
  
  static void rna_def_transform_orientation(BlenderRNA *brna)
@@@ -1192,7 -1147,6 +1193,7 @@@ static void rna_def_tool_settings(Blend
                {EDGE_MODE_TAG_SHARP, "SHARP", 0, "Tag Sharp", ""},
                {EDGE_MODE_TAG_CREASE, "CREASE", 0, "Tag Crease", ""},
                {EDGE_MODE_TAG_BEVEL, "BEVEL", 0, "Tag Bevel", ""},
 +              {EDGE_MODE_TAG_FREESTYLE, "FREESTYLE", 0, "Tag Freestyle Edge Mark", ""},
                {0, NULL, 0, NULL, NULL}};
  
        srna= RNA_def_struct(brna, "ToolSettings", NULL);
                                 "Project individual elements on the surface of other objects");
        RNA_def_property_ui_icon(prop, ICON_RETOPO, 0);
        RNA_def_property_update(prop, NC_SCENE|ND_TOOLSETTINGS, NULL); /* header redraw */
 -
 +      
        prop= RNA_def_property(srna, "use_snap_self", PROP_BOOLEAN, PROP_NONE);
        RNA_def_property_boolean_negative_sdna(prop, NULL, "snap_flag", SCE_SNAP_NO_SELF);
        RNA_def_property_ui_text(prop, "Project to Self", "Snap onto itself (editmode)");
@@@ -1606,12 -1560,6 +1607,12 @@@ void rna_def_render_layer_common(Struct
        if(scene) RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL);
        else RNA_def_property_clear_flag(prop, PROP_EDITABLE);
  
 +      prop= RNA_def_property(srna, "use_freestyle", PROP_BOOLEAN, PROP_NONE);
 +      RNA_def_property_boolean_sdna(prop, NULL, "layflag", SCE_LAY_FRS);
 +      RNA_def_property_ui_text(prop, "Freestyle", "Render stylized strokes in this Layer");
 +      if(scene) RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL);
 +      else RNA_def_property_clear_flag(prop, PROP_EDITABLE);
 +
        /* passes */
        prop= RNA_def_property(srna, "use_pass_combined", PROP_BOOLEAN, PROP_NONE);
        RNA_def_property_boolean_sdna(prop, NULL, "passflag", SCE_PASS_COMBINED);
        else RNA_def_property_clear_flag(prop, PROP_EDITABLE);
  }
  
 +static void rna_def_freestyle_linesets(BlenderRNA *brna, PropertyRNA *cprop)
 +{
 +      StructRNA *srna;
 +      PropertyRNA *prop;
 +
 +      RNA_def_property_srna(cprop, "Linesets");
 +      srna= RNA_def_struct(brna, "Linesets", NULL);
 +      RNA_def_struct_sdna(srna, "FreestyleSettings");
 +      RNA_def_struct_ui_text(srna, "Line Sets", "Line sets for associating lines and style parameters");
 +
 +      prop= RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE);
 +      RNA_def_property_struct_type(prop, "FreestyleLineSet");
 +      RNA_def_property_pointer_funcs(prop, "rna_FreestyleSettings_active_lineset_get", NULL, NULL, NULL);
 +      RNA_def_property_ui_text(prop, "Active Line Set", "Active line set being displayed");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "active_index", PROP_INT, PROP_UNSIGNED);
 +      RNA_def_property_int_funcs(prop, "rna_FreestyleSettings_active_lineset_index_get", "rna_FreestyleSettings_active_lineset_index_set", "rna_FreestyleSettings_active_lineset_index_range");
 +      RNA_def_property_ui_text(prop, "Active Line Set Index", "Index of active line set slot");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +}
 +
 +static void rna_def_freestyle_settings(BlenderRNA *brna)
 +{
 +      StructRNA *srna;
 +      PropertyRNA *prop;
 +
 +      static EnumPropertyItem edge_type_negation_items[] = {
 +              {0, "INCLUSIVE", 0, "Inclusive", "Select feature edges satisfying the given edge type conditions"},
 +              {FREESTYLE_LINESET_FE_NOT, "EXCLUSIVE", 0, "Exclusive", "Select feature edges not satisfying the given edge type conditions"},
 +              {0, NULL, 0, NULL, NULL}};
 +
 +      static EnumPropertyItem edge_type_combination_items[] = {
 +              {0, "OR", 0, "Logical OR", "Combine feature edge type conditions by logical OR (logical disjunction)"},
 +              {FREESTYLE_LINESET_FE_AND, "AND", 0, "Logical AND", "Combine feature edge type conditions by logical AND (logical conjunction)"},
 +              {0, NULL, 0, NULL, NULL}};
 +
 +      static EnumPropertyItem group_negation_items[] = {
 +              {0, "INCLUSIVE", 0, "Inclusive", "Select feature edges belonging to some object in the group"},
 +              {FREESTYLE_LINESET_GR_NOT, "EXCLUSIVE", 0, "Exclusive", "Select feature edges not belonging to any object in the group"},
 +              {0, NULL, 0, NULL, NULL}};
 +
 +      static EnumPropertyItem face_mark_negation_items[] = {
 +              {0, "INCLUSIVE", 0, "Inclusive", "Select feature edges satisfying the given face mark conditions"},
 +              {FREESTYLE_LINESET_FM_NOT, "EXCLUSIVE", 0, "Exclusive", "Select feature edges not satisfying the given face mark conditions"},
 +              {0, NULL, 0, NULL, NULL}};
 +
 +      static EnumPropertyItem face_mark_condition_items[] = {
 +              {0, "ONE", 0, "One Face", "Select feature edges if one of faces on the right and left has a face mark"},
 +              {FREESTYLE_LINESET_FM_BOTH, "BOTH", 0, "Both Faces", "Select feature edges if both faces on the right and left faces have a face mark"},
 +              {0, NULL, 0, NULL, NULL}};
 +
 +      static EnumPropertyItem freestyle_ui_mode_items[] = {
 +              {FREESTYLE_CONTROL_SCRIPT_MODE, "SCRIPT", 0, "Python Scripting Mode", "Advanced mode for using style modules in Python"},
 +              {FREESTYLE_CONTROL_EDITOR_MODE, "EDITOR", 0, "Parameter Editor Mode", "Basic mode for interactive style parameter editing"},
 +              {0, NULL, 0, NULL, NULL}};
 +
 +      static EnumPropertyItem visibility_items[] ={
 +              {FREESTYLE_QI_VISIBLE, "VISIBLE", 0, "Visible", "Select visible feature edges"},
 +              {FREESTYLE_QI_HIDDEN, "HIDDEN", 0, "Hidden", "Select hidden feature edges"},
 +              {FREESTYLE_QI_RANGE, "RANGE", 0, "QI Range", "Select feature edges within a range of quantitative invisibility (QI) values"},
 +              {0, NULL, 0, NULL, NULL}};
 +
 +      static EnumPropertyItem freestyle_raycasting_algorithm_items[] = {
 +              {FREESTYLE_ALGO_REGULAR, "REGULAR", 0, "Normal Ray Casting", "Consider all FEdges in each ViewEdge"},
 +              {FREESTYLE_ALGO_FAST, "FAST", 0, "Fast Ray Casting", "Sample some FEdges in each ViewEdge"},
 +              {FREESTYLE_ALGO_VERYFAST, "VERYFAST", 0, "Very Fast Ray Casting", "Sample one FEdge in each ViewEdge; do not save list of occluders"},
 +              {FREESTYLE_ALGO_CULLED_ADAPTIVE_TRADITIONAL, "CULLEDADAPTIVETRADITIONAL", 0, "Culled Traditional Visibility Detection", "Culled adaptive grid with heuristic density and traditional QI calculation"},
 +              {FREESTYLE_ALGO_ADAPTIVE_TRADITIONAL, "ADAPTIVETRADITIONAL", 0, "Unculled Traditional Visibility Detection", "Adaptive grid with heuristic density and traditional QI calculation"},
 +              {FREESTYLE_ALGO_CULLED_ADAPTIVE_CUMULATIVE, "CULLEDADAPTIVECUMULATIVE", 0, "Culled Cumulative Visibility Detection", "Culled adaptive grid with heuristic density and cumulative QI calculation"},
 +              {FREESTYLE_ALGO_ADAPTIVE_CUMULATIVE, "ADAPTIVECUMULATIVE", 0, "Unculled Cumulative Visibility Detection", "Adaptive grid with heuristic density and cumulative QI calculation"},
 +              {0, NULL, 0, NULL, NULL}};
 +
 +
 +      /* FreestyleLineSet */
 +
 +      srna= RNA_def_struct(brna, "FreestyleLineSet", NULL);
 +      RNA_def_struct_ui_text(srna, "Freestyle Line Set", "Line set for associating lines and style parameters");
 +
 +      /* access to line style settings is redirected through functions */
 +      /* to allow proper id-buttons functionality */
 +      prop= RNA_def_property(srna, "linestyle", PROP_POINTER, PROP_NONE);
 +      RNA_def_property_struct_type(prop, "FreestyleLineStyle");
 +      RNA_def_property_flag(prop, PROP_EDITABLE|PROP_NEVER_NULL);
 +      RNA_def_property_pointer_funcs(prop, "rna_FreestyleLineSet_linestyle_get", "rna_FreestyleLineSet_linestyle_set", NULL, NULL);
 +      RNA_def_property_ui_text(prop, "Line Style", "Line style settings");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
 +      RNA_def_property_string_sdna(prop, NULL, "name");
 +      RNA_def_property_ui_text(prop, "Line Set Name", "Line set name");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +      RNA_def_struct_name_property(srna, prop);
 +
 +      prop= RNA_def_property(srna, "use", PROP_BOOLEAN, PROP_NONE);
 +      RNA_def_property_boolean_sdna(prop, NULL, "flags", FREESTYLE_LINESET_ENABLED);
 +      RNA_def_property_ui_text(prop, "Use", "Enable or disable this line set during stroke rendering");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "select_by_visibility", PROP_BOOLEAN, PROP_NONE);
 +      RNA_def_property_boolean_sdna(prop, NULL, "selection", FREESTYLE_SEL_VISIBILITY);
 +      RNA_def_property_ui_text(prop, "Selection by Visibility", "Select feature edges based on visibility");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "select_by_edge_types", PROP_BOOLEAN, PROP_NONE);
 +      RNA_def_property_boolean_sdna(prop, NULL, "selection", FREESTYLE_SEL_EDGE_TYPES);
 +      RNA_def_property_ui_text(prop, "Selection by Edge Types", "Select feature edges based on edge types");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "select_by_group", PROP_BOOLEAN, PROP_NONE);
 +      RNA_def_property_boolean_sdna(prop, NULL, "selection", FREESTYLE_SEL_GROUP);
 +      RNA_def_property_ui_text(prop, "Selection by Group", "Select feature edges based on a group of objects");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "select_by_image_border", PROP_BOOLEAN, PROP_NONE);
 +      RNA_def_property_boolean_sdna(prop, NULL, "selection", FREESTYLE_SEL_IMAGE_BORDER);
 +      RNA_def_property_ui_text(prop, "Selection by Image Border", "Select feature edges by image border (less memory consumption)");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "select_by_face_marks", PROP_BOOLEAN, PROP_NONE);
 +      RNA_def_property_boolean_sdna(prop, NULL, "selection", FREESTYLE_SEL_FACE_MARK);
 +      RNA_def_property_ui_text(prop, "Selection by Face Marks", "Select feature edges by face marks");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "edge_type_negation", PROP_ENUM, PROP_NONE);
 +      RNA_def_property_enum_bitflag_sdna(prop, NULL, "flags");
 +      RNA_def_property_enum_items(prop, edge_type_negation_items);
 +      RNA_def_property_ui_text(prop, "Edge Type Negation", "Set the negation operation for conditions on feature edge types");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "edge_type_combination", PROP_ENUM, PROP_NONE);
 +      RNA_def_property_enum_bitflag_sdna(prop, NULL, "flags");
 +      RNA_def_property_enum_items(prop, edge_type_combination_items);
 +      RNA_def_property_ui_text(prop, "Edge Type Combination", "Set the combination operation for conditions on feature edge types");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "group", PROP_POINTER, PROP_NONE);
 +      RNA_def_property_pointer_sdna(prop, NULL, "group");
 +      RNA_def_property_struct_type(prop, "Group");
 +      RNA_def_property_flag(prop, PROP_EDITABLE);
 +      RNA_def_property_ui_text(prop, "Group", "A group of objects based on which feature edges are selected");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "group_negation", PROP_ENUM, PROP_NONE);
 +      RNA_def_property_enum_bitflag_sdna(prop, NULL, "flags");
 +      RNA_def_property_enum_items(prop, group_negation_items);
 +      RNA_def_property_ui_text(prop, "Group Negation", "Set the negation operation for conditions on feature edge types");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "face_mark_negation", PROP_ENUM, PROP_NONE);
 +      RNA_def_property_enum_bitflag_sdna(prop, NULL, "flags");
 +      RNA_def_property_enum_items(prop, face_mark_negation_items);
 +      RNA_def_property_ui_text(prop, "Face Mark Negation", "Set the negation operation for the condition on face marks");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "face_mark_condition", PROP_ENUM, PROP_NONE);
 +      RNA_def_property_enum_bitflag_sdna(prop, NULL, "flags");
 +      RNA_def_property_enum_items(prop, face_mark_condition_items);
 +      RNA_def_property_ui_text(prop, "Face Mark Condition", "Set a feature edge selection condition on face marks");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "select_silhouette", PROP_BOOLEAN, PROP_NONE);
 +      RNA_def_property_boolean_sdna(prop, NULL, "edge_types", FREESTYLE_FE_SILHOUETTE);
 +      RNA_def_property_ui_text(prop, "Silhouette", "Select silhouette edges");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "select_border", PROP_BOOLEAN, PROP_NONE);
 +      RNA_def_property_boolean_sdna(prop, NULL, "edge_types", FREESTYLE_FE_BORDER);
 +      RNA_def_property_ui_text(prop, "Border", "Select border edges");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "select_crease", PROP_BOOLEAN, PROP_NONE);
 +      RNA_def_property_boolean_sdna(prop, NULL, "edge_types", FREESTYLE_FE_CREASE);
 +      RNA_def_property_ui_text(prop, "Crease", "Select crease edges");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "select_ridge", PROP_BOOLEAN, PROP_NONE);
 +      RNA_def_property_boolean_sdna(prop, NULL, "edge_types", FREESTYLE_FE_RIDGE);
 +      RNA_def_property_ui_text(prop, "Ridge", "Select ridges");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "select_valley", PROP_BOOLEAN, PROP_NONE);
 +      RNA_def_property_boolean_sdna(prop, NULL, "edge_types", FREESTYLE_FE_VALLEY);
 +      RNA_def_property_ui_text(prop, "Valley", "Select valleys");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "select_suggestive_contour", PROP_BOOLEAN, PROP_NONE);
 +      RNA_def_property_boolean_sdna(prop, NULL, "edge_types", FREESTYLE_FE_SUGGESTIVE_CONTOUR);
 +      RNA_def_property_ui_text(prop, "Suggestive Contour", "Select suggestive contours");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "select_material_boundary", PROP_BOOLEAN, PROP_NONE);
 +      RNA_def_property_boolean_sdna(prop, NULL, "edge_types", FREESTYLE_FE_MATERIAL_BOUNDARY);
 +      RNA_def_property_ui_text(prop, "Material Boundary", "Select edges at material boundaries");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "select_contour", PROP_BOOLEAN, PROP_NONE);
 +      RNA_def_property_boolean_sdna(prop, NULL, "edge_types", FREESTYLE_FE_CONTOUR);
 +      RNA_def_property_ui_text(prop, "Contour", "Select contours");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "select_external_contour", PROP_BOOLEAN, PROP_NONE);
 +      RNA_def_property_boolean_sdna(prop, NULL, "edge_types", FREESTYLE_FE_EXTERNAL_CONTOUR);
 +      RNA_def_property_ui_text(prop, "External Contour", "Select external contours");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "select_edge_mark", PROP_BOOLEAN, PROP_NONE);
 +      RNA_def_property_boolean_sdna(prop, NULL, "edge_types", FREESTYLE_FE_EDGE_MARK);
 +      RNA_def_property_ui_text(prop, "Edge Mark", "Select edge marks");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "exclude_silhouette", PROP_BOOLEAN, PROP_NONE);
 +      RNA_def_property_boolean_sdna(prop, NULL, "exclude_edge_types", FREESTYLE_FE_SILHOUETTE);
 +      RNA_def_property_ui_text(prop, "Silhouette", "Exclude silhouette edges");
 +      RNA_def_property_ui_icon(prop, ICON_X, 0);
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "exclude_border", PROP_BOOLEAN, PROP_NONE);
 +      RNA_def_property_boolean_sdna(prop, NULL, "exclude_edge_types", FREESTYLE_FE_BORDER);
 +      RNA_def_property_ui_text(prop, "Border", "Exclude border edges");
 +      RNA_def_property_ui_icon(prop, ICON_X, 0);
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "exclude_crease", PROP_BOOLEAN, PROP_NONE);
 +      RNA_def_property_boolean_sdna(prop, NULL, "exclude_edge_types", FREESTYLE_FE_CREASE);
 +      RNA_def_property_ui_text(prop, "Crease", "Exclude crease edges");
 +      RNA_def_property_ui_icon(prop, ICON_X, 0);
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "exclude_ridge", PROP_BOOLEAN, PROP_NONE);
 +      RNA_def_property_boolean_sdna(prop, NULL, "exclude_edge_types", FREESTYLE_FE_RIDGE);
 +      RNA_def_property_ui_text(prop, "Ridge", "Exclude ridges");
 +      RNA_def_property_ui_icon(prop, ICON_X, 0);
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "exclude_valley", PROP_BOOLEAN, PROP_NONE);
 +      RNA_def_property_boolean_sdna(prop, NULL, "exclude_edge_types", FREESTYLE_FE_VALLEY);
 +      RNA_def_property_ui_text(prop, "Valley", "Exclude valleys");
 +      RNA_def_property_ui_icon(prop, ICON_X, 0);
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "exclude_suggestive_contour", PROP_BOOLEAN, PROP_NONE);
 +      RNA_def_property_boolean_sdna(prop, NULL, "exclude_edge_types", FREESTYLE_FE_SUGGESTIVE_CONTOUR);
 +      RNA_def_property_ui_text(prop, "Suggestive Contour", "Exclude suggestive contours");
 +      RNA_def_property_ui_icon(prop, ICON_X, 0);
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "exclude_material_boundary", PROP_BOOLEAN, PROP_NONE);
 +      RNA_def_property_boolean_sdna(prop, NULL, "exclude_edge_types", FREESTYLE_FE_MATERIAL_BOUNDARY);
 +      RNA_def_property_ui_text(prop, "Material Boundary", "Exclude edges at material boundaries");
 +      RNA_def_property_ui_icon(prop, ICON_X, 0);
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "exclude_contour", PROP_BOOLEAN, PROP_NONE);
 +      RNA_def_property_boolean_sdna(prop, NULL, "exclude_edge_types", FREESTYLE_FE_CONTOUR);
 +      RNA_def_property_ui_text(prop, "Contour", "Exclude contours");
 +      RNA_def_property_ui_icon(prop, ICON_X, 0);
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "exclude_external_contour", PROP_BOOLEAN, PROP_NONE);
 +      RNA_def_property_boolean_sdna(prop, NULL, "exclude_edge_types", FREESTYLE_FE_EXTERNAL_CONTOUR);
 +      RNA_def_property_ui_text(prop, "External Contour", "Exclude external contours");
 +      RNA_def_property_ui_icon(prop, ICON_X, 0);
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "exclude_edge_mark", PROP_BOOLEAN, PROP_NONE);
 +      RNA_def_property_boolean_sdna(prop, NULL, "exclude_edge_types", FREESTYLE_FE_EDGE_MARK);
 +      RNA_def_property_ui_text(prop, "Edge Mark", "Exclude edge marks");
 +      RNA_def_property_ui_icon(prop, ICON_X, 0);
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "visibility", PROP_ENUM, PROP_NONE);
 +      RNA_def_property_enum_sdna(prop, NULL, "qi");
 +      RNA_def_property_enum_items(prop, visibility_items);
 +      RNA_def_property_ui_text(prop, "Visibility", "Determine how to use visibility for feature edge selection");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "qi_start", PROP_INT, PROP_UNSIGNED);
 +      RNA_def_property_int_sdna(prop, NULL, "qi_start");
 +      RNA_def_property_range(prop, 0, INT_MAX);
 +      RNA_def_property_ui_text(prop, "Start", "First QI value of the QI range");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "qi_end", PROP_INT, PROP_UNSIGNED);
 +      RNA_def_property_int_sdna(prop, NULL, "qi_end");
 +      RNA_def_property_range(prop, 0, INT_MAX);
 +      RNA_def_property_ui_text(prop, "End", "Last QI value of the QI range");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      /* FreestyleModuleSettings */
 +
 +      srna= RNA_def_struct(brna, "FreestyleModuleSettings", NULL);
 +      RNA_def_struct_sdna(srna, "FreestyleModuleConfig");
 +      RNA_def_struct_ui_text(srna, "Freestyle Module", "Style module configuration for specifying a style module");
 +
 +      prop= RNA_def_property(srna, "module_path", PROP_STRING, PROP_FILEPATH);
 +      RNA_def_property_string_sdna(prop, NULL, "module_path");
 +      RNA_def_property_ui_text(prop, "Module Path", "Path to a style module file");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "use", PROP_BOOLEAN, PROP_NONE);
 +      RNA_def_property_boolean_sdna(prop, NULL, "is_displayed", 1);
 +      RNA_def_property_ui_text(prop, "Use", "Enable or disable this style module during stroke rendering");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      /* FreestyleSettings */
 +
 +      srna= RNA_def_struct(brna, "FreestyleSettings", NULL);
 +      RNA_def_struct_sdna(srna, "FreestyleConfig");
 +      RNA_def_struct_nested(brna, srna, "SceneRenderLayer");
 +      RNA_def_struct_ui_text(srna, "Frestyle Settings", "Freestyle settings for a SceneRenderLayer datablock");
 +
 +      prop= RNA_def_property(srna, "modules", PROP_COLLECTION, PROP_NONE);
 +      RNA_def_property_collection_sdna(prop, NULL, "modules", NULL);
 +      RNA_def_property_struct_type(prop, "FreestyleModuleSettings");
 +      RNA_def_property_ui_text(prop, "Style modules", "A list of style modules (to be applied from top to bottom)");
 +
 +      prop= RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE);
 +      RNA_def_property_enum_sdna(prop, NULL, "mode");
 +      RNA_def_property_enum_items(prop, freestyle_ui_mode_items);
 +      RNA_def_property_ui_text(prop, "Control Mode", "Select the Freestyle control mode");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "raycasting_algorithm", PROP_ENUM, PROP_NONE);
 +      RNA_def_property_enum_sdna(prop, NULL, "raycasting_algorithm");
 +      RNA_def_property_enum_items(prop, freestyle_raycasting_algorithm_items);
 +      RNA_def_property_ui_text(prop, "Raycasting Algorithm", "Select the Freestyle raycasting algorithm");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "use_suggestive_contours", PROP_BOOLEAN, PROP_NONE);
 +      RNA_def_property_boolean_sdna(prop, NULL, "flags", FREESTYLE_SUGGESTIVE_CONTOURS_FLAG);
 +      RNA_def_property_ui_text(prop, "Suggestive Contours", "Enable suggestive contours");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "use_ridges_and_valleys", PROP_BOOLEAN, PROP_NONE);
 +      RNA_def_property_boolean_sdna(prop, NULL, "flags", FREESTYLE_RIDGES_AND_VALLEYS_FLAG);
 +      RNA_def_property_ui_text(prop, "Ridges and Valleys", "Enable ridges and valleys");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "use_material_boundaries", PROP_BOOLEAN, PROP_NONE);
 +      RNA_def_property_boolean_sdna(prop, NULL, "flags", FREESTYLE_MATERIAL_BOUNDARIES_FLAG);
 +      RNA_def_property_ui_text(prop, "Material Boundaries", "Enable material boundaries");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "use_smoothness", PROP_BOOLEAN, PROP_NONE);
 +      RNA_def_property_boolean_sdna(prop, NULL, "flags", FREESTYLE_FACE_SMOOTHNESS_FLAG);
 +      RNA_def_property_ui_text(prop, "Face Smoothness", "Take face smoothness into account in view map calculation");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "sphere_radius", PROP_FLOAT, PROP_NONE);
 +      RNA_def_property_float_sdna(prop, NULL, "sphere_radius");
 +      RNA_def_property_range(prop, 0.0, 1000.0);
 +      RNA_def_property_ui_text(prop, "Sphere Radius", "Sphere radius for computing curvatures");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "kr_derivative_epsilon", PROP_FLOAT, PROP_NONE);
 +      RNA_def_property_float_sdna(prop, NULL, "dkr_epsilon");
 +      RNA_def_property_range(prop, 0.0, 1000.0);
 +      RNA_def_property_ui_text(prop, "Kr Derivative Epsilon", "Kr derivative epsilon for computing suggestive contours");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "crease_angle", PROP_FLOAT, PROP_NONE);
 +      RNA_def_property_float_sdna(prop, NULL, "crease_angle");
 +      RNA_def_property_range(prop, 0.0, 180.0);
 +      RNA_def_property_ui_text(prop, "Crease Angle", "Angular threshold in degrees (between 0 and 180) for detecting crease edges");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop= RNA_def_property(srna, "linesets", PROP_COLLECTION, PROP_NONE);
 +      RNA_def_property_collection_sdna(prop, NULL, "linesets", NULL);
 +      RNA_def_property_struct_type(prop, "FreestyleLineSet");
 +      RNA_def_property_ui_text(prop, "Line Sets", "");
 +      rna_def_freestyle_linesets(brna, prop);
 +}
 +
  static void rna_def_scene_game_recast_data(BlenderRNA *brna)
  {
        StructRNA *srna;
@@@ -2598,23 -2172,12 +2599,23 @@@ static void rna_def_scene_game_data(Ble
  static void rna_def_scene_render_layer(BlenderRNA *brna)
  {
        StructRNA *srna;
 +      PropertyRNA *prop;
  
        srna= RNA_def_struct(brna, "SceneRenderLayer", NULL);
        RNA_def_struct_ui_text(srna, "Scene Render Layer", "Render layer");
        RNA_def_struct_ui_icon(srna, ICON_RENDERLAYERS);
  
        rna_def_render_layer_common(srna, 1);
 +
 +      /* Freestyle */
 +
 +      rna_def_freestyle_settings(brna);
 +
 +      prop= RNA_def_property(srna, "freestyle_settings", PROP_POINTER, PROP_NONE);
 +      RNA_def_property_flag(prop, PROP_NEVER_NULL);
 +      RNA_def_property_pointer_sdna(prop, NULL, "freestyleConfig");
 +      RNA_def_property_struct_type(prop, "FreestyleSettings");
 +      RNA_def_property_ui_text(prop, "Freestyle Settings", "");
  }
  
  /* curve.splines */
@@@ -3317,11 -2880,6 +3318,11 @@@ static void rna_def_scene_render_data(B
        RNA_def_property_ui_text(prop, "Edge Color", "Edge color");
        RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL);
        
 +      prop= RNA_def_property(srna, "use_freestyle", PROP_BOOLEAN, PROP_NONE);
 +      RNA_def_property_boolean_sdna(prop, NULL, "mode", R_EDGE_FRS);
 +      RNA_def_property_ui_text(prop, "Edge", "Draw stylized strokes using Freestyle");
 +      RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL);
 +
        /* threads */
        prop= RNA_def_property(srna, "threads", PROP_INT, PROP_NONE);
        RNA_def_property_int_sdna(prop, NULL, "threads");
        
        prop= RNA_def_property(srna, "use_full_sample", PROP_BOOLEAN, PROP_NONE);
        RNA_def_property_boolean_sdna(prop, NULL, "scemode", R_FULL_SAMPLE);
-        RNA_def_property_boolean_funcs(prop, "rna_RenderSettings_full_sample_get", NULL);
+       RNA_def_property_boolean_funcs(prop, "rna_RenderSettings_full_sample_get", NULL);
        RNA_def_property_ui_text(prop, "Full Sample",
                                 "Save for every anti-aliasing sample the entire RenderLayer results "
                                 "(this solves anti-aliasing issues with compositing)");
index 9dc125bbdcc7d1c09ed1e6c76fd8432980358a0f,09b712fbfaf340e10709506ad5c0a2dac0e8ca0c..8406f232653143d66057625dd624988277c2ee23
@@@ -316,6 -316,7 +316,7 @@@ static void rna_def_userdef_theme_ui_fo
  
        srna= RNA_def_struct(brna, "ThemeFontStyle", NULL);
        RNA_def_struct_sdna(srna, "uiFontStyle");
+       RNA_def_struct_clear_flag(srna, STRUCT_UNDO);
        RNA_def_struct_ui_text(srna, "Font Style", "Theme settings for Font");
        
        prop= RNA_def_property(srna, "points", PROP_INT, PROP_NONE);
@@@ -366,6 -367,7 +367,7 @@@ static void rna_def_userdef_theme_ui_st
        
        srna= RNA_def_struct(brna, "ThemeStyle", NULL);
        RNA_def_struct_sdna(srna, "uiStyle");
+       RNA_def_struct_clear_flag(srna, STRUCT_UNDO);
        RNA_def_struct_ui_text(srna, "Style", "Theme settings for style sets");
        
        /* (not used yet)
@@@ -410,6 -412,7 +412,7 @@@ static void rna_def_userdef_theme_ui_wc
        
        srna= RNA_def_struct(brna, "ThemeWidgetColors", NULL);
        RNA_def_struct_sdna(srna, "uiWidgetColors");
+       RNA_def_struct_clear_flag(srna, STRUCT_UNDO);
        RNA_def_struct_ui_text(srna, "Theme Widget Color Set", "Theme settings for widget color sets");
                
        prop= RNA_def_property(srna, "outline", PROP_FLOAT, PROP_COLOR_GAMMA);
@@@ -465,6 -468,7 +468,7 @@@ static void rna_def_userdef_theme_ui_wc
        
        srna= RNA_def_struct(brna, "ThemeWidgetStateColors", NULL);
        RNA_def_struct_sdna(srna, "uiWidgetStateColors");
+       RNA_def_struct_clear_flag(srna, STRUCT_UNDO);
        RNA_def_struct_ui_text(srna, "Theme Widget State Color", "Theme settings for widget state colors");
                
        prop= RNA_def_property(srna, "inner_anim", PROP_FLOAT, PROP_COLOR_GAMMA);
@@@ -512,6 -516,7 +516,7 @@@ static void rna_def_userdef_theme_ui(Bl
        
        srna= RNA_def_struct(brna, "ThemeUserInterface", NULL);
        RNA_def_struct_sdna(srna, "ThemeUI");
+       RNA_def_struct_clear_flag(srna, STRUCT_UNDO);
        RNA_def_struct_ui_text(srna, "Theme User Interface", "Theme settings for user interface elements");
  
        prop= RNA_def_property(srna, "wcol_regular", PROP_POINTER, PROP_NONE);
@@@ -775,11 -780,6 +780,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)
@@@ -927,6 -922,7 +932,7 @@@ static void rna_def_userdef_theme_space
  
        srna= RNA_def_struct(brna, "ThemeView3D", NULL);
        RNA_def_struct_sdna(srna, "ThemeSpace");
+       RNA_def_struct_clear_flag(srna, STRUCT_UNDO);
        RNA_def_struct_ui_text(srna, "Theme 3D View", "Theme settings for the 3D View");
  
        rna_def_userdef_theme_spaces_main(srna, SPACE_VIEW3D);
@@@ -1064,6 -1060,7 +1070,7 @@@ static void rna_def_userdef_theme_space
  
        srna= RNA_def_struct(brna, "ThemeGraphEditor", NULL);
        RNA_def_struct_sdna(srna, "ThemeSpace");
+       RNA_def_struct_clear_flag(srna, STRUCT_UNDO);
        RNA_def_struct_ui_text(srna, "Theme Graph Editor", "Theme settings for the graph editor");
  
        rna_def_userdef_theme_spaces_main(srna, SPACE_IPO);
@@@ -1148,6 -1145,7 +1155,7 @@@ static void rna_def_userdef_theme_space
  
        srna= RNA_def_struct(brna, "ThemeFileBrowser", NULL);
        RNA_def_struct_sdna(srna, "ThemeSpace");
+       RNA_def_struct_clear_flag(srna, STRUCT_UNDO);
        RNA_def_struct_ui_text(srna, "Theme File Browser", "Theme settings for the File Browser");
  
        rna_def_userdef_theme_spaces_main(srna, SPACE_FILE);
@@@ -1197,6 -1195,7 +1205,7 @@@ static void rna_def_userdef_theme_space
  
        srna= RNA_def_struct(brna, "ThemeOutliner", NULL);
        RNA_def_struct_sdna(srna, "ThemeSpace");
+       RNA_def_struct_clear_flag(srna, STRUCT_UNDO);
        RNA_def_struct_ui_text(srna, "Theme Outliner", "Theme settings for the Outliner");
  
        rna_def_userdef_theme_spaces_main(srna, SPACE_OUTLINER);
@@@ -1210,6 -1209,7 +1219,7 @@@ static void rna_def_userdef_theme_space
  
        srna= RNA_def_struct(brna, "ThemeUserPreferences", NULL);
        RNA_def_struct_sdna(srna, "ThemeSpace");
+       RNA_def_struct_clear_flag(srna, STRUCT_UNDO);
        RNA_def_struct_ui_text(srna, "Theme User Preferences", "Theme settings for the User Preferences");
  
        rna_def_userdef_theme_spaces_main(srna, SPACE_USERPREF);
@@@ -1224,6 -1224,7 +1234,7 @@@ static void rna_def_userdef_theme_space
  
        srna= RNA_def_struct(brna, "ThemeConsole", NULL);
        RNA_def_struct_sdna(srna, "ThemeSpace");
+       RNA_def_struct_clear_flag(srna, STRUCT_UNDO);
        RNA_def_struct_ui_text(srna, "Theme Console", "Theme settings for the Console");
        
        rna_def_userdef_theme_spaces_main(srna, SPACE_CONSOLE);
@@@ -1267,6 -1268,7 +1278,7 @@@ static void rna_def_userdef_theme_space
  
        srna= RNA_def_struct(brna, "ThemeInfo", NULL);
        RNA_def_struct_sdna(srna, "ThemeSpace");
+       RNA_def_struct_clear_flag(srna, STRUCT_UNDO);
        RNA_def_struct_ui_text(srna, "Theme Info", "Theme settings for Info");
  
        rna_def_userdef_theme_spaces_main(srna, SPACE_INFO);
@@@ -1282,6 -1284,7 +1294,7 @@@ static void rna_def_userdef_theme_space
  
        srna= RNA_def_struct(brna, "ThemeTextEditor", NULL);
        RNA_def_struct_sdna(srna, "ThemeSpace");
+       RNA_def_struct_clear_flag(srna, STRUCT_UNDO);
        RNA_def_struct_ui_text(srna, "Theme Text Editor", "Theme settings for the Text Editor");
  
        rna_def_userdef_theme_spaces_main(srna, SPACE_TEXT);
@@@ -1350,6 -1353,7 +1363,7 @@@ static void rna_def_userdef_theme_space
  
        srna= RNA_def_struct(brna, "ThemeNodeEditor", NULL);
        RNA_def_struct_sdna(srna, "ThemeSpace");
+       RNA_def_struct_clear_flag(srna, STRUCT_UNDO);
        RNA_def_struct_ui_text(srna, "Theme Node Editor", "Theme settings for the Node Editor");
  
        rna_def_userdef_theme_spaces_main(srna, SPACE_NODE);
@@@ -1419,6 -1423,7 +1433,7 @@@ static void rna_def_userdef_theme_space
        
        srna= RNA_def_struct(brna, "ThemeLogicEditor", NULL);
        RNA_def_struct_sdna(srna, "ThemeSpace");
+       RNA_def_struct_clear_flag(srna, STRUCT_UNDO);
        RNA_def_struct_ui_text(srna, "Theme Logic Editor", "Theme settings for the Logic Editor");
        
        rna_def_userdef_theme_spaces_main(srna, SPACE_LOGIC);
@@@ -1439,6 -1444,7 +1454,7 @@@ static void rna_def_userdef_theme_space
  
        srna= RNA_def_struct(brna, "ThemeProperties", NULL);
        RNA_def_struct_sdna(srna, "ThemeSpace");
+       RNA_def_struct_clear_flag(srna, STRUCT_UNDO);
        RNA_def_struct_ui_text(srna, "Theme Properties", "Theme settings for the Properties");
  
        rna_def_userdef_theme_spaces_main(srna, SPACE_BUTS);
@@@ -1458,6 -1464,7 +1474,7 @@@ static void rna_def_userdef_theme_space
  
        srna= RNA_def_struct(brna, "ThemeTimeline", NULL);
        RNA_def_struct_sdna(srna, "ThemeSpace");
+       RNA_def_struct_clear_flag(srna, STRUCT_UNDO);
        RNA_def_struct_ui_text(srna, "Theme Timeline", "Theme settings for the Timeline");
  
        rna_def_userdef_theme_spaces_main(srna, SPACE_TIME);
@@@ -1483,6 -1490,7 +1500,7 @@@ static void rna_def_userdef_theme_space
  
        srna= RNA_def_struct(brna, "ThemeImageEditor", NULL);
        RNA_def_struct_sdna(srna, "ThemeSpace");
+       RNA_def_struct_clear_flag(srna, STRUCT_UNDO);
        RNA_def_struct_ui_text(srna, "Theme Image Editor", "Theme settings for the Image Editor");
  
        rna_def_userdef_theme_spaces_main(srna, SPACE_IMAGE);
@@@ -1510,6 -1518,7 +1528,7 @@@ static void rna_def_userdef_theme_space
  
        srna= RNA_def_struct(brna, "ThemeSequenceEditor", NULL);
        RNA_def_struct_sdna(srna, "ThemeSpace");
+       RNA_def_struct_clear_flag(srna, STRUCT_UNDO);
        RNA_def_struct_ui_text(srna, "Theme Sequence Editor", "Theme settings for the Sequence Editor");
  
        rna_def_userdef_theme_spaces_main(srna, SPACE_IMAGE);
@@@ -1601,6 -1610,7 +1620,7 @@@ static void rna_def_userdef_theme_space
  
        srna= RNA_def_struct(brna, "ThemeDopeSheet", NULL);
        RNA_def_struct_sdna(srna, "ThemeSpace");
+       RNA_def_struct_clear_flag(srna, STRUCT_UNDO);
        RNA_def_struct_ui_text(srna, "Theme DopeSheet", "Theme settings for the DopeSheet");
  
        rna_def_userdef_theme_spaces_main(srna, SPACE_ACTION);
@@@ -1686,6 -1696,7 +1706,7 @@@ static void rna_def_userdef_theme_space
  
        srna= RNA_def_struct(brna, "ThemeNLAEditor", NULL);
        RNA_def_struct_sdna(srna, "ThemeSpace");
+       RNA_def_struct_clear_flag(srna, STRUCT_UNDO);
        RNA_def_struct_ui_text(srna, "Theme NLA Editor", "Theme settings for the NLA Editor");
  
        rna_def_userdef_theme_spaces_main(srna, SPACE_NLA);
@@@ -1739,6 -1750,7 +1760,7 @@@ static void rna_def_userdef_theme_color
  
        srna= RNA_def_struct(brna, "ThemeBoneColorSet", NULL);
        RNA_def_struct_sdna(srna, "ThemeWireColor");
+       RNA_def_struct_clear_flag(srna, STRUCT_UNDO);
        RNA_def_struct_ui_text(srna, "Theme Bone Color Set", "Theme settings for bone color sets");
  
        prop= RNA_def_property(srna, "normal", PROP_FLOAT, PROP_COLOR_GAMMA);
@@@ -1773,6 -1785,7 +1795,7 @@@ static void rna_def_userdef_theme_space
  
        srna= RNA_def_struct(brna, "ThemeClipEditor", NULL);
        RNA_def_struct_sdna(srna, "ThemeSpace");
+       RNA_def_struct_clear_flag(srna, STRUCT_UNDO);
        RNA_def_struct_ui_text(srna, "Theme Clip Editor", "Theme settings for the Movie Clip Editor");
  
        rna_def_userdef_theme_spaces_main(srna, SPACE_CLIP);
@@@ -1881,6 -1894,7 +1904,7 @@@ static void rna_def_userdef_themes(Blen
  
        srna= RNA_def_struct(brna, "Theme", NULL);
        RNA_def_struct_sdna(srna, "bTheme");
+       RNA_def_struct_clear_flag(srna, STRUCT_UNDO);
        RNA_def_struct_ui_text(srna, "Theme", "Theme settings defining draw style and colors in the user interface");
  
        prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
@@@ -2014,6 -2028,7 +2038,7 @@@ static void rna_def_userdef_addon(Blend
  
        srna= RNA_def_struct(brna, "Addon", NULL);
        RNA_def_struct_sdna(srna, "bAddon");
+       RNA_def_struct_clear_flag(srna, STRUCT_UNDO);
        RNA_def_struct_ui_text(srna, "Addon", "Python addons to be loaded automatically");
  
        prop= RNA_def_property(srna, "module", PROP_STRING, PROP_NONE);
@@@ -2057,6 -2072,7 +2082,7 @@@ static void rna_def_userdef_solidlight(
  
        srna= RNA_def_struct(brna, "UserSolidLight", NULL);
        RNA_def_struct_sdna(srna, "SolidLight");
+       RNA_def_struct_clear_flag(srna, STRUCT_UNDO);
        RNA_def_struct_ui_text(srna, "Solid Light", "Light used for OpenGL lighting in solid draw mode");
        
        prop= RNA_def_property(srna, "use", PROP_BOOLEAN, PROP_NONE);
@@@ -2106,6 -2122,7 +2132,7 @@@ static void rna_def_userdef_view(Blende
        srna= RNA_def_struct(brna, "UserPreferencesView", NULL);
        RNA_def_struct_sdna(srna, "UserDef");
        RNA_def_struct_nested(brna, srna, "UserPreferences");
+       RNA_def_struct_clear_flag(srna, STRUCT_UNDO);
        RNA_def_struct_ui_text(srna, "View & Controls", "Preferences related to viewing data");
  
        /* View  */
@@@ -2321,6 -2338,7 +2348,7 @@@ static void rna_def_userdef_edit(Blende
        srna= RNA_def_struct(brna, "UserPreferencesEdit", NULL);
        RNA_def_struct_sdna(srna, "UserDef");
        RNA_def_struct_nested(brna, srna, "UserPreferences");
+       RNA_def_struct_clear_flag(srna, STRUCT_UNDO);
        RNA_def_struct_ui_text(srna, "Edit Methods", "Settings for interacting with Blender data");
        
        /* Edit Methods */
@@@ -2599,12 -2617,13 +2627,13 @@@ static void rna_def_userdef_system(Blen
                {0, "DEFAULT", 0, "Default (Default)", ""},
                {1, "ENGLISH", 0, "English (English)", "en_US"},
                {8, "FRENCH", 0, "French (Français)", "fr_FR"},
-               {9, "SPANISH", 0, "Spanish (Español)", "es_ES"},
+               {4, "ITALIAN", 0, "Italian (Italiano)", "it_IT"},
+               {15, "RUSSIAN", 0, "Russian (Русский)", "ru_RU"},
                {13, "SIMPLIFIED_CHINESE", 0, "Simplified Chinese (简体中文)", "zh_CN"},
+               {9, "SPANISH", 0, "Spanish (Español)", "es_ES"},
                {0, "", 0, "In progress", ""},
                {2, "JAPANESE", 0, "Japanese (日本語)", "ja_JP"},
                {3, "DUTCH", 0, "Dutch (Nederlandse taal)", "nl_NL"},
-               {4, "ITALIAN", 0, "Italian (Italiano)", "it_IT"},
                {5, "GERMAN", 0, "German (Deutsch)", "de_DE"},
                {6, "FINNISH", 0, "Finnish (Suomi)", "fi_FI"},
                {7, "SWEDISH", 0, "Swedish (Svenska)", "sv_SE"},
                {11, "CZECH", 0, "Czech (Český)", "cs_CZ"},
                {12, "BRAZILIAN_PORTUGUESE", 0, "Brazilian Portuguese (Português do Brasil)", "pt_BR"},
                {14, "TRADITIONAL_CHINESE", 0, "Traditional Chinese (繁體中文)", "zh_TW"},
-               {15, "RUSSIAN", 0, "Russian (Русский)", "ru_RU"},
                {16, "CROATIAN", 0, "Croatian (Hrvatski)", "hr_HR"},
                {17, "SERBIAN", 0, "Serbian (Српском језику)", "sr_RS"},
                {18, "UKRAINIAN", 0, "Ukrainian (Український)", "uk_UA"},
        srna= RNA_def_struct(brna, "UserPreferencesSystem", NULL);
        RNA_def_struct_sdna(srna, "UserDef");
        RNA_def_struct_nested(brna, srna, "UserPreferences");
+       RNA_def_struct_clear_flag(srna, STRUCT_UNDO);
        RNA_def_struct_ui_text(srna, "System & OpenGL", "Graphics driver and operating system settings");
  
        /* Language */
@@@ -2876,6 -2895,7 +2905,7 @@@ static void rna_def_userdef_input(Blend
        srna= RNA_def_struct(brna, "UserPreferencesInput", NULL);
        RNA_def_struct_sdna(srna, "UserDef");
        RNA_def_struct_nested(brna, srna, "UserPreferences");
+       RNA_def_struct_clear_flag(srna, STRUCT_UNDO);
        RNA_def_struct_ui_text(srna, "Input", "Settings for input devices");
        
        prop= RNA_def_property(srna, "select_mouse", PROP_ENUM, PROP_NONE);
@@@ -3031,6 -3051,7 +3061,7 @@@ static void rna_def_userdef_filepaths(B
        srna= RNA_def_struct(brna, "UserPreferencesFilePaths", NULL);
        RNA_def_struct_sdna(srna, "UserDef");
        RNA_def_struct_nested(brna, srna, "UserPreferences");
+       RNA_def_struct_clear_flag(srna, STRUCT_UNDO);
        RNA_def_struct_ui_text(srna, "File Paths", "Default paths for external files");
        
        prop= RNA_def_property(srna, "show_hidden_files_datablocks", PROP_BOOLEAN, PROP_NONE);
@@@ -3148,6 -3169,7 +3179,7 @@@ void rna_def_userdef_addon_collection(B
  
        RNA_def_property_srna(cprop, "Addons");
        srna= RNA_def_struct(brna, "Addons", NULL);
+       RNA_def_struct_clear_flag(srna, STRUCT_UNDO);
        RNA_def_struct_ui_text(srna, "User Addons", "Collection of addons");
  
        func= RNA_def_function(srna, "new", "rna_userdef_addon_new");
@@@ -3184,6 -3206,7 +3216,7 @@@ void RNA_def_userdef(BlenderRNA *brna
  
        srna= RNA_def_struct(brna, "UserPreferences", NULL);
        RNA_def_struct_sdna(srna, "UserDef");
+       RNA_def_struct_clear_flag(srna, STRUCT_UNDO);
        RNA_def_struct_ui_text(srna, "User Preferences", "Global user preferences");
  
        prop= RNA_def_property(srna, "active_section", PROP_ENUM, PROP_NONE);
index fa8238badaadf5adfb0dc0f87086f92b62a800d2,7075b0592b8982efebf638176a0af62cf6ea5d06..d42ad630e75871088f0e5334c7af7415127bedea
@@@ -4,9 -4,8 +4,9 @@@
  
  Import ('env')
  
- incs = '. ../editors/include ../makesdna ../makesrna ../blenlib ../blenkernel ../nodes'
+ incs = '. ../editors/include ../makesdna ../makesrna ../blenfont ../blenlib ../blenkernel ../nodes'
  incs += ' ../imbuf ../blenloader ../gpu ../render/extern/include ../windowmanager'
 +incs += ' ../freestyle/intern/python'
  incs += ' #intern/guardedalloc #intern/memutil #extern/glew/include'
  incs += ' #intern/audaspace/intern ' + env['BF_PYTHON_INC']
  
@@@ -44,5 -43,8 +44,8 @@@ if env['BF_BUILDINFO']
  if env['WITH_BF_INTERNATIONAL']:
      defs.append('WITH_INTERNATIONAL')
  
+ if env['WITH_BF_CYCLES']:
+     defs.append('WITH_CYCLES')
  sources = env.Glob('intern/*.c')
  env.BlenderLib( libname = 'bf_python', sources = Split(sources), includes = Split(incs), defines = defs, libtype = ['core'], priority = [361])
index 3fe8aada3aeecda19d7faba08a0ee30378b24313,63ccdea3f0d20b5382673dffd93ab2e9e96de594..73b2285ca131e3146c41f0401b86b7f8c9444f27
@@@ -25,6 -25,7 +25,7 @@@
  
  set(INC 
        ..
+       ../../blenfont
        ../../blenkernel
        ../../blenlib
        ../../blenloader
@@@ -33,7 -34,6 +34,7 @@@
        ../../makesrna
        ../../windowmanager
      ../../gpu
 +      ../../freestyle/intern/python
        ../../../../intern/guardedalloc
  )
  
@@@ -96,6 -96,10 +97,10 @@@ if(WITH_AUDASPACE
        add_definitions(-DWITH_AUDASPACE)
  endif()
  
+ if(WITH_CYCLES)
+       add_definitions(-DWITH_CYCLES)
+ endif()
  if(WITH_INTERNATIONAL)
          add_definitions(-DWITH_INTERNATIONAL)
  endif()
index b065546e30fd881cea4b4f7284de02cc2d2a9442,c00df7db87e8e1b392bd1dcae4bb6d9f9b15262c..2e6e8fa209929e1f8a872849c7e5938df54cac95
@@@ -214,7 -214,6 +214,7 @@@ void RE_TileProcessor(struct Render *re
  /* only RE_NewRender() needed, main Blender render calls */
  void RE_BlenderFrame(struct Render *re, struct Main *bmain, struct Scene *scene, struct SceneRenderLayer *srl, struct Object *camera_override, unsigned int lay, int frame, const short write_still);
  void RE_BlenderAnim(struct Render *re, struct Main *bmain, struct Scene *scene, struct Object *camera_override, unsigned int lay, int sfra, int efra, int tfra);
 +void RE_RenderFreestyleStrokes(struct Render *re, struct Main *bmain, struct Scene *scene);
  
  /* error reporting */
  void RE_SetReports(struct Render *re, struct ReportList *reports);
@@@ -234,7 -233,7 +234,7 @@@ void RE_MergeFullSample(struct Render *
  
  /* ancient stars function... go away! */
  void RE_make_stars(struct Render *re, struct Scene *scenev3d, void (*initfunc)(void),
-                                  void (*vertexfunc)(float*),  void (*termfunc)(void));
+                    void (*vertexfunc)(float*),  void (*termfunc)(void));
  
  /* display and event callbacks */
  void RE_display_init_cb       (struct Render *re, void *handle, void (*f)(void *handle, RenderResult *rr));
index b7fe4a2e024a435004757408ec4176d826ceff11,440c7170341ce71779d8c78cf9afcc773b9328b5..8e729b827cd65a62e16148166853792223376f64
@@@ -42,7 -42,6 +42,7 @@@
  #include "BLI_rand.h"
  #include "BLI_memarena.h"
  #include "BLI_ghash.h"
 +#include "BLI_edgehash.h"
  
  #include "DNA_armature_types.h"
  #include "DNA_camera_types.h"
@@@ -2291,7 -2290,7 +2291,7 @@@ static void displace_render_vert(Rende
        
        shi->displace[0]= shi->displace[1]= shi->displace[2]= 0.0;
        
-       do_material_tex(shi);
+       do_material_tex(shi, re);
        
        //printf("no=%f, %f, %f\nbefore co=%f, %f, %f\n", vr->n[0], vr->n[1], vr->n[2], 
        //vr->co[0], vr->co[1], vr->co[2]);
@@@ -2734,7 -2733,7 +2734,7 @@@ static void init_render_dm(DerivedMesh 
                                        v2= mface->v2;
                                        v3= mface->v3;
                                        v4= mface->v4;
 -                                      flag= mface->flag & ME_SMOOTH;
 +                                      flag= mface->flag & (ME_SMOOTH | ME_FREESTYLE_FACE);
  
                                        vlr= RE_findOrAddVlak(obr, obr->totvlak++);
                                        vlr->v1= RE_findOrAddVert(obr, vertofs+v1);
@@@ -3234,24 -3233,6 +3234,24 @@@ static void add_volume(Render *re, Obje
        BLI_addtail(&re->volumes, vo);
  }
  
 +static EdgeHash *make_freestyle_edge_mark_hash(MEdge *medge, int totedge)
 +{
 +      EdgeHash *edge_hash= BLI_edgehash_new();
 +      int a;
 +
 +      for(a=0; a<totedge; a++) {
 +              if(medge[a].flag & ME_FREESTYLE_EDGE)
 +                      BLI_edgehash_insert(edge_hash, medge[a].v1, medge[a].v2, medge+a);
 +      }
 +      return edge_hash;
 +}
 +
 +static int has_freestyle_edge_mark(EdgeHash *edge_hash, int v1, int v2)
 +{
 +      MEdge *medge= BLI_edgehash_lookup(edge_hash, v1, v2);
 +      return (!medge) ? 0 : 1;
 +}
 +
  static void init_render_mesh(Render *re, ObjectRen *obr, int timeoffset)
  {
        Object *ob= obr->ob;
                }
                
                if(!timeoffset) {
 +                      EdgeHash *edge_hash;
 +                      MEdge *medge;
 +                      int totedge;
 +
 +                      /* create a hash table of Freestyle edge marks */
 +                      medge= dm->getEdgeArray(dm);
 +                      totedge= dm->getNumEdges(dm);
 +                      edge_hash= make_freestyle_edge_mark_hash(medge, totedge);
 +
                        /* store customdata names, because DerivedMesh is freed */
                        RE_set_customdata_names(obr, &dm->faceData);
  
                                                
                                                if( mface->mat_nr==a1 ) {
                                                        float len;
 +                                                      int edge_mark= 0;
 +                                                              
                                                        int reverse_verts = negative_scale!=0 && do_autosmooth==0;
                                                        int rev_tab[] = {reverse_verts==0 ? 0 : 2, 1, reverse_verts==0 ? 2 : 0, 3};
                                                        v1= reverse_verts==0 ? mface->v1 : mface->v3;
                                                        v2= mface->v2;
                                                        v3= reverse_verts==0 ? mface->v3 : mface->v1;
                                                        v4= mface->v4;
 -                                                      flag= mface->flag & ME_SMOOTH;
 +                                                      flag= mface->flag & (ME_SMOOTH | ME_FREESTYLE_FACE);
  
                                                        vlr= RE_findOrAddVlak(obr, obr->totvlak++);
                                                        vlr->v1= RE_findOrAddVert(obr, vertofs+v1);
                                                        if(v4) vlr->v4= RE_findOrAddVert(obr, vertofs+v4);
                                                        else vlr->v4= 0;
  
 +                                                      /* Freestyle edge marks */
 +                                                      if(has_freestyle_edge_mark(edge_hash, v1, v2)) edge_mark |= R_EDGE_V1V2;
 +                                                      if(has_freestyle_edge_mark(edge_hash, v2, v3)) edge_mark |= R_EDGE_V2V3;
 +                                                      if (!v4) {
 +                                                              if(has_freestyle_edge_mark(edge_hash, v3, v1)) edge_mark |= R_EDGE_V3V1;
 +                                                      } else {
 +                                                              if(has_freestyle_edge_mark(edge_hash, v3, v4)) edge_mark |= R_EDGE_V3V4;
 +                                                              if(has_freestyle_edge_mark(edge_hash, v4, v1)) edge_mark |= R_EDGE_V4V1;
 +                                                      }
 +                                                      vlr->freestyle_edge_mark= edge_mark;
 +
                                                        /* render normals are inverted in render */
                                                        if(use_original_normals) {
                                                                MFace *mf= me->mface+a;
                                        }
                                }
                        }
 +
 +                      /* release the hash table of Freestyle edge marks */
 +                      BLI_edgehash_free(edge_hash, NULL);
                        
                        /* exception... we do edges for wire mode. potential conflict when faces exist... */
                        end= dm->getNumEdges(dm);
@@@ -3665,7 -3621,7 +3665,7 @@@ static void area_lamp_vectors(LampRen *
        float xsize= 0.5f*lar->area_size, ysize= 0.5f*lar->area_sizey, multifac;
  
        /* make it smaller, so area light can be multisampled */
-       multifac= 1.0f/sqrt((float)lar->ray_totsamp);
+       multifac= 1.0f/sqrtf((float)lar->ray_totsamp);
        xsize *= multifac;
        ysize *= multifac;
        
@@@ -3845,7 -3801,7 +3845,7 @@@ static GroupObject *add_render_lamp(Ren
        if(lar->mode & LA_HALO) {
                if(lar->spotsi>170.0f) lar->spotsi= 170.0f;
        }
-       lar->spotsi= cosM_PI*lar->spotsi/360.0f );
+       lar->spotsi= cosf( (float)M_PI*lar->spotsi/360.0f );
        lar->spotbl= (1.0f-lar->spotsi)*la->spotblend;
  
        memcpy(lar->mtex, la->mtex, MAX_MTEX*sizeof(void *));
@@@ -4072,8 -4028,8 +4072,8 @@@ void init_render_world(Render *re
                re->wrld.misi= 1.0f;
        }
        
-       re->wrld.linfac= 1.0 + pow((2.0*re->wrld.exp + 0.5), -10);
-       re->wrld.logfac= log( (re->wrld.linfac-1.0)/re->wrld.linfac )/re->wrld.range;
+       re->wrld.linfac= 1.0f + powf((2.0f*re->wrld.exp + 0.5f), -10);
+       re->wrld.logfac= logf((re->wrld.linfac-1.0f)/re->wrld.linfac) / re->wrld.range;
  }
  
  
@@@ -4126,7 -4082,7 +4126,7 @@@ static void set_phong_threshold(ObjectR
        
        if(tot) {
                thresh/= (float)tot;
-               obr->ob->smoothresh= cos(0.5*M_PI-saacos(thresh));
+               obr->ob->smoothresh= cosf(0.5f*(float)M_PI-saacos(thresh));
        }
  }
  
@@@ -4316,23 -4272,6 +4316,23 @@@ static void check_non_flat_quads(Object
                                        /* new normals */
                                        normal_tri_v3( vlr->n,vlr->v3->co, vlr->v2->co, vlr->v1->co);
                                        normal_tri_v3( vlr1->n,vlr1->v3->co, vlr1->v2->co, vlr1->v1->co);
 +
 +                                      /* Freestyle edge marks */
 +                                      if (vlr->flag & R_DIVIDE_24) {
 +                                              vlr1->freestyle_edge_mark=
 +                                                      ((vlr->freestyle_edge_mark & R_EDGE_V2V3) ? R_EDGE_V1V2 : 0) |
 +                                                      ((vlr->freestyle_edge_mark & R_EDGE_V3V4) ? R_EDGE_V2V3 : 0);
 +                                              vlr->freestyle_edge_mark=
 +                                                      ((vlr->freestyle_edge_mark & R_EDGE_V1V2) ? R_EDGE_V1V2 : 0) |
 +                                                      ((vlr->freestyle_edge_mark & R_EDGE_V4V1) ? R_EDGE_V3V1 : 0);
 +                                      } else {
 +                                              vlr1->freestyle_edge_mark=
 +                                                      ((vlr->freestyle_edge_mark & R_EDGE_V3V4) ? R_EDGE_V2V3 : 0) |
 +                                                      ((vlr->freestyle_edge_mark & R_EDGE_V4V1) ? R_EDGE_V3V1 : 0);
 +                                              vlr->freestyle_edge_mark=
 +                                                      ((vlr->freestyle_edge_mark & R_EDGE_V1V2) ? R_EDGE_V1V2 : 0) |
 +                                                      ((vlr->freestyle_edge_mark & R_EDGE_V2V3) ? R_EDGE_V2V3 : 0);
 +                                      }
                                }
                                /* clear the flag when not divided */
                                else vlr->flag &= ~R_DIVIDE_24;
@@@ -5321,11 -5260,11 +5321,11 @@@ static void speedvector_project(Render 
                /* angle between (0,0,-1) and (co) */
                copy_v3_v3(vec, co);
  
-               ang= saacos(-vec[2]/sqrt(vec[0]*vec[0] + vec[2]*vec[2]));
+               ang= saacos(-vec[2]/sqrtf(vec[0]*vec[0] + vec[2]*vec[2]));
                if(vec[0]<0.0f) ang= -ang;
                zco[0]= ang/pixelphix + zmulx;
                
-               ang= 0.5f*M_PI - saacos(vec[1]/sqrt(vec[0]*vec[0] + vec[1]*vec[1] + vec[2]*vec[2]));
+               ang= 0.5f*M_PI - saacos(vec[1]/sqrtf(vec[0]*vec[0] + vec[1]*vec[1] + vec[2]*vec[2]));
                zco[1]= ang/pixelphiy + zmuly;
                
        }
@@@ -5353,7 -5292,7 +5353,7 @@@ static void calculate_speedvector(cons
        /* maximize speed for image width, otherwise it never looks good */
        len= zco[0]*zco[0] + zco[1]*zco[1];
        if(len > winsq) {
-               len= winroot/sqrt(len);
+               len= winroot/sqrtf(len);
                zco[0]*= len;
                zco[1]*= len;
        }
@@@ -5563,7 -5502,7 +5563,7 @@@ static int load_fluidsimspeedvectors(Re
                // maximize speed as usual
                len= zco[0]*zco[0] + zco[1]*zco[1];
                if(len > winsq) {
-                       len= winroot/sqrt(len);
+                       len= winroot/sqrtf(len);
                        zco[0]*= len; zco[1]*= len;
                }
                
index dacbb6c7a8921e9575f3f7f34216410033ec1992,d7045c0b322465af7a43e37ddd527d5298291797..d4cd6e1da9271823748bbb5fb3a952764597c48a
@@@ -51,7 -51,6 +51,7 @@@
  #include "BKE_camera.h"
  #include "BKE_global.h"
  #include "BKE_image.h"
 +#include "BKE_library.h"
  #include "BKE_main.h"
  #include "BKE_node.h"
  #include "BKE_object.h"
@@@ -78,9 -77,6 +78,9 @@@
  #include "RE_engine.h"
  #include "RE_pipeline.h"
  
 +#include "FRS_freestyle.h"
 +#include "FRS_freestyle_config.h"
 +
  /* internal */
  #include "render_types.h"
  #include "renderpipeline.h"
@@@ -163,7 -159,7 +163,7 @@@ static void stats_background(void *UNUS
        megs_peak_memory = (peak_memory)/(1024.0*1024.0);
  
        fprintf(stdout, "Fra:%d Mem:%.2fM (%.2fM, peak %.2fM) ", rs->cfra,
-                                  megs_used_memory, mmap_used_memory, megs_peak_memory);
+               megs_used_memory, mmap_used_memory, megs_peak_memory);
  
        if(rs->curfield)
                fprintf(stdout, "Field %d ", rs->curfield);
@@@ -676,7 -672,6 +676,7 @@@ RenderResult *new_render_result(Render 
                rl->lay= (1<<20) -1;
                rl->layflag= 0x7FFF;    /* solid ztra halo strand */
                rl->passflag= SCE_PASS_COMBINED;
 +              FRS_add_freestyle_config( srl );
                
                re->r.actlay= 0;
        }
@@@ -1582,7 -1577,7 +1582,7 @@@ static RenderPart *find_next_pano_slice
  
                R.panodxp= (re->winx - (best->disprect.xmin + best->disprect.xmax) )/2;
                R.panodxv= ((viewplane->xmax-viewplane->xmin)*R.panodxp)/(float)(re->winx);
 -
 +              
                /* shift viewplane */
                R.viewplane.xmin = viewplane->xmin + R.panodxv;
                R.viewplane.xmax = viewplane->xmax + R.panodxv;
@@@ -1817,8 -1812,6 +1817,8 @@@ void RE_TileProcessor(Render *re
  
  /* ************  This part uses API, for rendering Blender scenes ********** */
  
 +static void add_freestyle(Render *re);
 +
  static void do_render_3d(Render *re)
  {
        /* try external */
        if(render_scene_needs_vector(re))
                RE_Database_FromScene_Vectors(re, re->main, re->scene, re->lay);
        else
-          RE_Database_FromScene(re, re->main, re->scene, re->lay, 1);
+               RE_Database_FromScene(re, re->main, re->scene, re->lay, 1);
        
        /* clear UI drawing locks */
        if(re->draw_lock)
                if(!re->test_break(re->tbh))
                        add_halo_flare(re);
        
 +      /* Freestyle  */
 +      if( re->r.mode & R_EDGE_FRS && re->r.renderer==R_INTERN)
 +              if(!re->test_break(re->tbh))
 +                      add_freestyle(re);
 +              
        /* free all render verts etc */
        RE_Database_Free(re);
        
@@@ -2292,66 -2280,6 +2292,66 @@@ static void render_composit_stats(void 
  }
  
  
 +/* invokes Freestyle stroke rendering */
 +static void add_freestyle(Render *re)
 +{
 +      SceneRenderLayer *srl;
 +      LinkData *link;
 +
 +      FRS_init_stroke_rendering(re);
 +
 +      for(srl= (SceneRenderLayer *)re->scene->r.layers.first; srl; srl= srl->next) {
 +
 +              link = (LinkData *)MEM_callocN(sizeof(LinkData), "LinkData to Freestyle render");
 +              BLI_addtail(&re->freestyle_renders, link);
 +
 +              if( FRS_is_freestyle_enabled(srl) ) {
 +                      link->data = (void *)FRS_do_stroke_rendering(re, srl);
 +              }
 +      }
 +
 +      FRS_finish_stroke_rendering(re);
 +}
 +
 +/* merges the results of Freestyle stroke rendering into a given render result */
 +static void composite_freestyle_renders(Render *re, int sample)
 +{
 +      Render *freestyle_render;
 +      SceneRenderLayer *srl;
 +      LinkData *link;
 +
 +      link = (LinkData *)re->freestyle_renders.first;
 +      for(srl= (SceneRenderLayer *)re->scene->r.layers.first; srl; srl= srl->next) {
 +              if( FRS_is_freestyle_enabled(srl) ) {
 +                      freestyle_render = (Render *)link->data;
 +                      read_render_result(freestyle_render, sample);
 +                      FRS_composite_result(re, srl, freestyle_render);
 +                      RE_FreeRenderResult(freestyle_render->result);
 +                      freestyle_render->result = NULL;
 +              }
 +              link = link->next;
 +      }
 +}
 +
 +/* releases temporary scenes and renders for Freestyle stroke rendering */
 +static void free_all_freestyle_renders(Scene *scene)
 +{
 +      Render *re1, *freestyle_render;
 +      LinkData *link;
 +
 +      for(re1= RenderGlobal.renderlist.first; re1; re1= re1->next) {
 +              for (link = (LinkData *)re1->freestyle_renders.first; link; link = link->next) {
 +                      if (link->data) {
 +                              freestyle_render = (Render *)link->data;
 +                              unlink_scene(G.main, freestyle_render->scene, scene);
 +                              RE_FreeRender(freestyle_render);
 +                      }
 +              }
 +              BLI_freelistN( &re1->freestyle_renders );
 +      }
 +}
 +
 +
  /* reads all buffers, calls optional composite, merges in first result->rectf */
  static void do_merge_fullsample(Render *re, bNodeTree *ntree)
  {
                for(re1= RenderGlobal.renderlist.first; re1; re1= re1->next) {
                        if(re1->scene->id.flag & LIB_DOIT) {
                                if(re1->r.scemode & R_FULL_SAMPLE) {
 -                                      if(sample)
 +                                      if(sample) {
                                                read_render_result(re1, sample);
 +                                              composite_freestyle_renders(re1, sample);
 +          &nb