diff options
Diffstat (limited to 'source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp')
-rw-r--r-- | source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp | 40 |
1 files changed, 18 insertions, 22 deletions
diff --git a/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp b/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp index 9c478c203e7..322acd9966c 100644 --- a/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp +++ b/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp @@ -43,8 +43,8 @@ extern "C" { #include "DNA_screen_types.h" #include "DNA_scene_types.h" +#include "BKE_collection.h" #include "BKE_customdata.h" -#include "BKE_depsgraph.h" #include "BKE_global.h" #include "BKE_library.h" /* free_libblock */ #include "BKE_material.h" @@ -59,6 +59,9 @@ extern "C" { #include "BLI_math_vector.h" #include "BLI_utildefines.h" +#include "DEG_depsgraph.h" +#include "DEG_depsgraph_build.h" + #include "RE_pipeline.h" #include "render_types.h" @@ -127,8 +130,8 @@ BlenderStrokeRenderer::BlenderStrokeRenderer(Render *re, int render_count) : Str BKE_scene_set_background(freestyle_bmain, freestyle_scene); // Camera - Object *object_camera = BKE_object_add(freestyle_bmain, freestyle_scene, OB_CAMERA, NULL); - DAG_relations_tag_update(freestyle_bmain); + Object *object_camera = BKE_object_add(freestyle_bmain, freestyle_scene, (SceneLayer *)freestyle_scene->render_layers.first, OB_CAMERA, NULL); + DEG_relations_tag_update(freestyle_bmain); Camera *camera = (Camera *)object_camera->data; camera->type = CAM_ORTHO; @@ -166,7 +169,7 @@ BlenderStrokeRenderer::~BlenderStrokeRenderer() // compositor has finished. // release objects and data blocks - for (Base *b = (Base *)freestyle_scene->base.first; b; b = b->next) { + for (Base *b = (Base *)((SceneLayer *)(freestyle_scene->render_layers.first))->object_bases.first; b; b = b->next) { Object *ob = b->object; void *data = ob->data; char *name = ob->id.name; @@ -189,7 +192,6 @@ BlenderStrokeRenderer::~BlenderStrokeRenderer() cerr << "Warning: unexpected object in the scene: " << name[0] << name[1] << ":" << (name + 2) << endl; } } - BLI_freelistN(&freestyle_scene->base); // release materials Link *lnk = (Link *)freestyle_bmain->mat.first; @@ -510,7 +512,7 @@ void BlenderStrokeRenderer::RenderStrokeRepBasic(StrokeRep *iStrokeRep) const // If still no material, create one if (!has_mat) { Material *ma = BKE_material_add(freestyle_bmain, "stroke_material"); - DAG_relations_tag_update(freestyle_bmain); + DEG_relations_tag_update(freestyle_bmain); ma->mode |= MA_VERTEXCOLP; ma->mode |= MA_TRANSP; ma->mode |= MA_SHLESS; @@ -674,8 +676,8 @@ int BlenderStrokeRenderer::get_stroke_count() const void BlenderStrokeRenderer::GenerateStrokeMesh(StrokeGroup *group, bool hasTex) { #if 0 - Object *object_mesh = BKE_object_add(freestyle_bmain, freestyle_scene, OB_MESH); - DAG_relations_tag_update(freestyle_bmain); + Object *object_mesh = BKE_object_add(freestyle_bmain, freestyle_scene, (SceneLayer *)freestyle_scene->render_layers.first, OB_MESH); + DEG_relations_tag_update(freestyle_bmain); #else Object *object_mesh = NewMesh(); #endif @@ -700,17 +702,13 @@ void BlenderStrokeRenderer::GenerateStrokeMesh(StrokeGroup *group, bool hasTex) if (hasTex) { // First UV layer - CustomData_add_layer_named(&mesh->pdata, CD_MTEXPOLY, CD_CALLOC, NULL, mesh->totpoly, uvNames[0]); CustomData_add_layer_named(&mesh->ldata, CD_MLOOPUV, CD_CALLOC, NULL, mesh->totloop, uvNames[0]); - CustomData_set_layer_active(&mesh->pdata, CD_MTEXPOLY, 0); CustomData_set_layer_active(&mesh->ldata, CD_MLOOPUV, 0); BKE_mesh_update_customdata_pointers(mesh, true); loopsuv[0] = mesh->mloopuv; // Second UV layer - CustomData_add_layer_named(&mesh->pdata, CD_MTEXPOLY, CD_CALLOC, NULL, mesh->totpoly, uvNames[1]); CustomData_add_layer_named(&mesh->ldata, CD_MLOOPUV, CD_CALLOC, NULL, mesh->totloop, uvNames[1]); - CustomData_set_layer_active(&mesh->pdata, CD_MTEXPOLY, 1); CustomData_set_layer_active(&mesh->ldata, CD_MLOOPUV, 1); BKE_mesh_update_customdata_pointers(mesh, true); loopsuv[1] = mesh->mloopuv; @@ -922,7 +920,6 @@ void BlenderStrokeRenderer::GenerateStrokeMesh(StrokeGroup *group, bool hasTex) Object *BlenderStrokeRenderer::NewMesh() const { Object *ob; - Base *base; char name[MAX_ID_NAME]; unsigned int mesh_id = get_stroke_mesh_id(); @@ -932,16 +929,13 @@ Object *BlenderStrokeRenderer::NewMesh() const ob->data = BKE_mesh_add(freestyle_bmain, name); ob->lay = 1; - base = BKE_scene_base_add(freestyle_scene, ob); - DAG_relations_tag_update(freestyle_bmain); -#if 0 - BKE_scene_base_deselect_all(scene); - BKE_scene_base_select(scene, base); -#else - (void)base; -#endif + SceneCollection *sc_master = BKE_collection_master(freestyle_scene); + BKE_collection_object_add(freestyle_scene, sc_master, ob); + + BKE_scene_base_add(freestyle_scene, ob); + DEG_relations_tag_update(freestyle_bmain); - DAG_id_tag_update_ex(freestyle_bmain, &ob->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME); + DEG_id_tag_update_ex(freestyle_bmain, &ob->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME); return ob; } @@ -958,6 +952,8 @@ Render *BlenderStrokeRenderer::RenderScene(Render * /*re*/, bool render) #endif Render *freestyle_render = RE_NewSceneRender(freestyle_scene); + DEG_scene_relations_update(freestyle_bmain, freestyle_scene); + freestyle_render->depsgraph = freestyle_scene->depsgraph_legacy; RE_RenderFreestyleStrokes(freestyle_render, freestyle_bmain, freestyle_scene, render && get_stroke_count() > 0); |