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:
authorJeroen Bakker <jeroen@blender.org>2021-07-21 10:35:21 +0300
committerJeroen Bakker <jeroen@blender.org>2021-07-21 10:35:21 +0300
commit9aa0a3f5335496481305ac63af4dd09fb6f449b4 (patch)
tree06003d765f76afd3fc5ceef29a58acecd3d8dcd9
parent75e41b127941613acd76514c6d8d0bd8cec19079 (diff)
Cleanup Preview rendering: Separate world preparation.
Small cleanup that moves world preparation out of scene preparation.
-rw-r--r--source/blender/editors/render/render_preview.c54
1 files changed, 40 insertions, 14 deletions
diff --git a/source/blender/editors/render/render_preview.c b/source/blender/editors/render/render_preview.c
index 259bbc2353e..36ca7718c7a 100644
--- a/source/blender/editors/render/render_preview.c
+++ b/source/blender/editors/render/render_preview.c
@@ -348,6 +348,38 @@ static ID *duplicate_ids(ID *id, const bool allow_failure)
}
}
+static World *preview_get_world(Main *pr_main)
+{
+ World *result = NULL;
+ const char *world_name = "World";
+ result = BLI_findstring(&pr_main->worlds, world_name, offsetof(ID, name) + 2);
+
+ /* No world found return first world. */
+ if (result == NULL) {
+ result = pr_main->worlds.first;
+ }
+
+ BLI_assert(result & "Preview file has no world.");
+ return result;
+}
+
+static void preview_sync_exposure(World *dst, const World *src)
+{
+ BLI_assert(dst);
+ BLI_assert(src);
+ dst->exp = src->exp;
+ dst->range = src->range;
+}
+
+static World *preview_prepare_world(Main *pr_main, const World *world)
+{
+ World *result = preview_get_world(pr_main);
+ if (world) {
+ preview_sync_exposure(result, world);
+ }
+ return result;
+}
+
/* 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(
@@ -368,13 +400,7 @@ static Scene *preview_prepare_scene(
/* this flag tells render to not execute depsgraph or ipos etc */
sce->r.scemode |= R_BUTS_PREVIEW;
- /* set world always back, is used now */
- sce->world = pr_main->worlds.first;
- /* now: exposure copy */
- if (scene->world) {
- sce->world->exp = scene->world->exp;
- sce->world->range = scene->world->range;
- }
+ BLI_strncpy(sce->r.engine, scene->r.engine, sizeof(sce->r.engine));
sce->r.color_mgt_flag = scene->r.color_mgt_flag;
BKE_color_managed_display_settings_copy(&sce->display_settings, &scene->display_settings);
@@ -400,13 +426,13 @@ static Scene *preview_prepare_scene(
sce->r.cfra = scene->r.cfra;
+ /* Setup the world. */
+ sce->world = preview_prepare_world(pr_main, scene->world);
+
if (id_type == ID_TE) {
/* Texture is not actually rendered with engine, just set dummy value. */
BLI_strncpy(sce->r.engine, RE_engine_id_BLENDER_EEVEE, sizeof(sce->r.engine));
}
- else {
- BLI_strncpy(sce->r.engine, scene->r.engine, sizeof(sce->r.engine));
- }
if (id_type == ID_MA) {
Material *mat = NULL, *origmat = (Material *)id;
@@ -689,8 +715,8 @@ void ED_preview_draw(const bContext *C, void *idp, void *parentp, void *slotp, r
struct ObjectPreviewData {
/* The main for the preview, not of the current file. */
Main *pr_main;
- /* Copy of the object to create the preview for. The copy is for thread safety (and to insert it
- * into an own main). */
+ /* Copy of the object to create the preview for. The copy is for thread safety (and to insert
+ * it into an own main). */
Object *object;
int sizex;
int sizey;
@@ -1549,8 +1575,8 @@ static void icon_preview_startjob_all_sizes(void *customdata,
/* check_engine_supports_preview() checks whether the engine supports "preview mode" (think:
* Material Preview). This check is only relevant when the render function called below is
- * going to use such a mode. Object and Action render functions use Solid mode, though, so they
- * can skip this test. */
+ * going to use such a mode. Object and Action render functions use Solid mode, though, so
+ * they can skip this test. */
/* TODO: Decouple the ID-type-specific render functions from this function, so that it's not
* necessary to know here what happens inside lower-level functions. */
const bool use_solid_render_mode = (ip->id != NULL) && ELEM(GS(ip->id->name), ID_OB, ID_AC);