Merged changes in the trunk up to revision 54171.
authorTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>
Tue, 29 Jan 2013 03:42:19 +0000 (03:42 +0000)
committerTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>
Tue, 29 Jan 2013 03:42:19 +0000 (03:42 +0000)
1  2 
SConstruct
intern/cycles/blender/addon/ui.py
release/scripts/startup/bl_ui/space_view3d.py
source/blender/blenkernel/intern/anim_sys.c
source/blender/blenkernel/intern/object.c
source/blender/blenkernel/intern/subsurf_ccg.c
source/blender/editors/interface/interface_templates.c
source/blender/makesrna/intern/rna_scene.c
source/blender/render/intern/source/pipeline.c

diff --combined SConstruct
index e3e58270cdda2fa8677d9d2f0298f136fb2d3fd7,eb22af1455b8d1bf5de778748f5bebffdf565202..70ada74cfa98b15d0ba824f59b60afe8dd8e42e5
@@@ -269,7 -269,6 +269,7 @@@ if 'blenderlite' in B.targets
      target_env_defs['WITH_BF_PYTHON'] = False
      target_env_defs['WITH_BF_3DMOUSE'] = False
      target_env_defs['WITH_BF_LIBMV'] = False
 +    target_env_defs['WITH_BF_FREESTYLE'] = False
  
      # Merge blenderlite, let command line to override
      for k,v in target_env_defs.iteritems():
