Merged changes in the trunk up to revision 54421.
authorTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>
Sun, 10 Feb 2013 10:17:59 +0000 (10:17 +0000)
committerTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>
Sun, 10 Feb 2013 10:17:59 +0000 (10:17 +0000)
Conflicts resolved:
release/datafiles/startup.blend
release/scripts/startup/bl_ui/properties_render.py
source/blender/SConscript
source/blender/blenloader/intern/readfile.c

48 files changed:
1  2 
CMakeLists.txt
SConstruct
build_files/scons/config/darwin-config.py
build_files/scons/config/win64-vc-config.py
build_files/scons/tools/Blender.py
doc/python_api/sphinx_doc_gen.py
intern/cycles/blender/addon/ui.py
release/datafiles/startup.blend
release/scripts/startup/bl_ui/properties_render.py
release/scripts/startup/bl_ui/space_view3d.py
source/blender/CMakeLists.txt
source/blender/SConscript
source/blender/blenkernel/CMakeLists.txt
source/blender/blenkernel/SConscript
source/blender/blenkernel/intern/anim_sys.c
source/blender/blenkernel/intern/group.c
source/blender/blenkernel/intern/library.c
source/blender/blenkernel/intern/material.c
source/blender/blenkernel/intern/object.c
source/blender/blenkernel/intern/scene.c
source/blender/blenloader/intern/readfile.c
source/blender/bmesh/CMakeLists.txt
source/blender/editors/interface/interface_templates.c
source/blender/editors/mesh/editmesh_tools.c
source/blender/editors/mesh/mesh_ops.c
source/blender/editors/render/render_shading.c
source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp
source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp
source/blender/freestyle/intern/system/PythonInterpreter.h
source/blender/makesdna/DNA_userdef_types.h
source/blender/makesrna/SConscript
source/blender/makesrna/intern/CMakeLists.txt
source/blender/makesrna/intern/SConscript
source/blender/makesrna/intern/makesrna.c
source/blender/makesrna/intern/rna_internal.h
source/blender/makesrna/intern/rna_main_api.c
source/blender/makesrna/intern/rna_mesh.c
source/blender/makesrna/intern/rna_scene.c
source/blender/makesrna/intern/rna_space.c
source/blender/makesrna/intern/rna_userdef.c
source/blender/python/bmesh/bmesh_py_types.c
source/blender/render/intern/source/convertblender.c
source/blender/render/intern/source/pipeline.c
source/blender/windowmanager/WM_types.h
source/blender/windowmanager/intern/wm_files.c
source/blenderplayer/bad_level_call_stubs/stubs.c
source/creator/CMakeLists.txt
source/creator/creator.c

diff --cc CMakeLists.txt
Simple merge
diff --cc SConstruct
Simple merge
Simple merge
Simple merge
Simple merge
index dc684178f40e144bb7eab6991b6ccbbd696be52b,d19cd414eb457970567857e61332b9ec60243de2..0a7e0668a97747c3e2894fcf308017a85a641054
Binary files differ
index cb5a473dba19ae287ec927a57f7f9680dbf56f73,1cd583283324cdb7927dec8f3e34b9c33d6af872..969cb8d4cad43fbb4e6e8d9fc9bfe477e025c1d8
@@@ -43,7 -43,18 +43,6 @@@ class RENDER_MT_framerate_presets(Menu)
      draw = Menu.draw_preset
  
  
 -class RENDER_UL_renderlayers(UIList):
 -    def draw_item(self, context, layout, data, item, icon, active_data, active_propname, index):
 -        # assert(isinstance(item, bpy.types.SceneRenderLayer)
 -        layer = item
 -        if self.layout_type in {'DEFAULT', 'COMPACT'}:
 -            layout.label(text=layer.name, translate=False, icon_value=icon)
 -            layout.prop(layer, "use", text="", index=index)
 -        elif self.layout_type in {'GRID'}:
 -            layout.alignment = 'CENTER'
 -            layout.label(text="", icon_value=icon)
 -
--
  class RenderButtonsPanel():
      bl_space_type = 'PROPERTIES'
      bl_region_type = 'WINDOW'
Simple merge
index e103aaf8befc964f1bfb132b43eb6028a6e1d044,8a4e2a39aa166d431bbb8f55683e8b8388159637..a4041212c89d154c4fee5e3b6a7e9062289fb7a0
@@@ -68,8 -65,4 +65,6 @@@ if env['WITH_BF_COLLADA']
      SConscript (['collada/SConscript'])
      
  if env['WITH_BF_COMPOSITOR']:
-     SConscript (['compositor/SConscript',
-                  'opencl/SConscript'])
+     SConscript (['compositor/SConscript'])
 +if env['WITH_BF_FREESTYLE']:
 +    SConscript (['freestyle/SConscript'])
Simple merge
index fdf23458c769f05247e8dbf9b0de250d6b29d50c,93bc0502b1958c24909cb1169f6c7506625ac5ff..abede57b3ce9d4d46250c28a0be242ccc2fa555b
@@@ -8854,7 -8659,24 +8868,24 @@@ static void do_versions(FileData *fd, L
                        SEQ_END
  
                        if (scene->r.bake_samples == 0)
 -                      scene->r.bake_samples = 256;
 +                              scene->r.bake_samples = 256;
+                       if (scene->world) {
+                               World *world = blo_do_versions_newlibadr(fd, scene->id.lib, scene->world);
+                               if (is_zero_v3(&world->horr)) {
+                                       if ((world->skytype & WO_SKYBLEND) == 0 || is_zero_v3(&world->zenr)) {
+                                               set_premul = true;
+                                       }
+                               }
+                       }
+                       else
+                               set_premul = true;
+                       if (set_premul) {
+                               printf("2.66 versioning fix: replacing black sky with premultiplied alpha for scene %s\n", scene->id.name + 2);
+                               scene->r.alphamode = R_ALPHAPREMUL;
+                       }
                }
  
                for (image = main->image.first; image; image = image->id.next) {
                }
        }
  
+       // add storage for compositor translate nodes when not existing
+       if (!MAIN_VERSION_ATLEAST(main, 265, 10)) {
+               bNodeTreeType *ntreetype;
+               ntreetype = ntreeGetType(NTREE_COMPOSIT);
+               if (ntreetype && ntreetype->foreach_nodetree)
+                       ntreetype->foreach_nodetree(main, NULL, do_version_node_fix_translate_wrapping);
+       }
        // if (main->versionfile < 265 || (main->versionfile == 265 && main->subversionfile < 7)) {
  
 +#ifdef WITH_FREESTYLE
 +      /* default values in Freestyle settings */
 +      {
 +              Scene *sce;
 +              SceneRenderLayer *srl;
 +              FreestyleLineStyle *linestyle;
 +
 +              for(sce = main->scene.first; sce; sce = sce->id.next) {
 +                      if (sce->r.line_thickness_mode == 0) {
 +                              sce->r.line_thickness_mode = R_LINE_THICKNESS_ABSOLUTE;
 +                              sce->r.unit_line_thickness = 1.0f;
 +                      }
 +                      for(srl = sce->r.layers.first; srl; srl = srl->next) {
 +                              if (srl->freestyleConfig.mode == 0)
 +                                      srl->freestyleConfig.mode = FREESTYLE_CONTROL_EDITOR_MODE;
 +                              if (srl->freestyleConfig.raycasting_algorithm == FREESTYLE_ALGO_CULLED_ADAPTIVE_CUMULATIVE ||
 +                                  srl->freestyleConfig.raycasting_algorithm == FREESTYLE_ALGO_CULLED_ADAPTIVE_TRADITIONAL) {
 +                                      srl->freestyleConfig.raycasting_algorithm = 0; /* deprecated */
 +                                      srl->freestyleConfig.flags |= FREESTYLE_CULLING;
 +                              }
 +                      }
 +              }
 +              for(linestyle = main->linestyle.first; linestyle; linestyle = linestyle->id.next) {
 +#if 1
 +                      /* disable the Misc panel for now */
 +                      if (linestyle->panel == LS_PANEL_MISC) {
 +                              linestyle->panel = LS_PANEL_STROKES;
 +                      }
 +#endif
 +                      if (linestyle->thickness_position == 0) {
 +                              linestyle->thickness_position = LS_THICKNESS_CENTER;
 +                              linestyle->thickness_ratio = 0.5f;
 +                      }
 +                      if (linestyle->chaining == 0)
 +                              linestyle->chaining = LS_CHAINING_PLAIN;
 +                      if (linestyle->rounds == 0)
 +                              linestyle->rounds = 3;
 +              }
 +      }
 +#endif
 +
        /* 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! */
  
