Merged changes in the trunk up to revision 53146.
authorTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>
Wed, 19 Dec 2012 01:49:58 +0000 (01:49 +0000)
committerTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>
Wed, 19 Dec 2012 01:49:58 +0000 (01:49 +0000)
Conflicts resolved:
release/datafiles/startup.blend
source/blender/blenkernel/CMakeLists.txt
source/blender/blenlib/intern/bpath.c
source/blender/blenloader/intern/readfile.c

53 files changed:
1  2 
intern/cycles/blender/addon/ui.py
release/scripts/startup/bl_ui/properties_render.py
source/blender/SConscript
source/blender/blenfont/BLF_translation.h
source/blender/blenkernel/BKE_main.h
source/blender/blenkernel/CMakeLists.txt
source/blender/blenkernel/SConscript
source/blender/blenkernel/intern/library.c
source/blender/blenkernel/intern/material.c
source/blender/blenkernel/intern/object.c
source/blender/blenkernel/intern/scene.c
source/blender/blenkernel/intern/subsurf_ccg.c
source/blender/blenloader/intern/readfile.c
source/blender/blenloader/intern/writefile.c
source/blender/bmesh/bmesh_class.h
source/blender/bmesh/intern/bmesh_construct.c
source/blender/editors/animation/anim_channels_defines.c
source/blender/editors/animation/anim_channels_edit.c
source/blender/editors/include/ED_anim_api.h
source/blender/editors/include/UI_resources.h
source/blender/editors/interface/interface_templates.c
source/blender/editors/interface/resources.c
source/blender/editors/mesh/editmesh_select.c
source/blender/editors/mesh/editmesh_tools.c
source/blender/editors/render/SConscript
source/blender/editors/space_view3d/drawobject.c
source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp
source/blender/makesdna/DNA_scene_types.h
source/blender/makesdna/DNA_space_types.h
source/blender/makesdna/DNA_userdef_types.h
source/blender/makesdna/intern/makesdna.c
source/blender/makesrna/RNA_access.h
source/blender/makesrna/SConscript
source/blender/makesrna/intern/makesrna.c
source/blender/makesrna/intern/rna_action.c
source/blender/makesrna/intern/rna_main_api.c
source/blender/makesrna/intern/rna_mesh.c
source/blender/makesrna/intern/rna_scene.c
source/blender/makesrna/intern/rna_space.c
source/blender/makesrna/intern/rna_userdef.c
source/blender/python/SConscript
source/blender/python/intern/CMakeLists.txt
source/blender/python/intern/bpy.c
source/blender/render/CMakeLists.txt
source/blender/render/SConscript
source/blender/render/extern/include/RE_pipeline.h
source/blender/render/intern/include/render_types.h
source/blender/render/intern/source/convertblender.c
source/blender/render/intern/source/pipeline.c
source/blender/windowmanager/SConscript
source/blender/windowmanager/intern/wm_files.c
source/blenderplayer/bad_level_call_stubs/stubs.c
source/creator/creator.c

Simple merge
Simple merge
Simple merge
index e3b16fd92e2111623623974f8dd0f2fa95c30a8f,b350cb718c83c7690f4a92933fc6afb849c1e6ee..70a3f927b2328198ee697216c8baa83ef11c8f74
@@@ -102,10 -102,9 +103,10 @@@ set(SR
        intern/lamp.c
        intern/lattice.c
        intern/library.c
 +      intern/linestyle.c
+       intern/mask.c
        intern/mask_evaluate.c
        intern/mask_rasterize.c
-       intern/mask.c
        intern/material.c
        intern/mball.c
        intern/mesh.c
Simple merge
index ffc188c081b3111af7f22cc6e0ea9e314a31d7ce,07cb3fdc687f5d690c1fcef552e1ef669f9911e9..5c044a0a3bd6e027afba5ee9af3214df63fd1ab6
@@@ -6037,6 -6005,14 +6019,14 @@@ static void direct_link_screen(FileDat
                                sfile->op = NULL;
                                sfile->params = newdataadr(fd, sfile->params);
                        }
 -                      }