@@@ -524,6 -523,7 +524,7 @@@ data_to_c("source/blender/compositor/op
  
  data_to_c_simple("release/datafiles/startup.blend")
  data_to_c_simple("release/datafiles/preview.blend")
+ data_to_c_simple("release/datafiles/preview_cycles.blend")
  
  # --- glsl ---
  data_to_c_simple("source/blender/gpu/shaders/gpu_shader_material.glsl")
@@@ -701,10 -701,6 +702,10 @@@ if env['OURPLATFORM']!='darwin'
                  if VERSION_RELEASE_CYCLE == "release" and "addons_contrib" in dn:
                      dn.remove('addons_contrib')
  
 +                # do not install freestyle if disabled
 +                if not env['WITH_BF_FREESTYLE'] and "freestyle" in dn:
 +                    dn.remove("freestyle")
 +
                  dir = os.path.join(env['BF_INSTALLDIR'], VERSION)
                  dir += os.sep + os.path.basename(scriptpath) + dp[len(scriptpath):]
  
index c4fee6f2de77fb7f4985de03fd71c846efe8f6e5,d05ceb5114852ede320ee507959ea8f54f7cc1c4..9d0b6d96f47351c97d14834979bf889046fac526
@@@ -220,69 -220,10 +220,69 @@@ class CyclesRender_PT_performance(Cycle
          sub.prop(rd, "use_persistent_data", text="Persistent Images")
  
  
 +class Cycles_PT_post_processing(CyclesButtonsPanel, Panel):
 +    bl_label = "Post Processing"
 +    bl_options = {'DEFAULT_CLOSED'}
 +
 +    def draw(self, context):
 +        layout = self.layout
 +
 +        rd = context.scene.render
 +
 +        split = layout.split()
 +
 +        col = split.column()
 +        col.prop(rd, "use_compositing")
 +        col.prop(rd, "use_sequencer")
 +
 +        col = split.column()
 +        col.prop(rd, "dither_intensity", text="Dither", slider=True)
 +
 +
 +class CyclesCamera_PT_dof(CyclesButtonsPanel, Panel):
 +    bl_label = "Depth of Field"
 +    bl_context = "data"
 +
 +    @classmethod
 +    def poll(cls, context):
 +        return context.camera and CyclesButtonsPanel.poll(context)
 +
 +    def draw(self, context):
 +        layout = self.layout
 +
 +        cam = context.camera
 +        ccam = cam.cycles
 +
 +        split = layout.split()
 +
 +        col = split.column()
 +        col.label("Focus:")
 +        col.prop(cam, "dof_object", text="")
 +
 +        sub = col.row()
 +        sub.active = cam.dof_object is None
 +        sub.prop(cam, "dof_distance", text="Distance")
 +
 +        col = split.column()
 +
 +        col.label("Aperture:")
 +        sub = col.column(align=True)
 +        sub.prop(ccam, "aperture_type", text="")
 +        if ccam.aperture_type == 'RADIUS':
 +            sub.prop(ccam, "aperture_size", text="Size")
 +        elif ccam.aperture_type == 'FSTOP':
 +            sub.prop(ccam, "aperture_fstop", text="Number")
 +
 +        sub = col.column(align=True)
 +        sub.prop(ccam, "aperture_blades", text="Blades")
 +        sub.prop(ccam, "aperture_rotation", text="Rotation")
 +
 +
  class CyclesRender_PT_layers(CyclesButtonsPanel, Panel):
      bl_label = "Layers"
 -    bl_options = {'DEFAULT_CLOSED'}
 -    COMPAT_ENGINES = {'BLENDER_RENDER'}
 +    bl_options = {'HIDE_HEADER'}
 +    bl_context = "render_layer"
 +    COMPAT_ENGINES = {'CYCLES'}
  
      def draw(self, context):
          layout = self.layout
          rd = scene.render
  
          row = layout.row()
 -        row.template_list("RENDER_UL_renderlayers", "", rd, "layers", rd.layers, "active_index", rows=2)
 +        row.template_list("RENDERLAYER_UL_renderlayers", "", rd, "layers", rd.layers, "active_index", rows=2)
  
          col = row.column(align=True)
          col.operator("scene.render_layer_add", icon='ZOOMIN', text="")
  
          row = layout.row()
          rl = rd.layers.active
 -        row.prop(rl, "name")
 +        if rl:
 +            row.prop(rl, "name")
          row.prop(rd, "use_single_layer", text="", icon_only=True)
  
 +
 +class CyclesRender_PT_layer_options(CyclesButtonsPanel, Panel):
 +    bl_label = "Layer"
 +    bl_options = {'DEFAULT_CLOSED'}
 +    bl_context = "render_layer"
 +    COMPAT_ENGINES = {'CYCLES'}
 +
 +    def draw(self, context):
 +        layout = self.layout
 +
 +        scene = context.scene
 +        rd = scene.render
 +        rl = rd.layers.active
 +
          split = layout.split()
  
          col = split.column()
          col.prop(rl, "samples")
          col.prop(rl, "use_sky", "Use Environment")
  
 +
 +class CyclesRender_PT_layer_passes(CyclesButtonsPanel, Panel):
 +    bl_label = "Render Passes"
 +    bl_options = {'DEFAULT_CLOSED'}
 +    bl_context = "render_layer"
 +    COMPAT_ENGINES = {'CYCLES'}
 +
 +    def draw(self, context):
 +        layout = self.layout
 +
 +        scene = context.scene
 +        rd = scene.render
 +        rl = rd.layers.active
 +
          split = layout.split()
  
          col = split.column()
          col.prop(rl, "use_pass_environment")
  
  
 -class Cycles_PT_post_processing(CyclesButtonsPanel, Panel):
 -    bl_label = "Post Processing"
 -    bl_options = {'DEFAULT_CLOSED'}
 -
 -    def draw(self, context):
 -        layout = self.layout
 -
 -        rd = context.scene.render
 -
 -        split = layout.split()
 -
 -        col = split.column()
 -        col.prop(rd, "use_compositing")
 -        col.prop(rd, "use_sequencer")
 -
 -        col = split.column()
 -        col.prop(rd, "dither_intensity", text="Dither", slider=True)
 -
 -
 -class CyclesCamera_PT_dof(CyclesButtonsPanel, Panel):
 -    bl_label = "Depth of Field"
 -    bl_context = "data"
 -
 -    @classmethod
 -    def poll(cls, context):
 -        return context.camera and CyclesButtonsPanel.poll(context)
 -
 -    def draw(self, context):
 -        layout = self.layout
 -
 -        cam = context.camera
 -        ccam = cam.cycles
 -
 -        split = layout.split()
 -
 -        col = split.column()
 -        col.label("Focus:")
 -        col.prop(cam, "dof_object", text="")
 -
 -        sub = col.row()
 -        sub.active = cam.dof_object is None
 -        sub.prop(cam, "dof_distance", text="Distance")
 -
 -        col = split.column()
 -
 -        col.label("Aperture:")
 -        sub = col.column(align=True)
 -        sub.prop(ccam, "aperture_type", text="")
 -        if ccam.aperture_type == 'RADIUS':
 -            sub.prop(ccam, "aperture_size", text="Size")
 -        elif ccam.aperture_type == 'FSTOP':
 -            sub.prop(ccam, "aperture_fstop", text="Number")
 -
 -        sub = col.column(align=True)
 -        sub.prop(ccam, "aperture_blades", text="Blades")
 -        sub.prop(ccam, "aperture_rotation", text="Rotation")
 -
 -
  class Cycles_PT_context_material(CyclesButtonsPanel, Panel):
      bl_label = ""
      bl_context = "material"
@@@ -1205,6 -1175,9 +1205,9 @@@ def get_panels()
          types.PARTICLE_PT_force_fields,
          types.PARTICLE_PT_vertexgroups,
          types.PARTICLE_PT_custom_props,
+         types.MATERIAL_PT_preview,
+         types.DATA_PT_preview,
+         types.WORLD_PT_preview,
          )
  
  
index 6c5cc93947b5c049632d395ded1873d469cfa23b,ac63dfa7e326bab7f3ba1b7a8529d8402ceccdb5..9753a368f545a017aaa1972b50346d7b46b96037
@@@ -1860,12 -1860,6 +1860,12 @@@ class VIEW3D_MT_edit_mesh_edges(Menu)
  
          layout.separator()
  
 +        if context.scene and bpy.app.build_options.freestyle:
 +            layout.operator("mesh.mark_freestyle_edge").clear = False
 +            layout.operator("mesh.mark_freestyle_edge", text="Clear Freestyle Edge").clear = True
 +
 +        layout.separator()
 +
          layout.operator("mesh.edge_rotate", text="Rotate Edge CW").use_ccw = False
          layout.operator("mesh.edge_rotate", text="Rotate Edge CCW").use_ccw = True
  
@@@ -1906,12 -1900,6 +1906,12 @@@ class VIEW3D_MT_edit_mesh_faces(Menu)
  
          layout.separator()
  
 +        if context.scene and bpy.app.build_options.freestyle:
 +            layout.operator("mesh.mark_freestyle_face").clear = False
 +            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")
  
@@@ -2515,9 -2503,6 +2515,9 @@@ 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")
 +        if context.scene and bpy.app.build_options.freestyle:
 +            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:")
@@@ -2702,6 -2687,8 +2702,8 @@@ class VIEW3D_PT_etch_a_ton(Panel)
          col.prop(toolsettings, "use_etch_quick")
          col.prop(toolsettings, "use_etch_overdraw")
  
+         col.separator()
          col.prop(toolsettings, "etch_convert_mode")
  
          if toolsettings.etch_convert_mode == 'LENGTH':
          elif toolsettings.etch_convert_mode == 'RETARGET':
              col.prop(toolsettings, "etch_template")
              col.prop(toolsettings, "etch_roll_mode")
-             col.prop(toolsettings, "use_etch_autoname")
-             col.prop(toolsettings, "etch_number")
-             col.prop(toolsettings, "etch_side")
  
-         col.operator("sketch.convert", text="Convert")
+             col.separator()
+             colsub = col.column(align=True)
+             colsub.prop(toolsettings, "use_etch_autoname")
+             sub = colsub.column() 
+             sub.enabled = not toolsettings.use_etch_autoname
+             sub.prop(toolsettings, "etch_number")
+             sub.prop(toolsettings, "etch_side")
+         col.separator()
+         col.operator("sketch.convert", text="Convert to Bones")
+         col.operator("sketch.delete", text="Delete Strokes")
  
  
  class VIEW3D_PT_context_properties(Panel):
index aecf6e5e437db8d3765dbce5f007d998328413b7,df2cc7cc461a056d06e418674ce9515d422daadf..c8fd8aa93e53fcbb57e9b170128b99d9de357bdc
@@@ -86,9 -86,6 +86,9 @@@ short id_type_can_have_animdata(ID *id
                case ID_PA:
                case ID_MA: case ID_TE: case ID_NT:
                case ID_LA: case ID_CA: case ID_WO:
 +#ifdef WITH_FREESTYLE
 +              case ID_LS:
 +#endif
                case ID_SPK:
                case ID_SCE:
                case ID_MC:
@@@ -507,7 -504,7 +507,7 @@@ void BKE_animdata_separate_by_basepath(
                else if (dstAdt->action == srcAdt->action) {
                        printf("Argh! Source and Destination share animation! ('%s' and '%s' both use '%s') Making new empty action\n",
                               srcID->name, dstID->name, srcAdt->action->id.name);
+                       
                        /* TODO: review this... */
                        id_us_min(&dstAdt->action->id);
                        dstAdt->action = add_empty_action(dstAdt->action->id.name + 2);
                                        /* just need to change lists */
                                        BLI_remlink(&srcAdt->drivers, fcu);
                                        BLI_addtail(&dstAdt->drivers, fcu);
+                                       
                                        /* TODO: add depsgraph flushing calls? */
+                                       
                                        /* can stop now, as moved already */
                                        break;
                                }
@@@ -830,12 -827,7 +830,12 @@@ void BKE_animdata_main_cb(Main *mainptr
  
        /* scenes */
        ANIMDATA_NODETREE_IDS_CB(mainptr->scene.first, Scene);
 -}
 +
 +#ifdef WITH_FREESTYLE
 +      /* line styles */
 +      ANIMDATA_IDS_CB(mainptr->linestyle.first);
 +#endif
 +      }
  
  /* Fix all RNA-Paths throughout the database (directly access the Global.main version)
   * NOTE: it is assumed that the structure we're replacing is <prefix><["><name><"]>
@@@ -920,11 -912,6 +920,11 @@@ void BKE_all_animdata_fix_paths_rename(
        /* worlds */
        RENAMEFIX_ANIM_NODETREE_IDS(mainptr->world.first, World);
        
 +#ifdef WITH_FREESTYLE
 +      /* linestyles */
 +      RENAMEFIX_ANIM_IDS(mainptr->linestyle.first);
 +#endif
 +      
        /* scenes */
        RENAMEFIX_ANIM_NODETREE_IDS(mainptr->scene.first, Scene);
  }
@@@ -2410,11 -2397,6 +2410,11 @@@ void BKE_animsys_evaluate_all_animation
        /* movie clips */
        EVAL_ANIM_IDS(main->movieclip.first, ADT_RECALC_ANIM);
  
 +#ifdef WITH_FREESTYLE
 +      /* linestyles */
 +      EVAL_ANIM_IDS(main->linestyle.first, ADT_RECALC_ANIM);
 +#endif
 +      
        /* objects */
        /* ADT_RECALC_ANIM doesn't need to be supplied here, since object AnimData gets
         * this tagged by Depsgraph on framechange. This optimization means that objects
index 8a6309593f19702a221e5dfc31273ae4cd0c9dc7,aac1d9f1f7ba83bc0d5f3dcc4bef6d78223b8393..a46196f38d8e7557bc35e8185b9fb1a1cb08372f
  
  #include "GPU_material.h"
  
 +#ifdef WITH_FREESTYLE
 +#  include "FRS_freestyle.h"
 +#endif
 +
  /* Local function protos */
  float originmat[3][3];  /* after BKE_object_where_is_calc(), can be used in other functions (bad!) */
  
@@@ -673,16 -669,6 +673,16 @@@ void BKE_object_unlink(Object *ob
                                }
                                SEQ_END
                        }
 +
 +#ifdef WITH_FREESTYLE
 +                      {
 +                              SceneRenderLayer *srl;
 +
 +                              for (srl= sce->r.layers.first; srl; srl= srl->next) {
 +                                      FRS_unlink_target_object(&srl->freestyleConfig, ob);
 +                              }
 +                      }
 +#endif
                }
  
                sce = sce->id.next;
@@@ -1822,7 -1808,7 +1822,7 @@@ static void ob_parcurve(Scene *scene, O
                CLAMP(ctime, 0.0f, 1.0f);
        }
        else {
-               ctime = scene->r.cfra;
+               ctime = BKE_scene_frame_get(scene);
                if (IS_EQF(cu->pathlen, 0.0f) == 0)
                        ctime /= cu->pathlen;
                
@@@ -2201,7 -2187,7 +2201,7 @@@ void BKE_object_where_is_calc_mat4(Scen
  
  void BKE_object_where_is_calc(struct Scene *scene, Object *ob)
  {
-       BKE_object_where_is_calc_time(scene, ob, (float)scene->r.cfra);
+       BKE_object_where_is_calc_time(scene, ob, BKE_scene_frame_get(scene));
  }
  
  void BKE_object_where_is_calc_simul(Scene *scene, Object *ob)
                bConstraintOb *cob;
                
                cob = BKE_constraints_make_evalob(scene, ob, NULL, CONSTRAINT_OBTYPE_OBJECT);
-               BKE_solve_constraints(&ob->constraints, cob, (float)scene->r.cfra);
+               BKE_solve_constraints(&ob->constraints, cob, BKE_scene_frame_get(scene));
                BKE_constraints_clear_evalob(cob);
        }
  }