Simple merge
index ca4cbd35edcb7503af6e3039011f85461d19af53,0000000000000000000000000000000000000000..a742a45ec12e026960653711a477651b0fd9bcd9
mode 100644,000000..100644
--- /dev/null
@@@ -1,513 -1,0 +1,513 @@@
-       material = BKE_material_add("stroke_material");
 +/*
 + * ***** 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.
 + *
 + * The Original Code is Copyright (C) 2010 Blender Foundation.
 + * All rights reserved.
 + *
 + * The Original Code is: all of this file.
 + *
 + * Contributor(s): none yet.
 + *
 + * ***** END GPL LICENSE BLOCK *****
 + */
 +
 +/** \file blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp
 + *  \ingroup freestyle
 + */
 +
 +#include "BlenderStrokeRenderer.h"
 +#include "BlenderTextureManager.h"
 +
 +#include "../application/AppConfig.h"
 +#include "../stroke/Canvas.h"
 +
 +#include "BKE_global.h"
 +
 +// XXX Are those "ifdef __cplusplus" useful here?
 +#ifdef __cplusplus
 +extern "C" {
 +#endif
 +
 +#include "MEM_guardedalloc.h"
 +
 +#include "DNA_camera_types.h"
 +#include "DNA_customdata_types.h"
 +#include "DNA_listBase.h"
 +#include "DNA_meshdata_types.h"
 +#include "DNA_mesh_types.h"
 +#include "DNA_object_types.h"
 +#include "DNA_screen_types.h"
 +
 +#include "BKE_customdata.h"
 +#include "BKE_global.h"
 +#include "BKE_library.h" /* free_libblock */
 +#include "BKE_main.h" /* struct Main */
 +#include "BKE_material.h"
 +#include "BKE_mesh.h"
 +#include "BKE_object.h"
 +#include "BKE_scene.h"
 +
 +#include "RE_pipeline.h"
 +
 +#ifdef __cplusplus
 +}
 +#endif
 +
 +BlenderStrokeRenderer::BlenderStrokeRenderer(Render* re, int render_count) : StrokeRenderer()
 +{
 +      // TEMPORARY - need a  texture manager
 +      _textureManager = new BlenderTextureManager;
 +      _textureManager->load();
 +
 +      // for stroke mesh generation
 +      _width = re->winx;
 +      _height = re->winy;
 +
 +      //Scene.New("FreestyleStrokes")
 +      old_scene = re->scene;
 +
 +      char name[22];
 +      BLI_snprintf(name, sizeof(name), "FRS%d_%s", render_count, re->scene->id.name + 2);
 +      freestyle_scene = BKE_scene_add(G.main, name);
 +      freestyle_scene->r.cfra = old_scene->r.cfra;
 +      freestyle_scene->r.mode = old_scene->r.mode &
 +                                ~(R_EDGE_FRS | R_SHADOW | R_SSS | R_PANORAMA | R_ENVMAP | R_MBLUR | R_BORDER);
 +      freestyle_scene->r.xsch = re->rectx; // old_scene->r.xsch
 +      freestyle_scene->r.ysch = re->recty; // old_scene->r.ysch
 +      freestyle_scene->r.xasp = 1.0f; // old_scene->r.xasp;
 +      freestyle_scene->r.yasp = 1.0f; // old_scene->r.yasp;
 +      freestyle_scene->r.tilex = old_scene->r.tilex;
 +      freestyle_scene->r.tiley = old_scene->r.tiley;
 +      freestyle_scene->r.size = 100; // old_scene->r.size
 +      freestyle_scene->r.maximsize = old_scene->r.maximsize;
 +      freestyle_scene->r.ocres = old_scene->r.ocres;
 +      freestyle_scene->r.color_mgt_flag = 0; // old_scene->r.color_mgt_flag;
 +      freestyle_scene->r.scemode = old_scene->r.scemode & ~(R_SINGLE_LAYER);
 +      freestyle_scene->r.flag = old_scene->r.flag;
 +      freestyle_scene->r.threads = old_scene->r.threads;
 +      freestyle_scene->r.border.xmin = old_scene->r.border.xmin;
 +      freestyle_scene->r.border.ymin = old_scene->r.border.ymin;
 +      freestyle_scene->r.border.xmax = old_scene->r.border.xmax;
 +      freestyle_scene->r.border.ymax = old_scene->r.border.ymax;
 +      strcpy(freestyle_scene->r.pic, old_scene->r.pic);
 +      freestyle_scene->r.safety.xmin = old_scene->r.safety.xmin;
 +      freestyle_scene->r.safety.ymin = old_scene->r.safety.ymin;
 +      freestyle_scene->r.safety.xmax = old_scene->r.safety.xmax;
 +      freestyle_scene->r.safety.ymax = old_scene->r.safety.ymax;
 +      freestyle_scene->r.osa = old_scene->r.osa;
 +      freestyle_scene->r.filtertype = old_scene->r.filtertype;
 +      freestyle_scene->r.gauss = old_scene->r.gauss;
 +      freestyle_scene->r.dither_intensity = old_scene->r.dither_intensity;
 +      BLI_strncpy(freestyle_scene->r.engine, old_scene->r.engine, sizeof(freestyle_scene->r.engine));
 +      freestyle_scene->r.im_format.planes = R_IMF_PLANES_RGBA; 
 +      freestyle_scene->r.im_format.imtype = R_IMF_IMTYPE_PNG;
 +      BKE_scene_disable_color_management(freestyle_scene);
 +
 +      if (G.debug & G_DEBUG_FREESTYLE) {
 +              printf("%s: %d threads\n", __func__, freestyle_scene->r.threads);
 +      }
 +
 +      // Render layer
 +      SceneRenderLayer *srl = (SceneRenderLayer *)freestyle_scene->r.layers.first;
 +      srl->layflag = SCE_LAY_SOLID | SCE_LAY_ZTRA;
 +
 +      BKE_scene_set_background(G.main, freestyle_scene);
 +
 +      // Camera
 +      Object* object_camera = BKE_object_add(freestyle_scene, OB_CAMERA);
 +
 +      Camera* camera = (Camera *)object_camera->data;
 +      camera->type = CAM_ORTHO;
 +      camera->ortho_scale = max(re->rectx, re->recty);
 +      camera->clipsta = 0.1f;
 +      camera->clipend = 100.0f;
 +
 +      _z_delta = 0.00001f;
 +      _z = camera->clipsta + _z_delta;
 +
 +      // test
 +      //_z = 999.90f; _z_delta = 0.01f;
 +
 +      object_camera->loc[0] = re->disprect.xmin + 0.5f * re->rectx;
 +      object_camera->loc[1] = re->disprect.ymin + 0.5f * re->recty;
 +      object_camera->loc[2] = 1.0f;
 +
 +      freestyle_scene->camera = object_camera;
 +
 +      // Material
-       ob = BKE_object_add_only_object(OB_MESH, name);
++      material = BKE_material_add(G.main, "stroke_material");
 +      material->mode |= MA_VERTEXCOLP;
 +      material->mode |= MA_TRANSP;
 +      material->mode |= MA_SHLESS;
 +      material->vcol_alpha = 1;
 +}
 +
 +BlenderStrokeRenderer::~BlenderStrokeRenderer()
 +{
 +      if (0 != _textureManager) {
 +              delete _textureManager;
 +              _textureManager = NULL;
 +      }
 +
 +      // The freestyle_scene object is not released here.  Instead,
 +      // the scene is released in free_all_freestyle_renders() in
 +      // source/blender/render/intern/source/pipeline.c, after the
 +      // compositor has finished.
 +
 +      // release objects and data blocks
 +      for (Base *b = (Base*)freestyle_scene->base.first; b; b = b->next) {
 +              Object *ob = b->object;
 +              void *data = ob->data;
 +              char name[24];
 +              strcpy(name, ob->id.name);
 +#if 0
 +              if (G.debug & G_DEBUG_FREESTYLE) {
 +                      cout << "removing " << name[0] << name[1] << ":" << (name+2) << endl;
 +              }
 +#endif
 +              switch (ob->type) {
 +              case OB_MESH:
 +                      BKE_libblock_free(&G.main->object, ob);
 +                      BKE_libblock_free(&G.main->mesh, data);
 +                      break;
 +              case OB_CAMERA:
 +                      BKE_libblock_free(&G.main->object, ob);
 +                      BKE_libblock_free(&G.main->camera, data);
 +                      freestyle_scene->camera = NULL;
 +                      break;
 +              default:
 +                      cerr << "Warning: unexpected object in the scene: " << name[0] << name[1] << ":" << (name+2) << endl;
 +              }
 +      }
 +      BLI_freelistN(&freestyle_scene->base);
 +
 +      // release material
 +      BKE_libblock_free(&G.main->mat, material);
 +
 +      BKE_scene_set_background(G.main, old_scene);
 +}
 +
 +float BlenderStrokeRenderer::get_stroke_vertex_z(void) const
 +{
 +      float z = _z;
 +      BlenderStrokeRenderer *self = const_cast<BlenderStrokeRenderer *>(this);
 +      if (!(_z < _z_delta * 100000.0f))
 +              self->_z_delta *= 10.0f;
 +      self->_z += _z_delta;
 +      return -z;
 +}
 +
 +void BlenderStrokeRenderer::RenderStrokeRep(StrokeRep *iStrokeRep) const
 +{
 +      RenderStrokeRepBasic(iStrokeRep);
 +}
 +
 +void BlenderStrokeRenderer::RenderStrokeRepBasic(StrokeRep *iStrokeRep) const
 +{
 +      ////////////////////
 +      //  Build up scene
 +      ////////////////////
 +
 +      vector<Strip*>& strips = iStrokeRep->getStrips();
 +      Strip::vertex_container::iterator v[3];
 +      StrokeVertexRep *svRep[3];
 +      /* Vec3r color[3]; */ /* UNUSED */
 +      unsigned int vertex_index, edge_index, loop_index;
 +      Vec2r p;
 +
 +      for (vector<Strip*>::iterator s = strips.begin(), send = strips.end();
 +           s != send;
 +           ++s){
 +              Strip::vertex_container& strip_vertices = (*s)->vertices();
 +              int strip_vertex_count = (*s)->sizeStrip();
 +              int xl, xu, yl, yu, n, visible_faces, visible_segments;
 +              bool visible;
 +
 +              // iterate over all vertices and count visible faces and strip segments
 +              // (note: a strip segment is a series of visible faces, while two strip
 +              // segments are separated by one or more invisible faces)
 +              v[0] = strip_vertices.begin();
 +              v[1] = v[0] + 1;
 +              v[2] = v[0] + 2;
 +              visible_faces = visible_segments = 0;
 +              visible = false;
 +              for (n = 2; n < strip_vertex_count; n++, v[0]++, v[1]++, v[2]++) {
 +                      svRep[0] = *(v[0]);
 +                      svRep[1] = *(v[1]);
 +                      svRep[2] = *(v[2]);
 +                      xl = xu = yl = yu = 0;
 +                      for (int j = 0; j < 3; j++) {
 +                              p = svRep[j]->point2d();
 +                              if (p[0] < 0.0)
 +                                      xl++;
 +                              else if (p[0] > _width)
 +                                      xu++;
 +                              if (p[1] < 0.0)
 +                                      yl++;
 +                              else if (p[1] > _height)
 +                                      yu++;
 +                      }
 +                      if (xl == 3 || xu == 3 || yl == 3 || yu == 3) {
 +                              visible = false;
 +                      }
 +                      else {
 +                              visible_faces++;
 +                              if (!visible)
 +                                      visible_segments++;
 +                              visible = true;
 +                      }
 +              }
 +              if (visible_faces == 0)
 +                      continue;
 +
 +              //me = Mesh.New()
 +#if 0
 +              Object* object_mesh = BKE_object_add(freestyle_scene, OB_MESH);
 +#else
 +              Object* object_mesh = NewMesh();
 +#endif
 +              Mesh* mesh = (Mesh*)object_mesh->data;
 +#if 0
 +              MEM_freeN(mesh->bb);
 +              mesh->bb = NULL;
 +              mesh->id.us = 0;
 +#endif
 +#if 1
 +              //me.materials = [mat]
 +              mesh->mat = (Material**)MEM_mallocN(1 * sizeof(Material*), "MaterialList");
 +              mesh->mat[0] = material;
 +              mesh->totcol = 1;
 +              test_object_materials((ID*)mesh);
 +#else
 +              assign_material(object_mesh, material, object_mesh->totcol + 1);
 +              object_mesh->actcol = object_mesh->totcol;
 +#endif
 +
 +              // vertices allocation
 +              mesh->totvert = visible_faces + visible_segments * 2;
 +              mesh->mvert = (MVert*)CustomData_add_layer(&mesh->vdata, CD_MVERT, CD_CALLOC, NULL, mesh->totvert);
 +
 +              // edges allocation
 +              mesh->totedge = visible_faces * 2 + visible_segments;
 +              mesh->medge = (MEdge*)CustomData_add_layer(&mesh->edata, CD_MEDGE, CD_CALLOC, NULL, mesh->totedge);
 +
 +              // faces allocation
 +              mesh->totpoly = visible_faces;
 +              mesh->mpoly = (MPoly*)CustomData_add_layer(&mesh->pdata, CD_MPOLY, CD_CALLOC, NULL, mesh->totpoly);
 +
 +              // loops allocation
 +              mesh->totloop = visible_faces * 3;
 +              mesh->mloop = (MLoop*)CustomData_add_layer(&mesh->ldata, CD_MLOOP, CD_CALLOC, NULL, mesh->totloop);
 +
 +              // colors allocation
 +              mesh->mloopcol = (MLoopCol*)CustomData_add_layer(&mesh->ldata, CD_MLOOPCOL, CD_CALLOC, NULL, mesh->totloop);
 +
 +              ////////////////////
 +              //  Data copy
 +              ////////////////////
 +
 +              MVert *vertices = mesh->mvert;
 +              MEdge *edges = mesh->medge;
 +              MPoly *polys = mesh->mpoly;
 +              MLoop *loops = mesh->mloop;
 +              MLoopCol *colors = mesh->mloopcol;
 +
 +              v[0] = strip_vertices.begin();
 +              v[1] = v[0] + 1;
 +              v[2] = v[0] + 2;
 +
 +              vertex_index = edge_index = loop_index = 0;
 +              visible = false;
 +
 +              // Note: Mesh generation in the following loop assumes stroke strips
 +              // to be triangle strips.
 +              for (n = 2; n < strip_vertex_count; n++, v[0]++, v[1]++, v[2]++) {
 +                      svRep[0] = *(v[0]);
 +                      svRep[1] = *(v[1]);
 +                      svRep[2] = *(v[2]);
 +                      xl = xu = yl = yu = 0;
 +                      for (int j = 0; j < 3; j++) {
 +                              p = svRep[j]->point2d();
 +                              if (p[0] < 0.0)
 +                                      xl++;
 +                              else if (p[0] > _width)
 +                                      xu++;
 +                              if (p[1] < 0.0)
 +                                      yl++;
 +                              else if (p[1] > _height)
 +                                      yu++;
 +                      }
 +                      if (xl == 3 || xu == 3 || yl == 3 || yu == 3) {
 +                              visible = false;
 +                      }
 +                      else {
 +                              if (!visible) {
 +                                      // first vertex
 +                                      vertices->co[0] = svRep[0]->point2d()[0];
 +                                      vertices->co[1] = svRep[0]->point2d()[1];
 +                                      vertices->co[2] = get_stroke_vertex_z();
 +                                      ++vertices;
 +                                      ++vertex_index;
 +
 +                                      // second vertex
 +                                      vertices->co[0] = svRep[1]->point2d()[0];
 +                                      vertices->co[1] = svRep[1]->point2d()[1];
 +                                      vertices->co[2] = get_stroke_vertex_z();
 +                                      ++vertices;
 +                                      ++vertex_index;
 +
 +                                      // first edge
 +                                      edges->v1 = vertex_index - 2;
 +                                      edges->v2 = vertex_index - 1;
 +                                      ++edges;
 +                                      ++edge_index;
 +                              }
 +                              visible = true;
 +
 +                              // vertex
 +                              vertices->co[0] = svRep[2]->point2d()[0];
 +                              vertices->co[1] = svRep[2]->point2d()[1];
 +                              vertices->co[2] = get_stroke_vertex_z();
 +                              ++vertices;
 +                              ++vertex_index;
 +
 +                              // edges
 +                              edges->v1 = vertex_index - 1;
 +                              edges->v2 = vertex_index - 3;
 +                              ++edges;
 +                              ++edge_index;
 +
 +                              edges->v1 = vertex_index - 1;
 +                              edges->v2 = vertex_index - 2;
 +                              ++edges;
 +                              ++edge_index;
 +
 +                              // poly
 +                              polys->loopstart = loop_index;
 +                              polys->totloop = 3;
 +                              ++polys;
 +
 +                              // loops
 +                              if (n % 2 == 0) {
 +                                      loops[0].v = vertex_index - 1;
 +                                      loops[0].e = edge_index - 1;
 +
 +                                      loops[1].v = vertex_index - 2;
 +                                      loops[1].e = edge_index - 3;
 +
 +                                      loops[2].v = vertex_index - 3;
 +                                      loops[2].e = edge_index - 2;
 +                              }
 +                              else {
 +                                      loops[0].v = vertex_index - 1;
 +                                      loops[0].e = edge_index - 2;
 +
 +                                      loops[1].v = vertex_index - 3;
 +                                      loops[1].e = edge_index - 3;
 +
 +                                      loops[2].v = vertex_index - 2;
 +                                      loops[2].e = edge_index - 1;
 +                              }
 +                              loops += 3;
 +                              loop_index += 3;
 +
 +                              // colors
 +                              if (n % 2 == 0) {
 +                                      colors[0].r = (short)(255.0f * svRep[2]->color()[0]);
 +                                      colors[0].g = (short)(255.0f * svRep[2]->color()[1]);
 +                                      colors[0].b = (short)(255.0f * svRep[2]->color()[2]);
 +                                      colors[0].a = (short)(255.0f * svRep[2]->alpha());
 +
 +                                      colors[1].r = (short)(255.0f * svRep[1]->color()[0]);
 +                                      colors[1].g = (short)(255.0f * svRep[1]->color()[1]);
 +                                      colors[1].b = (short)(255.0f * svRep[1]->color()[2]);
 +                                      colors[1].a = (short)(255.0f * svRep[1]->alpha());
 +
 +                                      colors[2].r = (short)(255.0f * svRep[0]->color()[0]);
 +                                      colors[2].g = (short)(255.0f * svRep[0]->color()[1]);
 +                                      colors[2].b = (short)(255.0f * svRep[0]->color()[2]);
 +                                      colors[2].a = (short)(255.0f * svRep[0]->alpha());
 +                              }
 +                              else {
 +                                      colors[0].r = (short)(255.0f * svRep[2]->color()[0]);
 +                                      colors[0].g = (short)(255.0f * svRep[2]->color()[1]);
 +                                      colors[0].b = (short)(255.0f * svRep[2]->color()[2]);
 +                                      colors[0].a = (short)(255.0f * svRep[2]->alpha());
 +
 +                                      colors[1].r = (short)(255.0f * svRep[0]->color()[0]);
 +                                      colors[1].g = (short)(255.0f * svRep[0]->color()[1]);
 +                                      colors[1].b = (short)(255.0f * svRep[0]->color()[2]);
 +                                      colors[1].a = (short)(255.0f * svRep[0]->alpha());
 +
 +                                      colors[2].r = (short)(255.0f * svRep[1]->color()[0]);
 +                                      colors[2].g = (short)(255.0f * svRep[1]->color()[1]);
 +                                      colors[2].b = (short)(255.0f * svRep[1]->color()[2]);
 +                                      colors[2].a = (short)(255.0f * svRep[1]->alpha());
 +                              }
 +                              colors += 3;
 +                      }
 +              } // loop over strip vertices
 +#if 0
 +              BKE_mesh_validate(mesh, TRUE);
 +#endif
 +      } // loop over strips
 +}
 +
 +// A replacement of BKE_object_add() for better performance.
 +Object *BlenderStrokeRenderer::NewMesh() const
 +{
 +      Object *ob;
 +      Base *base;
 +      char name[MAX_ID_NAME];
 +      static unsigned int mesh_id = 0xffffffff;
 +
 +      BLI_snprintf(name, MAX_ID_NAME, "0%08xOB", mesh_id);
-       ob->data = BKE_mesh_add(name);
++      ob = BKE_object_add_only_object(G.main, OB_MESH, name);
 +      BLI_snprintf(name, MAX_ID_NAME, "0%08xME", mesh_id);
++      ob->data = BKE_mesh_add(G.main, name);
 +      ob->lay = 1;
 +
 +      base = BKE_scene_base_add(freestyle_scene, ob);
 +#if 0
 +      BKE_scene_base_deselect_all(scene);
 +      BKE_scene_base_select(scene, base);
 +#else
 +      (void)base;
 +#endif
 +      ob->recalc |= OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME;
 +
 +      --mesh_id;
 +
 +      return ob;
 +}
 +
 +Render* BlenderStrokeRenderer::RenderScene(Render *re)
 +{
 +      Camera *camera = (Camera*)freestyle_scene->camera->data;
 +      if (camera->clipend < _z)
 +              camera->clipend = _z + _z_delta * 100.0f;
 +#if 0
 +      if (G.debug & G_DEBUG_FREESTYLE) {
 +              cout << "clipsta " << camera->clipsta << ", clipend " << camera->clipend << endl;
 +      }
 +#endif
 +
 +      Render *freestyle_render = RE_NewRender(freestyle_scene->id.name);
 +
 +      RE_RenderFreestyleStrokes(freestyle_render, G.main, freestyle_scene);
 +      return freestyle_render;
 +}
