Cleanup: remove bmain argument from BKE_scene_graph_update_for_newframe

Reviewers: sergey

Differential Revision: https://developer.blender.org/D8613
This commit is contained in:
Jacques Lucke 2020-08-18 15:45:58 +02:00
parent f653a4f349
commit d9f7cbb8af
23 changed files with 72 additions and 54 deletions

View File

@ -145,7 +145,7 @@ void BKE_scene_update_tag_audio_volume(struct Depsgraph *, struct Scene *scene);
void BKE_scene_graph_update_tagged(struct Depsgraph *depsgraph, struct Main *bmain);
void BKE_scene_graph_evaluated_ensure(struct Depsgraph *depsgraph, struct Main *bmain);
void BKE_scene_graph_update_for_newframe(struct Depsgraph *depsgraph, struct Main *bmain);
void BKE_scene_graph_update_for_newframe(struct Depsgraph *depsgraph);
void BKE_scene_view_layer_graph_evaluated_ensure(struct Main *bmain,
struct Scene *scene,

View File

@ -4025,7 +4025,6 @@ static void ptcache_dt_to_str(char *str, double dtime)
/* if bake is not given run simulations to current frame */
void BKE_ptcache_bake(PTCacheBaker *baker)
{
Main *bmain = baker->bmain;
Scene *scene = baker->scene;
ViewLayer *view_layer = baker->view_layer;
struct Depsgraph *depsgraph = baker->depsgraph;
@ -4156,7 +4155,7 @@ void BKE_ptcache_bake(PTCacheBaker *baker)
stime = ptime = PIL_check_seconds_timer();
for (int fr = CFRA; fr <= endframe; fr += baker->quick_step, CFRA = fr) {
BKE_scene_graph_update_for_newframe(depsgraph, bmain);
BKE_scene_graph_update_for_newframe(depsgraph);
if (baker->update_progress) {
float progress = ((float)(CFRA - startframe) / (float)(endframe - startframe));
@ -4255,7 +4254,7 @@ void BKE_ptcache_bake(PTCacheBaker *baker)
CFRA = cfrao;
if (bake) { /* already on cfra unless baking */
BKE_scene_graph_update_for_newframe(depsgraph, bmain);
BKE_scene_graph_update_for_newframe(depsgraph);
}
/* TODO: call redraw all windows somehow */

View File

@ -1541,10 +1541,11 @@ void BKE_scene_graph_evaluated_ensure(Depsgraph *depsgraph, Main *bmain)
}
/* applies changes right away, does all sets too */
void BKE_scene_graph_update_for_newframe(Depsgraph *depsgraph, Main *bmain)
void BKE_scene_graph_update_for_newframe(Depsgraph *depsgraph)
{
Scene *scene = DEG_get_input_scene(depsgraph);
ViewLayer *view_layer = DEG_get_input_view_layer(depsgraph);
Main *bmain = DEG_get_bmain(depsgraph);
/* Keep this first. */
BKE_callback_exec_id(bmain, &scene->id, BKE_CB_EVT_FRAME_CHANGE_PRE);

View File

@ -3593,7 +3593,7 @@ static ImBuf *seq_render_scene_strip(const SeqRenderData *context,
/* opengl offscreen render */
depsgraph = BKE_scene_get_depsgraph(context->bmain, scene, view_layer, true);
BKE_scene_graph_update_for_newframe(depsgraph, context->bmain);
BKE_scene_graph_update_for_newframe(depsgraph);
ibuf = sequencer_view3d_fn(
/* set for OpenGL render (NULL when scrubbing) */
depsgraph,
@ -3695,7 +3695,7 @@ finally:
scene->r.subframe = orig_data.subframe;
if (is_frame_update && (depsgraph != NULL)) {
BKE_scene_graph_update_for_newframe(depsgraph, context->bmain);
BKE_scene_graph_update_for_newframe(depsgraph);
}
#ifdef DURIAN_CAMERA_SWITCH

View File

@ -55,6 +55,9 @@ struct Scene *DEG_get_input_scene(const Depsgraph *graph);
/* Get view layer that depsgraph was built for. */
struct ViewLayer *DEG_get_input_view_layer(const Depsgraph *graph);
/* Get bmain that depsgraph was built for. */
struct Main *DEG_get_bmain(const Depsgraph *graph);
/* Get evaluation mode that depsgraph was built for. */
eEvaluationMode DEG_get_mode(const Depsgraph *graph);

View File

@ -61,6 +61,12 @@ struct ViewLayer *DEG_get_input_view_layer(const Depsgraph *graph)
return deg_graph->view_layer;
}
struct Main *DEG_get_bmain(const Depsgraph *graph)
{
const deg::Depsgraph *deg_graph = reinterpret_cast<const deg::Depsgraph *>(graph);
return deg_graph->bmain;
}
eEvaluationMode DEG_get_mode(const Depsgraph *graph)
{
const deg::Depsgraph *deg_graph = reinterpret_cast<const deg::Depsgraph *>(graph);

View File

@ -69,9 +69,9 @@ typedef struct MPathTarget {
/* ........ */
/* update scene for current frame */
static void motionpaths_calc_update_scene(Main *bmain, struct Depsgraph *depsgraph)
static void motionpaths_calc_update_scene(struct Depsgraph *depsgraph)
{
BKE_scene_graph_update_for_newframe(depsgraph, bmain);
BKE_scene_graph_update_for_newframe(depsgraph);
}
Depsgraph *animviz_depsgraph_build(Main *bmain,
@ -95,7 +95,7 @@ Depsgraph *animviz_depsgraph_build(Main *bmain,
MEM_freeN(ids);
/* Update once so we can access pointers of evaluated animation data. */
motionpaths_calc_update_scene(bmain, depsgraph);
motionpaths_calc_update_scene(depsgraph);
return depsgraph;
}
@ -471,7 +471,7 @@ void animviz_calc_motionpaths(Depsgraph *depsgraph,
}
else {
/* Update relevant data for new frame. */
motionpaths_calc_update_scene(bmain, depsgraph);
motionpaths_calc_update_scene(depsgraph);
}
/* perform baking for targets */
@ -484,7 +484,7 @@ void animviz_calc_motionpaths(Depsgraph *depsgraph,
* We always have to restore the current frame though. */
CFRA = cfra;
if (range != ANIMVIZ_CALC_RANGE_CURRENT_FRAME && restore) {
motionpaths_calc_update_scene(bmain, depsgraph);
motionpaths_calc_update_scene(depsgraph);
}
if (is_active_depsgraph) {

View File

@ -3645,7 +3645,6 @@ static int gpencil_strokes_reproject_exec(bContext *C, wmOperator *op)
{
bGPdata *gpd = ED_gpencil_data_get_active(C);
Scene *scene = CTX_data_scene(C);
Main *bmain = CTX_data_main(C);
Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
ARegion *region = CTX_wm_region(C);
int oldframe = (int)DEG_get_ctime(depsgraph);
@ -3669,7 +3668,7 @@ static int gpencil_strokes_reproject_exec(bContext *C, wmOperator *op)
if ((mode == GP_REPROJECT_SURFACE) && (cfra_prv != gpf_->framenum)) {
cfra_prv = gpf_->framenum;
CFRA = gpf_->framenum;
BKE_scene_graph_update_for_newframe(depsgraph, bmain);
BKE_scene_graph_update_for_newframe(depsgraph);
}
ED_gpencil_stroke_reproject(depsgraph, &gsc, sctx, gpl, gpf_, gps, mode, keep_original);
@ -3679,7 +3678,7 @@ static int gpencil_strokes_reproject_exec(bContext *C, wmOperator *op)
/* return frame state and DB to original state */
CFRA = oldframe;
BKE_scene_graph_update_for_newframe(depsgraph, bmain);
BKE_scene_graph_update_for_newframe(depsgraph);
if (sctx != NULL) {
ED_transform_snap_object_context_destroy(sctx);

View File

@ -246,7 +246,7 @@ static int gpencil_bake_mesh_animation_exec(bContext *C, wmOperator *op)
/* Move scene to new frame. */
CFRA = i;
BKE_scene_graph_update_for_newframe(depsgraph, bmain);
BKE_scene_graph_update_for_newframe(depsgraph);
/* Loop all objects in the list. */
LISTBASE_FOREACH (GpBakeOb *, elem, &list) {
@ -287,7 +287,7 @@ static int gpencil_bake_mesh_animation_exec(bContext *C, wmOperator *op)
/* Return scene frame state and DB to original state. */
CFRA = oldframe;
BKE_scene_graph_update_for_newframe(depsgraph, bmain);
BKE_scene_graph_update_for_newframe(depsgraph);
/* Remove unused materials. */
int actcol = ob_gpencil->actcol;

View File

@ -879,7 +879,6 @@ static bool screen_opengl_render_init(bContext *C, wmOperator *op)
static void screen_opengl_render_end(bContext *C, OGLRender *oglrender)
{
Main *bmain = CTX_data_main(C);
Scene *scene = oglrender->scene;
int i;
@ -929,7 +928,7 @@ static void screen_opengl_render_end(bContext *C, OGLRender *oglrender)
if (oglrender->timer) { /* exec will not have a timer */
Depsgraph *depsgraph = oglrender->depsgraph;
scene->r.cfra = oglrender->cfrao;
BKE_scene_graph_update_for_newframe(depsgraph, bmain);
BKE_scene_graph_update_for_newframe(depsgraph);
WM_event_remove_timer(oglrender->wm, oglrender->win, oglrender->timer);
}
@ -1119,7 +1118,6 @@ static bool schedule_write_result(OGLRender *oglrender, RenderResult *rr)
static bool screen_opengl_render_anim_step(bContext *C, wmOperator *op)
{
Main *bmain = CTX_data_main(C);
OGLRender *oglrender = op->customdata;
Scene *scene = oglrender->scene;
Depsgraph *depsgraph = oglrender->depsgraph;
@ -1134,7 +1132,7 @@ static bool screen_opengl_render_anim_step(bContext *C, wmOperator *op)
CFRA++;
}
while (CFRA < oglrender->nfra) {
BKE_scene_graph_update_for_newframe(depsgraph, bmain);
BKE_scene_graph_update_for_newframe(depsgraph);
CFRA++;
}
@ -1161,7 +1159,7 @@ static bool screen_opengl_render_anim_step(bContext *C, wmOperator *op)
WM_cursor_time(oglrender->win, scene->r.cfra);
BKE_scene_graph_update_for_newframe(depsgraph, bmain);
BKE_scene_graph_update_for_newframe(depsgraph);
if (view_context) {
if (oglrender->rv3d->persp == RV3D_CAMOB && oglrender->v3d->camera &&

View File

@ -1594,7 +1594,7 @@ void ED_update_for_newframe(Main *bmain, Depsgraph *depsgraph)
ED_clip_update_frame(bmain, scene->r.cfra);
/* this function applies the changes too */
BKE_scene_graph_update_for_newframe(depsgraph, bmain);
BKE_scene_graph_update_for_newframe(depsgraph);
}
/*

View File

@ -306,7 +306,6 @@ static void SOUND_OT_update_animation_flags(wmOperatorType *ot)
static int sound_bake_animation_exec(bContext *C, wmOperator *UNUSED(op))
{
Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
/* NOTE: We will be forcefully evaluating dependency graph at every frame, so no need to ensure
* current scene state is evaluated as it will be lost anyway. */
@ -318,11 +317,11 @@ static int sound_bake_animation_exec(bContext *C, wmOperator *UNUSED(op))
for (cfra = (scene->r.sfra > 0) ? (scene->r.sfra - 1) : 0; cfra <= scene->r.efra + 1; cfra++) {
scene->r.cfra = cfra;
BKE_scene_graph_update_for_newframe(depsgraph, bmain);
BKE_scene_graph_update_for_newframe(depsgraph);
}
scene->r.cfra = oldfra;
BKE_scene_graph_update_for_newframe(depsgraph, bmain);
BKE_scene_graph_update_for_newframe(depsgraph);
return OPERATOR_FINISHED;
}

View File

@ -655,7 +655,7 @@ void FRS_do_stroke_rendering(Render *re, ViewLayer *view_layer)
ViewLayer *scene_view_layer = (ViewLayer *)BLI_findstring(
&re->scene->view_layers, view_layer->name, offsetof(ViewLayer, name));
Depsgraph *depsgraph = DEG_graph_new(re->main, re->scene, scene_view_layer, DAG_EVAL_RENDER);
BKE_scene_graph_update_for_newframe(depsgraph, re->main);
BKE_scene_graph_update_for_newframe(depsgraph);
// prepare Freestyle:
// - load mesh

View File

@ -128,7 +128,10 @@ static void deformStroke(GpencilModifierData *md,
BKE_gpencil_stroke_geometry_update(gps);
}
static void bakeModifier(Main *bmain, Depsgraph *depsgraph, GpencilModifierData *md, Object *ob)
static void bakeModifier(Main *UNUSED(bmain),
Depsgraph *depsgraph,
GpencilModifierData *md,
Object *ob)
{
Scene *scene = DEG_get_evaluated_scene(depsgraph);
Object *object_eval = DEG_get_evaluated_object(depsgraph, ob);
@ -147,7 +150,7 @@ static void bakeModifier(Main *bmain, Depsgraph *depsgraph, GpencilModifierData
* NOTE: this assumes that we don't want armature animation on non-keyframed frames
*/
CFRA = gpf->framenum;
BKE_scene_graph_update_for_newframe(depsgraph, bmain);
BKE_scene_graph_update_for_newframe(depsgraph);
/* compute armature effects on this frame */
LISTBASE_FOREACH (bGPDstroke *, gps, &gpf->strokes) {
@ -158,7 +161,7 @@ static void bakeModifier(Main *bmain, Depsgraph *depsgraph, GpencilModifierData
/* return frame state and DB to original state */
CFRA = oldframe;
BKE_scene_graph_update_for_newframe(depsgraph, bmain);
BKE_scene_graph_update_for_newframe(depsgraph);
}
static bool isDisabled(GpencilModifierData *md, int UNUSED(userRenderParams))

View File

@ -280,7 +280,10 @@ static void deformStroke(GpencilModifierData *md,
/* FIXME: Ideally we be doing this on a copy of the main depsgraph
* (i.e. one where we don't have to worry about restoring state)
*/
static void bakeModifier(Main *bmain, Depsgraph *depsgraph, GpencilModifierData *md, Object *ob)
static void bakeModifier(Main *UNUSED(bmain),
Depsgraph *depsgraph,
GpencilModifierData *md,
Object *ob)
{
HookGpencilModifierData *mmd = (HookGpencilModifierData *)md;
Scene *scene = DEG_get_evaluated_scene(depsgraph);
@ -297,7 +300,7 @@ static void bakeModifier(Main *bmain, Depsgraph *depsgraph, GpencilModifierData
* NOTE: this assumes that we don't want hook animation on non-keyframed frames
*/
CFRA = gpf->framenum;
BKE_scene_graph_update_for_newframe(depsgraph, bmain);
BKE_scene_graph_update_for_newframe(depsgraph);
/* compute hook effects on this frame */
LISTBASE_FOREACH (bGPDstroke *, gps, &gpf->strokes) {
@ -308,7 +311,7 @@ static void bakeModifier(Main *bmain, Depsgraph *depsgraph, GpencilModifierData
/* return frame state and DB to original state */
CFRA = oldframe;
BKE_scene_graph_update_for_newframe(depsgraph, bmain);
BKE_scene_graph_update_for_newframe(depsgraph);
}
static void freeData(GpencilModifierData *md)

View File

@ -126,7 +126,10 @@ static void deformStroke(GpencilModifierData *md,
/* FIXME: Ideally we be doing this on a copy of the main depsgraph
* (i.e. one where we don't have to worry about restoring state)
*/
static void bakeModifier(Main *bmain, Depsgraph *depsgraph, GpencilModifierData *md, Object *ob)
static void bakeModifier(Main *UNUSED(bmain),
Depsgraph *depsgraph,
GpencilModifierData *md,
Object *ob)
{
LatticeGpencilModifierData *mmd = (LatticeGpencilModifierData *)md;
Scene *scene = DEG_get_evaluated_scene(depsgraph);
@ -144,7 +147,7 @@ static void bakeModifier(Main *bmain, Depsgraph *depsgraph, GpencilModifierData
* NOTE: this assumes that we don't want lattice animation on non-keyframed frames
*/
CFRA = gpf->framenum;
BKE_scene_graph_update_for_newframe(depsgraph, bmain);
BKE_scene_graph_update_for_newframe(depsgraph);
/* recalculate lattice data */
BKE_gpencil_lattice_init(ob);
@ -165,7 +168,7 @@ static void bakeModifier(Main *bmain, Depsgraph *depsgraph, GpencilModifierData
/* return frame state and DB to original state */
CFRA = oldframe;
BKE_scene_graph_update_for_newframe(depsgraph, bmain);
BKE_scene_graph_update_for_newframe(depsgraph);
}
static void freeData(GpencilModifierData *md)

View File

@ -174,7 +174,10 @@ static void generateStrokes(GpencilModifierData *md, Depsgraph *depsgraph, Objec
}
}
static void bakeModifier(Main *bmain, Depsgraph *depsgraph, GpencilModifierData *md, Object *ob)
static void bakeModifier(Main *UNUSED(bmain),
Depsgraph *depsgraph,
GpencilModifierData *md,
Object *ob)
{
Scene *scene = DEG_get_evaluated_scene(depsgraph);
bGPdata *gpd = ob->data;
@ -184,7 +187,7 @@ static void bakeModifier(Main *bmain, Depsgraph *depsgraph, GpencilModifierData
LISTBASE_FOREACH (bGPDframe *, gpf, &gpl->frames) {
/* apply mirror effects on this frame */
CFRA = gpf->framenum;
BKE_scene_graph_update_for_newframe(depsgraph, bmain);
BKE_scene_graph_update_for_newframe(depsgraph);
/* compute mirror effects on this frame */
generate_geometry(md, ob, gpl, gpf);
@ -193,7 +196,7 @@ static void bakeModifier(Main *bmain, Depsgraph *depsgraph, GpencilModifierData
/* return frame state and DB to original state */
CFRA = oldframe;
BKE_scene_graph_update_for_newframe(depsgraph, bmain);
BKE_scene_graph_update_for_newframe(depsgraph);
}
static bool isDisabled(GpencilModifierData *UNUSED(md), int UNUSED(userRenderParams))

View File

@ -259,7 +259,10 @@ static void deformStroke(GpencilModifierData *md,
/* FIXME: Ideally we be doing this on a copy of the main depsgraph
* (i.e. one where we don't have to worry about restoring state)
*/
static void bakeModifier(Main *bmain, Depsgraph *depsgraph, GpencilModifierData *md, Object *ob)
static void bakeModifier(Main *UNUSED(bmain),
Depsgraph *depsgraph,
GpencilModifierData *md,
Object *ob)
{
TintGpencilModifierData *mmd = (TintGpencilModifierData *)md;
Scene *scene = DEG_get_evaluated_scene(depsgraph);
@ -276,7 +279,7 @@ static void bakeModifier(Main *bmain, Depsgraph *depsgraph, GpencilModifierData
* NOTE: this assumes that we don't want animation on non-keyframed frames
*/
CFRA = gpf->framenum;
BKE_scene_graph_update_for_newframe(depsgraph, bmain);
BKE_scene_graph_update_for_newframe(depsgraph);
/* compute effects on this frame */
LISTBASE_FOREACH (bGPDstroke *, gps, &gpf->strokes) {
@ -287,7 +290,7 @@ static void bakeModifier(Main *bmain, Depsgraph *depsgraph, GpencilModifierData
/* return frame state and DB to original state */
CFRA = oldframe;
BKE_scene_graph_update_for_newframe(depsgraph, bmain);
BKE_scene_graph_update_for_newframe(depsgraph);
}
static void freeData(GpencilModifierData *md)

View File

@ -156,7 +156,7 @@ static void export_startjob(void *customdata,
// Update the scene for the next frame to render.
scene->r.cfra = static_cast<int>(frame);
scene->r.subframe = frame - scene->r.cfra;
BKE_scene_graph_update_for_newframe(data->depsgraph, data->bmain);
BKE_scene_graph_update_for_newframe(data->depsgraph);
CLOG_INFO(&LOG, 2, "Exporting frame %.2f", frame);
ExportSubset export_subset = abc_archive->export_subset_for_frame(frame);
@ -177,7 +177,7 @@ static void export_startjob(void *customdata,
// Finish up by going back to the keyframe that was current before we started.
if (CFRA != orig_frame) {
CFRA = orig_frame;
BKE_scene_graph_update_for_newframe(data->depsgraph, data->bmain);
BKE_scene_graph_update_for_newframe(data->depsgraph);
}
data->export_ok = !data->was_canceled;

View File

@ -127,7 +127,7 @@ static void export_startjob(void *customdata,
// Update the scene for the next frame to render.
scene->r.cfra = static_cast<int>(frame);
scene->r.subframe = frame - scene->r.cfra;
BKE_scene_graph_update_for_newframe(data->depsgraph, data->bmain);
BKE_scene_graph_update_for_newframe(data->depsgraph);
iter.set_export_frame(frame);
iter.iterate_and_write();
@ -147,7 +147,7 @@ static void export_startjob(void *customdata,
// Finish up by going back to the keyframe that was current before we started.
if (CFRA != orig_frame) {
CFRA = orig_frame;
BKE_scene_graph_update_for_newframe(data->depsgraph, data->bmain);
BKE_scene_graph_update_for_newframe(data->depsgraph);
}
data->export_ok = true;

View File

@ -73,7 +73,7 @@ static void rna_Scene_frame_set(Scene *scene, Main *bmain, int frame, float subf
for (ViewLayer *view_layer = scene->view_layers.first; view_layer != NULL;
view_layer = view_layer->next) {
Depsgraph *depsgraph = BKE_scene_get_depsgraph(bmain, scene, view_layer, true);
BKE_scene_graph_update_for_newframe(depsgraph, bmain);
BKE_scene_graph_update_for_newframe(depsgraph);
}
# ifdef WITH_PYTHON

View File

@ -615,7 +615,7 @@ static void engine_depsgraph_init(RenderEngine *engine, ViewLayer *view_layer)
DEG_ids_clear_recalc(bmain, depsgraph);
}
else {
BKE_scene_graph_update_for_newframe(engine->depsgraph, bmain);
BKE_scene_graph_update_for_newframe(engine->depsgraph);
}
}
@ -637,7 +637,7 @@ void RE_engine_frame_set(RenderEngine *engine, int frame, float subframe)
CLAMP(cfra, MINAFRAME, MAXFRAME);
BKE_scene_frame_set(re->scene, cfra);
BKE_scene_graph_update_for_newframe(engine->depsgraph, re->main);
BKE_scene_graph_update_for_newframe(engine->depsgraph);
BKE_scene_camera_switch_update(re->scene);
}

View File

@ -3151,7 +3151,6 @@ static const EnumPropertyItem redraw_timer_type_items[] = {
};
static void redraw_timer_step(bContext *C,
Main *bmain,
Scene *scene,
struct Depsgraph *depsgraph,
wmWindow *win,
@ -3202,7 +3201,7 @@ static void redraw_timer_step(bContext *C,
}
else if (type == eRTAnimationStep) {
scene->r.cfra += (cfra == scene->r.cfra) ? 1 : -1;
BKE_scene_graph_update_for_newframe(depsgraph, bmain);
BKE_scene_graph_update_for_newframe(depsgraph);
}
else if (type == eRTAnimationPlay) {
/* play anim, return on same frame as started with */
@ -3215,7 +3214,7 @@ static void redraw_timer_step(bContext *C,
scene->r.cfra = scene->r.sfra;
}
BKE_scene_graph_update_for_newframe(depsgraph, bmain);
BKE_scene_graph_update_for_newframe(depsgraph);
redraw_timer_window_swap(C);
}
}
@ -3231,7 +3230,6 @@ static void redraw_timer_step(bContext *C,
static int redraw_timer_exec(bContext *C, wmOperator *op)
{
Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
wmWindow *win = CTX_wm_window(C);
ScrArea *area = CTX_wm_area(C);
@ -3256,7 +3254,7 @@ static int redraw_timer_exec(bContext *C, wmOperator *op)
wm_window_make_drawable(wm, win);
for (a = 0; a < iter; a++) {
redraw_timer_step(C, bmain, scene, depsgraph, win, area, region, type, cfra);
redraw_timer_step(C, scene, depsgraph, win, area, region, type, cfra);
iter_steps += 1;
if (time_limit != 0.0) {