@@@ -2684,7 -2670,7 +2684,7 @@@ void BKE_object_handle_update(Scene *sc
                if (ob->recalc & OB_RECALC_DATA) {
                        ID *data_id = (ID *)ob->data;
                        AnimData *adt = BKE_animdata_from_id(data_id);
-                       float ctime = (float)scene->r.cfra;  /* XXX this is bad... */
+                       float ctime = BKE_scene_frame_get(scene);
                        
                        if (G.debug & G_DEBUG)
                                printf("recalcdata %s\n", ob->id.name + 2);
index ce6e158b6d978cdb268ed8cb382e069ea56bc83f,e03100280d61d75d748e7807c95a490e7d060f05..0d0944d6ea76cfb9d88b219440ba75c0d39a90e5
@@@ -964,11 -964,7 +964,11 @@@ static void ccgDM_getFinalEdge(DerivedM
  
                edgeFlag = (ccgdm->edgeFlags) ? &ccgdm->edgeFlags[i] : NULL;
                if (edgeFlag)
 +#ifdef WITH_FREESTYLE
 +                      flags |= (*edgeFlag & (ME_SEAM | ME_SHARP | ME_FREESTYLE_EDGE)) | ME_EDGEDRAW | ME_EDGERENDER;
 +#else
                        flags |= (*edgeFlag & (ME_SEAM | ME_SHARP)) | ME_EDGEDRAW | ME_EDGERENDER;
 +#endif
                else
                        flags |= ME_EDGEDRAW | ME_EDGERENDER;
  
@@@ -1019,7 -1015,7 +1019,7 @@@ static void ccgDM_getFinalFace(DerivedM
        }
        else {
                mf->flag = ME_SMOOTH;
 -      }
 +}
  
        mf->edcode = 0;
  }
@@@ -1236,11 -1232,7 +1236,11 @@@ static void ccgDM_copyFinalEdgeArray(De
  
                if (edgeFlags) {
                        if (edgeIdx != -1) {
 +#ifdef WITH_FREESTYLE
 +                              ed_flag |= ((edgeFlags[index] & (ME_SEAM | ME_SHARP | ME_FREESTYLE_EDGE)) | ME_EDGEDRAW | ME_EDGERENDER);
 +#else
                                ed_flag |= ((edgeFlags[index] & (ME_SEAM | ME_SHARP)) | ME_EDGEDRAW | ME_EDGERENDER);
 +#endif
                        }
                }
                else {
@@@ -1720,7 -1712,7 +1720,7 @@@ static void ccgDM_drawFacesSolid(Derive
        if (ccgdm->pbvh && ccgdm->multires.mmd && !fast) {
                if (dm->numTessFaceData) {
                        BKE_pbvh_draw(ccgdm->pbvh, partial_redraw_planes, NULL,
-                                                 setMaterial, FALSE);
+                                     setMaterial, FALSE);
                        glShadeModel(GL_FLAT);
                }
  
index ec2b4f5adf056b084e35283eefa4f993992b920f,26a8f703545968fed08ba43e5a5bd61365fa6450..58d593919396f5985aece88ff4727e4a71e5cf9a
@@@ -58,6 -58,7 +58,7 @@@
  #include "BKE_material.h"
  #include "BKE_modifier.h"
  #include "BKE_object.h"
+ #include "BKE_packedFile.h"
  #include "BKE_particle.h"
  #include "BKE_report.h"
  #include "BKE_sca.h"
@@@ -329,9 -330,6 +330,9 @@@ static const char *template_id_browse_t
                        case ID_MA:  return N_("Browse Material to be linked");
                        case ID_TE:  return N_("Browse Texture to be linked");
                        case ID_IM:  return N_("Browse Image to be linked");
 +#ifdef WITH_FREESTYLE
 +                      case ID_LS:  return N_("Browse Line Style Data to be linked");
 +#endif
                        case ID_LT:  return N_("Browse Lattice Data to be linked");
                        case ID_LA:  return N_("Browse Lamp Data to be linked");
                        case ID_CA:  return N_("Browse Camera Data to be linked");
@@@ -367,9 -365,6 +368,9 @@@ static const char *template_id_context(
                        case ID_MA:  return BLF_I18NCONTEXT_ID_MATERIAL;
                        case ID_TE:  return BLF_I18NCONTEXT_ID_TEXTURE;
                        case ID_IM:  return BLF_I18NCONTEXT_ID_IMAGE;
 +#ifdef WITH_FREESTYLE
 +                      case ID_LS:  return BLF_I18NCONTEXT_ID_FREESTYLELINESTYLE;
 +#endif
                        case ID_LT:  return BLF_I18NCONTEXT_ID_LATTICE;
                        case ID_LA:  return BLF_I18NCONTEXT_ID_LAMP;
                        case ID_CA:  return BLF_I18NCONTEXT_ID_CAMERA;
@@@ -525,11 -520,7 +526,11 @@@ static void template_ID(bContext *C, ui
                                                 BLF_I18NCONTEXT_ID_NODETREE,
                                                 BLF_I18NCONTEXT_ID_BRUSH,
                                                 BLF_I18NCONTEXT_ID_PARTICLESETTINGS,
 -                                               BLF_I18NCONTEXT_ID_GPENCIL);
 +                                               BLF_I18NCONTEXT_ID_GPENCIL,
 +#ifdef WITH_FREESTYLE
 +                                                                               BLF_I18NCONTEXT_ID_FREESTYLELINESTYLE
 +#endif
 +              );
                
                if (newop) {
                        but = uiDefIconTextButO(block, BUT, newop, WM_OP_INVOKE_DEFAULT, ICON_ZOOMIN,
                        uiButSetFlag(but, UI_BUT_DISABLED);
        }
  
-       if (flag & UI_ID_OPEN) {
+       /* Due to space limit in UI - skip the "open" icon for packed data, and allow to unpack.
+          Only for images, sound and fonts */
+       if (id && BKE_pack_check(id)) {
+               but = uiDefIconButO(block, BUT, "FILE_OT_unpack_item", WM_OP_INVOKE_REGION_WIN, ICON_PACKAGE, 0, 0, UI_UNIT_X, UI_UNIT_Y, "Packed File");
+               uiButGetOperatorPtrRNA(but);
+               
+               RNA_string_set(but->opptr, "id_name", id->name + 2);
+               RNA_int_set(but->opptr, "id_type", GS(id->name));
+               
+       }
+       else if (flag & UI_ID_OPEN) {
                int w = id ? UI_UNIT_X : (flag & UI_ID_ADD_NEW) ? UI_UNIT_X * 3 : UI_UNIT_X * 6;
                
                if (openop) {
@@@ -2440,7 -2442,7 +2452,7 @@@ static void uilist_draw_item_default(st
                uiItemL(layout, name, icon);
                break;
        }
 -
 +              
        /* free name */
        if (namebuf) {
                MEM_freeN(namebuf);
@@@ -2523,7 -2525,7 +2535,7 @@@ void uiTemplateList(uiLayout *layout, b
        if (ui_list_type == NULL) {
                RNA_warning("List type %s not found", listtype_name);
                return;
 -      }
 +                      }
  
        draw_item = ui_list_type->draw_item ? ui_list_type->draw_item : uilist_draw_item_default;
  
                ui_list = MEM_callocN(sizeof(uiList), __func__);
                BLI_strncpy(ui_list->list_id, ui_list_id, sizeof(ui_list->list_id));
                BLI_addtail(&ar->ui_lists, ui_list);
 -      }
 +                                      }
  
        /* Because we can't actually pass type across save&load... */
        ui_list->type = ui_list_type;
                                        if (icon == ICON_DOT)
                                                icon = ICON_NONE;
                                        draw_item(ui_list, C, row, dataptr, &itemptr, icon, active_dataptr, active_propname, i);
 -                              }
 +      }
  
                                i++;
 -                      }
 +}
                        RNA_PROP_END;
                }
  
index 96bd0fb327e038aaa1a93d554e47c52d435201d6,cac423b8d43d6f4ee2cf14b843cdff7b660b5c5e..843743b9a9a63d261fc1e3432419346ef28e0af0
@@@ -39,9 -39,6 +39,9 @@@
  #include "DNA_scene_types.h"
  #include "DNA_userdef_types.h"
  #include "DNA_world_types.h"
 +#ifdef WITH_FREESTYLE
 +#  include "DNA_linestyle_types.h"
 +#endif
  
  #include "BLI_math.h"
  
@@@ -336,10 -333,6 +336,10 @@@ EnumPropertyItem image_color_depth_item
  
  #include "RE_engine.h"
  
 +#ifdef WITH_FREESTYLE
 +#  include "FRS_freestyle.h"
 +#endif
 +
  static void rna_SpaceImageEditor_uv_sculpt_update(Main *bmain, Scene *scene, PointerRNA *UNUSED(ptr))
  {
        ED_space_image_uv_sculpt_update(bmain->wm.first, scene->toolsettings);
@@@ -1467,52 -1460,6 +1467,52 @@@ static char *rna_ToolSettings_path(Poin
        return BLI_strdup("tool_settings");
  }
  
 +#ifdef WITH_FREESTYLE
 +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,
 +                                                             int *softmin, int *softmax)
 +{
 +      FreestyleConfig *config = (FreestyleConfig *)ptr->data;
 +
 +      *min = 0;
 +      *max = max_ii(0, BLI_countlist(&config->linesets) - 1);
 +}
 +
 +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);
 +}
 +#endif
 +
  #else
  
  static void rna_def_transform_orientation(BlenderRNA *brna)