index 543c47b21535e55b3f819c88400585b0c5e1ba09,0000000000000000000000000000000000000000..c5a3642e2c6a4dc82bb49fa523cd067eac173c9c
mode 100644,000000..100644
--- /dev/null
@@@ -1,932 -1,0 +1,932 @@@
-       Text *text = BKE_text_add(lineset_name);
 +/*
 + * ***** 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.
 + *
 + * The Original Code is Copyright (C) 2010 Blender Foundation.
 + * All rights reserved.
 + *
 + * The Original Code is: all of this file.
 + *
 + * Contributor(s): none yet.
 + *
 + * ***** END GPL LICENSE BLOCK *****
 + */
 +
 +/** \file blender/freestyle/intern/blender_interface/FRS_freestyle.cpp
 + *  \ingroup freestyle
 + */
 +
 +#include <iostream>
 +#include <map>
 +#include <set>
 +
 +#include "../application/AppCanvas.h"
 +#include "../application/AppConfig.h"
 +#include "../application/AppView.h"
 +#include "../application/Controller.h"
 +
 +#include "BKE_global.h"
 +
 +using namespace std;
 +
 +// XXX Are those "ifdef __cplusplus" useful here?
 +#ifdef __cplusplus
 +extern "C" {
 +#endif
 +
 +#include "MEM_guardedalloc.h"
 +
 +#include "DNA_camera_types.h"
 +#include "DNA_freestyle_types.h"
 +#include "DNA_group_types.h"
 +#include "DNA_text_types.h"
 +
 +#include "BKE_global.h"
 +#include "BKE_library.h"
 +#include "BKE_linestyle.h"
 +#include "BKE_main.h"
 +#include "BKE_text.h"
 +
 +#include "BLI_blenlib.h"
 +#include "BLI_math.h"
 +
 +#include "BPY_extern.h"
 +
 +#include "renderpipeline.h"
 +#include "pixelblending.h"
 +
 +#include "FRS_freestyle.h"
 +#include "FRS_freestyle_config.h"
 +
 +#define DEFAULT_SPHERE_RADIUS 1.0f
 +#define DEFAULT_DKR_EPSILON   0.0f
 +
 +// Freestyle configuration
 +static short freestyle_is_initialized = 0;
 +static Config::Path *pathconfig = NULL;
 +static Controller *controller = NULL;
 +static AppView *view = NULL;
 +
 +// line set buffer for copy & paste
 +static FreestyleLineSet lineset_buffer;
 +static bool lineset_copied = false;
 +
 +// camera information
 +float freestyle_viewpoint[3];
 +float freestyle_mv[4][4];
 +float freestyle_proj[4][4];
 +int freestyle_viewport[4];
 +
 +// current scene
 +Scene *freestyle_scene;
 +
 +string default_module_path;
 +
 +// function declarations
 +static void copy_lineset(FreestyleLineSet *new_lineset, FreestyleLineSet *lineset);
 +static void copy_module(FreestyleModuleConfig *new_module, FreestyleModuleConfig *module);
 +
 +//=======================================================
 +//   Initialization 
 +//=======================================================
 +
 +void FRS_initialize()
 +{
 +      if (freestyle_is_initialized)
 +              return;
 +
 +      pathconfig = new Config::Path;
 +      controller = new Controller();
 +      view = new AppView;
 +      controller->setView(view);
 +      controller->Clear();
 +      freestyle_scene = NULL;
 +      lineset_copied = false;
 +
 +      default_module_path = pathconfig->getProjectDir() + Config::DIR_SEP + "style_modules" +
 +                            Config::DIR_SEP + "contour.py";
 +
 +      freestyle_is_initialized = 1;
 +}
 +
 +void FRS_set_context(bContext *C)
 +{
 +      if (G.debug & G_DEBUG_FREESTYLE) {
 +              cout << "FRS_set_context: context 0x" << C << " scene 0x" << CTX_data_scene(C) << endl;
 +      }
 +      controller->setContext(C);
 +}
 +
 +void FRS_read_file(bContext *C)
 +{
 +      lineset_copied = false;
 +}
 +
 +void FRS_exit()
 +{
 +      delete pathconfig;
 +      delete controller;
 +      delete view;
 +}
 +
 +//=======================================================
 +//   Rendering 
 +//=======================================================
 +
 +static void init_view(Render *re)
 +{
 +      int width = re->winx;
 +      int height = re->winy;
 +      int xmin = re->disprect.xmin;
 +      int ymin = re->disprect.ymin;
 +      int xmax = re->disprect.xmax;
 +      int ymax = re->disprect.ymax;
 +
 +      float thickness = 1.0f;
 +      switch (re->r.line_thickness_mode) {
 +      case R_LINE_THICKNESS_ABSOLUTE:
 +              thickness = re->r.unit_line_thickness * (re->r.size / 100.f);
 +              break;
 +      case R_LINE_THICKNESS_RELATIVE:
 +              thickness = height / 480.f;
 +              break;
 +      }
 +
 +      freestyle_viewport[0] = freestyle_viewport[1] = 0;
 +      freestyle_viewport[2] = width;
 +      freestyle_viewport[3] = height;
 +
 +      view->setWidth(width);
 +      view->setHeight(height);
 +      view->setBorder(xmin, ymin, xmax, ymax);
 +      view->setThickness(thickness);
 +
 +      if (G.debug & G_DEBUG_FREESTYLE) {
 +              cout << "\n===  Dimensions of the 2D image coordinate system  ===" << endl;
 +              cout << "Width  : " << width << endl;
 +              cout << "Height : " << height << endl;
 +              if (re->r.mode & R_BORDER)
 +                      cout << "Border : (" << xmin << ", " << ymin << ") - (" << xmax << ", " << ymax << ")" << endl;
 +              cout << "Unit line thickness : " << thickness << " pixel(s)" << endl;
 +      }
 +}
 +
 +static void init_camera(Render *re)
 +{
 +      // It is assumed that imported meshes are in the camera coordinate system.
 +      // Therefore, the view point (i.e., camera position) is at the origin, and
 +      // the the model-view matrix is simply the identity matrix.
 +
 +      freestyle_viewpoint[0] = 0.0;
 +      freestyle_viewpoint[1] = 0.0;
 +      freestyle_viewpoint[2] = 0.0;
 +
 +      for (int i = 0; i < 4; i++) {
 +              for (int j = 0; j < 4; j++)
 +                      freestyle_mv[i][j] = (i == j) ? 1.0 : 0.0;
 +      }
 +
 +      for (int i = 0; i < 4; i++) {
 +              for (int j = 0; j < 4; j++)
 +                      freestyle_proj[i][j] = re->winmat[i][j];
 +      }
 +
 +#if 0
 +      print_m4("mv", freestyle_mv);
 +      print_m4("proj", freestyle_proj);
 +#endif
 +}
 +
 +static char *escape_quotes(char *name)
 +{
 +      char *s = (char*)MEM_mallocN(strlen(name) * 2 + 1, "escape_quotes");
 +      char *p = s;
 +      while (*name) {
 +              if (*name == '\'')
 +                      *(p++) = '\\';
 +              *(p++) = *(name++);
 +      }
 +      *p = '\0';
 +      return s;
 +}
 +
 +static Text *create_lineset_handler(char *layer_name, char *lineset_name)
 +{
 +      char *s1 = escape_quotes(layer_name);
 +      char *s2 = escape_quotes(lineset_name);
++      Text *text = BKE_text_add(G.main, lineset_name);
 +      BKE_text_write(text, "import parameter_editor; parameter_editor.process('");
 +      BKE_text_write(text, s1);
 +      BKE_text_write(text, "', '");
 +      BKE_text_write(text, s2);
 +      BKE_text_write(text, "')\n");
 +      MEM_freeN(s1);
 +      MEM_freeN(s2);
 +      return text;
 +}
 +
 +struct edge_type_condition
 +{
 +      int edge_type, value;
 +};
 +
 +// examines the conditions and returns true if the target edge type needs to be computed
 +static bool test_edge_type_conditions(struct edge_type_condition *conditions,
 +                                      int num_edge_types, bool logical_and, int target, bool distinct)
 +{
 +      int target_condition = 0;
 +      int num_non_target_positive_conditions = 0;
 +      int num_non_target_negative_conditions = 0;
 +
 +      for (int i = 0; i < num_edge_types; i++) {
 +              if (conditions[i].edge_type == target)
 +                      target_condition = conditions[i].value;
 +              else if (conditions[i].value > 0)
 +                      ++num_non_target_positive_conditions;
 +              else if (conditions[i].value < 0)
 +                      ++num_non_target_negative_conditions;
 +      }
 +      if (distinct) {
 +              // In this case, the 'target' edge type is assumed to appear on distinct edge
 +              // of its own and never together with other edge types.
 +              if (logical_and) {
 +                      if (num_non_target_positive_conditions > 0)
 +                              return false;
 +                      if (target_condition > 0)
 +                              return true;
 +                      if (target_condition < 0)
 +                              return false;
 +                      if (num_non_target_negative_conditions > 0)
 +                              return true;
 +              }
 +              else {
 +                      if (target_condition > 0)
 +                              return true;
 +                      if (num_non_target_negative_conditions > 0)
 +                              return true;
 +                      if (target_condition < 0)
 +                              return false;
 +                      if (num_non_target_positive_conditions > 0)
 +                              return false;
 +              }
 +      }
 +      else {
 +              // In this case, the 'target' edge type may appear together with other edge types.
 +              if (target_condition > 0)
 +                      return true;
 +              if (target_condition < 0)
 +                      return true;
 +              if (logical_and) {
 +                      if (num_non_target_positive_conditions > 0)
 +                              return false;
 +                      if (num_non_target_negative_conditions > 0)
 +                              return true;
 +              }
 +              else {
 +                      if (num_non_target_negative_conditions > 0)
 +                              return true;
 +                      if (num_non_target_positive_conditions > 0)
 +                              return false;
 +              }
 +      }
 +      return true;
 +}
 +
 +static void prepare(Render *re, SceneRenderLayer *srl)
 +{
 +      // load mesh
 +      re->i.infostr = "Freestyle: Mesh loading";
 +      re->stats_draw(re->sdh, &re->i);
 +      re->i.infostr = NULL;
 +      if (controller->LoadMesh(re, srl)) // returns if scene cannot be loaded or if empty
 +              return;
 +      if (re->test_break(re->tbh))
 +              return;
 +
 +      // add style modules
 +      FreestyleConfig *config = &srl->freestyleConfig;
 +
 +      if (G.debug & G_DEBUG_FREESTYLE) {
 +              cout << "\n===  Rendering options  ===" << endl;
 +      }
 +      int layer_count = 0;
 +
 +      switch (config->mode) {
 +      case FREESTYLE_CONTROL_SCRIPT_MODE:
 +              if (G.debug & G_DEBUG_FREESTYLE) {
 +                      cout << "Modules :" << endl;
 +              }
 +              for (FreestyleModuleConfig *module_conf = (FreestyleModuleConfig*)config->modules.first;
 +                   module_conf;
 +                   module_conf = module_conf->next)
 +              {
 +                      if(module_conf->is_displayed) {
 +                              if (G.debug & G_DEBUG_FREESTYLE) {
 +                                      cout << "  " << layer_count+1 << ": " << module_conf->module_path << endl;
 +                              }
 +                              controller->InsertStyleModule(layer_count, module_conf->module_path);
 +                              controller->toggleLayer(layer_count, true);
 +                              layer_count++;
 +                      }
 +              }
 +              if (G.debug & G_DEBUG_FREESTYLE) {
 +                      cout << endl;
 +              }
 +              controller->setComputeRidgesAndValleysFlag((config->flags & FREESTYLE_RIDGES_AND_VALLEYS_FLAG) ? true : false);
 +              controller->setComputeSuggestiveContoursFlag((config->flags & FREESTYLE_SUGGESTIVE_CONTOURS_FLAG) ? true : false);
 +              controller->setComputeMaterialBoundariesFlag((config->flags & FREESTYLE_MATERIAL_BOUNDARIES_FLAG) ? true : false);
 +              break;
 +      case FREESTYLE_CONTROL_EDITOR_MODE:
 +              int use_ridges_and_valleys = 0;
 +              int use_suggestive_contours = 0;
 +              int use_material_boundaries = 0;
 +              struct edge_type_condition conditions[] = {
 +                      {FREESTYLE_FE_SILHOUETTE, 0},
 +                      {FREESTYLE_FE_BORDER, 0},
 +                      {FREESTYLE_FE_CREASE, 0},
 +                      {FREESTYLE_FE_RIDGE_VALLEY, 0},
 +                      {FREESTYLE_FE_SUGGESTIVE_CONTOUR, 0},
 +                      {FREESTYLE_FE_MATERIAL_BOUNDARY, 0},
 +                      {FREESTYLE_FE_CONTOUR, 0},
 +                      {FREESTYLE_FE_EXTERNAL_CONTOUR, 0},
 +                      {FREESTYLE_FE_EDGE_MARK, 0}
 +              };
 +              int num_edge_types = sizeof(conditions) / sizeof(struct edge_type_condition);
 +              if (G.debug & G_DEBUG_FREESTYLE) {
 +                      cout << "Linesets:" << endl;
 +              }
 +              for (FreestyleLineSet *lineset = (FreestyleLineSet*)config->linesets.first;
 +                   lineset;
 +                   lineset = lineset->next)
 +              {
 +                      if (lineset->flags & FREESTYLE_LINESET_ENABLED) {
 +                              if (G.debug & G_DEBUG_FREESTYLE) {
 +                                      cout << "  " << layer_count+1 << ": " << lineset->name << " - "
 +                                           << lineset->linestyle->id.name+2 << endl;
 +                              }
 +                              Text *text = create_lineset_handler(srl->name, lineset->name);
 +                              controller->InsertStyleModule(layer_count, lineset->name, text);
 +                              controller->toggleLayer(layer_count, true);
 +                              if (!(lineset->selection & FREESTYLE_SEL_EDGE_TYPES) || !lineset->edge_types) {
 +                                      ++use_ridges_and_valleys;
 +                                      ++use_suggestive_contours;
 +                                      ++use_material_boundaries;
 +                              }
 +                              else {
 +                                      // conditions for feature edge selection by edge types
 +                                      for (int i = 0; i < num_edge_types; i++) {
 +                                              if (!(lineset->edge_types & conditions[i].edge_type))
 +                                                      conditions[i].value = 0; // no condition specified
 +                                              else if (!(lineset->exclude_edge_types & conditions[i].edge_type))
 +                                                      conditions[i].value = 1; // condition: X
 +                                              else
 +                                                      conditions[i].value = -1; // condition: NOT X
 +                                      }
 +                                      // logical operator for the selection conditions
 +                                      bool logical_and = ((lineset->flags & FREESTYLE_LINESET_FE_AND) != 0);
 +                                      // negation operator
 +                                      if (lineset->flags & FREESTYLE_LINESET_FE_NOT) {
 +                                              // convert an Exclusive condition into an Inclusive equivalent using De Morgan's laws:
 +                                              //   NOT (X OR Y) --> (NOT X) AND (NOT Y)
 +                                              //   NOT (X AND Y) --> (NOT X) OR (NOT Y)
 +                                              for (int i = 0; i < num_edge_types; i++)
 +                                                      conditions[i].value *= -1;
 +                                              logical_and = !logical_and;
 +                                      }
 +                                      if (test_edge_type_conditions(conditions, num_edge_types, logical_and,
 +                                                                    FREESTYLE_FE_RIDGE_VALLEY, true))
 +                                      {
 +                                              ++use_ridges_and_valleys;
 +                                      }
 +                                      if (test_edge_type_conditions(conditions, num_edge_types, logical_and,
 +                                                                    FREESTYLE_FE_SUGGESTIVE_CONTOUR, true))
 +                                      {
 +                                              ++use_suggestive_contours;
 +                                      }
 +                                      if (test_edge_type_conditions(conditions, num_edge_types, logical_and,
 +                                                                    FREESTYLE_FE_MATERIAL_BOUNDARY, true))
 +                                      {
 +                                              ++use_material_boundaries;
 +                                      }
 +                              }
 +                              layer_count++;
 +                      }
 +              }
 +              controller->setComputeRidgesAndValleysFlag(use_ridges_and_valleys > 0);
 +              controller->setComputeSuggestiveContoursFlag(use_suggestive_contours > 0);
 +              controller->setComputeMaterialBoundariesFlag(use_material_boundaries > 0);
 +              break;
 +      }
 +
 +      // set parameters
 +      if (config->flags & FREESTYLE_ADVANCED_OPTIONS_FLAG) {
 +              controller->setSphereRadius(config->sphere_radius);
 +              controller->setSuggestiveContourKrDerivativeEpsilon(config->dkr_epsilon);
 +      }
 +      else {
 +              controller->setSphereRadius(DEFAULT_SPHERE_RADIUS);
 +              controller->setSuggestiveContourKrDerivativeEpsilon(DEFAULT_DKR_EPSILON);
 +      }
 +      controller->setFaceSmoothness((config->flags & FREESTYLE_FACE_SMOOTHNESS_FLAG) ? true : false);
 +      controller->setCreaseAngle(RAD2DEGF(config->crease_angle));
 +      controller->setVisibilityAlgo((config->flags & FREESTYLE_CULLING) ?
 +                                    FREESTYLE_ALGO_CULLED_ADAPTIVE_CUMULATIVE :
 +                                    FREESTYLE_ALGO_ADAPTIVE_CUMULATIVE);
 +
 +      if (G.debug & G_DEBUG_FREESTYLE) {
 +              cout << "Crease angle : " << controller->getCreaseAngle() << endl;
 +              cout << "Sphere radius : " << controller->getSphereRadius() << endl;
 +              cout << "Face smoothness : " << (controller->getFaceSmoothness() ? "enabled" : "disabled") << endl;
 +              cout << "Redges and valleys : " << (controller->getComputeRidgesAndValleysFlag() ? "enabled" : "disabled")
 +                   << endl;
 +              cout << "Suggestive contours : " << (controller->getComputeSuggestiveContoursFlag() ? "enabled" : "disabled")
 +                   << endl;
 +              cout << "Suggestive contour Kr derivative epsilon : " << controller->getSuggestiveContourKrDerivativeEpsilon()
 +                   << endl;
 +              cout << "Material boundaries : " << (controller->getComputeMaterialBoundariesFlag() ? "enabled" : "disabled")
 +                   << endl;
 +              cout << endl;
 +      }
 +
 +      // set diffuse and z depth passes
 +      RenderLayer *rl = RE_GetRenderLayer(re->result, srl->name);
 +      bool diffuse = false, z = false;
 +      for (RenderPass *rpass = (RenderPass*)rl->passes.first; rpass; rpass = rpass->next) {
 +              switch (rpass->passtype) {
 +              case SCE_PASS_DIFFUSE:
 +                      controller->setPassDiffuse(rpass->rect, rpass->rectx, rpass->recty);
 +                      diffuse = true;
 +                      break;
 +              case SCE_PASS_Z:
 +                      controller->setPassZ(rpass->rect, rpass->rectx, rpass->recty);
 +                      z = true;
 +                      break;
 +              }
 +      }
 +      if (G.debug & G_DEBUG_FREESTYLE) {
 +              cout << "Passes :" << endl;
 +              cout << "  Diffuse = " << (diffuse ? "enabled" : "disabled") << endl;
 +              cout << "  Z = " << (z ? "enabled" : "disabled") << endl;
 +      }
 +
 +      // compute view map
 +      re->i.infostr = "Freestyle: View map creation";
 +      re->stats_draw(re->sdh, &re->i);
 +      re->i.infostr = NULL;
 +      controller->ComputeViewMap();
 +}
 +
 +void FRS_composite_result(Render* re, SceneRenderLayer* srl, Render* freestyle_render)
 +{
 +      RenderLayer *rl;
 +      float *src, *dest, *pixSrc, *pixDest;
 +      int x, y, rectx, recty;
 +
 +      if (freestyle_render == NULL || freestyle_render->result == NULL)
 +              return;
 +
 +      rl = render_get_active_layer( freestyle_render, freestyle_render->result );
 +      if (!rl || rl->rectf == NULL) {
 +              if (G.debug & G_DEBUG_FREESTYLE) {
 +                      cout << "Cannot find Freestyle result image" << endl;
 +              }
 +              return;
 +      }
 +      src  = rl->rectf;
 +#if 0
 +      if (G.debug & G_DEBUG_FREESTYLE) {
 +              cout << "src: " << rl->rectx << " x " << rl->recty << endl;
 +      }
 +#endif
 +
 +      rl = RE_GetRenderLayer(re->result, srl->name);
 +      if (!rl || rl->rectf == NULL) {
 +              if (G.debug & G_DEBUG_FREESTYLE) {
 +                      cout << "No layer to composite to" << endl;
 +              }
 +              return;
 +      }
 +      dest = rl->rectf;
 +#if 0
 +      if (G.debug & G_DEBUG_FREESTYLE) {
 +              cout << "dest: " << rl->rectx << " x " << rl->recty << endl;
 +      }
 +#endif
 +
 +      rectx = re->rectx;
 +      recty = re->recty;
 +      for (y = 0; y < recty; y++) {
 +              for (x = 0; x < rectx; x++) {
 +                      pixSrc = src + 4 * (rectx * y + x);
 +                      if (pixSrc[3] > 0.0) {
 +                              pixDest = dest + 4 * (rectx * y + x);
 +                              addAlphaOverFloat(pixDest, pixSrc);
 +                      }
 +              }
 +      }
 +}
 +
 +static int displayed_layer_count(SceneRenderLayer *srl)
 +{
 +      int count = 0;
 +
 +      switch (srl->freestyleConfig.mode) {
 +      case FREESTYLE_CONTROL_SCRIPT_MODE:
 +              for (FreestyleModuleConfig *module = (FreestyleModuleConfig*)srl->freestyleConfig.modules.first;
 +                   module;
 +                   module = module->next)
 +              {
 +                      if (module->is_displayed)
 +                              count++;
 +              }
 +              break;
 +      case FREESTYLE_CONTROL_EDITOR_MODE:
 +              for (FreestyleLineSet *lineset = (FreestyleLineSet*)srl->freestyleConfig.linesets.first;
 +                   lineset;
 +                   lineset = lineset->next)
 +              {
 +                      if (lineset->flags & FREESTYLE_LINESET_ENABLED)
 +                              count++;
 +              }
 +              break;
 +      }
 +      return count;
 +}
 +
 +int FRS_is_freestyle_enabled(SceneRenderLayer *srl)
 +{
 +      return (!(srl->layflag & SCE_LAY_DISABLE) && srl->layflag & SCE_LAY_FRS && displayed_layer_count(srl) > 0);
 +}
 +
 +void FRS_init_stroke_rendering(Render *re)
 +{
 +      if (G.debug & G_DEBUG_FREESTYLE) {
 +              cout << endl;
 +              cout << "#===============================================================" << endl;
 +              cout << "#  Freestyle" << endl;
 +              cout << "#===============================================================" << endl;
 +      }
 +
 +      init_view(re);
 +      init_camera(re);
 +
 +      controller->ResetRenderCount();
 +}
 +
 +Render *FRS_do_stroke_rendering(Render *re, SceneRenderLayer *srl)
 +{
 +      Render *freestyle_render = NULL;
 +
 +      RenderMonitor monitor(re);
 +      controller->setRenderMonitor(&monitor);
 +
 +      if (G.debug & G_DEBUG_FREESTYLE) {
 +              cout << endl;
 +              cout << "----------------------------------------------------------" << endl;
 +              cout << "|  " << (re->scene->id.name + 2) << "|" << srl->name << endl;
 +              cout << "----------------------------------------------------------" << endl;
 +      }
 +
 +      // prepare Freestyle:
 +      //   - load mesh
 +      //   - add style modules
 +      //   - set parameters
 +      //   - compute view map
 +      prepare(re, srl);
 +
 +      if (re->test_break(re->tbh)) {
 +              controller->CloseFile();
 +              if (G.debug & G_DEBUG_FREESTYLE) {
 +                      cout << "Break" << endl;
 +              }
 +              return NULL;
 +      }
 +
 +      // render and composite Freestyle result
 +      if (controller->_ViewMap) {
 +              // render strokes
 +              re->i.infostr = "Freestyle: Stroke rendering";
 +              re->stats_draw(re->sdh, &re->i);
 +              re->i.infostr = NULL;
 +              freestyle_scene = re->scene;
 +              controller->DrawStrokes();
 +              freestyle_render = controller->RenderStrokes(re);
 +              controller->CloseFile();
 +              freestyle_scene = NULL;
 +
 +              // composite result
 +              FRS_composite_result(re, srl, freestyle_render);
 +              RE_FreeRenderResult(freestyle_render->result);
 +              freestyle_render->result = NULL;
 +      }
 +
 +      return freestyle_render;
 +}
 +
 +void FRS_finish_stroke_rendering(Render *re) {
 +      // clear canvas
 +      controller->Clear();
 +}
 +
 +//=======================================================
 +//   Freestyle Panel Configuration
 +//=======================================================
 +
 +void FRS_init_freestyle_config(FreestyleConfig *config)
 +{
 +      config->mode = FREESTYLE_CONTROL_SCRIPT_MODE;
 +
 +      config->modules.first = config->modules.last = NULL;
 +      config->flags = 0;
 +      config->sphere_radius = DEFAULT_SPHERE_RADIUS;
 +      config->dkr_epsilon = DEFAULT_DKR_EPSILON;
 +      config->crease_angle = DEG2RADF(120.0f);
 +
 +      config->linesets.first = config->linesets.last = NULL;
 +}
 +
 +void FRS_free_freestyle_config(FreestyleConfig *config)
 +{
 +      FreestyleLineSet *lineset;
 +
 +      for (lineset = (FreestyleLineSet*)config->linesets.first; lineset; lineset = lineset->next) {
 +              if (lineset->group) {
 +                      lineset->group->id.us--;
 +                      lineset->group = NULL;
 +              }
 +              lineset->linestyle->id.us--;
 +              lineset->linestyle = NULL;
 +      }
 +      BLI_freelistN(&config->linesets);
 +      BLI_freelistN(&config->modules);
 +}
 +
 +void FRS_copy_freestyle_config(FreestyleConfig *new_config, FreestyleConfig *config)
 +{
 +      FreestyleLineSet *lineset, *new_lineset;
 +      FreestyleModuleConfig *module, *new_module;
 +
 +      new_config->mode = config->mode;
 +      new_config->raycasting_algorithm = config->raycasting_algorithm; /* deprecated */
 +      new_config->flags = config->flags;
 +      new_config->sphere_radius = config->sphere_radius;
 +      new_config->dkr_epsilon = config->dkr_epsilon;
 +      new_config->crease_angle = config->crease_angle;
 +
 +      new_config->linesets.first = new_config->linesets.last = NULL;
 +      for (lineset = (FreestyleLineSet*)config->linesets.first; lineset; lineset = lineset->next) {
 +              new_lineset = FRS_alloc_lineset();
 +              copy_lineset(new_lineset, lineset);
 +              BLI_addtail(&new_config->linesets, (void*)new_lineset);
 +      }
 +
 +      new_config->modules.first = new_config->modules.last = NULL;
 +      for (module = (FreestyleModuleConfig*)config->modules.first; module; module = module->next) {
 +              new_module = FRS_alloc_module();
 +              copy_module(new_module, module);
 +              BLI_addtail(&new_config->modules, (void*)new_module);
 +      }
 +}
 +
 +static void copy_lineset(FreestyleLineSet *new_lineset, FreestyleLineSet *lineset)
 +{
 +      new_lineset->linestyle = lineset->linestyle;
 +      new_lineset->linestyle->id.us++;
 +      new_lineset->flags = lineset->flags;
 +      new_lineset->selection = lineset->selection;
 +      new_lineset->qi = lineset->qi;
 +      new_lineset->qi_start = lineset->qi_start;
 +      new_lineset->qi_end = lineset->qi_end;
 +      new_lineset->edge_types = lineset->edge_types;
 +      new_lineset->exclude_edge_types = lineset->exclude_edge_types;
 +      new_lineset->group = lineset->group;
 +      if (new_lineset->group) {
 +              new_lineset->group->id.us++;
 +      }
 +      strcpy(new_lineset->name, lineset->name);
 +}
 +
 +FreestyleModuleConfig *FRS_alloc_module()
 +{
 +      return (FreestyleModuleConfig*)MEM_callocN(sizeof(FreestyleModuleConfig), "style module configuration");
 +}
 +
 +void FRS_add_module(FreestyleConfig *config)
 +{
 +      FreestyleModuleConfig *module_conf = (FreestyleModuleConfig*)MEM_callocN(sizeof(FreestyleModuleConfig),
 +                                                                               "style module configuration");
 +      BLI_addtail(&config->modules, (void*)module_conf);
 +
 +      strcpy(module_conf->module_path, default_module_path.c_str());
 +      module_conf->is_displayed = 1;
 +}
 +
 +static void copy_module(FreestyleModuleConfig *new_module, FreestyleModuleConfig *module)
 +{
 +      strcpy(new_module->module_path, module->module_path);
 +      new_module->is_displayed = module->is_displayed;
 +}
 +
 +void FRS_delete_module(FreestyleConfig *config, FreestyleModuleConfig *module_conf)
 +{
 +      BLI_freelinkN(&config->modules, module_conf);
 +}
 +
 +void FRS_move_module_up(FreestyleConfig *config, FreestyleModuleConfig *module_conf)
 +{
 +      BLI_remlink(&config->modules, module_conf);
 +      BLI_insertlinkbefore(&config->modules, module_conf->prev, module_conf);
 +}
 +
 +void FRS_move_module_down(FreestyleConfig *config, FreestyleModuleConfig *module_conf)
 +{
 +      BLI_remlink(&config->modules, module_conf);
 +      BLI_insertlinkafter(&config->modules, module_conf->next, module_conf);
 +}
 +
 +static void unique_lineset_name(FreestyleConfig *config, FreestyleLineSet *lineset)
 +{
 +      BLI_uniquename(&config->linesets, lineset, "FreestyleLineSet", '.', offsetof(FreestyleLineSet, name),
 +                     sizeof(lineset->name));
 +}
 +
 +FreestyleLineSet *FRS_alloc_lineset()
 +{
 +      return (FreestyleLineSet*)MEM_callocN(sizeof(FreestyleLineSet), "Freestyle line set");
 +}
 +
 +FreestyleLineSet *FRS_add_lineset(FreestyleConfig *config)
 +{
 +      int lineset_index = BLI_countlist(&config->linesets);
 +
 +      FreestyleLineSet *lineset = FRS_alloc_lineset();
 +      BLI_addtail(&config->linesets, (void*)lineset);
 +      FRS_set_active_lineset_index(config, lineset_index);
 +
 +      lineset->linestyle = FRS_new_linestyle("LineStyle", NULL);
 +      lineset->flags |= FREESTYLE_LINESET_ENABLED;
 +      lineset->selection = FREESTYLE_SEL_IMAGE_BORDER;
 +      lineset->qi = FREESTYLE_QI_VISIBLE;
 +      lineset->qi_start = 0;
 +      lineset->qi_end = 100;
 +      lineset->edge_types = FREESTYLE_FE_SILHOUETTE | FREESTYLE_FE_BORDER | FREESTYLE_FE_CREASE;
 +      lineset->exclude_edge_types = 0;
 +      lineset->group = NULL;
 +      if (lineset_index > 0)
 +              sprintf(lineset->name, "LineSet %i", lineset_index + 1);
 +      else
 +              strcpy(lineset->name, "LineSet");
 +      unique_lineset_name(config, lineset);
 +
 +      return lineset;
 +}
 +
 +void FRS_copy_active_lineset(FreestyleConfig *config)
 +{
 +      FreestyleLineSet *lineset = FRS_get_active_lineset(config);
 +
 +      if (lineset) {
 +              lineset_buffer.linestyle = lineset->linestyle;
 +              lineset_buffer.flags = lineset->flags;
 +              lineset_buffer.selection = lineset->selection;
 +              lineset_buffer.qi = lineset->qi;
 +              lineset_buffer.qi_start = lineset->qi_start;
 +              lineset_buffer.qi_end = lineset->qi_end;
 +              lineset_buffer.edge_types = lineset->edge_types;
 +              lineset_buffer.exclude_edge_types = lineset->exclude_edge_types;
 +              lineset_buffer.group = lineset->group;
 +              strcpy(lineset_buffer.name, lineset->name);
 +              lineset_copied = true;
 +      }
 +}
 +
 +void FRS_paste_active_lineset(FreestyleConfig *config)
 +{
 +      if (!lineset_copied)
 +              return;
 +
 +      FreestyleLineSet *lineset = FRS_get_active_lineset(config);
 +
 +      if (lineset) {
 +              lineset->linestyle->id.us--;
 +              lineset->linestyle = lineset_buffer.linestyle;
 +              lineset->linestyle->id.us++;
 +              lineset->flags = lineset_buffer.flags;
 +              lineset->selection = lineset_buffer.selection;
 +              lineset->qi = lineset_buffer.qi;
 +              lineset->qi_start = lineset_buffer.qi_start;
 +              lineset->qi_end = lineset_buffer.qi_end;
 +              lineset->edge_types = lineset_buffer.edge_types;
 +              lineset->exclude_edge_types = lineset_buffer.exclude_edge_types;
 +              if (lineset->group) {
 +                      lineset->group->id.us--;
 +                      lineset->group = NULL;
 +              }
 +              if (lineset_buffer.group) {
 +                      lineset->group = lineset_buffer.group;
 +                      lineset->group->id.us++;
 +              }
 +              strcpy(lineset->name, lineset_buffer.name);
 +              unique_lineset_name(config, lineset);
 +              lineset->flags |= FREESTYLE_LINESET_CURRENT;
 +      }
 +}
 +
 +void FRS_delete_active_lineset(FreestyleConfig *config)
 +{
 +      FreestyleLineSet *lineset = FRS_get_active_lineset(config);
 +
 +      if (lineset) {
 +              if (lineset->group) {
 +                      lineset->group->id.us--;
 +                      lineset->group = NULL;
 +              }
 +              lineset->linestyle->id.us--;
 +              lineset->linestyle = NULL;
 +              BLI_remlink(&config->linesets, lineset);
 +              MEM_freeN(lineset);
 +              FRS_set_active_lineset_index(config, 0);
 +      }
 +}
 +
 +void FRS_move_active_lineset_up(FreestyleConfig *config)
 +{
 +      FreestyleLineSet *lineset = FRS_get_active_lineset(config);
 +
 +      if (lineset) {
 +              BLI_remlink(&config->linesets, lineset);
 +              BLI_insertlinkbefore(&config->linesets, lineset->prev, lineset);
 +      }
 +}
 +
 +void FRS_move_active_lineset_down(FreestyleConfig *config)
 +{
 +      FreestyleLineSet *lineset = FRS_get_active_lineset(config);
 +
 +      if (lineset) {
 +              BLI_remlink(&config->linesets, lineset);
 +              BLI_insertlinkafter(&config->linesets, lineset->next, lineset);
 +      }
 +}
 +
 +FreestyleLineSet *FRS_get_active_lineset(FreestyleConfig *config)
 +{
 +      FreestyleLineSet *lineset;
 +
 +      for (lineset = (FreestyleLineSet*)config->linesets.first; lineset; lineset = lineset->next) {
 +              if (lineset->flags & FREESTYLE_LINESET_CURRENT)
 +                      return lineset;
 +      }
 +      return NULL;
 +}
 +
 +short FRS_get_active_lineset_index(FreestyleConfig *config)
 +{
 +      FreestyleLineSet *lineset;
 +      short i;
 +
 +      for (lineset = (FreestyleLineSet*)config->linesets.first, i = 0; lineset; lineset = lineset->next, i++) {
 +              if (lineset->flags & FREESTYLE_LINESET_CURRENT)
 +                      return i;
 +      }
 +      return 0;
 +}
 +
 +void FRS_set_active_lineset_index(FreestyleConfig *config, short index)
 +{
 +      FreestyleLineSet *lineset;
 +      short i;
 +
 +      for (lineset = (FreestyleLineSet*)config->linesets.first, i = 0; lineset; lineset = lineset->next, i++) {
 +              if (i == index)
 +                      lineset->flags |= FREESTYLE_LINESET_CURRENT;
 +              else
 +                      lineset->flags &= ~FREESTYLE_LINESET_CURRENT;
 +      }
 +}
 +
 +void FRS_unlink_target_object(FreestyleConfig *config, Object *ob)
 +{
 +      FreestyleLineSet *lineset;
 +
 +      for (lineset = (FreestyleLineSet*)config->linesets.first; lineset; lineset = lineset->next) {
 +              FRS_unlink_linestyle_target_object(lineset->linestyle, ob);
 +      }
 +}
 +
 +#ifdef __cplusplus
 +} // extern "C"
 +#endif
