[Bf-blender-cvs] [bbb1c0a077e] blender2.8: Render preview: Always make sure all ID datablocks references by objects are in bmain
Sergey Sharybin
noreply at git.blender.org
Mon Jul 24 14:54:00 CEST 2017
Commit: bbb1c0a077eaee74f0a3d6872e8513f756bc65a6
Author: Sergey Sharybin
Date: Mon Jul 24 14:50:26 2017 +0200
Branches: blender2.8
https://developer.blender.org/rBbbb1c0a077eaee74f0a3d6872e8513f756bc65a6
Render preview: Always make sure all ID datablocks references by objects are in bmain
Otherwise we'll have confused dependency graph builder, which wouldn't be able to
build proper graph.
Didn't find a way to avoid world copy here, we can probably escape with some shallow
copy here, but that will currently complicate code a lot.
Ideas to consider here:
- Use shallow copy of existing world after new ID management API is in place.
Downside would be thread safety, kind of nice to have everything local.
- Switch depsgraph away from ID_TAG and do hash lookup or so.
This will slow down depsgraph builder, but will make code more reliable.
===================================================================
M source/blender/editors/render/render_preview.c
===================================================================
diff --git a/source/blender/editors/render/render_preview.c b/source/blender/editors/render/render_preview.c
index 1a3d1ce083e..f10cf034f7e 100644
--- a/source/blender/editors/render/render_preview.c
+++ b/source/blender/editors/render/render_preview.c
@@ -318,6 +318,16 @@ static void set_preview_layer(SceneLayer *scene_layer, char pr_type)
}
}
+static World *preview_get_localized_world(ShaderPreview *sp, World *world)
+{
+ if (sp->worldcopy != NULL) {
+ return sp->worldcopy;
+ }
+ sp->worldcopy = localize_world(world);
+ BLI_addtail(&sp->pr_main->world, sp->worldcopy);
+ return sp->worldcopy;
+}
+
/* call this with a pointer to initialize preview scene */
/* call this with NULL to restore assigned ID pointers in preview scene */
static Scene *preview_prepare_scene(Main *bmain, Scene *scene, ID *id, int id_type, ShaderPreview *sp)
@@ -439,8 +449,9 @@ static Scene *preview_prepare_scene(Main *bmain, Scene *scene, ID *id, int id_ty
}
else {
/* use current scene world to light sphere */
- if (mat->pr_type == MA_SPHERE_A)
- sce->world = scene->world;
+ if (mat->pr_type == MA_SPHERE_A) {
+ sce->world = preview_get_localized_world(sp, scene->world);
+ }
}
if (sp->pr_method == PR_ICON_RENDER) {
@@ -452,7 +463,7 @@ static Scene *preview_prepare_scene(Main *bmain, Scene *scene, ID *id, int id_ty
/* same as above, use current scene world to light sphere */
if (BKE_scene_use_new_shading_nodes(scene))
- sce->world = scene->world;
+ sce->world = preview_get_localized_world(sp, scene->world);
}
}
else {
@@ -541,7 +552,7 @@ static Scene *preview_prepare_scene(Main *bmain, Scene *scene, ID *id, int id_ty
if (!BKE_scene_use_new_shading_nodes(scene)) {
if (la && la->type == LA_SUN && (la->sun_effect_type & LA_SUN_EFFECT_SKY)) {
set_preview_layer(scene_layer, MA_ATMOS);
- sce->world = scene->world;
+ sce->world = preview_get_localized_world(sp, scene->world);
sce->camera = (Object *)BLI_findstring(&pr_main->object, "CameraAtmo", offsetof(ID, name) + 2);
}
else {
More information about the Bf-blender-cvs
mailing list