@@@ -1580,9 -1527,6 +1580,9 @@@ 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", ""},
 +#ifdef WITH_FREESTYLE
 +              {EDGE_MODE_TAG_FREESTYLE, "FREESTYLE", 0, "Tag Freestyle Edge Mark", ""},
 +#endif
                {0, NULL, 0, NULL, NULL}
        };
  
        /* etch-a-ton */
        prop = RNA_def_property(srna, "use_bone_sketching", PROP_BOOLEAN, PROP_NONE);
        RNA_def_property_boolean_sdna(prop, NULL, "bone_sketching", BONE_SKETCHING);
-       RNA_def_property_ui_text(prop, "Use Bone Sketching", "DOC BROKEN");
+       RNA_def_property_ui_text(prop, "Use Bone Sketching", "Use sketching to create and edit bones");
  /*    RNA_def_property_ui_icon(prop, ICON_EDIT, 0); */
+       RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
  
        prop = RNA_def_property(srna, "use_etch_quick", PROP_BOOLEAN, PROP_NONE);
        RNA_def_property_boolean_sdna(prop, NULL, "bone_sketching", BONE_SKETCHING_QUICK);
-       RNA_def_property_ui_text(prop, "Quick Sketching", "DOC BROKEN");
+       RNA_def_property_ui_text(prop, "Quick Sketching", "Automatically convert and delete on stroke end");
  
        prop = RNA_def_property(srna, "use_etch_overdraw", PROP_BOOLEAN, PROP_NONE);
        RNA_def_property_boolean_sdna(prop, NULL, "bone_sketching", BONE_SKETCHING_ADJUST);
-       RNA_def_property_ui_text(prop, "Overdraw Sketching", "DOC BROKEN");
+       RNA_def_property_ui_text(prop, "Overdraw Sketching", "Adjust strokes by drawing near them");
        
        prop = RNA_def_property(srna, "use_etch_autoname", PROP_BOOLEAN, PROP_NONE);
        RNA_def_property_boolean_sdna(prop, NULL, "skgen_retarget_options", SK_RETARGET_AUTONAME);
-       RNA_def_property_ui_text(prop, "Autoname", "DOC BROKEN");
+       RNA_def_property_ui_text(prop, "Autoname Bones", "Automatically generate values to replace &N and &S suffix placeholders in template names");
  
        prop = RNA_def_property(srna, "etch_number", PROP_STRING, PROP_NONE);
        RNA_def_property_string_sdna(prop, NULL, "skgen_num_string");
-       RNA_def_property_ui_text(prop, "Number", "DOC BROKEN");
+       RNA_def_property_ui_text(prop, "Number", "Text to replace &N with (e.g. 'Finger.&N' -> 'Finger.1' or 'Finger.One')");
  
        prop = RNA_def_property(srna, "etch_side", PROP_STRING, PROP_NONE);
        RNA_def_property_string_sdna(prop, NULL, "skgen_num_string");
-       RNA_def_property_ui_text(prop, "Side", "DOC BROKEN");
+       RNA_def_property_ui_text(prop, "Side", "Text to replace &S with (e.g. 'Arm.&S' -> 'Arm.R' or 'Arm.Right')");
  
        prop = RNA_def_property(srna, "etch_template", PROP_POINTER, PROP_NONE);
        RNA_def_property_pointer_sdna(prop, NULL, "skgen_template");
        RNA_def_property_float_sdna(prop, NULL, "skgen_correlation_limit");
        RNA_def_property_range(prop, 0.00001, 1.0);
        RNA_def_property_ui_range(prop, 0.01, 1.0, 0.01, 2);
-       RNA_def_property_ui_text(prop, "Limit", "Number of bones in the subdivided stroke");
+       RNA_def_property_ui_text(prop, "Limit", "Correlation threshold for number of bones in the subdivided stroke");
        RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
  
        prop = RNA_def_property(srna, "etch_length_limit", PROP_FLOAT, PROP_DISTANCE);
        RNA_def_property_float_sdna(prop, NULL, "skgen_length_limit");
        RNA_def_property_range(prop, 0.00001, 100000.0);
        RNA_def_property_ui_range(prop, 0.001, 100.0, 0.1, 3);
-       RNA_def_property_ui_text(prop, "Length", "Number of bones in the subdivided stroke");
+       RNA_def_property_ui_text(prop, "Length", "Maximum length of the subdivided bones");
        RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
  
        prop = RNA_def_property(srna, "etch_roll_mode", PROP_ENUM, PROP_NONE);
