Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2017-07-24 15:50:26 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2017-07-24 15:50:26 +0300
commitbbb1c0a077eaee74f0a3d6872e8513f756bc65a6 (patch)
tree4c2f1f2b9680a081b9916c690921c42ef08f14d3 /source/blender
parent4fd3582b32c56692a74c2719b2f064847418491a (diff)
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.
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/editors/render/render_preview.c19
1 files changed, 15 insertions, 4 deletions
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 {