diff options
author | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2013-04-24 02:40:13 +0400 |
---|---|---|
committer | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2013-04-24 02:40:13 +0400 |
commit | a1ed1dd26b622604a3488e7599943b65817d3411 (patch) | |
tree | ca427dc279d1808a4547af14245c973411331e81 | |
parent | 9465ecf63494e069684e6792ac651e80488ce914 (diff) |
Fix for full-sample anti-aliasing (FSAA) not working with Freestyle.
Reverted the trunk revision 56136 and part of revision 56127 concerning the local Main
for Freestyle and temporary scene generation for stroke rendering.
The function do_merge_fullsample() in pipeline.c has access to the Scene of each Render,
so that the temporary Scene generated by Freestyle has to be kept for FSAA even after
stroke rendering has been done. By the same token, the local Main has been moved from
the BlenderStrokeRenderer class to Render. It is noted that free_all_freestyle_renders()
in pipeline.c is intended to get the temporary Scene of each Render released specifically
taking account of the FSAA case.
4 files changed, 27 insertions, 24 deletions
diff --git a/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp b/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp index 4cb74776573..124905cbe8a 100644 --- a/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp +++ b/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp @@ -57,7 +57,7 @@ namespace Freestyle { BlenderStrokeRenderer::BlenderStrokeRenderer(Render *re, int render_count) : StrokeRenderer() { - memset(&_freestyle_bmain, 0, sizeof(Main)); + freestyle_bmain = &re->freestyle_bmain; // TEMPORARY - need a texture manager _textureManager = new BlenderTextureManager; @@ -71,7 +71,7 @@ BlenderStrokeRenderer::BlenderStrokeRenderer(Render *re, int render_count) : Str char name[22]; BLI_snprintf(name, sizeof(name), "FRS%d_%s", render_count, re->scene->id.name + 2); - freestyle_scene = BKE_scene_add(&_freestyle_bmain, name); + freestyle_scene = BKE_scene_add(freestyle_bmain, 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); @@ -114,10 +114,10 @@ BlenderStrokeRenderer::BlenderStrokeRenderer(Render *re, int render_count) : Str SceneRenderLayer *srl = (SceneRenderLayer *)freestyle_scene->r.layers.first; srl->layflag = SCE_LAY_SOLID | SCE_LAY_ZTRA; - BKE_scene_set_background(&_freestyle_bmain, freestyle_scene); + BKE_scene_set_background(freestyle_bmain, freestyle_scene); // Camera - Object *object_camera = BKE_object_add(&_freestyle_bmain, freestyle_scene, OB_CAMERA); + Object *object_camera = BKE_object_add(freestyle_bmain, freestyle_scene, OB_CAMERA); Camera *camera = (Camera *)object_camera->data; camera->type = CAM_ORTHO; @@ -135,7 +135,7 @@ BlenderStrokeRenderer::BlenderStrokeRenderer(Render *re, int render_count) : Str freestyle_scene->camera = object_camera; // Material - material = BKE_material_add(&_freestyle_bmain, "stroke_material"); + material = BKE_material_add(freestyle_bmain, "stroke_material"); material->mode |= MA_VERTEXCOLP; material->mode |= MA_TRANSP; material->mode |= MA_SHLESS; @@ -169,12 +169,12 @@ BlenderStrokeRenderer::~BlenderStrokeRenderer() #endif switch (ob->type) { case OB_MESH: - BKE_libblock_free(&_freestyle_bmain.object, ob); - BKE_libblock_free(&_freestyle_bmain.mesh, data); + BKE_libblock_free(&freestyle_bmain->object, ob); + BKE_libblock_free(&freestyle_bmain->mesh, data); break; case OB_CAMERA: - BKE_libblock_free(&_freestyle_bmain.object, ob); - BKE_libblock_free(&_freestyle_bmain.camera, data); + BKE_libblock_free(&freestyle_bmain->object, ob); + BKE_libblock_free(&freestyle_bmain->camera, data); freestyle_scene->camera = NULL; break; default: @@ -184,9 +184,7 @@ BlenderStrokeRenderer::~BlenderStrokeRenderer() BLI_freelistN(&freestyle_scene->base); // release material - BKE_libblock_free(&_freestyle_bmain.mat, material); - - BKE_scene_unlink(&_freestyle_bmain, freestyle_scene, NULL); + BKE_libblock_free(&freestyle_bmain->mat, material); } float BlenderStrokeRenderer::get_stroke_vertex_z(void) const @@ -270,7 +268,7 @@ void BlenderStrokeRenderer::RenderStrokeRepBasic(StrokeRep *iStrokeRep) const //me = Mesh.New() #if 0 - Object *object_mesh = BKE_object_add(&_freestyle_bmain, freestyle_scene, OB_MESH); + Object *object_mesh = BKE_object_add(freestyle_bmain, freestyle_scene, OB_MESH); #else Object *object_mesh = NewMesh(); #endif @@ -278,7 +276,7 @@ void BlenderStrokeRenderer::RenderStrokeRepBasic(StrokeRep *iStrokeRep) const mesh->mat = (Material **)MEM_mallocN(1 * sizeof(Material *), "MaterialList"); mesh->mat[0] = material; mesh->totcol = 1; - test_object_materials((Main *) &_freestyle_bmain, (ID *)mesh); + test_object_materials(freestyle_bmain, (ID *)mesh); // vertices allocation mesh->totvert = visible_faces + visible_segments * 2; @@ -461,9 +459,9 @@ Object *BlenderStrokeRenderer::NewMesh() const /* XXX this is for later review, for now we start names with 27 (DEL) to allow ignoring them in DAG_ids_check_recalc() */ BLI_snprintf(name, MAX_ID_NAME, "%c0%08xOB", 27, mesh_id); - ob = BKE_object_add_only_object((Main *) &_freestyle_bmain, OB_MESH, name); + ob = BKE_object_add_only_object(freestyle_bmain, OB_MESH, name); BLI_snprintf(name, MAX_ID_NAME, "%c0%08xME", 27, mesh_id); - ob->data = BKE_mesh_add((Main *) &_freestyle_bmain, name); + ob->data = BKE_mesh_add(freestyle_bmain, name); ob->lay = 1; base = BKE_scene_base_add(freestyle_scene, ob); @@ -491,11 +489,7 @@ Render *BlenderStrokeRenderer::RenderScene(Render *re) Render *freestyle_render = RE_NewRender(freestyle_scene->id.name); - RE_RenderFreestyleStrokes(freestyle_render, &_freestyle_bmain, freestyle_scene); - - // rendering is done, scene would be freed in destructor, - // no need to store it's in render structure - freestyle_render->scene = NULL; + RE_RenderFreestyleStrokes(freestyle_render, freestyle_bmain, freestyle_scene); return freestyle_render; } diff --git a/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.h b/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.h index 4a80e8ce7e2..4d34f70f689 100644 --- a/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.h +++ b/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.h @@ -54,7 +54,7 @@ public: Render *RenderScene(Render *re); protected: - Main _freestyle_bmain; + Main *freestyle_bmain; Scene *old_scene; Scene *freestyle_scene; Material *material; diff --git a/source/blender/render/intern/include/render_types.h b/source/blender/render/intern/include/render_types.h index eb2f1cb5826..4706cd02dd1 100644 --- a/source/blender/render/intern/include/render_types.h +++ b/source/blender/render/intern/include/render_types.h @@ -44,6 +44,8 @@ #include "BLI_threads.h" +#include "BKE_main.h" + #include "RE_pipeline.h" #include "RE_shader_ext.h" /* TexResult, ShadeResult, ShadeInput */ #include "sunsky.h" @@ -237,6 +239,7 @@ struct Render ListBase volume_precache_parts; #ifdef WITH_FREESTYLE + struct Main freestyle_bmain; ListBase freestyle_renders; #endif diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c index d765547296f..5510c07e19c 100644 --- a/source/blender/render/intern/source/pipeline.c +++ b/source/blender/render/intern/source/pipeline.c @@ -1529,6 +1529,11 @@ static void tag_scenes_for_render(Render *re) for (sce = re->main->scene.first; sce; sce = sce->id.next) sce->id.flag &= ~LIB_DOIT; +#ifdef WITH_FREESTYLE + for (sce = re->freestyle_bmain.scene.first; sce; sce = sce->id.next) + sce->id.flag &= ~LIB_DOIT; +#endif + if (RE_GetCamera(re) && composite_needs_render(re->scene, 1)) re->scene->id.flag |= LIB_DOIT; @@ -1662,10 +1667,11 @@ static void free_all_freestyle_renders(void) for (link = (LinkData *)re1->freestyle_renders.first; link; link = link->next) { if (link->data) { freestyle_render = (Render *)link->data; + BKE_scene_unlink(&re1->freestyle_bmain, freestyle_render->scene, NULL); RE_FreeRender(freestyle_render); } } - BLI_freelistN( &re1->freestyle_renders ); + BLI_freelistN(&re1->freestyle_renders); } } #endif @@ -1711,7 +1717,7 @@ static void do_merge_fullsample(Render *re, bNodeTree *ntree) BLI_rw_mutex_lock(&re->resultmutex, THREAD_LOCK_WRITE); render_result_exr_file_read(re1, sample); #ifdef WITH_FREESTYLE - if( re1->r.mode & R_EDGE_FRS) + if (re1->r.mode & R_EDGE_FRS) composite_freestyle_renders(re1, sample); #endif BLI_rw_mutex_unlock(&re->resultmutex); |