diff options
Diffstat (limited to 'source/blender/blenkernel/intern/scene.c')
-rw-r--r-- | source/blender/blenkernel/intern/scene.c | 54 |
1 files changed, 47 insertions, 7 deletions
diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index 19c2ff10901..cc656775c14 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -58,7 +58,7 @@ #include "BLI_threads.h" #include "BLI_task.h" -#include "BLF_translation.h" +#include "BLT_translation.h" #include "BKE_anim.h" #include "BKE_animsys.h" @@ -72,6 +72,7 @@ #include "BKE_global.h" #include "BKE_gpencil.h" #include "BKE_group.h" +#include "BKE_icons.h" #include "BKE_idprop.h" #include "BKE_image.h" #include "BKE_library.h" @@ -346,6 +347,10 @@ Scene *BKE_scene_copy(Scene *sce, int type) } } + if (sce->preview) { + scen->preview = BKE_previewimg_copy(sce->preview); + } + return scen; } @@ -455,17 +460,19 @@ void BKE_scene_free(Scene *sce) BKE_sound_destroy_scene(sce); BKE_color_managed_view_settings_free(&sce->view_settings); + + BKE_previewimg_free(&sce->preview); } -Scene *BKE_scene_add(Main *bmain, const char *name) +void BKE_scene_init(Scene *sce) { - Scene *sce; ParticleEditSettings *pset; int a; const char *colorspace_name; SceneRenderView *srv; - sce = BKE_libblock_alloc(bmain, ID_SCE, name); + BLI_assert(MEMCMP_STRUCT_OFS_IS_ZERO(sce, id)); + sce->lay = sce->layact = 1; sce->r.mode = R_GAMMA | R_OSA | R_SHADOW | R_SSS | R_ENVMAP | R_RAYTRACE; @@ -735,6 +742,17 @@ Scene *BKE_scene_add(Main *bmain, const char *name) copy_v2_fl2(sce->safe_areas.title_center, 17.5f / 100.0f, 5.0f / 100.0f); copy_v2_fl2(sce->safe_areas.action_center, 15.0f / 100.0f, 5.0f / 100.0f); + sce->preview = NULL; +} + +Scene *BKE_scene_add(Main *bmain, const char *name) +{ + Scene *sce; + + sce = BKE_libblock_alloc(bmain, ID_SCE, name); + + BKE_scene_init(sce); + return sce; } @@ -756,6 +774,11 @@ Base *BKE_scene_base_find(Scene *scene, Object *ob) return BLI_findptr(&scene->base, ob, offsetof(Base, object)); } +/** + * Sets the active scene, mainly used when running in background mode (``--scene`` command line argument). + * This is also called to set the scene directly, bypassing windowing code. + * Otherwise #ED_screen_set_scene is used when changing scenes by the user. + */ void BKE_scene_set_background(Main *bmain, Scene *scene) { Scene *sce; @@ -1346,7 +1369,7 @@ static void scene_do_rb_simulation_recursive(Scene *scene, float ctime) * * Ideally Mballs shouldn't do such an iteration and use DAG * queries instead. For the time being we've got new DAG - * let's keep it simple and update mballs in a ingle thread. + * let's keep it simple and update mballs in a single thread. */ #define MBALL_SINGLETHREAD_HACK @@ -1573,6 +1596,16 @@ static void scene_free_unused_opensubdiv_cache(Scene *scene) if (md != NULL && md->type == eModifierType_Subsurf) { SubsurfModifierData *smd = (SubsurfModifierData *) md; bool object_in_editmode = object->mode == OB_MODE_EDIT; + if (!smd->use_opensubdiv || + DAG_get_eval_flags_for_object(scene, object) & DAG_EVAL_NEED_CPU) + { + if (smd->mCache != NULL) { + ccgSubSurf_free_osd_mesh(smd->mCache); + } + if (smd->emCache != NULL) { + ccgSubSurf_free_osd_mesh(smd->emCache); + } + } if (object_in_editmode && smd->mCache != NULL) { ccgSubSurf_free(smd->mCache); smd->mCache = NULL; @@ -1782,6 +1815,11 @@ void BKE_scene_update_tagged(EvaluationContext *eval_ctx, Main *bmain, Scene *sc else #endif { +#ifdef OPENSUBDIV_GL_WORKAROUND + if (DEG_needs_eval(scene->depsgraph)) { + scene_free_unused_opensubdiv_cache(scene); + } +#endif DEG_evaluate_on_refresh(eval_ctx, scene->depsgraph, scene); /* TODO(sergey): This is to beocme a node in new depsgraph. */ BKE_mask_update_scene(bmain, scene); @@ -1863,6 +1901,8 @@ void BKE_scene_update_for_newframe_ex(EvaluationContext *eval_ctx, Main *bmain, (void) do_invisible_flush; #endif + DAG_editors_update_pre(bmain, sce, true); + /* keep this first */ BLI_callback_exec(bmain, &sce->id, BLI_CB_EVT_FRAME_CHANGE_PRE); BLI_callback_exec(bmain, &sce->id, BLI_CB_EVT_SCENE_UPDATE_PRE); @@ -2143,8 +2183,8 @@ bool BKE_scene_use_new_shading_nodes(const Scene *scene) bool BKE_scene_use_shading_nodes_custom(Scene *scene) { - RenderEngineType *type = RE_engines_find(scene->r.engine); - return (type && type->flag & RE_USE_SHADING_NODES_CUSTOM); + RenderEngineType *type = RE_engines_find(scene->r.engine); + return (type && type->flag & RE_USE_SHADING_NODES_CUSTOM); } bool BKE_scene_uses_blender_internal(const Scene *scene) |