diff options
author | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2012-10-06 18:06:40 +0400 |
---|---|---|
committer | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2012-10-06 18:06:40 +0400 |
commit | 5d95a72916839bacbc5515022944509d6580202c (patch) | |
tree | 70d04748559e844895de6765a4c08aff8a352167 /source/blender/freestyle/intern | |
parent | e91f33101ff0999e07f7ce941f31dca793d954e7 (diff) |
An attempt to improve the performance of temporary scene generation for stroke rendering.
Many thanks to Joshua Leung (aligorith) for the performance analysis of BKE_object_add function:
http://lists.blender.org/pipermail/bf-committers/2012-October/037759.html
Diffstat (limited to 'source/blender/freestyle/intern')
-rw-r--r-- | source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp | 27 | ||||
-rw-r--r-- | source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.h | 2 |
2 files changed, 29 insertions, 0 deletions
diff --git a/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp b/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp index e7f43f71ade..a25570b1bdc 100644 --- a/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp +++ b/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp @@ -224,7 +224,11 @@ void BlenderStrokeRenderer::RenderStrokeRepBasic(StrokeRep *iStrokeRep) const{ 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; // MEM_freeN(mesh->bb); // mesh->bb= NULL; @@ -408,6 +412,29 @@ void BlenderStrokeRenderer::RenderStrokeRepBasic(StrokeRep *iStrokeRep) const{ } +// 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); + //BKE_scene_base_deselect_all(scene); + //BKE_scene_base_select(scene, base); + 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) diff --git a/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.h b/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.h index b7d8c5b95d7..022a115456f 100644 --- a/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.h +++ b/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.h @@ -29,6 +29,8 @@ public: virtual void RenderStrokeRep(StrokeRep *iStrokeRep) const; virtual void RenderStrokeRepBasic(StrokeRep *iStrokeRep) const; + Object* NewMesh() const; + Render* RenderScene(Render *re); protected: |