Depsgraph: add helper to ensure a given scene/view_layer graph is up-to-date.

Since that call make the graph active, it should only be used in active
editing context aware code (i.e. essentially, operators).
This commit is contained in:
Bastien Montagne 2018-08-03 10:13:33 +02:00
parent f55863acd4
commit b5a1e3d471
2 changed files with 15 additions and 0 deletions

View File

@ -147,6 +147,9 @@ void BKE_scene_graph_update_tagged(struct Depsgraph *depsgraph,
void BKE_scene_graph_update_for_newframe(struct Depsgraph *depsgraph,
struct Main *bmain);
void BKE_scene_view_layer_graph_evaluated_ensure(
struct Main *bmain, struct Scene *scene, struct ViewLayer *view_layer);
struct SceneRenderView *BKE_scene_add_render_view(struct Scene *sce, const char *name);
bool BKE_scene_remove_render_view(struct Scene *scene, struct SceneRenderView *srv);

View File

@ -1477,6 +1477,18 @@ void BKE_scene_graph_update_for_newframe(Depsgraph *depsgraph,
DEG_ids_clear_recalc(bmain, depsgraph);
}
/** Ensures given scene/view_layer pair has a valid, up-to-date depsgraph.
*
* \warning Sets matching depsgraph as active, so should only be called from the active editing context
* (usually, from operators).
*/
void BKE_scene_view_layer_graph_evaluated_ensure(Main *bmain, Scene *scene, ViewLayer *view_layer)
{
Depsgraph *depsgraph = BKE_scene_get_depsgraph(scene, view_layer, true);
DEG_make_active(depsgraph);
BKE_scene_graph_update_tagged(depsgraph, bmain);
}
/* return default view */
SceneRenderView *BKE_scene_add_render_view(Scene *sce, const char *name)
{