@@@ -2134,16 -2079,6 +2135,16 @@@ 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);
  
 +#ifdef WITH_FREESTYLE
 +      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);
 +#endif
 +
        /* 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);
  }
  
 +#ifdef WITH_FREESTYLE
 +static void rna_def_freestyle_linesets(BlenderRNA *brna, PropertyRNA *cprop)
 +{
 +      StructRNA *srna;
 +      PropertyRNA *prop;
 +
 +      RNA_def_property_srna(cprop, "Linesets");
 +      srna = RNA_def_struct(brna, "Linesets", NULL);
 +      RNA_def_struct_sdna(srna, "FreestyleSettings");
 +      RNA_def_struct_ui_text(srna, "Line Sets", "Line sets for associating lines and style parameters");
 +
 +      prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE);
 +      RNA_def_property_struct_type(prop, "FreestyleLineSet");
 +      RNA_def_property_pointer_funcs(prop, "rna_FreestyleSettings_active_lineset_get", NULL, NULL, NULL);
 +      RNA_def_property_ui_text(prop, "Active Line Set", "Active line set being displayed");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop = RNA_def_property(srna, "active_index", PROP_INT, PROP_UNSIGNED);
 +      RNA_def_property_int_funcs(prop, "rna_FreestyleSettings_active_lineset_index_get",
 +                                 "rna_FreestyleSettings_active_lineset_index_set",
 +                                 "rna_FreestyleSettings_active_lineset_index_range");
 +      RNA_def_property_ui_text(prop, "Active Line Set Index", "Index of active line set slot");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +}
 +
 +static void rna_def_freestyle_settings(BlenderRNA *brna)
 +{
 +      StructRNA *srna;
 +      PropertyRNA *prop;
 +
 +      static EnumPropertyItem edge_type_negation_items[] = {
 +              {0, "INCLUSIVE", 0, "Inclusive", "Select feature edges satisfying the given edge type conditions"},
 +              {FREESTYLE_LINESET_FE_NOT, "EXCLUSIVE", 0, "Exclusive",
 +                                         "Select feature edges not satisfying the given edge type conditions"},
 +              {0, NULL, 0, NULL, NULL}
 +      };
 +
 +      static EnumPropertyItem edge_type_combination_items[] = {
 +              {0, "OR", 0, "Logical OR", "Combine feature edge type conditions by logical OR (logical disjunction)"},
 +              {FREESTYLE_LINESET_FE_AND, "AND", 0, "Logical AND",
 +                                         "Combine feature edge type conditions by logical AND (logical conjunction)"},
 +              {0, NULL, 0, NULL, NULL}
 +      };
 +
 +      static EnumPropertyItem group_negation_items[] = {
 +              {0, "INCLUSIVE", 0, "Inclusive", "Select feature edges belonging to some object in the group"},
 +              {FREESTYLE_LINESET_GR_NOT, "EXCLUSIVE", 0, "Exclusive",
 +                                         "Select feature edges not belonging to any object in the group"},
 +              {0, NULL, 0, NULL, NULL}
 +      };
 +
 +      static EnumPropertyItem face_mark_negation_items[] = {
 +              {0, "INCLUSIVE", 0, "Inclusive", "Select feature edges satisfying the given face mark conditions"},
 +              {FREESTYLE_LINESET_FM_NOT, "EXCLUSIVE", 0, "Exclusive",
 +                                         "Select feature edges not satisfying the given face mark conditions"},
 +              {0, NULL, 0, NULL, NULL}
 +      };
 +
 +      static EnumPropertyItem face_mark_condition_items[] = {
 +              {0, "ONE", 0, "One Face", "Select feature edges if one of faces on the right and left has a face mark"},
 +              {FREESTYLE_LINESET_FM_BOTH, "BOTH", 0, "Both Faces",
 +                                          "Select feature edges if both faces on the right and left faces have a face mark"},
 +              {0, NULL, 0, NULL, NULL}
 +      };
 +
 +      static EnumPropertyItem freestyle_ui_mode_items[] = {
 +              {FREESTYLE_CONTROL_SCRIPT_MODE, "SCRIPT", 0, "Python Scripting Mode",
 +                                              "Advanced mode for using style modules in Python"},
 +              {FREESTYLE_CONTROL_EDITOR_MODE, "EDITOR", 0, "Parameter Editor Mode",
 +                                              "Basic mode for interactive style parameter editing"},
 +              {0, NULL, 0, NULL, NULL}
 +      };
 +
 +      static EnumPropertyItem visibility_items[] ={
 +              {FREESTYLE_QI_VISIBLE, "VISIBLE", 0, "Visible", "Select visible feature edges"},
 +              {FREESTYLE_QI_HIDDEN, "HIDDEN", 0, "Hidden", "Select hidden feature edges"},
 +              {FREESTYLE_QI_RANGE, "RANGE", 0, "QI Range",
 +                                   "Select feature edges within a range of quantitative invisibility (QI) values"},
 +              {0, NULL, 0, NULL, NULL}
 +      };
 +
 +      static EnumPropertyItem freestyle_raycasting_algorithm_items[] = {
 +              {FREESTYLE_ALGO_REGULAR, "REGULAR", 0, "Normal Ray Casting", "Consider all FEdges in each ViewEdge"},
 +              {FREESTYLE_ALGO_FAST, "FAST", 0, "Fast Ray Casting", "Sample some FEdges in each ViewEdge"},
 +              {FREESTYLE_ALGO_VERYFAST, "VERYFAST", 0, "Very Fast Ray Casting",
 +                                        "Sample one FEdge in each ViewEdge; do not save list of occluders"},
 +              {FREESTYLE_ALGO_CULLED_ADAPTIVE_TRADITIONAL, "CULLEDADAPTIVETRADITIONAL", 0,
 +                                                           "Culled Traditional Visibility Detection",
 +                                                           "Culled adaptive grid with heuristic density and "
 +                                                           "traditional QI calculation"},
 +              {FREESTYLE_ALGO_ADAPTIVE_TRADITIONAL, "ADAPTIVETRADITIONAL", 0, "Unculled Traditional Visibility Detection",
 +                                                    "Adaptive grid with heuristic density and traditional QI calculation"},
 +              {FREESTYLE_ALGO_CULLED_ADAPTIVE_CUMULATIVE, "CULLEDADAPTIVECUMULATIVE", 0,
 +                                                          "Culled Cumulative Visibility Detection",
 +                                                          "Culled adaptive grid with heuristic density and "
 +                                                          "cumulative QI calculation"},
 +              {FREESTYLE_ALGO_ADAPTIVE_CUMULATIVE, "ADAPTIVECUMULATIVE", 0, "Unculled Cumulative Visibility Detection",
 +                                                   "Adaptive grid with heuristic density and cumulative QI calculation"},
 +              {0, NULL, 0, NULL, NULL}
 +      };
 +
 +
 +      /* FreestyleLineSet */
 +
 +      srna = RNA_def_struct(brna, "FreestyleLineSet", NULL);
 +      RNA_def_struct_ui_text(srna, "Freestyle Line Set", "Line set for associating lines and style parameters");
 +
 +      /* access to line style settings is redirected through functions
 +       * to allow proper id-buttons functionality
 +       */
 +      prop = RNA_def_property(srna, "linestyle", PROP_POINTER, PROP_NONE);
 +      RNA_def_property_struct_type(prop, "FreestyleLineStyle");
 +      RNA_def_property_flag(prop, PROP_EDITABLE|PROP_NEVER_NULL);
 +      RNA_def_property_pointer_funcs(prop, "rna_FreestyleLineSet_linestyle_get",
 +                                     "rna_FreestyleLineSet_linestyle_set", NULL, NULL);
 +      RNA_def_property_ui_text(prop, "Line Style", "Line style settings");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
 +      RNA_def_property_string_sdna(prop, NULL, "name");
 +      RNA_def_property_ui_text(prop, "Line Set Name", "Line set name");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +      RNA_def_struct_name_property(srna, prop);
 +
 +      prop = RNA_def_property(srna, "use", PROP_BOOLEAN, PROP_NONE);
 +      RNA_def_property_boolean_sdna(prop, NULL, "flags", FREESTYLE_LINESET_ENABLED);
 +      RNA_def_property_ui_text(prop, "Use", "Enable or disable this line set during stroke rendering");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop = RNA_def_property(srna, "select_by_visibility", PROP_BOOLEAN, PROP_NONE);
 +      RNA_def_property_boolean_sdna(prop, NULL, "selection", FREESTYLE_SEL_VISIBILITY);
 +      RNA_def_property_ui_text(prop, "Selection by Visibility", "Select feature edges based on visibility");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop = RNA_def_property(srna, "select_by_edge_types", PROP_BOOLEAN, PROP_NONE);
 +      RNA_def_property_boolean_sdna(prop, NULL, "selection", FREESTYLE_SEL_EDGE_TYPES);
 +      RNA_def_property_ui_text(prop, "Selection by Edge Types", "Select feature edges based on edge types");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop = RNA_def_property(srna, "select_by_group", PROP_BOOLEAN, PROP_NONE);
 +      RNA_def_property_boolean_sdna(prop, NULL, "selection", FREESTYLE_SEL_GROUP);
 +      RNA_def_property_ui_text(prop, "Selection by Group", "Select feature edges based on a group of objects");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop = RNA_def_property(srna, "select_by_image_border", PROP_BOOLEAN, PROP_NONE);
 +      RNA_def_property_boolean_sdna(prop, NULL, "selection", FREESTYLE_SEL_IMAGE_BORDER);
 +      RNA_def_property_ui_text(prop, "Selection by Image Border",
 +                               "Select feature edges by image border (less memory consumption)");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop = RNA_def_property(srna, "select_by_face_marks", PROP_BOOLEAN, PROP_NONE);
 +      RNA_def_property_boolean_sdna(prop, NULL, "selection", FREESTYLE_SEL_FACE_MARK);
 +      RNA_def_property_ui_text(prop, "Selection by Face Marks", "Select feature edges by face marks");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop = RNA_def_property(srna, "edge_type_negation", PROP_ENUM, PROP_NONE);
 +      RNA_def_property_enum_bitflag_sdna(prop, NULL, "flags");
 +      RNA_def_property_enum_items(prop, edge_type_negation_items);
 +      RNA_def_property_ui_text(prop, "Edge Type Negation",
 +                               "Set the negation operation for conditions on feature edge types");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop = RNA_def_property(srna, "edge_type_combination", PROP_ENUM, PROP_NONE);
 +      RNA_def_property_enum_bitflag_sdna(prop, NULL, "flags");
 +      RNA_def_property_enum_items(prop, edge_type_combination_items);
 +      RNA_def_property_ui_text(prop, "Edge Type Combination",
 +                               "Set the combination operation for conditions on feature edge types");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop = RNA_def_property(srna, "group", PROP_POINTER, PROP_NONE);
 +      RNA_def_property_pointer_sdna(prop, NULL, "group");
 +      RNA_def_property_struct_type(prop, "Group");
 +      RNA_def_property_flag(prop, PROP_EDITABLE);
 +      RNA_def_property_ui_text(prop, "Group", "A group of objects based on which feature edges are selected");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop = RNA_def_property(srna, "group_negation", PROP_ENUM, PROP_NONE);
 +      RNA_def_property_enum_bitflag_sdna(prop, NULL, "flags");
 +      RNA_def_property_enum_items(prop, group_negation_items);
 +      RNA_def_property_ui_text(prop, "Group Negation",
 +                               "Set the negation operation for conditions on feature edge types");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop = RNA_def_property(srna, "face_mark_negation", PROP_ENUM, PROP_NONE);
 +      RNA_def_property_enum_bitflag_sdna(prop, NULL, "flags");
 +      RNA_def_property_enum_items(prop, face_mark_negation_items);
 +      RNA_def_property_ui_text(prop, "Face Mark Negation",
 +                               "Set the negation operation for the condition on face marks");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop = RNA_def_property(srna, "face_mark_condition", PROP_ENUM, PROP_NONE);
 +      RNA_def_property_enum_bitflag_sdna(prop, NULL, "flags");
 +      RNA_def_property_enum_items(prop, face_mark_condition_items);
 +      RNA_def_property_ui_text(prop, "Face Mark Condition", "Set a feature edge selection condition on face marks");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop = RNA_def_property(srna, "select_silhouette", PROP_BOOLEAN, PROP_NONE);
 +      RNA_def_property_boolean_sdna(prop, NULL, "edge_types", FREESTYLE_FE_SILHOUETTE);
 +      RNA_def_property_ui_text(prop, "Silhouette", "Select silhouette edges");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop = RNA_def_property(srna, "select_border", PROP_BOOLEAN, PROP_NONE);
 +      RNA_def_property_boolean_sdna(prop, NULL, "edge_types", FREESTYLE_FE_BORDER);
 +      RNA_def_property_ui_text(prop, "Border", "Select border edges");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop = RNA_def_property(srna, "select_crease", PROP_BOOLEAN, PROP_NONE);
 +      RNA_def_property_boolean_sdna(prop, NULL, "edge_types", FREESTYLE_FE_CREASE);
 +      RNA_def_property_ui_text(prop, "Crease", "Select crease edges");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop = RNA_def_property(srna, "select_ridge_valley", PROP_BOOLEAN, PROP_NONE);
 +      RNA_def_property_boolean_sdna(prop, NULL, "edge_types", FREESTYLE_FE_RIDGE_VALLEY);
 +      RNA_def_property_ui_text(prop, "Ridge & Valley", "Select ridges and valleys");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop = RNA_def_property(srna, "select_suggestive_contour", PROP_BOOLEAN, PROP_NONE);
 +      RNA_def_property_boolean_sdna(prop, NULL, "edge_types", FREESTYLE_FE_SUGGESTIVE_CONTOUR);
 +      RNA_def_property_ui_text(prop, "Suggestive Contour", "Select suggestive contours");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop = RNA_def_property(srna, "select_material_boundary", PROP_BOOLEAN, PROP_NONE);
 +      RNA_def_property_boolean_sdna(prop, NULL, "edge_types", FREESTYLE_FE_MATERIAL_BOUNDARY);
 +      RNA_def_property_ui_text(prop, "Material Boundary", "Select edges at material boundaries");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop = RNA_def_property(srna, "select_contour", PROP_BOOLEAN, PROP_NONE);
 +      RNA_def_property_boolean_sdna(prop, NULL, "edge_types", FREESTYLE_FE_CONTOUR);
 +      RNA_def_property_ui_text(prop, "Contour", "Select contours");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop = RNA_def_property(srna, "select_external_contour", PROP_BOOLEAN, PROP_NONE);
 +      RNA_def_property_boolean_sdna(prop, NULL, "edge_types", FREESTYLE_FE_EXTERNAL_CONTOUR);
 +      RNA_def_property_ui_text(prop, "External Contour", "Select external contours");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop = RNA_def_property(srna, "select_edge_mark", PROP_BOOLEAN, PROP_NONE);
 +      RNA_def_property_boolean_sdna(prop, NULL, "edge_types", FREESTYLE_FE_EDGE_MARK);
 +      RNA_def_property_ui_text(prop, "Edge Mark", "Select edge marks");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop = RNA_def_property(srna, "exclude_silhouette", PROP_BOOLEAN, PROP_NONE);
 +      RNA_def_property_boolean_sdna(prop, NULL, "exclude_edge_types", FREESTYLE_FE_SILHOUETTE);
 +      RNA_def_property_ui_text(prop, "Silhouette", "Exclude silhouette edges");
 +      RNA_def_property_ui_icon(prop, ICON_X, 0);
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop = RNA_def_property(srna, "exclude_border", PROP_BOOLEAN, PROP_NONE);
 +      RNA_def_property_boolean_sdna(prop, NULL, "exclude_edge_types", FREESTYLE_FE_BORDER);
 +      RNA_def_property_ui_text(prop, "Border", "Exclude border edges");
 +      RNA_def_property_ui_icon(prop, ICON_X, 0);
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop = RNA_def_property(srna, "exclude_crease", PROP_BOOLEAN, PROP_NONE);
 +      RNA_def_property_boolean_sdna(prop, NULL, "exclude_edge_types", FREESTYLE_FE_CREASE);
 +      RNA_def_property_ui_text(prop, "Crease", "Exclude crease edges");
 +      RNA_def_property_ui_icon(prop, ICON_X, 0);
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop = RNA_def_property(srna, "exclude_ridge_valley", PROP_BOOLEAN, PROP_NONE);
 +      RNA_def_property_boolean_sdna(prop, NULL, "exclude_edge_types", FREESTYLE_FE_RIDGE_VALLEY);
 +      RNA_def_property_ui_text(prop, "Ridge & Valley", "Exclude ridges and valleys");
 +      RNA_def_property_ui_icon(prop, ICON_X, 0);
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop = RNA_def_property(srna, "exclude_suggestive_contour", PROP_BOOLEAN, PROP_NONE);
 +      RNA_def_property_boolean_sdna(prop, NULL, "exclude_edge_types", FREESTYLE_FE_SUGGESTIVE_CONTOUR);
 +      RNA_def_property_ui_text(prop, "Suggestive Contour", "Exclude suggestive contours");
 +      RNA_def_property_ui_icon(prop, ICON_X, 0);
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop = RNA_def_property(srna, "exclude_material_boundary", PROP_BOOLEAN, PROP_NONE);
 +      RNA_def_property_boolean_sdna(prop, NULL, "exclude_edge_types", FREESTYLE_FE_MATERIAL_BOUNDARY);
 +      RNA_def_property_ui_text(prop, "Material Boundary", "Exclude edges at material boundaries");
 +      RNA_def_property_ui_icon(prop, ICON_X, 0);
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop = RNA_def_property(srna, "exclude_contour", PROP_BOOLEAN, PROP_NONE);
 +      RNA_def_property_boolean_sdna(prop, NULL, "exclude_edge_types", FREESTYLE_FE_CONTOUR);
 +      RNA_def_property_ui_text(prop, "Contour", "Exclude contours");
 +      RNA_def_property_ui_icon(prop, ICON_X, 0);
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop = RNA_def_property(srna, "exclude_external_contour", PROP_BOOLEAN, PROP_NONE);
 +      RNA_def_property_boolean_sdna(prop, NULL, "exclude_edge_types", FREESTYLE_FE_EXTERNAL_CONTOUR);
 +      RNA_def_property_ui_text(prop, "External Contour", "Exclude external contours");
 +      RNA_def_property_ui_icon(prop, ICON_X, 0);
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop = RNA_def_property(srna, "exclude_edge_mark", PROP_BOOLEAN, PROP_NONE);
 +      RNA_def_property_boolean_sdna(prop, NULL, "exclude_edge_types", FREESTYLE_FE_EDGE_MARK);
 +      RNA_def_property_ui_text(prop, "Edge Mark", "Exclude edge marks");
 +      RNA_def_property_ui_icon(prop, ICON_X, 0);
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop = RNA_def_property(srna, "visibility", PROP_ENUM, PROP_NONE);
 +      RNA_def_property_enum_sdna(prop, NULL, "qi");
 +      RNA_def_property_enum_items(prop, visibility_items);
 +      RNA_def_property_ui_text(prop, "Visibility", "Determine how to use visibility for feature edge selection");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop = RNA_def_property(srna, "qi_start", PROP_INT, PROP_UNSIGNED);
 +      RNA_def_property_int_sdna(prop, NULL, "qi_start");
 +      RNA_def_property_range(prop, 0, INT_MAX);
 +      RNA_def_property_ui_text(prop, "Start", "First QI value of the QI range");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop = RNA_def_property(srna, "qi_end", PROP_INT, PROP_UNSIGNED);
 +      RNA_def_property_int_sdna(prop, NULL, "qi_end");
 +      RNA_def_property_range(prop, 0, INT_MAX);
 +      RNA_def_property_ui_text(prop, "End", "Last QI value of the QI range");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      /* FreestyleModuleSettings */
 +
 +      srna = RNA_def_struct(brna, "FreestyleModuleSettings", NULL);
 +      RNA_def_struct_sdna(srna, "FreestyleModuleConfig");
 +      RNA_def_struct_ui_text(srna, "Freestyle Module", "Style module configuration for specifying a style module");
 +
 +      prop = RNA_def_property(srna, "module_path", PROP_STRING, PROP_FILEPATH);
 +      RNA_def_property_string_sdna(prop, NULL, "module_path");
 +      RNA_def_property_ui_text(prop, "Module Path", "Path to a style module file");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop = RNA_def_property(srna, "use", PROP_BOOLEAN, PROP_NONE);
 +      RNA_def_property_boolean_sdna(prop, NULL, "is_displayed", 1);
 +      RNA_def_property_ui_text(prop, "Use", "Enable or disable this style module during stroke rendering");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      /* FreestyleSettings */
 +
 +      srna = RNA_def_struct(brna, "FreestyleSettings", NULL);
 +      RNA_def_struct_sdna(srna, "FreestyleConfig");
 +      RNA_def_struct_nested(brna, srna, "SceneRenderLayer");
 +      RNA_def_struct_ui_text(srna, "Frestyle Settings", "Freestyle settings for a SceneRenderLayer datablock");
 +
 +      prop = RNA_def_property(srna, "modules", PROP_COLLECTION, PROP_NONE);
 +      RNA_def_property_collection_sdna(prop, NULL, "modules", NULL);
 +      RNA_def_property_struct_type(prop, "FreestyleModuleSettings");
 +      RNA_def_property_ui_text(prop, "Style modules", "A list of style modules (to be applied from top to bottom)");
 +
 +      prop = RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE);
 +      RNA_def_property_enum_sdna(prop, NULL, "mode");
 +      RNA_def_property_enum_items(prop, freestyle_ui_mode_items);
 +      RNA_def_property_ui_text(prop, "Control Mode", "Select the Freestyle control mode");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop = RNA_def_property(srna, "raycasting_algorithm", PROP_ENUM, PROP_NONE);
 +      RNA_def_property_enum_sdna(prop, NULL, "raycasting_algorithm");
 +      RNA_def_property_enum_items(prop, freestyle_raycasting_algorithm_items);
 +      RNA_def_property_ui_text(prop, "Raycasting Algorithm", "Select the Freestyle raycasting algorithm");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop = RNA_def_property(srna, "use_culling", PROP_BOOLEAN, PROP_NONE);
 +      RNA_def_property_boolean_sdna(prop, NULL, "flags", FREESTYLE_CULLING);
 +      RNA_def_property_ui_text(prop, "Culling", "If enabled, out-of-view edges are ignored");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop = RNA_def_property(srna, "use_suggestive_contours", PROP_BOOLEAN, PROP_NONE);
 +      RNA_def_property_boolean_sdna(prop, NULL, "flags", FREESTYLE_SUGGESTIVE_CONTOURS_FLAG);
 +      RNA_def_property_ui_text(prop, "Suggestive Contours", "Enable suggestive contours");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop = RNA_def_property(srna, "use_ridges_and_valleys", PROP_BOOLEAN, PROP_NONE);
 +      RNA_def_property_boolean_sdna(prop, NULL, "flags", FREESTYLE_RIDGES_AND_VALLEYS_FLAG);
 +      RNA_def_property_ui_text(prop, "Ridges and Valleys", "Enable ridges and valleys");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop = RNA_def_property(srna, "use_material_boundaries", PROP_BOOLEAN, PROP_NONE);
 +      RNA_def_property_boolean_sdna(prop, NULL, "flags", FREESTYLE_MATERIAL_BOUNDARIES_FLAG);
 +      RNA_def_property_ui_text(prop, "Material Boundaries", "Enable material boundaries");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop = RNA_def_property(srna, "use_smoothness", PROP_BOOLEAN, PROP_NONE);
 +      RNA_def_property_boolean_sdna(prop, NULL, "flags", FREESTYLE_FACE_SMOOTHNESS_FLAG);
 +      RNA_def_property_ui_text(prop, "Face Smoothness", "Take face smoothness into account in view map calculation");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop = RNA_def_property(srna, "use_advanced_options", PROP_BOOLEAN, PROP_NONE);
 +      RNA_def_property_boolean_sdna(prop, NULL, "flags", FREESTYLE_ADVANCED_OPTIONS_FLAG);
 +      RNA_def_property_ui_text(prop, "Advanced Edge Detection Options",
 +                               "Enable advanced edge detection options (sphere radius and Kr derivative epsilon)");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop = RNA_def_property(srna, "sphere_radius", PROP_FLOAT, PROP_NONE);
 +      RNA_def_property_float_sdna(prop, NULL, "sphere_radius");
 +      RNA_def_property_range(prop, 0.0, 1000.0);
 +      RNA_def_property_ui_text(prop, "Sphere Radius", "Sphere radius for computing curvatures");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop = RNA_def_property(srna, "kr_derivative_epsilon", PROP_FLOAT, PROP_NONE);
 +      RNA_def_property_float_sdna(prop, NULL, "dkr_epsilon");
 +      RNA_def_property_range(prop, -1000.0, 1000.0);
 +      RNA_def_property_ui_text(prop, "Kr Derivative Epsilon", "Kr derivative epsilon for computing suggestive contours");
 +      RNA_def_property_update(prop, NC_SCENE, NULL);
 +
 +      prop = RNA_def_property(srna, "crease_angle", PROP_FLOAT, PROP_ANGLE);
 +      RNA_def_property_float_sdna(prop, NULL, "crease_angle");
 +      RNA_def_property_range(prop, 0.0, DEG2RAD(180.0));
 +      RNA_def_property_ui_text(prop, "Crease Angle", "Angular threshold 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);
 +}
 +#endif
 +
  static void rna_def_scene_game_recast_data(BlenderRNA *brna)
  {
        StructRNA *srna;
@@@ -3037,7 -2562,7 +3038,7 @@@ static void rna_def_scene_game_data(Ble
        RNA_def_property_float_sdna(prop, NULL, "eyeseparation");
        RNA_def_property_range(prop, 0.01, 5.0);
        RNA_def_property_ui_text(prop, "Eye Separation",
-                                "Set the distance between the eyes - the camera focal length/30 should be fine");
+                                "Set the distance between the eyes - the camera focal distance/30 should be fine");
        RNA_def_property_update(prop, NC_SCENE, NULL);
        
        /* Dome */
        RNA_def_property_update(prop, NC_SCENE, NULL);
  
        /* mode */
+       /* not used  *//* deprecated !!!!!!!!!!!!! */
        prop = RNA_def_property(srna, "use_occlusion_culling", PROP_BOOLEAN, PROP_NONE);
        RNA_def_property_boolean_sdna(prop, NULL, "mode", WO_DBVT_CULLING);
-       RNA_def_property_ui_text(prop, "DBVT culling",
-                                "Use optimized Bullet DBVT tree for view frustum and occlusion culling");
+       RNA_def_property_ui_text(prop, "DBVT Culling",
+                                "Use optimized Bullet DBVT tree for view frustum and occlusion culling "
+                                "(more efficient, but it can waste unecessary CPU if the scene doesn't have Occluder objects");
        
        /* not used  *//* deprecated !!!!!!!!!!!!! */
        prop = RNA_def_property(srna, "use_activity_culling", PROP_BOOLEAN, PROP_NONE);
  static void rna_def_scene_render_layer(BlenderRNA *brna)
  {
        StructRNA *srna;
 +      PropertyRNA *prop;
  
        srna = RNA_def_struct(brna, "SceneRenderLayer", NULL);
        RNA_def_struct_ui_text(srna, "Scene Render Layer", "Render layer");
        RNA_def_struct_path_func(srna, "rna_SceneRenderLayer_path");
  
        rna_def_render_layer_common(srna, 1);
 +
 +#ifdef WITH_FREESTYLE
 +      /* 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", "");
 +#endif
  }
  
  /* curve.splines */
@@@ -3923,15 -3437,6 +3926,15 @@@ static void rna_def_scene_render_data(B
                {0, NULL, 0, NULL, NULL}
        };
  
 +#ifdef WITH_FREESTYLE
 +      static EnumPropertyItem freestyle_thickness_items[] = {
 +              {R_LINE_THICKNESS_ABSOLUTE, "ABSOLUTE", 0, "Absolute", "Specify unit line thickness in pixels"},
 +              {R_LINE_THICKNESS_RELATIVE, "RELATIVE", 0, "Relative",
 +                                          "Unit line thickness is scaled by the proportion of the present vertical image "
 +                                    "resolution to 480 pixels"},
 +              {0, NULL, 0, NULL, NULL}};
 +#endif
 +
        rna_def_scene_ffmpeg_settings(brna);
  #ifdef WITH_QUICKTIME
        rna_def_scene_quicktime_settings(brna);
        RNA_def_property_ui_text(prop, "Edge Color", "Edge color");
        RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
        
 +#ifdef WITH_FREESTYLE
 +      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);
 +#endif
 +
        /* threads */
        prop = RNA_def_property(srna, "threads", PROP_INT, PROP_NONE);
        RNA_def_property_int_sdna(prop, NULL, "threads");
        RNA_def_property_ui_text(prop, "Persistent Data", "Keep render data around for faster re-renders");
        RNA_def_property_update(prop, 0, "rna_Scene_use_persistent_data_update");
  
 +#ifdef WITH_FREESTYLE
 +      /* Freestyle line thickness options */
 +      prop = RNA_def_property(srna, "line_thickness_mode", PROP_ENUM, PROP_NONE);
 +      RNA_def_property_enum_sdna(prop, NULL, "line_thickness_mode");
 +      RNA_def_property_enum_items(prop, freestyle_thickness_items);
 +      RNA_def_property_ui_text(prop, "Line Thickness Mode", "Line thickness mode for Freestyle line drawing");
 +
 +      prop = RNA_def_property(srna, "unit_line_thickness", PROP_FLOAT, PROP_NONE);
 +      RNA_def_property_float_sdna(prop, NULL, "unit_line_thickness");
 +      RNA_def_property_range(prop, 0.f, 10000.f);
 +      RNA_def_property_ui_text(prop, "Unit Line Thickness", "Unit line thickness in pixels");
 +#endif
 +
        /* Scene API */
        RNA_api_scene_render(srna);
  }