index 6093b6e4dcd1bd0cf92fb712c61ccaaa0c8e765d,0000000000000000000000000000000000000000..3a5e45604b630c2d2b9e85cc7234364e280fb103
mode 100644,000000..100644
--- /dev/null
@@@ -1,198 -1,0 +1,198 @@@
-               Text *text = BKE_text_load(fn, G.main->name);
 +/*
 + * ***** 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.
 + *
 + * The Original Code is Copyright (C) 2010 Blender Foundation.
 + * All rights reserved.
 + *
 + * The Original Code is: all of this file.
 + *
 + * Contributor(s): none yet.
 + *
 + * ***** END GPL LICENSE BLOCK *****
 + */
 +
 +#ifndef __FREESTYLE_PYTHON_INTERPRETER_H__
 +#define __FREESTYLE_PYTHON_INTERPRETER_H__
 +
 +/** \file blender/freestyle/intern/system/PythonInterpreter.h
 + *  \ingroup freestyle
 + *  \brief Python Interpreter
 + *  \author Emmanuel Turquin
 + *  \date 17/04/2003
 + */
 +
 +#include <iostream>
 +#include <Python.h>
 +
 +#include "StringUtils.h"
 +#include "Interpreter.h"
 +
 +//soc
 +extern "C" {
 +
 +#include "MEM_guardedalloc.h"
 +
 +#include "DNA_text_types.h"
 +
 +#include "BKE_context.h"
 +#include "BKE_global.h"
 +#include "BKE_library.h"
 +#include "BKE_main.h"
 +#include "BKE_report.h"
 +#include "BKE_text.h"
 +
 +#include "BPY_extern.h"
 +
 +}
 +
 +class LIB_SYSTEM_EXPORT PythonInterpreter : public Interpreter
 +{
 +public:
 +      PythonInterpreter()
 +      {
 +              _language = "Python";
 +              _context = 0;
 +              //Py_Initialize();
 +      }
 +
 +      virtual ~PythonInterpreter()
 +      {
 +              //Py_Finalize();
 +      }
 +
 +      void setContext(bContext *C)
 +      {
 +              _context = C;
 +      }
 +
 +      int interpretFile(const string& filename)
 +      {
 +              initPath();
 +
 +              ReportList *reports = CTX_wm_reports(_context);
 +              BKE_reports_clear(reports);
 +              char *fn = const_cast<char*>(filename.c_str());
 +#if 0
 +              int status = BPY_filepath_exec(_context, fn, reports);
 +#else
 +              int status;
-               struct Text *text = BKE_text_add("tmp_freestyle_initpath.txt");
++              Text *text = BKE_text_load(G.main, fn, G.main->name);
 +              if (text) {
 +                      status = BPY_text_exec(_context, text, reports, false);
 +                      BKE_text_unlink(G.main, text);
 +                      BKE_libblock_free(&G.main->text, text);
 +              }
 +              else {
 +                      BKE_reportf(reports, RPT_ERROR, "Cannot open file: %s", fn);
 +                      status = 0;
 +              }
 +#endif
 +
 +              if (status != 1) {
 +                      cerr << "\nError executing Python script from PythonInterpreter::interpretFile" << endl;
 +                      cerr << "File: " << fn << endl;
 +                      cerr << "Errors: " << endl;
 +                      BKE_reports_print(reports, RPT_ERROR);
 +                      return 1;
 +              }
 +
 +              // cleaning up
 +              BKE_reports_clear(reports);
 +
 +              return 0;
 +      }
 +
 +      int interpretText(struct Text *text, const string& name) {
 +              initPath();
 +
 +              ReportList *reports = CTX_wm_reports(_context);
 +
 +              BKE_reports_clear(reports);
 +
 +              if (!BPY_text_exec(_context, text, reports, false)) {
 +                      cerr << "\nError executing Python script from PythonInterpreter::interpretText" << endl;
 +                      cerr << "Name: " << name << endl;
 +                      cerr << "Errors: " << endl;
 +                      BKE_reports_print(reports, RPT_ERROR);
 +                      return 1;
 +              }
 +
 +              BKE_reports_clear(reports);
 +
 +              return 0;
 +      }
 +
 +      struct Options
 +      {
 +              static void setPythonPath(const string& path)
 +              {
 +                      _path = path;
 +              }
 +
 +              static string getPythonPath()
 +              {
 +                      return _path;
 +              }
 +      };
 +
 +      void reset()
 +      {
 +              Py_Finalize();
 +              Py_Initialize();
 +              _initialized = false;
 +      }
 +
 +private:
 +      bContext *_context;
 +
 +      void initPath()
 +      {
 +              if (_initialized)
 +                      return;
 +
 +              vector<string> pathnames;
 +              StringUtils::getPathName(_path, "", pathnames);
 +
++              struct Text *text = BKE_text_add(G.main, "tmp_freestyle_initpath.txt");
 +              string cmd = "import sys\n";
 +              txt_insert_buf(text, const_cast<char*>(cmd.c_str()));
 +
 +              for (vector<string>::const_iterator it = pathnames.begin(); it != pathnames.end(); ++it) {
 +                      if (!it->empty()) {
 +                              if (G.debug & G_DEBUG_FREESTYLE) {
 +                                      cout << "Adding Python path: " << *it << endl;
 +                              }
 +                              cmd = "sys.path.append(r\"" + *it + "\")\n";
 +                              txt_insert_buf(text, const_cast<char *>(cmd.c_str()));
 +                      }
 +              }
 +
 +              BPY_text_exec(_context, text, NULL, false);
 +
 +              // cleaning up
 +              BKE_text_unlink(G.main, text);
 +              BKE_libblock_free(&G.main->text, text);
 +
 +              //PyRun_SimpleString("from Freestyle import *");
 +              _initialized = true;
 +      }
 +
 +      static bool _initialized;
 +      static string _path;
 +};
 +
 +#endif // __FREESTYLE_PYTHON_INTERPRETER_H__
Simple merge
Simple merge
Simple merge