+                       else if (sl->spacetype == SPACE_CLIP) {
+                               SpaceClip *sclip = (SpaceClip *)sl;
+                               
+                               sclip->scopes.track_search = NULL;
+                               sclip->scopes.track_preview = NULL;
+                               sclip->draw_context = NULL;
+                               sclip->scopes.ok = 0;
++              }
                }
                
                sa->actionzones.first = sa->actionzones.last = NULL;
@@@ -8573,39 -8376,58 +8567,92 @@@ static void do_versions(FileData *fd, L
                }
        }
  
+       if (main->versionfile < 265 || (main->versionfile == 265 && main->subversionfile < 3)) {
+               bScreen *sc;
+               for (sc = main->screen.first; sc; sc = sc->id.next) {
+                       ScrArea *sa;
+                       for (sa = sc->areabase.first; sa; sa = sa->next) {
+                               SpaceLink *sl;
+                               for (sl = sa->spacedata.first; sl; sl = sl->next) {
+                                       switch (sl->spacetype) {
+                                               case SPACE_VIEW3D:
+                                               {
+                                                       View3D *v3d = (View3D *)sl;
+                                                       v3d->flag2 |= V3D_SHOW_GPENCIL;
+                                                       break;
+                                               }
+                                               case SPACE_SEQ:
+                                               {
+                                                       SpaceSeq *sseq = (SpaceSeq *)sl;
+                                                       sseq->flag |= SEQ_SHOW_GPENCIL;
+                                                       break;
+                                               }
+                                               case SPACE_IMAGE:
+                                               {
+                                                       SpaceImage *sima = (SpaceImage *)sl;
+                                                       sima->flag |= SI_SHOW_GPENCIL;
+                                                       break;
+                                               }
+                                               case SPACE_NODE:
+                                               {
+                                                       SpaceNode *snode = (SpaceNode *)sl;
+                                                       snode->flag |= SNODE_SHOW_GPENCIL;
+                                                       break;
+                                               }
+                                               case SPACE_CLIP:
+                                               {
+                                                       SpaceClip *sclip = (SpaceClip *)sl;
+                                                       sclip->flag |= SC_SHOW_GPENCIL;
+                                                       break;
+                                               }
+                                       }
+                               }
+                       }
+               }
+       }
+       {
+               Scene *scene;
+               for (scene = main->scene.first; scene; scene = scene->id.next) {
+                       if (scene->r.bake_rays_number == 0)
+                               scene->r.bake_rays_number = 256;
+               }
+       }
++
 +      /* 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 (linestyle->thickness_position == 0) {
 +                              linestyle->thickness_position = LS_THICKNESS_CENTER;
 +                              linestyle->thickness_ratio = 0.5f;
 +                      }
 +                      if (linestyle->chaining == 0)
 +                              linestyle->chaining = LS_CHAINING_PLAIN;
 +                      if (linestyle->rounds == 0)
 +                              linestyle->rounds = 3;
 +              }
 +      }
 +
        /* WATCH IT!!!: pointers from libdata have not been converted yet here! */
        /* WATCH IT 2!: Userdef struct init has to be in editors/interface/resources.c! */
  