index 866932632c27b06152feaaa82fa1208dcb758c5d,2c90110b458e1e82c95582b6e0677d6256c3c38e..d77ca10e0b2bb50d120e1921ce02e00669cc99bb
  #include "RE_engine.h"
  #include "RE_pipeline.h"
  
 +#ifdef WITH_FREESTYLE
 +#  include "BKE_library.h"
 +#  include "FRS_freestyle.h"
 +#endif
 +
  /* internal */
  #include "render_result.h"
  #include "render_types.h"
@@@ -947,10 -942,6 +947,10 @@@ void RE_TileProcessor(Render *re
  
  /* ************  This part uses API, for rendering Blender scenes ********** */
  
 +#ifdef WITH_FREESTYLE
 +static void add_freestyle(Render *re);
 +#endif
 +
  static void do_render_3d(Render *re)
  {
        float cfra;
                if (!re->test_break(re->tbh))
                        add_halo_flare(re);
        
 +#ifdef WITH_FREESTYLE
 +      /* Freestyle  */
 +      if( re->r.mode & R_EDGE_FRS)
 +              if(!re->test_break(re->tbh))
 +                      add_freestyle(re);
 +#endif
 +              
        /* free all render verts etc */
        RE_Database_Free(re);
        
@@@ -1437,74 -1421,6 +1437,74 @@@ static void render_composit_stats(void 
        R.i.infostr = NULL;
  }
  
 +#ifdef WITH_FREESTYLE
 +/* invokes Freestyle stroke rendering */
 +static void add_freestyle(Render *re)
 +{
 +      SceneRenderLayer *srl, *actsrl;
 +      LinkData *link;
 +
 +      actsrl = BLI_findlink(&re->r.layers, re->r.actlay);
 +
 +      FRS_init_stroke_rendering(re);
 +
 +      for (srl= (SceneRenderLayer *)re->r.layers.first; srl; srl= srl->next) {
 +
 +              link = (LinkData *)MEM_callocN(sizeof(LinkData), "LinkData to Freestyle render");
 +              BLI_addtail(&re->freestyle_renders, link);
 +
 +              if ((re->r.scemode & R_SINGLE_LAYER) && srl != actsrl)
 +                      continue;
 +              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, *actsrl;
 +      LinkData *link;
 +
 +      actsrl = BLI_findlink(&re->r.layers, re->r.actlay);
 +
 +      link = (LinkData *)re->freestyle_renders.first;
 +      for (srl= (SceneRenderLayer *)re->r.layers.first; srl; srl= srl->next) {
 +              if ((re->r.scemode & R_SINGLE_LAYER) && srl != actsrl)
 +                      continue;
 +              if (FRS_is_freestyle_enabled(srl)) {
 +                      freestyle_render = (Render *)link->data;
 +                      render_result_exr_file_read(freestyle_render, sample);
 +                      FRS_composite_result(re, srl, freestyle_render);
 +                      RE_FreeRenderResult(freestyle_render->result);
 +                      freestyle_render->result = NULL;
 +              }
 +              link = link->next;
 +      }
 +}
 +
 +/* releases temporary scenes and renders for Freestyle stroke rendering */
 +static void free_all_freestyle_renders(Scene *scene)
 +{
 +      Render *re1, *freestyle_render;
 +      LinkData *link;
 +
 +      for (re1= RenderGlobal.renderlist.first; re1; re1= re1->next) {
 +              for (link = (LinkData *)re1->freestyle_renders.first; link; link = link->next) {
 +                      if (link->data) {
 +                              freestyle_render = (Render *)link->data;
 +                              BKE_scene_unlink(G.main, freestyle_render->scene, scene);
 +                              RE_FreeRender(freestyle_render);
 +                      }
 +              }
 +              BLI_freelistN( &re1->freestyle_renders );
 +      }
 +}
 +#endif
  
  /* reads all buffers, calls optional composite, merges in first result->rectf */
  static void do_merge_fullsample(Render *re, bNodeTree *ntree)
                                        if (sample) {
                                                BLI_rw_mutex_lock(&re->resultmutex, THREAD_LOCK_WRITE);
                                                render_result_exr_file_read(re1, sample);
 +#ifdef WITH_FREESTYLE
 +                                              if( re1->r.mode & R_EDGE_FRS)
 +                                                      composite_freestyle_renders(re1, sample);
 +#endif
                                                BLI_rw_mutex_unlock(&re->resultmutex);
                                        }
                                        ntreeCompositTagRender(re1->scene); /* ensure node gets exec to put buffers on stack */
@@@ -1752,10 -1664,6 +1752,10 @@@ static void do_render_composite_fields_
                        do_merge_fullsample(re, NULL);
        }
  
 +#ifdef WITH_FREESTYLE
 +      free_all_freestyle_renders(re->scene);
 +#endif
 +
        /* weak... the display callback wants an active renderlayer pointer... */
        re->result->renlay = render_get_active_layer(re, re->result);
        re->display_draw(re->ddh, re->result, NULL);
@@@ -1879,8 -1787,6 +1879,6 @@@ static void do_render_all_options(Rende
        /* ensure no images are in memory from previous animated sequences */
        BKE_image_all_free_anim_ibufs(re->r.cfra);
  
-       re->pool = BKE_image_pool_new();
        if (RE_engine_render(re, 1)) {
                /* in this case external render overrides all */
        }
                re->display_draw(re->ddh, re->result, NULL);
        }
        else {
+               re->pool = BKE_image_pool_new();
                do_render_composite_fields_blur_3d(re);
+               BKE_image_pool_free(re->pool);
+               re->pool = NULL;
        }
        
        re->i.lastframetime = PIL_check_seconds_timer() - re->i.starttime;
                renderresult_stampinfo(re);
                re->display_draw(re->ddh, re->result, NULL);
        }
-       BKE_image_pool_free(re->pool);
-       re->pool = NULL;
  }
  
  static int check_valid_camera(Scene *scene, Object *camera_override)
@@@ -2232,17 -2140,6 +2232,17 @@@ void RE_BlenderFrame(Render *re, Main *
        G.is_rendering = FALSE;
  }
  
 +#ifdef WITH_FREESTYLE
 +void RE_RenderFreestyleStrokes(Render *re, Main *bmain, Scene *scene)
 +{
 +      re->result_ok= 0;
 +      if(render_initialize_from_main(re, bmain, scene, NULL, NULL, scene->lay, 0, 0)) {
 +              do_render_fields_blur_3d(re);
 +      }
 +      re->result_ok= 1;
 +}
 +#endif
 +
  static int do_write_image_or_movie(Render *re, Main *bmain, Scene *scene, bMovieHandle *mh, const char *name_override)
  {
        char name[FILE_MAX];