From d0956e9cb3077971a9ae6c1ba9560604d5ad1ef7 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Mon, 11 Jun 2018 12:14:18 +0200 Subject: Cleanup: Moar G.main removal of Hell. This commit actually adds some G.main... but at much, much higher level than the ones it removes, so should still be better ;) --- source/blender/alembic/intern/abc_exporter.cc | 12 +++--- source/blender/alembic/intern/abc_mball.cc | 6 +-- source/blender/alembic/intern/abc_mball.h | 2 +- source/blender/blenkernel/BKE_anim.h | 17 ++++---- source/blender/blenkernel/BKE_displist.h | 11 ++--- source/blender/blenkernel/BKE_dynamicpaint.h | 4 +- source/blender/blenkernel/BKE_global.h | 7 +++- source/blender/blenkernel/BKE_group.h | 4 +- source/blender/blenkernel/BKE_mball.h | 6 ++- source/blender/blenkernel/BKE_mball_tessellate.h | 3 +- source/blender/blenkernel/BKE_object.h | 12 +++++- source/blender/blenkernel/BKE_scene.h | 2 +- source/blender/blenkernel/intern/anim.c | 2 +- source/blender/blenkernel/intern/depsgraph.c | 4 +- source/blender/blenkernel/intern/displist.c | 11 ++--- source/blender/blenkernel/intern/dynamicpaint.c | 47 +++++++++++----------- source/blender/blenkernel/intern/group.c | 5 ++- source/blender/blenkernel/intern/library.c | 6 +-- source/blender/blenkernel/intern/mball.c | 12 +++--- .../blender/blenkernel/intern/mball_tessellate.c | 13 +++--- source/blender/blenkernel/intern/mesh_convert.c | 4 +- source/blender/blenkernel/intern/object.c | 38 +++++++++-------- source/blender/blenkernel/intern/object_dupli.c | 18 +++++---- source/blender/blenkernel/intern/object_update.c | 27 +++++++------ source/blender/blenkernel/intern/pointcache.c | 2 +- source/blender/blenkernel/intern/scene.c | 27 +++++++------ source/blender/blenkernel/intern/smoke.c | 19 +++++---- .../depsgraph/intern/builder/deg_builder_nodes.cc | 3 +- .../intern/builder/deg_builder_relations.cc | 2 +- source/blender/editors/object/object_add.c | 10 ++--- source/blender/editors/object/object_modifier.c | 3 +- source/blender/editors/physics/dynamicpaint_ops.c | 2 +- source/blender/editors/space_view3d/drawobject.c | 4 +- source/blender/editors/space_view3d/view3d_draw.c | 4 +- .../editors/transform/transform_conversions.c | 2 +- .../editors/transform/transform_snap_object.c | 2 +- source/blender/gpu/intern/gpu_material.c | 2 +- source/blender/makesrna/intern/rna_meta.c | 2 +- source/blender/makesrna/intern/rna_object_api.c | 6 +-- source/blender/modifiers/intern/MOD_dynamicpaint.c | 2 +- .../blender/render/intern/source/convertblender.c | 8 ++-- 41 files changed, 211 insertions(+), 162 deletions(-) (limited to 'source') diff --git a/source/blender/alembic/intern/abc_exporter.cc b/source/blender/alembic/intern/abc_exporter.cc index 67575cb52d5..7e8f4e3cd15 100644 --- a/source/blender/alembic/intern/abc_exporter.cc +++ b/source/blender/alembic/intern/abc_exporter.cc @@ -111,7 +111,7 @@ static bool object_is_smoke_sim(Object *ob) return false; } -static bool object_type_is_exportable(EvaluationContext *eval_ctx, Scene *scene, Object *ob) +static bool object_type_is_exportable(Main *bmain, EvaluationContext *eval_ctx, Scene *scene, Object *ob) { switch (ob->type) { case OB_MESH: @@ -126,7 +126,7 @@ static bool object_type_is_exportable(EvaluationContext *eval_ctx, Scene *scene, case OB_CAMERA: return true; case OB_MBALL: - return AbcMBallWriter::isBasisBall(eval_ctx, scene, ob); + return AbcMBallWriter::isBasisBall(bmain, eval_ctx, scene, ob); default: return false; } @@ -386,11 +386,11 @@ void AbcExporter::exploreTransform(EvaluationContext *eval_ctx, Object *ob, Obje return; } - if (object_type_is_exportable(eval_ctx, m_scene, ob)) { + if (object_type_is_exportable(m_bmain, eval_ctx, m_scene, ob)) { createTransformWriter(ob, parent, dupliObParent); } - ListBase *lb = object_duplilist(eval_ctx, m_scene, ob); + ListBase *lb = object_duplilist(m_bmain, eval_ctx, m_scene, ob); if (lb) { DupliObject *link = static_cast(lb->first); @@ -506,7 +506,7 @@ void AbcExporter::exploreObject(EvaluationContext *eval_ctx, Object *ob, Object createShapeWriter(ob, dupliObParent); - ListBase *lb = object_duplilist(eval_ctx, m_scene, ob); + ListBase *lb = object_duplilist(m_bmain, eval_ctx, m_scene, ob); if (lb) { DupliObject *link = static_cast(lb->first); @@ -551,7 +551,7 @@ void AbcExporter::createParticleSystemsWriters(Object *ob, AbcTransformWriter *x void AbcExporter::createShapeWriter(Object *ob, Object *dupliObParent) { - if (!object_type_is_exportable(m_bmain->eval_ctx, m_scene, ob)) { + if (!object_type_is_exportable(m_bmain, m_bmain->eval_ctx, m_scene, ob)) { return; } diff --git a/source/blender/alembic/intern/abc_mball.cc b/source/blender/alembic/intern/abc_mball.cc index c5712daf499..05700e6024e 100644 --- a/source/blender/alembic/intern/abc_mball.cc +++ b/source/blender/alembic/intern/abc_mball.cc @@ -103,7 +103,7 @@ void AbcMBallWriter::do_write() */ EvaluationContext eval_ctx; DEG_evaluation_context_init(&eval_ctx, DAG_EVAL_RENDER); - BKE_displist_make_mball_forRender(&eval_ctx, m_scene, m_object, &disp); + BKE_displist_make_mball_forRender(m_bmain, &eval_ctx, m_scene, m_object, &disp); BKE_mesh_from_metaball(&disp, tmpmesh); BKE_displist_free(&disp); @@ -115,8 +115,8 @@ void AbcMBallWriter::do_write() m_mesh_ob->data = NULL; } -bool AbcMBallWriter::isBasisBall(EvaluationContext *eval_ctx, Scene *scene, Object *ob) +bool AbcMBallWriter::isBasisBall(Main *bmain, EvaluationContext *eval_ctx, Scene *scene, Object *ob) { - Object *basis_ob = BKE_mball_basis_find(eval_ctx, scene, ob); + Object *basis_ob = BKE_mball_basis_find(bmain, eval_ctx, scene, ob); return ob == basis_ob; } diff --git a/source/blender/alembic/intern/abc_mball.h b/source/blender/alembic/intern/abc_mball.h index 9a74006f839..46567ff3386 100644 --- a/source/blender/alembic/intern/abc_mball.h +++ b/source/blender/alembic/intern/abc_mball.h @@ -51,7 +51,7 @@ public: ~AbcMBallWriter(); - static bool isBasisBall(EvaluationContext *eval_ctx, Scene *scene, Object *ob); + static bool isBasisBall(Main *bmain, EvaluationContext *eval_ctx, Scene *scene, Object *ob); private: virtual void do_write(); diff --git a/source/blender/blenkernel/BKE_anim.h b/source/blender/blenkernel/BKE_anim.h index 584f0da323a..902331f4649 100644 --- a/source/blender/blenkernel/BKE_anim.h +++ b/source/blender/blenkernel/BKE_anim.h @@ -32,15 +32,16 @@ * \author nzc * \since March 2001 */ -struct EvaluationContext; -struct Path; -struct Object; -struct Scene; -struct ListBase; struct bAnimVizSettings; struct bMotionPath; struct bPoseChannel; +struct EvaluationContext; +struct ListBase; +struct Main; +struct Object; +struct Path; struct ReportList; +struct Scene; /* ---------------------------------------------------- */ /* Animation Visualization */ @@ -65,8 +66,10 @@ int where_on_path(struct Object *ob, float ctime, float vec[4], float dir[3], fl /* ---------------------------------------------------- */ /* Dupli-Geometry */ -struct ListBase *object_duplilist_ex(struct EvaluationContext *eval_ctx, struct Scene *sce, struct Object *ob, bool update); -struct ListBase *object_duplilist(struct EvaluationContext *eval_ctx, struct Scene *sce, struct Object *ob); +struct ListBase *object_duplilist_ex( + struct Main *bmain, struct EvaluationContext *eval_ctx, struct Scene *sce, struct Object *ob, bool update); +struct ListBase *object_duplilist( + struct Main *bmain, struct EvaluationContext *eval_ctx, struct Scene *sce, struct Object *ob); void free_object_duplilist(struct ListBase *lb); int count_duplilist(struct Object *ob); diff --git a/source/blender/blenkernel/BKE_displist.h b/source/blender/blenkernel/BKE_displist.h index 9625f05192a..f5c6fb37ccc 100644 --- a/source/blender/blenkernel/BKE_displist.h +++ b/source/blender/blenkernel/BKE_displist.h @@ -57,11 +57,12 @@ enum { /* prototypes */ -struct Scene; -struct Object; -struct ListBase; struct DerivedMesh; struct EvaluationContext; +struct ListBase; +struct Main; +struct Object; +struct Scene; /* used for curves, nurbs, mball, importing */ typedef struct DispList { @@ -92,8 +93,8 @@ void BKE_displist_make_curveTypes(struct Scene *scene, struct Object *ob, const void BKE_displist_make_curveTypes_forRender(struct Scene *scene, struct Object *ob, struct ListBase *dispbase, struct DerivedMesh **r_dm_final, const bool for_orco, const bool use_render_resolution); void BKE_displist_make_curveTypes_forOrco(struct Scene *scene, struct Object *ob, struct ListBase *dispbase); -void BKE_displist_make_mball(struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob); -void BKE_displist_make_mball_forRender(struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob, struct ListBase *dispbase); +void BKE_displist_make_mball(struct Main *bmain, struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob); +void BKE_displist_make_mball_forRender(struct Main *bmain, struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob, struct ListBase *dispbase); bool BKE_displist_surfindex_get(DispList *dl, int a, int *b, int *p1, int *p2, int *p3, int *p4); void BKE_displist_fill(struct ListBase *dispbase, struct ListBase *to, const float normal_proj[3], const bool flipnormal); diff --git a/source/blender/blenkernel/BKE_dynamicpaint.h b/source/blender/blenkernel/BKE_dynamicpaint.h index 9d738045ad1..cc1ff1a2375 100644 --- a/source/blender/blenkernel/BKE_dynamicpaint.h +++ b/source/blender/blenkernel/BKE_dynamicpaint.h @@ -28,6 +28,7 @@ */ struct EvaluationContext; +struct Main; struct Scene; /* Actual surface point */ @@ -62,7 +63,7 @@ typedef struct PaintWavePoint { } PaintWavePoint; struct DerivedMesh *dynamicPaint_Modifier_do( - struct EvaluationContext *eval_ctx, struct DynamicPaintModifierData *pmd, struct Scene *scene, + struct Main *bmain, struct EvaluationContext *eval_ctx, struct DynamicPaintModifierData *pmd, struct Scene *scene, struct Object *ob, struct DerivedMesh *dm); void dynamicPaint_Modifier_free(struct DynamicPaintModifierData *pmd); void dynamicPaint_Modifier_copy(const struct DynamicPaintModifierData *pmd, struct DynamicPaintModifierData *tsmd); @@ -87,6 +88,7 @@ struct DynamicPaintSurface *get_activeSurface(struct DynamicPaintCanvasSettings /* image sequence baking */ int dynamicPaint_createUVSurface(struct Scene *scene, struct DynamicPaintSurface *surface, float *progress, short *do_update); int dynamicPaint_calculateFrame( + struct Main *bmain, struct EvaluationContext *eval_ctx, struct DynamicPaintSurface *surface, struct Scene *scene, struct Object *cObject, int frame); void dynamicPaint_outputSurfaceImage(struct DynamicPaintSurface *surface, char *filename, short output_layer); diff --git a/source/blender/blenkernel/BKE_global.h b/source/blender/blenkernel/BKE_global.h index 45a0a765ce1..db816cb9e14 100644 --- a/source/blender/blenkernel/BKE_global.h +++ b/source/blender/blenkernel/BKE_global.h @@ -54,7 +54,7 @@ typedef struct Global { /* strings: lastsaved */ char ima[1024], lib[1024]; /* 1024 = FILE_MAX */ - /* when set: G.main->name contains valid relative base path */ + /* when set: G_MAIN->name contains valid relative base path */ bool relbase_valid; bool file_loaded; bool save_over; @@ -221,6 +221,11 @@ enum { /* Memory is allocated where? blender.c */ extern Global G; +/** + * Stupid macro to hide the few *valid* usages of G.main (from startup/exit code e.g.), helps with cleanup task. + */ +#define G_MAIN (G).main + #ifdef __cplusplus } #endif diff --git a/source/blender/blenkernel/BKE_group.h b/source/blender/blenkernel/BKE_group.h index e07dd259970..9e1ad1bc789 100644 --- a/source/blender/blenkernel/BKE_group.h +++ b/source/blender/blenkernel/BKE_group.h @@ -52,6 +52,8 @@ bool BKE_group_object_exists(struct Group *group, struct Object *ob); bool BKE_group_object_cyclic_check(struct Main *bmain, struct Object *object, struct Group *group); bool BKE_group_is_animated(struct Group *group, struct Object *parent); -void BKE_group_handle_recalc_and_update(struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *parent, struct Group *group); +void BKE_group_handle_recalc_and_update( + struct Main *bmain, struct EvaluationContext *eval_ctx, + struct Scene *scene, struct Object *parent, struct Group *group); #endif /* __BKE_GROUP_H__ */ diff --git a/source/blender/blenkernel/BKE_mball.h b/source/blender/blenkernel/BKE_mball.h index c73dd7260c4..87bc7b2dfc5 100644 --- a/source/blender/blenkernel/BKE_mball.h +++ b/source/blender/blenkernel/BKE_mball.h @@ -49,12 +49,14 @@ void BKE_mball_make_local(struct Main *bmain, struct MetaBall *mb, const bool li bool BKE_mball_is_basis_for(struct Object *ob1, struct Object *ob2); bool BKE_mball_is_basis(struct Object *ob); -struct Object *BKE_mball_basis_find(struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob); +struct Object *BKE_mball_basis_find( + struct Main *bmain, struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob); void BKE_mball_texspace_calc(struct Object *ob); float *BKE_mball_make_orco(struct Object *ob, struct ListBase *dispbase); -void BKE_mball_properties_copy(struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *active_object); +void BKE_mball_properties_copy( + struct Main *bmain, struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *active_object); bool BKE_mball_minmax(struct MetaBall *mb, float min[3], float max[3]); bool BKE_mball_minmax_ex(struct MetaBall *mb, float min[3], float max[3], diff --git a/source/blender/blenkernel/BKE_mball_tessellate.h b/source/blender/blenkernel/BKE_mball_tessellate.h index 361f31b704c..254d5e9248a 100644 --- a/source/blender/blenkernel/BKE_mball_tessellate.h +++ b/source/blender/blenkernel/BKE_mball_tessellate.h @@ -24,11 +24,12 @@ * \ingroup bke */ struct EvaluationContext; +struct Main; struct Object; struct Scene; void BKE_mball_polygonize( - struct EvaluationContext *eval_ctx, struct Scene *scene, + struct Main *bmain, struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob, struct ListBase *dispbase); void BKE_mball_cubeTable_free(void); diff --git a/source/blender/blenkernel/BKE_object.h b/source/blender/blenkernel/BKE_object.h index f9761ad4334..9d99a0ad84b 100644 --- a/source/blender/blenkernel/BKE_object.h +++ b/source/blender/blenkernel/BKE_object.h @@ -207,6 +207,7 @@ void BKE_object_eval_uber_transform( struct EvaluationContext *eval_ctx, struct Object *ob); void BKE_object_eval_uber_data( + struct Main *bmain, struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob); @@ -223,11 +224,17 @@ void BKE_object_eval_transform_all( struct Object *object); void BKE_object_handle_data_update( + struct Main *bmain, + struct EvaluationContext *eval_ctx, + struct Scene *scene, + struct Object *ob); +void BKE_object_handle_update( + struct Main *bmain, struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob); -void BKE_object_handle_update(struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob); void BKE_object_handle_update_ex( + struct Main *bmain, struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob, struct RigidBodyWorld *rbw, @@ -284,7 +291,8 @@ struct KDTree *BKE_object_as_kdtree(struct Object *ob, int *r_tot); bool BKE_object_modifier_use_time(struct Object *ob, struct ModifierData *md); bool BKE_object_modifier_update_subframe( - struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob, bool update_mesh, + struct Main *bmain, struct EvaluationContext *eval_ctx, + struct Scene *scene, struct Object *ob, bool update_mesh, int parent_recursion, float frame, int type); diff --git a/source/blender/blenkernel/BKE_scene.h b/source/blender/blenkernel/BKE_scene.h index 0e1472b7062..ae809641480 100644 --- a/source/blender/blenkernel/BKE_scene.h +++ b/source/blender/blenkernel/BKE_scene.h @@ -87,7 +87,7 @@ typedef struct SceneBaseIter { int phase; } SceneBaseIter; -int BKE_scene_base_iter_next(struct EvaluationContext *eval_ctx, struct SceneBaseIter *iter, +int BKE_scene_base_iter_next(struct Main *bmain, struct EvaluationContext *eval_ctx, struct SceneBaseIter *iter, struct Scene **scene, int val, struct Base **base, struct Object **ob); void BKE_scene_base_flag_to_objects(struct Scene *scene); diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c index a0f069bccf2..a09065f8b5d 100644 --- a/source/blender/blenkernel/intern/anim.c +++ b/source/blender/blenkernel/intern/anim.c @@ -340,7 +340,7 @@ static void motionpaths_calc_update_scene(Scene *scene) * is animated but not attached to/updatable from objects */ for (base = scene->base.first; base; base = base->next) { /* update this object */ - BKE_object_handle_update(G.main->eval_ctx, scene, base->object); + BKE_object_handle_update(G.main, G.main->eval_ctx, scene, base->object); /* if this is the last one we need to update, let's stop to save some time */ if (base == last) diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c index 80275324da6..78f564e5e5e 100644 --- a/source/blender/blenkernel/intern/depsgraph.c +++ b/source/blender/blenkernel/intern/depsgraph.c @@ -740,7 +740,7 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O } case OB_MBALL: { - Object *mom = BKE_mball_basis_find(G.main->eval_ctx, scene, ob); + Object *mom = BKE_mball_basis_find(G.main, G.main->eval_ctx, scene, ob); if (mom != ob) { node2 = dag_get_node(dag, mom); @@ -777,7 +777,7 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O if (cu->family[0] != '\n') { ListBase *duplilist; DupliObject *dob; - duplilist = object_duplilist(G.main->eval_ctx, scene, ob); + duplilist = object_duplilist(G.main, G.main->eval_ctx, scene, ob); for (dob = duplilist->first; dob; dob = dob->next) { node2 = dag_get_node(dag, dob->ob); dag_add_relation(dag, node, node2, DAG_RL_DATA_DATA | DAG_RL_OB_DATA, "Object Font"); diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c index 00e319efb7a..f59691dd70e 100644 --- a/source/blender/blenkernel/intern/displist.c +++ b/source/blender/blenkernel/intern/displist.c @@ -52,6 +52,7 @@ #include "BKE_displist.h" #include "BKE_cdderivedmesh.h" #include "BKE_object.h" +#include "BKE_main.h" #include "BKE_mball.h" #include "BKE_mball_tessellate.h" #include "BKE_curve.h" @@ -726,12 +727,12 @@ float BKE_displist_calc_taper(Scene *scene, Object *taperobj, int cur, int tot) return displist_calc_taper(scene, taperobj, fac); } -void BKE_displist_make_mball(EvaluationContext *eval_ctx, Scene *scene, Object *ob) +void BKE_displist_make_mball(Main *bmain, EvaluationContext *eval_ctx, Scene *scene, Object *ob) { if (!ob || ob->type != OB_MBALL) return; - if (ob == BKE_mball_basis_find(eval_ctx, scene, ob)) { + if (ob == BKE_mball_basis_find(bmain, eval_ctx, scene, ob)) { if (ob->curve_cache) { BKE_displist_free(&(ob->curve_cache->disp)); } @@ -739,7 +740,7 @@ void BKE_displist_make_mball(EvaluationContext *eval_ctx, Scene *scene, Object * ob->curve_cache = MEM_callocN(sizeof(CurveCache), "CurveCache for MBall"); } - BKE_mball_polygonize(eval_ctx, scene, ob, &ob->curve_cache->disp); + BKE_mball_polygonize(bmain, eval_ctx, scene, ob, &ob->curve_cache->disp); BKE_mball_texspace_calc(ob); object_deform_mball(ob, &ob->curve_cache->disp); @@ -749,9 +750,9 @@ void BKE_displist_make_mball(EvaluationContext *eval_ctx, Scene *scene, Object * } } -void BKE_displist_make_mball_forRender(EvaluationContext *eval_ctx, Scene *scene, Object *ob, ListBase *dispbase) +void BKE_displist_make_mball_forRender(Main *bmain, EvaluationContext *eval_ctx, Scene *scene, Object *ob, ListBase *dispbase) { - BKE_mball_polygonize(eval_ctx, scene, ob, dispbase); + BKE_mball_polygonize(bmain, eval_ctx, scene, ob, dispbase); BKE_mball_texspace_calc(ob); object_deform_mball(ob, dispbase); diff --git a/source/blender/blenkernel/intern/dynamicpaint.c b/source/blender/blenkernel/intern/dynamicpaint.c index 87fd10c7e7d..ab5fe1d45f5 100644 --- a/source/blender/blenkernel/intern/dynamicpaint.c +++ b/source/blender/blenkernel/intern/dynamicpaint.c @@ -2073,7 +2073,7 @@ static void canvas_copyDerivedMesh(DynamicPaintCanvasSettings *canvas, DerivedMe * Updates derived mesh copy and processes dynamic paint step / caches. */ static void dynamicPaint_frameUpdate( - EvaluationContext *eval_ctx, DynamicPaintModifierData *pmd, Scene *scene, Object *ob, DerivedMesh *dm) + Main *bmain, EvaluationContext *eval_ctx, DynamicPaintModifierData *pmd, Scene *scene, Object *ob, DerivedMesh *dm) { if (pmd->canvas) { DynamicPaintCanvasSettings *canvas = pmd->canvas; @@ -2136,7 +2136,7 @@ static void dynamicPaint_frameUpdate( else if (can_simulate) { /* calculate surface frame */ canvas->flags |= MOD_DPAINT_BAKING; - dynamicPaint_calculateFrame(eval_ctx, surface, scene, ob, current_frame); + dynamicPaint_calculateFrame(bmain, eval_ctx, surface, scene, ob, current_frame); canvas->flags &= ~MOD_DPAINT_BAKING; /* restore canvas derivedmesh if required */ @@ -2155,14 +2155,14 @@ static void dynamicPaint_frameUpdate( } /* Modifier call. Processes dynamic paint modifier step. */ -DerivedMesh *dynamicPaint_Modifier_do( +DerivedMesh *dynamicPaint_Modifier_do(Main *bmain, EvaluationContext *eval_ctx, DynamicPaintModifierData *pmd, Scene *scene, Object *ob, DerivedMesh *dm) { if (pmd->canvas) { DerivedMesh *ret; /* Update canvas data for a new frame */ - dynamicPaint_frameUpdate(eval_ctx, pmd, scene, ob, dm); + dynamicPaint_frameUpdate(bmain, eval_ctx, pmd, scene, ob, dm); /* Return output mesh */ ret = dynamicPaint_Modifier_apply(pmd, ob, dm); @@ -2171,7 +2171,7 @@ DerivedMesh *dynamicPaint_Modifier_do( } else { /* Update canvas data for a new frame */ - dynamicPaint_frameUpdate(eval_ctx, pmd, scene, ob, dm); + dynamicPaint_frameUpdate(bmain, eval_ctx, pmd, scene, ob, dm); /* Return output mesh */ return dynamicPaint_Modifier_apply(pmd, ob, dm); @@ -3746,7 +3746,7 @@ static void dynamic_paint_brush_velocity_compute_cb( } static void dynamicPaint_brushMeshCalculateVelocity( - EvaluationContext *eval_ctx, Scene *scene, + Main *bmain, EvaluationContext *eval_ctx, Scene *scene, Object *ob, DynamicPaintBrushSettings *brush, Vec3f **brushVel, float timescale) { float prev_obmat[4][4]; @@ -3769,7 +3769,7 @@ static void dynamicPaint_brushMeshCalculateVelocity( scene->r.subframe = prev_sfra; BKE_object_modifier_update_subframe( - eval_ctx, scene, ob, true, SUBFRAME_RECURSION, BKE_scene_frame_get(scene), eModifierType_DynamicPaint); + bmain, eval_ctx, scene, ob, true, SUBFRAME_RECURSION, BKE_scene_frame_get(scene), eModifierType_DynamicPaint); dm_p = CDDM_copy(brush->dm); numOfVerts_p = dm_p->getNumVerts(dm_p); mvert_p = dm_p->getVertArray(dm_p); @@ -3780,7 +3780,7 @@ static void dynamicPaint_brushMeshCalculateVelocity( scene->r.subframe = cur_sfra; BKE_object_modifier_update_subframe( - eval_ctx, scene, ob, true, SUBFRAME_RECURSION, BKE_scene_frame_get(scene), eModifierType_DynamicPaint); + bmain, eval_ctx, scene, ob, true, SUBFRAME_RECURSION, BKE_scene_frame_get(scene), eModifierType_DynamicPaint); dm_c = brush->dm; numOfVerts_c = dm_c->getNumVerts(dm_c); mvert_c = dm_p->getVertArray(dm_c); @@ -3812,7 +3812,7 @@ static void dynamicPaint_brushMeshCalculateVelocity( /* calculate velocity for object center point */ static void dynamicPaint_brushObjectCalculateVelocity( - EvaluationContext *eval_ctx, Scene *scene, Object *ob, Vec3f *brushVel, float timescale) + Main *bmain, EvaluationContext *eval_ctx, Scene *scene, Object *ob, Vec3f *brushVel, float timescale) { float prev_obmat[4][4]; float cur_loc[3] = {0.0f}, prev_loc[3] = {0.0f}; @@ -3831,14 +3831,14 @@ static void dynamicPaint_brushObjectCalculateVelocity( scene->r.cfra = prev_fra; scene->r.subframe = prev_sfra; BKE_object_modifier_update_subframe( - eval_ctx, scene, ob, false, SUBFRAME_RECURSION, BKE_scene_frame_get(scene), eModifierType_DynamicPaint); + bmain, eval_ctx, scene, ob, false, SUBFRAME_RECURSION, BKE_scene_frame_get(scene), eModifierType_DynamicPaint); copy_m4_m4(prev_obmat, ob->obmat); /* current frame dm */ scene->r.cfra = cur_fra; scene->r.subframe = cur_sfra; BKE_object_modifier_update_subframe( - eval_ctx, scene, ob, false, SUBFRAME_RECURSION, BKE_scene_frame_get(scene), eModifierType_DynamicPaint); + bmain, eval_ctx, scene, ob, false, SUBFRAME_RECURSION, BKE_scene_frame_get(scene), eModifierType_DynamicPaint); /* calculate speed */ mul_m4_v3(prev_obmat, prev_loc); @@ -4210,7 +4210,8 @@ static void dynamic_paint_paint_mesh_cell_point_cb_ex( } } -static int dynamicPaint_paintMesh(EvaluationContext *eval_ctx, +static int dynamicPaint_paintMesh(Main *bmain, + EvaluationContext *eval_ctx, DynamicPaintSurface *surface, DynamicPaintBrushSettings *brush, Object *brushOb, @@ -4227,7 +4228,7 @@ static int dynamicPaint_paintMesh(EvaluationContext *eval_ctx, const MLoop *mloop = NULL; if (brush->flags & MOD_DPAINT_USES_VELOCITY) - dynamicPaint_brushMeshCalculateVelocity(eval_ctx, scene, brushOb, brush, &brushVelocity, timescale); + dynamicPaint_brushMeshCalculateVelocity(bmain, eval_ctx, scene, brushOb, brush, &brushVelocity, timescale); if (!brush->dm) return 0; @@ -4717,7 +4718,7 @@ static void dynamic_paint_paint_single_point_cb_ex( } static int dynamicPaint_paintSinglePoint( - EvaluationContext *eval_ctx, DynamicPaintSurface *surface, float *pointCoord, DynamicPaintBrushSettings *brush, + Main *bmain, EvaluationContext *eval_ctx, DynamicPaintSurface *surface, float *pointCoord, DynamicPaintBrushSettings *brush, Object *brushOb, BrushMaterials *bMats, Scene *scene, float timescale) { PaintSurfaceData *sData = surface->data; @@ -4725,7 +4726,7 @@ static int dynamicPaint_paintSinglePoint( Vec3f brushVel; if (brush->flags & MOD_DPAINT_USES_VELOCITY) - dynamicPaint_brushObjectCalculateVelocity(eval_ctx, scene, brushOb, &brushVel, timescale); + dynamicPaint_brushObjectCalculateVelocity(bmain, eval_ctx, scene, brushOb, &brushVel, timescale); const MVert *mvert = brush->dm->getVertArray(brush->dm); @@ -6016,7 +6017,7 @@ static int dynamicPaint_generateBakeData(DynamicPaintSurface *surface, const Sce * Do Dynamic Paint step. Paints scene brush objects of current state/frame to the surface. */ static int dynamicPaint_doStep( - EvaluationContext *eval_ctx, Scene *scene, + Main *bmain, EvaluationContext *eval_ctx, Scene *scene, Object *ob, DynamicPaintSurface *surface, float timescale, float subframe) { PaintSurfaceData *sData = surface->data; @@ -6100,7 +6101,7 @@ static int dynamicPaint_doStep( /* update object data on this subframe */ if (subframe) { scene_setSubframe(scene, subframe); - BKE_object_modifier_update_subframe(eval_ctx, scene, brushObj, true, SUBFRAME_RECURSION, + BKE_object_modifier_update_subframe(bmain, eval_ctx, scene, brushObj, true, SUBFRAME_RECURSION, BKE_scene_frame_get(scene), eModifierType_DynamicPaint); } /* Prepare materials if required */ @@ -6123,11 +6124,11 @@ static int dynamicPaint_doStep( /* Object center distance: */ else if (brush->collision == MOD_DPAINT_COL_POINT && brushObj != ob) { dynamicPaint_paintSinglePoint( - eval_ctx, surface, brushObj->loc, brush, brushObj, &bMats, scene, timescale); + bmain, eval_ctx, surface, brushObj->loc, brush, brushObj, &bMats, scene, timescale); } /* Mesh volume/proximity: */ else if (brushObj != ob) { - dynamicPaint_paintMesh(eval_ctx, surface, brush, brushObj, &bMats, scene, timescale); + dynamicPaint_paintMesh(bmain, eval_ctx, surface, brush, brushObj, &bMats, scene, timescale); } /* free temp material data */ @@ -6137,7 +6138,7 @@ static int dynamicPaint_doStep( if (subframe) { scene->r.cfra = scene_frame; scene->r.subframe = scene_subframe; - BKE_object_modifier_update_subframe(eval_ctx, scene, brushObj, true, SUBFRAME_RECURSION, + BKE_object_modifier_update_subframe(bmain, eval_ctx, scene, brushObj, true, SUBFRAME_RECURSION, BKE_scene_frame_get(scene), eModifierType_DynamicPaint); } @@ -6197,7 +6198,7 @@ static int dynamicPaint_doStep( * Calculate a single frame and included subframes for surface */ int dynamicPaint_calculateFrame( - EvaluationContext *eval_ctx, DynamicPaintSurface *surface, Scene *scene, Object *cObject, int frame) + Main *bmain, EvaluationContext *eval_ctx, DynamicPaintSurface *surface, Scene *scene, Object *cObject, int frame) { float timescale = 1.0f; @@ -6215,10 +6216,10 @@ int dynamicPaint_calculateFrame( for (st = 1; st <= surface->substeps; st++) { float subframe = ((float) st) / (surface->substeps + 1); - if (!dynamicPaint_doStep(eval_ctx, scene, cObject, surface, timescale, subframe)) + if (!dynamicPaint_doStep(bmain, eval_ctx, scene, cObject, surface, timescale, subframe)) return 0; } } - return dynamicPaint_doStep(eval_ctx, scene, cObject, surface, timescale, 0.0f); + return dynamicPaint_doStep(bmain, eval_ctx, scene, cObject, surface, timescale, 0.0f); } diff --git a/source/blender/blenkernel/intern/group.c b/source/blender/blenkernel/intern/group.c index 6dc8cc5aff1..578aa97c255 100644 --- a/source/blender/blenkernel/intern/group.c +++ b/source/blender/blenkernel/intern/group.c @@ -330,7 +330,8 @@ static void group_replaces_nla(Object *parent, Object *target, char mode) * you can draw everything, leaves tags in objects to signal it needs further updating */ /* note: does not work for derivedmesh and render... it recreates all again in convertblender.c */ -void BKE_group_handle_recalc_and_update(EvaluationContext *eval_ctx, Scene *scene, Object *UNUSED(parent), Group *group) +void BKE_group_handle_recalc_and_update( + Main *bmain, EvaluationContext *eval_ctx, Scene *scene, Object *UNUSED(parent), Group *group) { GroupObject *go; @@ -370,7 +371,7 @@ void BKE_group_handle_recalc_and_update(EvaluationContext *eval_ctx, Scene *scen for (go = group->gobject.first; go; go = go->next) { if (go->ob) { if (go->ob->recalc) { - BKE_object_handle_update(eval_ctx, scene, go->ob); + BKE_object_handle_update(bmain, eval_ctx, scene, go->ob); } } } diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index 4982c9a2f61..aed86665d64 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -1602,13 +1602,13 @@ const char *BKE_main_blendfile_path(const Main *bmain) } /** - * Return filepath of global main (G.main). + * Return filepath of global main (G_MAIN). * - * \warning Usage is not recommended, you should always try to get a velid Main pointer from context... + * \warning Usage is not recommended, you should always try to get a valid Main pointer from context... */ const char *BKE_main_blendfile_path_from_global(void) { - return BKE_main_blendfile_path(G.main); + return BKE_main_blendfile_path(G_MAIN); } /* ***************** ID ************************ */ diff --git a/source/blender/blenkernel/intern/mball.c b/source/blender/blenkernel/intern/mball.c index d15275e66ce..8438957b0ef 100644 --- a/source/blender/blenkernel/intern/mball.c +++ b/source/blender/blenkernel/intern/mball.c @@ -316,7 +316,7 @@ bool BKE_mball_is_basis_for(Object *ob1, Object *ob2) * are copied to all metaballs in same "group" (metaballs with same base name: MBall, * MBall.001, MBall.002, etc). The most important is to copy properties to the base metaball, * because this metaball influence polygonisation of metaballs. */ -void BKE_mball_properties_copy(EvaluationContext *eval_ctx, Scene *scene, Object *active_object) +void BKE_mball_properties_copy(Main *bmain, EvaluationContext *eval_ctx, Scene *scene, Object *active_object) { Scene *sce_iter = scene; Base *base; @@ -328,8 +328,8 @@ void BKE_mball_properties_copy(EvaluationContext *eval_ctx, Scene *scene, Object BLI_split_name_num(basisname, &basisnr, active_object->id.name + 2, '.'); - BKE_scene_base_iter_next(eval_ctx, &iter, &sce_iter, 0, NULL, NULL); - while (BKE_scene_base_iter_next(eval_ctx, &iter, &sce_iter, 1, &base, &ob)) { + BKE_scene_base_iter_next(bmain, eval_ctx, &iter, &sce_iter, 0, NULL, NULL); + while (BKE_scene_base_iter_next(bmain, eval_ctx, &iter, &sce_iter, 1, &base, &ob)) { if (ob->type == OB_MBALL) { if (ob != active_object) { BLI_split_name_num(obname, &obnr, ob->id.name + 2, '.'); @@ -359,7 +359,7 @@ void BKE_mball_properties_copy(EvaluationContext *eval_ctx, Scene *scene, Object * * warning!, is_basis_mball() can fail on returned object, see long note above. */ -Object *BKE_mball_basis_find(EvaluationContext *eval_ctx, Scene *scene, Object *basis) +Object *BKE_mball_basis_find(Main *bmain, EvaluationContext *eval_ctx, Scene *scene, Object *basis) { Scene *sce_iter = scene; Base *base; @@ -370,8 +370,8 @@ Object *BKE_mball_basis_find(EvaluationContext *eval_ctx, Scene *scene, Object * BLI_split_name_num(basisname, &basisnr, basis->id.name + 2, '.'); - BKE_scene_base_iter_next(eval_ctx, &iter, &sce_iter, 0, NULL, NULL); - while (BKE_scene_base_iter_next(eval_ctx, &iter, &sce_iter, 1, &base, &ob)) { + BKE_scene_base_iter_next(bmain, eval_ctx, &iter, &sce_iter, 0, NULL, NULL); + while (BKE_scene_base_iter_next(bmain, eval_ctx, &iter, &sce_iter, 1, &base, &ob)) { if ((ob->type == OB_MBALL) && !(base->flag & OB_FROMDUPLI)) { if (ob != bob) { BLI_split_name_num(obname, &obnr, ob->id.name + 2, '.'); diff --git a/source/blender/blenkernel/intern/mball_tessellate.c b/source/blender/blenkernel/intern/mball_tessellate.c index a1ae3a7f572..cc82d12a776 100644 --- a/source/blender/blenkernel/intern/mball_tessellate.c +++ b/source/blender/blenkernel/intern/mball_tessellate.c @@ -49,9 +49,10 @@ #include "BKE_global.h" #include "BKE_depsgraph.h" -#include "BKE_scene.h" #include "BKE_displist.h" +#include "BKE_main.h" #include "BKE_mball_tessellate.h" /* own include */ +#include "BKE_scene.h" #include "BLI_strict_flags.h" @@ -1055,7 +1056,7 @@ static void polygonize(PROCESS *process) * Iterates over ALL objects in the scene and all of its sets, including * making all duplis(not only metas). Copies metas to mainb array. * Computes bounding boxes for building BVH. */ -static void init_meta(EvaluationContext *eval_ctx, PROCESS *process, Scene *scene, Object *ob) +static void init_meta(Main *bmain, EvaluationContext *eval_ctx, PROCESS *process, Scene *scene, Object *ob) { Scene *sce_iter = scene; Base *base; @@ -1074,8 +1075,8 @@ static void init_meta(EvaluationContext *eval_ctx, PROCESS *process, Scene *scen BLI_split_name_num(obname, &obnr, ob->id.name + 2, '.'); /* make main array */ - BKE_scene_base_iter_next(eval_ctx, &iter, &sce_iter, 0, NULL, NULL); - while (BKE_scene_base_iter_next(eval_ctx, &iter, &sce_iter, 1, &base, &bob)) { + BKE_scene_base_iter_next(bmain, eval_ctx, &iter, &sce_iter, 0, NULL, NULL); + while (BKE_scene_base_iter_next(bmain, eval_ctx, &iter, &sce_iter, 1, &base, &bob)) { if (bob->type == OB_MBALL) { zero_size = 0; ml = NULL; @@ -1232,7 +1233,7 @@ static void init_meta(EvaluationContext *eval_ctx, PROCESS *process, Scene *scen } } -void BKE_mball_polygonize(EvaluationContext *eval_ctx, Scene *scene, Object *ob, ListBase *dispbase) +void BKE_mball_polygonize(Main *bmain, EvaluationContext *eval_ctx, Scene *scene, Object *ob, ListBase *dispbase) { MetaBall *mb; DispList *dl; @@ -1266,7 +1267,7 @@ void BKE_mball_polygonize(EvaluationContext *eval_ctx, Scene *scene, Object *ob, process.pgn_elements = BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE, "Metaball memarena"); /* initialize all mainb (MetaElems) */ - init_meta(eval_ctx, &process, scene, ob); + init_meta(bmain, eval_ctx, &process, scene, ob); if (process.totelem > 0) { build_bvh_spatial(&process, &process.metaball_bvh, 0, process.totelem, &process.allbb); diff --git a/source/blender/blenkernel/intern/mesh_convert.c b/source/blender/blenkernel/intern/mesh_convert.c index 81aeabd2f5c..e9ef7638da3 100644 --- a/source/blender/blenkernel/intern/mesh_convert.c +++ b/source/blender/blenkernel/intern/mesh_convert.c @@ -876,7 +876,7 @@ Mesh *BKE_mesh_new_from_object( case OB_MBALL: { /* metaballs don't have modifiers, so just convert to mesh */ - Object *basis_ob = BKE_mball_basis_find(bmain->eval_ctx, sce, ob); + Object *basis_ob = BKE_mball_basis_find(bmain, bmain->eval_ctx, sce, ob); /* todo, re-generatre for render-res */ /* metaball_polygonize(scene, ob) */ @@ -895,7 +895,7 @@ Mesh *BKE_mesh_new_from_object( */ EvaluationContext eval_ctx; DEG_evaluation_context_init(&eval_ctx, DAG_EVAL_RENDER); - BKE_displist_make_mball_forRender(&eval_ctx, sce, ob, &disp); + BKE_displist_make_mball_forRender(bmain, &eval_ctx, sce, ob, &disp); BKE_mesh_from_metaball(&disp, tmpmesh); BKE_displist_free(&disp); } diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index ea3ecf29c15..875bc442f8a 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -2432,7 +2432,7 @@ bool BKE_object_minmax_dupli( else { ListBase *lb; DupliObject *dob; - lb = object_duplilist(bmain->eval_ctx, scene, ob); + lb = object_duplilist(bmain, bmain->eval_ctx, scene, ob); for (dob = lb->first; dob; dob = dob->next) { if ((use_hidden == false) && (dob->no_draw != 0)) { /* pass */ @@ -2509,7 +2509,7 @@ void BKE_scene_foreach_display_point( ListBase *lb; DupliObject *dob; - lb = object_duplilist(bmain->eval_ctx, scene, ob); + lb = object_duplilist(bmain, bmain->eval_ctx, scene, ob); for (dob = lb->first; dob; dob = dob->next) { if (dob->no_draw == 0) { BKE_object_foreach_display_point(dob->ob, dob->mat, func_cb, user_data); @@ -2589,7 +2589,8 @@ bool BKE_object_parent_loop_check(const Object *par, const Object *ob) return BKE_object_parent_loop_check(par->parent, ob); } -static void object_handle_update_proxy(EvaluationContext *eval_ctx, +static void object_handle_update_proxy(Main *bmain, + EvaluationContext *eval_ctx, Scene *scene, Object *object, const bool do_proxy_update) @@ -2606,7 +2607,7 @@ static void object_handle_update_proxy(EvaluationContext *eval_ctx, if (object->proxy_group == NULL) { if (do_proxy_update) { // printf("call update, lib ob %s proxy %s\n", ob->proxy->id.name, ob->id.name); - BKE_object_handle_update(eval_ctx, scene, object->proxy); + BKE_object_handle_update(bmain, eval_ctx, scene, object->proxy); } } } @@ -2619,13 +2620,14 @@ static void object_handle_update_proxy(EvaluationContext *eval_ctx, /* the main object update call, for object matrix, constraints, keys and displist (modifiers) */ /* requires flags to be set! */ /* Ideally we shouldn't have to pass the rigid body world, but need bigger restructuring to avoid id */ -void BKE_object_handle_update_ex(EvaluationContext *eval_ctx, +void BKE_object_handle_update_ex(Main *bmain, + EvaluationContext *eval_ctx, Scene *scene, Object *ob, RigidBodyWorld *rbw, const bool do_proxy_update) { if ((ob->recalc & OB_RECALC_ALL) == 0) { - object_handle_update_proxy(eval_ctx, scene, ob, do_proxy_update); + object_handle_update_proxy(bmain, eval_ctx, scene, ob, do_proxy_update); return; } /* Speed optimization for animation lookups. */ @@ -2659,12 +2661,12 @@ void BKE_object_handle_update_ex(EvaluationContext *eval_ctx, } if (ob->recalc & OB_RECALC_DATA) { - BKE_object_handle_data_update(eval_ctx, scene, ob); + BKE_object_handle_data_update(bmain, eval_ctx, scene, ob); } ob->recalc &= ~OB_RECALC_ALL; - object_handle_update_proxy(eval_ctx, scene, ob, do_proxy_update); + object_handle_update_proxy(bmain, eval_ctx, scene, ob, do_proxy_update); } /* WARNING: "scene" here may not be the scene object actually resides in. @@ -2672,9 +2674,9 @@ void BKE_object_handle_update_ex(EvaluationContext *eval_ctx, * e.g. "scene" <-- set 1 <-- set 2 ("ob" lives here) <-- set 3 <-- ... <-- set n * rigid bodies depend on their world so use BKE_object_handle_update_ex() to also pass along the corrent rigid body world */ -void BKE_object_handle_update(EvaluationContext *eval_ctx, Scene *scene, Object *ob) +void BKE_object_handle_update(Main *bmain, EvaluationContext *eval_ctx, Scene *scene, Object *ob) { - BKE_object_handle_update_ex(eval_ctx, scene, ob, NULL, true); + BKE_object_handle_update_ex(bmain, eval_ctx, scene, ob, NULL, true); } void BKE_object_sculpt_modifiers_changed(Object *ob) @@ -3605,9 +3607,11 @@ static void object_cacheIgnoreClear(Object *ob, int state) /* Note: this function should eventually be replaced by depsgraph functionality. * Avoid calling this in new code unless there is a very good reason for it! */ -bool BKE_object_modifier_update_subframe(EvaluationContext *eval_ctx, Scene *scene, Object *ob, bool update_mesh, - int parent_recursion, float frame, - int type) +bool BKE_object_modifier_update_subframe( + Main *bmain, EvaluationContext *eval_ctx, + Scene *scene, Object *ob, bool update_mesh, + int parent_recursion, float frame, + int type) { ModifierData *md = modifiers_findByType(ob, (ModifierType)type); bConstraint *con; @@ -3630,8 +3634,8 @@ bool BKE_object_modifier_update_subframe(EvaluationContext *eval_ctx, Scene *sce if (parent_recursion) { int recursion = parent_recursion - 1; bool no_update = false; - if (ob->parent) no_update |= BKE_object_modifier_update_subframe(eval_ctx, scene, ob->parent, 0, recursion, frame, type); - if (ob->track) no_update |= BKE_object_modifier_update_subframe(eval_ctx, scene, ob->track, 0, recursion, frame, type); + if (ob->parent) no_update |= BKE_object_modifier_update_subframe(bmain, eval_ctx, scene, ob->parent, 0, recursion, frame, type); + if (ob->track) no_update |= BKE_object_modifier_update_subframe(bmain, eval_ctx, scene, ob->track, 0, recursion, frame, type); /* skip subframe if object is parented * to vertex of a dynamic paint canvas */ @@ -3648,7 +3652,7 @@ bool BKE_object_modifier_update_subframe(EvaluationContext *eval_ctx, Scene *sce cti->get_constraint_targets(con, &targets); for (ct = targets.first; ct; ct = ct->next) { if (ct->tar) - BKE_object_modifier_update_subframe(eval_ctx, scene, ct->tar, 0, recursion, frame, type); + BKE_object_modifier_update_subframe(bmain, eval_ctx, scene, ct->tar, 0, recursion, frame, type); } /* free temp targets */ if (cti->flush_constraint_targets) @@ -3664,7 +3668,7 @@ bool BKE_object_modifier_update_subframe(EvaluationContext *eval_ctx, Scene *sce /* ignore cache clear during subframe updates * to not mess up cache validity */ object_cacheIgnoreClear(ob, 1); - BKE_object_handle_update(eval_ctx, scene, ob); + BKE_object_handle_update(bmain, eval_ctx, scene, ob); object_cacheIgnoreClear(ob, 0); } else diff --git a/source/blender/blenkernel/intern/object_dupli.c b/source/blender/blenkernel/intern/object_dupli.c index 56d5cb609fc..19450b88947 100644 --- a/source/blender/blenkernel/intern/object_dupli.c +++ b/source/blender/blenkernel/intern/object_dupli.c @@ -74,6 +74,7 @@ typedef struct DupliContext { bool animated; Group *group; /* XXX child objects are selected from this group if set, could be nicer */ + Main *bmain; Scene *scene; Object *object; float space_mat[4][4]; @@ -96,9 +97,12 @@ typedef struct DupliGenerator { static const DupliGenerator *get_dupli_generator(const DupliContext *ctx); /* create initial context for root object */ -static void init_context(DupliContext *r_ctx, EvaluationContext *eval_ctx, Scene *scene, Object *ob, float space_mat[4][4], bool update) +static void init_context( + DupliContext *r_ctx, Main *bmain, EvaluationContext *eval_ctx, + Scene *scene, Object *ob, float space_mat[4][4], bool update) { r_ctx->eval_ctx = eval_ctx; + r_ctx->bmain = bmain; r_ctx->scene = scene; /* don't allow BKE_object_handle_update for viewport during render, can crash */ r_ctx->do_update = update && !(G.is_rendering && eval_ctx->mode != DAG_EVAL_RENDER); @@ -306,7 +310,7 @@ static void make_duplis_group(const DupliContext *ctx) if (ctx->do_update) { /* note: update is optional because we don't always need object * transformations to be correct. Also fixes bug [#29616]. */ - BKE_group_handle_recalc_and_update(ctx->eval_ctx, ctx->scene, ob, group); + BKE_group_handle_recalc_and_update(ctx->bmain, ctx->eval_ctx, ctx->scene, ob, group); } animated = BKE_group_is_animated(group, ob); @@ -940,7 +944,7 @@ static void make_duplis_particle_system(const DupliContext *ctx, ParticleSystem /* gather list of objects or single object */ if (part->ren_as == PART_DRAW_GR) { if (ctx->do_update) { - BKE_group_handle_recalc_and_update(ctx->eval_ctx, scene, par, part->dup_group); + BKE_group_handle_recalc_and_update(ctx->bmain, ctx->eval_ctx, scene, par, part->dup_group); } if (part->draw & PART_DRAW_COUNT_GR) { @@ -1217,11 +1221,11 @@ static const DupliGenerator *get_dupli_generator(const DupliContext *ctx) /* ---- ListBase dupli container implementation ---- */ /* Returns a list of DupliObject */ -ListBase *object_duplilist_ex(EvaluationContext *eval_ctx, Scene *scene, Object *ob, bool update) +ListBase *object_duplilist_ex(Main *bmain, EvaluationContext *eval_ctx, Scene *scene, Object *ob, bool update) { ListBase *duplilist = MEM_callocN(sizeof(ListBase), "duplilist"); DupliContext ctx; - init_context(&ctx, eval_ctx, scene, ob, NULL, update); + init_context(&ctx, bmain, eval_ctx, scene, ob, NULL, update); if (ctx.gen) { ctx.duplilist = duplilist; ctx.gen->make_duplis(&ctx); @@ -1232,9 +1236,9 @@ ListBase *object_duplilist_ex(EvaluationContext *eval_ctx, Scene *scene, Object /* note: previously updating was always done, this is why it defaults to be on * but there are likely places it can be called without updating */ -ListBase *object_duplilist(EvaluationContext *eval_ctx, Scene *sce, Object *ob) +ListBase *object_duplilist(Main *bmain, EvaluationContext *eval_ctx, Scene *sce, Object *ob) { - return object_duplilist_ex(eval_ctx, sce, ob, true); + return object_duplilist_ex(bmain, eval_ctx, sce, ob, true); } void free_object_duplilist(ListBase *lb) diff --git a/source/blender/blenkernel/intern/object_update.c b/source/blender/blenkernel/intern/object_update.c index 8ab3028c935..bb738033f02 100644 --- a/source/blender/blenkernel/intern/object_update.c +++ b/source/blender/blenkernel/intern/object_update.c @@ -39,25 +39,26 @@ #include "BLI_math.h" #include "BLI_threads.h" -#include "BKE_global.h" +#include "BKE_animsys.h" #include "BKE_armature.h" #include "BKE_action.h" #include "BKE_constraint.h" #include "BKE_depsgraph.h" #include "BKE_DerivedMesh.h" -#include "BKE_animsys.h" #include "BKE_displist.h" +#include "BKE_editmesh.h" #include "BKE_effect.h" +#include "BKE_global.h" +#include "BKE_image.h" #include "BKE_key.h" #include "BKE_lamp.h" #include "BKE_lattice.h" -#include "BKE_editmesh.h" +#include "BKE_main.h" +#include "BKE_material.h" #include "BKE_object.h" #include "BKE_particle.h" #include "BKE_pointcache.h" #include "BKE_scene.h" -#include "BKE_material.h" -#include "BKE_image.h" #include "DEG_depsgraph.h" @@ -138,9 +139,11 @@ void BKE_object_eval_done(EvaluationContext *UNUSED(eval_ctx), Object *ob) else ob->transflag &= ~OB_NEG_SCALE; } -void BKE_object_handle_data_update(EvaluationContext *eval_ctx, - Scene *scene, - Object *ob) +void BKE_object_handle_data_update( + Main *bmain, + EvaluationContext *eval_ctx, + Scene *scene, + Object *ob) { ID *data_id = (ID *)ob->data; AnimData *adt = BKE_animdata_from_id(data_id); @@ -197,7 +200,7 @@ void BKE_object_handle_data_update(EvaluationContext *eval_ctx, break; case OB_MBALL: - BKE_displist_make_mball(eval_ctx, scene, ob); + BKE_displist_make_mball(bmain, eval_ctx, scene, ob); break; case OB_CURVE: @@ -260,7 +263,7 @@ void BKE_object_handle_data_update(EvaluationContext *eval_ctx, ob->transflag |= OB_DUPLIPARTS; } - particle_system_update(G.main, scene, ob, psys, (eval_ctx->mode == DAG_EVAL_RENDER)); + particle_system_update(bmain, scene, ob, psys, (eval_ctx->mode == DAG_EVAL_RENDER)); psys = psys->next; } else if (psys->flag & PSYS_DELETE) { @@ -322,13 +325,13 @@ void BKE_object_eval_uber_transform(EvaluationContext *eval_ctx, Object *object) } } -void BKE_object_eval_uber_data(EvaluationContext *eval_ctx, +void BKE_object_eval_uber_data(Main *bmain, EvaluationContext *eval_ctx, Scene *scene, Object *ob) { DEG_debug_print_eval(__func__, ob->id.name, ob); BLI_assert(ob->type != OB_ARMATURE); - BKE_object_handle_data_update(eval_ctx, scene, ob); + BKE_object_handle_data_update(bmain, eval_ctx, scene, ob); ob->recalc &= ~(OB_RECALC_DATA | OB_RECALC_TIME); } diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index c7dacf97624..61971456df3 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -1719,7 +1719,7 @@ void BKE_ptcache_ids_from_object(ListBase *lb, Object *ob, Scene *scene, int dup if (scene && (duplis-- > 0) && (ob->transflag & OB_DUPLI)) { ListBase *lb_dupli_ob; /* don't update the dupli groups, we only want their pid's */ - if ((lb_dupli_ob = object_duplilist_ex(G.main->eval_ctx, scene, ob, false))) { + if ((lb_dupli_ob = object_duplilist_ex(G.main, G.main->eval_ctx, scene, ob, false))) { DupliObject *dob; for (dob= lb_dupli_ob->first; dob; dob= dob->next) { if (dob->ob != ob) { /* avoids recursive loops with dupliframes: bug 22988 */ diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index 8fd88b12974..24daae2cc71 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -972,7 +972,7 @@ Scene *BKE_scene_set_name(Main *bmain, const char *name) } /* Used by metaballs, return *all* objects (including duplis) existing in the scene (including scene's sets) */ -int BKE_scene_base_iter_next(EvaluationContext *eval_ctx, SceneBaseIter *iter, +int BKE_scene_base_iter_next(Main *bmain, EvaluationContext *eval_ctx, SceneBaseIter *iter, Scene **scene, int val, Base **base, Object **ob) { bool run_again = true; @@ -1041,7 +1041,7 @@ int BKE_scene_base_iter_next(EvaluationContext *eval_ctx, SceneBaseIter *iter, * this enters eternal loop because of * makeDispListMBall getting called inside of group_duplilist */ if ((*base)->object->dup_group == NULL) { - iter->duplilist = object_duplilist_ex(eval_ctx, (*scene), (*base)->object, false); + iter->duplilist = object_duplilist_ex(bmain, eval_ctx, (*scene), (*base)->object, false); iter->dupob = iter->duplilist->first; @@ -1364,7 +1364,7 @@ static void scene_update_drivers(Main *UNUSED(bmain), Scene *scene) } /* deps hack - do extra recalcs at end */ -static void scene_depsgraph_hack(EvaluationContext *eval_ctx, Scene *scene, Scene *scene_parent) +static void scene_depsgraph_hack(Main *bmain, EvaluationContext *eval_ctx, Scene *scene, Scene *scene_parent) { Base *base; @@ -1373,7 +1373,7 @@ static void scene_depsgraph_hack(EvaluationContext *eval_ctx, Scene *scene, Scen /* sets first, we allow per definition current scene to have * dependencies on sets, but not the other way around. */ if (scene->set) - scene_depsgraph_hack(eval_ctx, scene->set, scene_parent); + scene_depsgraph_hack(bmain, eval_ctx, scene->set, scene_parent); for (base = scene->base.first; base; base = base->next) { Object *ob = base->object; @@ -1388,7 +1388,7 @@ static void scene_depsgraph_hack(EvaluationContext *eval_ctx, Scene *scene, Scen recalc |= OB_RECALC_DATA; ob->recalc |= recalc; - BKE_object_handle_update(eval_ctx, scene_parent, ob); + BKE_object_handle_update(bmain, eval_ctx, scene_parent, ob); if (ob->dup_group && (ob->transflag & OB_DUPLIGROUP)) { GroupObject *go; @@ -1397,7 +1397,7 @@ static void scene_depsgraph_hack(EvaluationContext *eval_ctx, Scene *scene, Scen if (go->ob) go->ob->recalc |= recalc; } - BKE_group_handle_recalc_and_update(eval_ctx, scene_parent, ob, ob->dup_group); + BKE_group_handle_recalc_and_update(bmain, eval_ctx, scene_parent, ob, ob->dup_group); } } } @@ -1484,6 +1484,7 @@ typedef struct StatisicsEntry { typedef struct ThreadedObjectUpdateState { /* TODO(sergey): We might want this to be per-thread object. */ EvaluationContext *eval_ctx; + Main *bmain; Scene *scene; Scene *scene_parent; double base_time; @@ -1501,17 +1502,17 @@ typedef struct ThreadedObjectUpdateState { static void scene_update_object_add_task(void *node, void *user_data); -static void scene_update_all_bases(EvaluationContext *eval_ctx, Scene *scene, Scene *scene_parent) +static void scene_update_all_bases(Main *bmain, EvaluationContext *eval_ctx, Scene *scene, Scene *scene_parent) { Base *base; for (base = scene->base.first; base; base = base->next) { Object *object = base->object; - BKE_object_handle_update_ex(eval_ctx, scene_parent, object, scene->rigidbody_world, true); + BKE_object_handle_update_ex(bmain, eval_ctx, scene_parent, object, scene->rigidbody_world, true); if (object->dup_group && (object->transflag & OB_DUPLIGROUP)) - BKE_group_handle_recalc_and_update(eval_ctx, scene_parent, object, object->dup_group); + BKE_group_handle_recalc_and_update(bmain, eval_ctx, scene_parent, object, object->dup_group); /* always update layer, so that animating layers works (joshua july 2010) */ /* XXX commented out, this has depsgraph issues anyway - and this breaks setting scenes @@ -1529,6 +1530,7 @@ static void scene_update_object_func(TaskPool * __restrict pool, void *taskdata, void *node = taskdata; Object *object = DAG_get_node_object(node); EvaluationContext *eval_ctx = state->eval_ctx; + Main *bmain = state->bmain; Scene *scene = state->scene; Scene *scene_parent = state->scene_parent; @@ -1559,7 +1561,7 @@ static void scene_update_object_func(TaskPool * __restrict pool, void *taskdata, * separately from main thread because of we've got no idea about * dependencies inside the group. */ - BKE_object_handle_update_ex(eval_ctx, scene_parent, object, scene->rigidbody_world, false); + BKE_object_handle_update_ex(bmain, eval_ctx, scene_parent, object, scene->rigidbody_world, false); /* Calculate statistics. */ if (add_to_stats) { @@ -1700,6 +1702,7 @@ static void scene_update_objects(EvaluationContext *eval_ctx, Main *bmain, Scene } state.eval_ctx = eval_ctx; + state.bmain = bmain; state.scene = scene; state.scene_parent = scene_parent; @@ -1757,7 +1760,7 @@ static void scene_update_objects(EvaluationContext *eval_ctx, Main *bmain, Scene #endif if (need_singlethread_pass) { - scene_update_all_bases(eval_ctx, scene, scene_parent); + scene_update_all_bases(bmain, eval_ctx, scene, scene_parent); } if (need_free_scheduler) { @@ -2059,7 +2062,7 @@ void BKE_scene_update_for_newframe_ex(EvaluationContext *eval_ctx, Main *bmain, #ifdef WITH_LEGACY_DEPSGRAPH if (!use_new_eval) { - scene_depsgraph_hack(eval_ctx, sce, sce); + scene_depsgraph_hack(bmain, eval_ctx, sce, sce); } #endif diff --git a/source/blender/blenkernel/intern/smoke.c b/source/blender/blenkernel/intern/smoke.c index 41ee8a4c7e8..2ab892a0233 100644 --- a/source/blender/blenkernel/intern/smoke.c +++ b/source/blender/blenkernel/intern/smoke.c @@ -2106,7 +2106,8 @@ BLI_INLINE void apply_inflow_fields(SmokeFlowSettings *sfs, float emission_value } } -static void update_flowsfluids(EvaluationContext *eval_ctx, Scene *scene, Object *ob, SmokeDomainSettings *sds, float dt) +static void update_flowsfluids( + Main *bmain, EvaluationContext *eval_ctx, Scene *scene, Object *ob, SmokeDomainSettings *sds, float dt) { Object **flowobjs = NULL; EmissionMap *emaps = NULL; @@ -2213,7 +2214,9 @@ static void update_flowsfluids(EvaluationContext *eval_ctx, Scene *scene, Object else { /* MOD_SMOKE_FLOW_SOURCE_MESH */ /* update flow object frame */ BLI_mutex_lock(&object_update_lock); - BKE_object_modifier_update_subframe(eval_ctx, scene, collob, true, 5, BKE_scene_frame_get(scene), eModifierType_Smoke); + BKE_object_modifier_update_subframe( + bmain, eval_ctx, scene, collob, + true, 5, BKE_scene_frame_get(scene), eModifierType_Smoke); BLI_mutex_unlock(&object_update_lock); /* apply flow */ @@ -2561,7 +2564,8 @@ static void update_effectors(Scene *scene, Object *ob, SmokeDomainSettings *sds, } static void step( - EvaluationContext *eval_ctx, Scene *scene, Object *ob, SmokeModifierData *smd, DerivedMesh *domain_dm, float fps) + Main *bmain, EvaluationContext *eval_ctx, + Scene *scene, Object *ob, SmokeModifierData *smd, DerivedMesh *domain_dm, float fps) { SmokeDomainSettings *sds = smd->domain; /* stability values copied from wturbulence.cpp */ @@ -2631,7 +2635,7 @@ static void step( for (substep = 0; substep < totalSubsteps; substep++) { // calc animated obstacle velocities - update_flowsfluids(eval_ctx, scene, ob, sds, dtSubdiv); + update_flowsfluids(bmain, eval_ctx, scene, ob, sds, dtSubdiv); update_obstacles(scene, ob, sds, dtSubdiv, substep, totalSubsteps); if (sds->total_cells > 1) { @@ -2728,7 +2732,8 @@ static DerivedMesh *createDomainGeometry(SmokeDomainSettings *sds, Object *ob) return result; } -static void smokeModifier_process(EvaluationContext *eval_ctx, SmokeModifierData *smd, Scene *scene, Object *ob, DerivedMesh *dm) +static void smokeModifier_process( + Main *bmain, EvaluationContext *eval_ctx, SmokeModifierData *smd, Scene *scene, Object *ob, DerivedMesh *dm) { if ((smd->type & MOD_SMOKE_TYPE_FLOW)) { @@ -2849,7 +2854,7 @@ static void smokeModifier_process(EvaluationContext *eval_ctx, SmokeModifierData } - step(eval_ctx, scene, ob, smd, dm, scene->r.frs_sec / scene->r.frs_sec_base); + step(bmain, eval_ctx, scene, ob, smd, dm, scene->r.frs_sec / scene->r.frs_sec_base); } // create shadows before writing cache so they get stored @@ -2877,7 +2882,7 @@ struct DerivedMesh *smokeModifier_do(SmokeModifierData *smd, Scene *scene, Objec BLI_rw_mutex_lock(smd->domain->fluid_mutex, THREAD_LOCK_WRITE); /* Ugly G.main, hopefully won't be needed anymore in 2.8 */ - smokeModifier_process(G.main->eval_ctx , smd, scene, ob, dm); + smokeModifier_process(G.main, G.main->eval_ctx , smd, scene, ob, dm); if ((smd->type & MOD_SMOKE_TYPE_DOMAIN) && smd->domain) BLI_rw_mutex_unlock(smd->domain->fluid_mutex); diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc index c646d7c20ff..b0894101414 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc @@ -769,6 +769,7 @@ void DepsgraphNodeBuilder::build_obdata_geom(Object *object) op_node = add_operation_node(&object->id, DEG_NODE_TYPE_GEOMETRY, function_bind(BKE_object_eval_uber_data, + bmain_, _1, scene_, object), @@ -838,7 +839,7 @@ void DepsgraphNodeBuilder::build_obdata_geom(Object *object) case OB_MBALL: { - Object *mom = BKE_mball_basis_find(bmain_->eval_ctx, scene_, object); + Object *mom = BKE_mball_basis_find(bmain_, bmain_->eval_ctx, scene_, object); /* NOTE: Only the motherball gets evaluated, it's children are * having empty placeholders for the correct relations being built. */ diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc index 3628eede210..e8adabb2668 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc @@ -1612,7 +1612,7 @@ void DepsgraphRelationBuilder::build_obdata_geom(Object *object) case OB_MBALL: { - Object *mom = BKE_mball_basis_find(bmain_->eval_ctx, scene_, object); + Object *mom = BKE_mball_basis_find(bmain_, bmain_->eval_ctx, scene_, object); ComponentKey mom_geom_key(&mom->id, DEG_NODE_TYPE_GEOMETRY); /* motherball - mom depends on children! */ if (mom == object) { diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index cd163298642..c6da37d692e 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -1351,7 +1351,7 @@ static void make_object_duplilist_real(bContext *C, Scene *scene, Base *base, return; } - lb_duplis = object_duplilist(bmain->eval_ctx, scene, base->object); + lb_duplis = object_duplilist(bmain, bmain->eval_ctx, scene, base->object); dupli_gh = BLI_ghash_ptr_new(__func__); if (use_hierarchy) { @@ -1562,7 +1562,7 @@ static void convert_ensure_curve_cache(Main *bmain, Scene *scene, Object *ob) BKE_displist_make_curveTypes(scene, ob, false); } else if (ob->type == OB_MBALL) { - BKE_displist_make_mball(bmain->eval_ctx, scene, ob); + BKE_displist_make_mball(bmain, bmain->eval_ctx, scene, ob); } } } @@ -1648,7 +1648,7 @@ static int convert_exec(bContext *C, wmOperator *op) if (ob->type == OB_MBALL && target == OB_MESH) { if (BKE_mball_is_basis(ob) == false) { Object *ob_basis; - ob_basis = BKE_mball_basis_find(bmain->eval_ctx, scene, ob); + ob_basis = BKE_mball_basis_find(bmain, bmain->eval_ctx, scene, ob); if (ob_basis) { ob_basis->flag &= ~OB_DONE; } @@ -1862,7 +1862,7 @@ static int convert_exec(bContext *C, wmOperator *op) base->flag &= ~SELECT; ob->flag &= ~SELECT; - baseob = BKE_mball_basis_find(bmain->eval_ctx, scene, ob); + baseob = BKE_mball_basis_find(bmain, bmain->eval_ctx, scene, ob); if (ob != baseob) { /* if motherball is converting it would be marked as done later */ @@ -1933,7 +1933,7 @@ static int convert_exec(bContext *C, wmOperator *op) if (ob->flag & OB_DONE) { Object *ob_basis = NULL; if (BKE_mball_is_basis(ob) || - ((ob_basis = BKE_mball_basis_find(bmain->eval_ctx, scene, ob)) && (ob_basis->flag & OB_DONE))) + ((ob_basis = BKE_mball_basis_find(bmain, bmain->eval_ctx, scene, ob)) && (ob_basis->flag & OB_DONE))) { ED_base_object_free_and_unlink(bmain, scene, base); } diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c index 368fd4fd98d..a9b364651e7 100644 --- a/source/blender/editors/object/object_modifier.c +++ b/source/blender/editors/object/object_modifier.c @@ -1898,6 +1898,7 @@ static int meshdeform_poll(bContext *C) static int meshdeform_bind_exec(bContext *C, wmOperator *op) { + Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); Object *ob = ED_object_active_context(C); MeshDeformModifierData *mmd = (MeshDeformModifierData *)edit_modifier_property_get(op, ob, eModifierType_MeshDeform); @@ -1946,7 +1947,7 @@ static int meshdeform_bind_exec(bContext *C, wmOperator *op) BKE_lattice_modifiers_calc(scene, ob); } else if (ob->type == OB_MBALL) { - BKE_displist_make_mball(CTX_data_main(C)->eval_ctx, scene, ob); + BKE_displist_make_mball(bmain, bmain->eval_ctx, scene, ob); } else if (ELEM(ob->type, OB_CURVE, OB_SURF, OB_FONT)) { BKE_displist_make_curveTypes(scene, ob, 0); diff --git a/source/blender/editors/physics/dynamicpaint_ops.c b/source/blender/editors/physics/dynamicpaint_ops.c index d63c28bb0cf..c04fb8d63d1 100644 --- a/source/blender/editors/physics/dynamicpaint_ops.c +++ b/source/blender/editors/physics/dynamicpaint_ops.c @@ -384,7 +384,7 @@ static void dynamicPaint_bakeImageSequence(DynamicPaintBakeJob *job) /* calculate a frame */ scene->r.cfra = (int)frame; ED_update_for_newframe(job->bmain, scene, 1); - if (!dynamicPaint_calculateFrame(job->bmain->eval_ctx, surface, scene, cObject, frame)) { + if (!dynamicPaint_calculateFrame(job->bmain, job->bmain->eval_ctx, surface, scene, cObject, frame)) { job->success = 0; return; } diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index 807b240870e..b3c4f988f19 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -2321,7 +2321,7 @@ static void ensure_curve_cache(Main *bmain, Scene *scene, Object *object) BKE_displist_make_curveTypes(scene, object, false); break; case OB_MBALL: - BKE_displist_make_mball(bmain->eval_ctx, scene, object); + BKE_displist_make_mball(bmain, bmain->eval_ctx, scene, object); break; case OB_LATTICE: BKE_lattice_modifiers_calc(scene, object); @@ -8186,7 +8186,7 @@ void draw_object_select(Main *bmain, Scene *scene, ARegion *ar, View3D *v3d, Bas Base tbase; tbase.flag = OB_FROMDUPLI; - lb = object_duplilist(bmain->eval_ctx, scene, base->object); + lb = object_duplilist(bmain, bmain->eval_ctx, scene, base->object); for (dob = lb->first; dob; dob = dob->next) { float omat[4][4]; diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index 3c89c9c6ca6..b82a841f40e 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -2115,7 +2115,7 @@ static void draw_dupli_objects_color( } tbase.flag = OB_FROMDUPLI | base->flag; - lb = object_duplilist(bmain->eval_ctx, scene, base->object); + lb = object_duplilist(bmain, bmain->eval_ctx, scene, base->object); // BLI_listbase_sort(lb, dupli_ob_sort); /* might be nice to have if we have a dupli list with mixed objects. */ apply_data = duplilist_apply(base->object, scene, lb); @@ -2632,7 +2632,7 @@ static void gpu_update_lamps_shadows_world(Main *bmain, Scene *scene, View3D *v3 if (ob->transflag & OB_DUPLI) { DupliObject *dob; - ListBase *lb = object_duplilist(bmain->eval_ctx, scene, ob); + ListBase *lb = object_duplilist(bmain, bmain->eval_ctx, scene, ob); for (dob = lb->first; dob; dob = dob->next) if (dob->ob->type == OB_LAMP) diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index 9f2effde46a..606ffa657ce 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -5635,7 +5635,7 @@ static void set_trans_object_base_flags(TransInfo *t) for (base = scene->base.first; base; base = base->next) { if (base->object->recalc & OB_RECALC_ALL) { /* TODO(sergey): Ideally, it's not needed. */ - BKE_object_handle_update(bmain->eval_ctx, t->scene, base->object); + BKE_object_handle_update(bmain, bmain->eval_ctx, t->scene, base->object); } } diff --git a/source/blender/editors/transform/transform_snap_object.c b/source/blender/editors/transform/transform_snap_object.c index 1293d26bc65..f9c628877c1 100644 --- a/source/blender/editors/transform/transform_snap_object.c +++ b/source/blender/editors/transform/transform_snap_object.c @@ -168,7 +168,7 @@ static void iter_snap_objects( Object *obj = base->object; if (obj->transflag & OB_DUPLI) { DupliObject *dupli_ob; - ListBase *lb = object_duplilist(sctx->bmain->eval_ctx, sctx->scene, obj); + ListBase *lb = object_duplilist(sctx->bmain, sctx->bmain->eval_ctx, sctx->scene, obj); for (dupli_ob = lb->first; dupli_ob; dupli_ob = dupli_ob->next) { use_obedit = obedit && dupli_ob->ob->data == obedit->data; sob_callback(sctx, use_obedit, use_obedit ? obedit : dupli_ob->ob, dupli_ob->mat, data); diff --git a/source/blender/gpu/intern/gpu_material.c b/source/blender/gpu/intern/gpu_material.c index 40ff9ca629b..22755375061 100644 --- a/source/blender/gpu/intern/gpu_material.c +++ b/source/blender/gpu/intern/gpu_material.c @@ -1043,7 +1043,7 @@ static void material_lights(GPUShadeInput *shi, GPUShadeResult *shr) } if (ob->transflag & OB_DUPLI) { - ListBase *lb = object_duplilist(G.main->eval_ctx, shi->gpumat->scene, ob); + ListBase *lb = object_duplilist(G.main, G.main->eval_ctx, shi->gpumat->scene, ob); for (DupliObject *dob = lb->first; dob; dob = dob->next) { Object *ob_iter = dob->ob; diff --git a/source/blender/makesrna/intern/rna_meta.c b/source/blender/makesrna/intern/rna_meta.c index 999dab60bc0..07f36b3efff 100644 --- a/source/blender/makesrna/intern/rna_meta.c +++ b/source/blender/makesrna/intern/rna_meta.c @@ -101,7 +101,7 @@ static void rna_MetaBall_update_data(Main *bmain, Scene *scene, PointerRNA *ptr) if (mb->id.us > 0) { for (ob = bmain->object.first; ob; ob = ob->id.next) if (ob->data == mb) - BKE_mball_properties_copy(bmain->eval_ctx, scene, ob); + BKE_mball_properties_copy(bmain, bmain->eval_ctx, scene, ob); DAG_id_tag_update(&mb->id, 0); WM_main_add_notifier(NC_GEOM | ND_DATA, mb); diff --git a/source/blender/makesrna/intern/rna_object_api.c b/source/blender/makesrna/intern/rna_object_api.c index d3a1f2a14e7..356355fa61c 100644 --- a/source/blender/makesrna/intern/rna_object_api.c +++ b/source/blender/makesrna/intern/rna_object_api.c @@ -191,7 +191,7 @@ static void dupli_render_particle_set(Scene *scene, Object *ob, int level, int e dupli_render_particle_set(scene, go->ob, level + 1, enable); } /* When no longer needed, duplilist should be freed with Object.free_duplilist */ -static void rna_Object_create_duplilist(Object *ob, ReportList *reports, Scene *sce, int settings) +static void rna_Object_create_duplilist(Object *ob, Main *bmain, ReportList *reports, Scene *sce, int settings) { bool for_render = (settings == DAG_EVAL_RENDER); EvaluationContext eval_ctx; @@ -211,7 +211,7 @@ static void rna_Object_create_duplilist(Object *ob, ReportList *reports, Scene * } if (for_render) dupli_render_particle_set(sce, ob, 0, 1); - ob->duplilist = object_duplilist(&eval_ctx, sce, ob); + ob->duplilist = object_duplilist(bmain, &eval_ctx, sce, ob); if (for_render) dupli_render_particle_set(sce, ob, 0, 0); /* ob->duplilist should now be freed with Object.free_duplilist */ @@ -573,13 +573,13 @@ void RNA_api_object(StructRNA *srna) /* duplis */ func = RNA_def_function(srna, "dupli_list_create", "rna_Object_create_duplilist"); + RNA_def_function_flag(func, FUNC_USE_MAIN | FUNC_USE_REPORTS); RNA_def_function_ui_description(func, "Create a list of dupli objects for this object, needs to " "be freed manually with free_dupli_list to restore the " "objects real matrix and layers"); parm = RNA_def_pointer(func, "scene", "Scene", "", "Scene within which to evaluate duplis"); RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED); RNA_def_enum(func, "settings", dupli_eval_mode_items, 0, "", "Generate texture coordinates for rendering"); - RNA_def_function_flag(func, FUNC_USE_REPORTS); func = RNA_def_function(srna, "dupli_list_clear", "rna_Object_free_duplilist"); RNA_def_function_ui_description(func, "Free the list of dupli objects"); diff --git a/source/blender/modifiers/intern/MOD_dynamicpaint.c b/source/blender/modifiers/intern/MOD_dynamicpaint.c index 7dcaba5562c..8fa8ddd3098 100644 --- a/source/blender/modifiers/intern/MOD_dynamicpaint.c +++ b/source/blender/modifiers/intern/MOD_dynamicpaint.c @@ -114,7 +114,7 @@ static DerivedMesh *applyModifier( /* dont apply dynamic paint on orco dm stack */ if (!(flag & MOD_APPLY_ORCO)) { - return dynamicPaint_Modifier_do(G.main->eval_ctx, pmd, md->scene, ob, dm); + return dynamicPaint_Modifier_do(G.main, G.main->eval_ctx, pmd, md->scene, ob, dm); } return dm; } diff --git a/source/blender/render/intern/source/convertblender.c b/source/blender/render/intern/source/convertblender.c index 8675ffec313..8105f94cb31 100644 --- a/source/blender/render/intern/source/convertblender.c +++ b/source/blender/render/intern/source/convertblender.c @@ -2184,7 +2184,7 @@ static void init_render_mball(Render *re, ObjectRen *obr) int a, need_orco, vlakindex, *index, negative_scale; ListBase dispbase= {NULL, NULL}; - if (ob!=BKE_mball_basis_find(re->eval_ctx, re->scene, ob)) + if (ob!=BKE_mball_basis_find(re->main, re->eval_ctx, re->scene, ob)) return; mul_m4_m4m4(mat, re->viewmat, ob->obmat); @@ -2199,7 +2199,7 @@ static void init_render_mball(Render *re, ObjectRen *obr) need_orco= 1; } - BKE_displist_make_mball_forRender(re->eval_ctx, re->scene, ob, &dispbase); + BKE_displist_make_mball_forRender(re->main, re->eval_ctx, re->scene, ob, &dispbase); dl= dispbase.first; if (dl == NULL) return; @@ -4862,7 +4862,7 @@ static int allow_render_object(Render *re, Object *ob, int nolamps, int onlysele } /* don't add non-basic meta objects, ends up having renderobjects with no geometry */ - if (ob->type == OB_MBALL && ob!=BKE_mball_basis_find(re->eval_ctx, re->scene, ob)) + if (ob->type == OB_MBALL && ob != BKE_mball_basis_find(re->main, re->eval_ctx, re->scene, ob)) return 0; if (nolamps && (ob->type==OB_LAMP)) @@ -5049,7 +5049,7 @@ static void database_init_objects(Render *re, unsigned int renderlay, int nolamp /* create list of duplis generated by this object, particle * system need to have render settings set for dupli particles */ dupli_render_particle_set(re, ob, timeoffset, 0, 1); - duplilist = object_duplilist(re->eval_ctx, re->scene, ob); + duplilist = object_duplilist(re->main, re->eval_ctx, re->scene, ob); duplilist_apply_data = duplilist_apply(ob, NULL, duplilist); /* postpone 'dupli_render_particle_set', since RE_addRenderInstance reads * index values from 'dob->persistent_id[0]', referencing 'psys->child' which -- cgit v1.2.3