Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/scene.c
| Show All 33 Lines | |||||
| #include <stdio.h> | #include <stdio.h> | ||||
| #include <string.h> | #include <string.h> | ||||
| #include "MEM_guardedalloc.h" | #include "MEM_guardedalloc.h" | ||||
| #include "DNA_anim_types.h" | #include "DNA_anim_types.h" | ||||
| #include "DNA_group_types.h" | #include "DNA_group_types.h" | ||||
| #include "DNA_linestyle_types.h" | #include "DNA_linestyle_types.h" | ||||
| #include "DNA_mesh_types.h" | |||||
| #include "DNA_node_types.h" | #include "DNA_node_types.h" | ||||
| #include "DNA_object_types.h" | #include "DNA_object_types.h" | ||||
| #include "DNA_rigidbody_types.h" | #include "DNA_rigidbody_types.h" | ||||
| #include "DNA_scene_types.h" | #include "DNA_scene_types.h" | ||||
| #include "DNA_screen_types.h" | #include "DNA_screen_types.h" | ||||
| #include "DNA_sequence_types.h" | #include "DNA_sequence_types.h" | ||||
| #include "DNA_space_types.h" | #include "DNA_space_types.h" | ||||
| #include "DNA_view3d_types.h" | |||||
| #include "DNA_windowmanager_types.h" | |||||
| #include "BLI_math.h" | #include "BLI_math.h" | ||||
| #include "BLI_blenlib.h" | #include "BLI_blenlib.h" | ||||
| #include "BLI_utildefines.h" | #include "BLI_utildefines.h" | ||||
| #include "BLI_callbacks.h" | #include "BLI_callbacks.h" | ||||
| #include "BLI_string.h" | #include "BLI_string.h" | ||||
| #include "BLI_threads.h" | #include "BLI_threads.h" | ||||
| #include "BLI_task.h" | #include "BLI_task.h" | ||||
| #include "BLF_translation.h" | #include "BLF_translation.h" | ||||
| #include "BKE_anim.h" | #include "BKE_anim.h" | ||||
| #include "BKE_animsys.h" | #include "BKE_animsys.h" | ||||
| #include "BKE_action.h" | #include "BKE_action.h" | ||||
| #include "BKE_colortools.h" | #include "BKE_colortools.h" | ||||
| #include "BKE_depsgraph.h" | #include "BKE_depsgraph.h" | ||||
| #include "BKE_editmesh.h" | |||||
| #include "BKE_fcurve.h" | #include "BKE_fcurve.h" | ||||
| #include "BKE_freestyle.h" | #include "BKE_freestyle.h" | ||||
| #include "BKE_global.h" | #include "BKE_global.h" | ||||
| #include "BKE_group.h" | #include "BKE_group.h" | ||||
| #include "BKE_idprop.h" | #include "BKE_idprop.h" | ||||
| #include "BKE_image.h" | #include "BKE_image.h" | ||||
| #include "BKE_library.h" | #include "BKE_library.h" | ||||
| #include "BKE_main.h" | #include "BKE_main.h" | ||||
| #include "BKE_mask.h" | #include "BKE_mask.h" | ||||
| #include "BKE_node.h" | #include "BKE_node.h" | ||||
| #include "BKE_object.h" | #include "BKE_object.h" | ||||
| #include "BKE_paint.h" | #include "BKE_paint.h" | ||||
| #include "BKE_rigidbody.h" | #include "BKE_rigidbody.h" | ||||
| #include "BKE_scene.h" | #include "BKE_scene.h" | ||||
| #include "BKE_sequencer.h" | #include "BKE_sequencer.h" | ||||
| #include "BKE_sound.h" | #include "BKE_sound.h" | ||||
| #include "BKE_world.h" | #include "BKE_world.h" | ||||
| #include "RE_engine.h" | #include "RE_engine.h" | ||||
| #include "PIL_time.h" | #include "PIL_time.h" | ||||
| #include "IMB_colormanagement.h" | #include "IMB_colormanagement.h" | ||||
| #include "bmesh.h" | |||||
| //XXX #include "BIF_previewrender.h" | //XXX #include "BIF_previewrender.h" | ||||
| //XXX #include "BIF_editseq.h" | //XXX #include "BIF_editseq.h" | ||||
| #ifdef WIN32 | #ifdef WIN32 | ||||
| #else | #else | ||||
| # include <sys/time.h> | # include <sys/time.h> | ||||
| #endif | #endif | ||||
| ▲ Show 20 Lines • Show All 1,452 Lines • ▼ Show 20 Lines | static void scene_update_tagged_recursive(EvaluationContext *eval_ctx, Main *bmain, Scene *scene, Scene *scene_parent) | ||||
| /* scene drivers... */ | /* scene drivers... */ | ||||
| scene_update_drivers(bmain, scene); | scene_update_drivers(bmain, scene); | ||||
| /* update masking curves */ | /* update masking curves */ | ||||
| BKE_mask_update_scene(bmain, scene); | BKE_mask_update_scene(bmain, scene); | ||||
| } | } | ||||
| static bool check_rendered_viewport_visible(Main *bmain) | |||||
| { | |||||
| wmWindowManager *wm = bmain->wm.first; | |||||
| wmWindow *window; | |||||
| for (window = wm->windows.first; window != NULL; window = window->next) { | |||||
| bScreen *screen = window->screen; | |||||
| ScrArea *area; | |||||
| for (area = screen->areabase.first; area != NULL; area = area->next) { | |||||
| View3D *v3d = area->spacedata.first; | |||||
| if (area->spacetype != SPACE_VIEW3D) { | |||||
| continue; | |||||
| } | |||||
| if (v3d->drawtype == OB_RENDER) { | |||||
| return true; | |||||
| } | |||||
| } | |||||
| } | |||||
| return false; | |||||
| } | |||||
| static void prepare_mesh_for_viewport_render(Main *bmain, Scene *scene) | |||||
| { | |||||
| /* This is needed to prepare mesh to be used by the render | |||||
| * engine from the viewport rendering. We do loading here | |||||
| * so all the objects which shares the same mesh datablock | |||||
| * are nicely tagged for update and updated. | |||||
| * | |||||
| * This makes it so viewport render engine doesn't need to | |||||
| * call loading of the edit data for the mesh objects. | |||||
| */ | |||||
| Object *obedit = scene->obedit; | |||||
| if (obedit) { | |||||
| Mesh *mesh = obedit->data; | |||||
| /* TODO(sergey): Check object recalc flags as well? */ | |||||
| if ((obedit->type == OB_MESH) && | |||||
| (mesh->id.flag & (LIB_ID_RECALC | LIB_ID_RECALC_DATA))) | |||||
| { | |||||
| if (check_rendered_viewport_visible(bmain)) { | |||||
| BMesh *bm = mesh->edit_btmesh->bm; | |||||
| BM_mesh_bm_to_me(bm, mesh, false); | |||||
| DAG_id_tag_update(&mesh->id, 0); | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| void BKE_scene_update_tagged(EvaluationContext *eval_ctx, Main *bmain, Scene *scene) | void BKE_scene_update_tagged(EvaluationContext *eval_ctx, Main *bmain, Scene *scene) | ||||
| { | { | ||||
| Scene *sce_iter; | Scene *sce_iter; | ||||
| /* keep this first */ | /* keep this first */ | ||||
| BLI_callback_exec(bmain, &scene->id, BLI_CB_EVT_SCENE_UPDATE_PRE); | BLI_callback_exec(bmain, &scene->id, BLI_CB_EVT_SCENE_UPDATE_PRE); | ||||
| /* (re-)build dependency graph if needed */ | /* (re-)build dependency graph if needed */ | ||||
| for (sce_iter = scene; sce_iter; sce_iter = sce_iter->set) | for (sce_iter = scene; sce_iter; sce_iter = sce_iter->set) | ||||
| DAG_scene_relations_update(bmain, sce_iter); | DAG_scene_relations_update(bmain, sce_iter); | ||||
| /* flush editing data if needed */ | |||||
| prepare_mesh_for_viewport_render(bmain, scene); | |||||
| /* flush recalc flags to dependencies */ | /* flush recalc flags to dependencies */ | ||||
| DAG_ids_flush_tagged(bmain); | DAG_ids_flush_tagged(bmain); | ||||
| /* removed calls to quick_cache, see pointcache.c */ | /* removed calls to quick_cache, see pointcache.c */ | ||||
| /* clear "LIB_DOIT" flag from all materials, to prevent infinite recursion problems later | /* clear "LIB_DOIT" flag from all materials, to prevent infinite recursion problems later | ||||
| * when trying to find materials with drivers that need evaluating [#32017] | * when trying to find materials with drivers that need evaluating [#32017] | ||||
| */ | */ | ||||
| ▲ Show 20 Lines • Show All 343 Lines • Show Last 20 Lines | |||||