@@@ -8625,8 -8447,11 +8672,11 @@@ static void lib_link_all(FileData *fd, 
  {
        oldnewmap_sort(fd);
        
 -              lib_link_windowmanager(fd, main);
 -              lib_link_screen(fd, main);
+       /* No load UI for undo memfiles */
+       if (fd->memfile == NULL) {
 +      lib_link_windowmanager(fd, main);
 +      lib_link_screen(fd, main);
+       }
        lib_link_scene(fd, main);
        lib_link_object(fd, main);
        lib_link_curve(fd, main);
@@@ -9687,29 -9505,15 +9738,35 @@@ static void expand_mask(FileData *fd, M
        }
  }
  
- static void expand_main(FileData *fd, Main *mainvar)
 +static void expand_linestyle(FileData *fd, Main *mainvar, FreestyleLineStyle *linestyle)
 +{
 +      LineStyleModifier *m;
 +
 +      if (linestyle->adt)
 +              expand_animdata(fd, mainvar, linestyle->adt);
 +      for (m = linestyle->color_modifiers.first; m; m = m->next) {
 +              if (m->type == LS_MODIFIER_DISTANCE_FROM_OBJECT)
 +                      expand_doit(fd, mainvar, ((LineStyleColorModifier_DistanceFromObject *)m)->target);
 +      }
 +      for (m = linestyle->alpha_modifiers.first; m; m = m->next){
 +              if (m->type == LS_MODIFIER_DISTANCE_FROM_OBJECT)
 +                      expand_doit(fd, mainvar, ((LineStyleAlphaModifier_DistanceFromObject *)m)->target);
 +      }
 +      for (m = linestyle->thickness_modifiers.first; m; m = m->next){
 +              if (m->type == LS_MODIFIER_DISTANCE_FROM_OBJECT)
 +                      expand_doit(fd, mainvar, ((LineStyleThicknessModifier_DistanceFromObject *)m)->target);
 +      }
 +}
 +
+ void BLO_main_expander(void (*expand_doit_func)(void *, Main *, void *))
+ {
+       expand_doit = expand_doit_func;
+ }
+ void BLO_expand_main(void *fdhandle, Main *mainvar)
  {
        ListBase *lbarray[MAX_LIBARRAY];
+       FileData *fd = fdhandle;
        ID *id;
        int a, do_it = TRUE;
        
Simple merge
index 68dfbf66ec33b7a8b951832d8dbd48adf69b9604,6ca7777f8e26f7be82da6f94dbdba9c0cc8a5256..2538ddfc8865b27f2b2cac41836c244e019fbc50
@@@ -1492,12 -1487,9 +1494,12 @@@ static int mouse_mesh_shortest_path_edg
                        case EDGE_MODE_TAG_BEVEL:
                                me->drawflag |= ME_DRAWBWEIGHTS;
                                break;
 +                      case EDGE_MODE_TAG_FREESTYLE:
 +                              me->drawflag |= ME_DRAW_FREESTYLE_EDGE;
 +                              break;
                }
                
-               EDBM_update_generic(C, em, FALSE);
+               EDBM_update_generic(em, FALSE, FALSE);
  
                return TRUE;
        }
index e7f974053907cdf16330a5a7b1bb81a316c71826,0000000000000000000000000000000000000000..f2ce7df0f6c5411327f8ad16a4d2d8467d60b893
mode 100644,000000..100644
--- /dev/null
@@@ -1,493 -1,0 +1,493 @@@
-       freestyle_scene = BKE_scene_add(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/BlenderStrokeRenderer.cpp
 + *  \ingroup freestyle
 + */
 +
 +#include "BlenderStrokeRenderer.h"
 +#include "BlenderTextureManager.h"
 +
 +#include "../application/AppConfig.h"
 +#include "../stroke/Canvas.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);
 +
 +      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
 +      material = BKE_material_add("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);
 +              //cout << "removing " << name[0] << name[1] << ":" << (name+2) << endl;
 +              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];
 +      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 = BKE_object_add_only_object(OB_MESH, name);
 +      BLI_snprintf(name, MAX_ID_NAME, "0%08xME", mesh_id);
 +      ob->data = BKE_mesh_add(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);
 +#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;
 +      //cout << "clipsta " << camera->clipsta << ", clipend " << camera->clipend << endl;
 +
 +      Render *freestyle_render = RE_NewRender(freestyle_scene->id.name);
 +
 +      RE_RenderFreestyleStrokes(freestyle_render, G.main, freestyle_scene);
 +      return freestyle_render;
 +}
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
index 24b0830e6511fd4a2536bdd8999c23c9b3313991,413d7cb959e0bf10c2f15215c1f6d3c5f2edeee4..39df6a01f61f8441a44d4a5509404157f5f62a4c
@@@ -943,10 -940,11 +943,13 @@@ void RE_TileProcessor(Render *re
  
  /* ************  This part uses API, for rendering Blender scenes ********** */
  
 +static void add_freestyle(Render *re);
 +
  static void do_render_3d(Render *re)
  {
+       float cfra;
+       int cfra_backup;
        /* try external */
        if (RE_engine_render(re, 0))
                return;
Simple merge