Cleanup: Moar G.main removal of Hell.
authorBastien Montagne <montagne29@wanadoo.fr>
Mon, 11 Jun 2018 10:14:18 +0000 (12:14 +0200)
committerBastien Montagne <montagne29@wanadoo.fr>
Mon, 11 Jun 2018 10:15:14 +0000 (12:15 +0200)
This commit actually adds some G.main... but at much, much higher level
than the ones it removes, so should still be better ;)

42 files changed:
intern/cycles/blender/blender_object.cpp
source/blender/alembic/intern/abc_exporter.cc
source/blender/alembic/intern/abc_mball.cc
source/blender/alembic/intern/abc_mball.h
source/blender/blenkernel/BKE_anim.h
source/blender/blenkernel/BKE_displist.h
source/blender/blenkernel/BKE_dynamicpaint.h
source/blender/blenkernel/BKE_global.h
source/blender/blenkernel/BKE_group.h
source/blender/blenkernel/BKE_mball.h
source/blender/blenkernel/BKE_mball_tessellate.h
source/blender/blenkernel/BKE_object.h
source/blender/blenkernel/BKE_scene.h
source/blender/blenkernel/intern/anim.c
source/blender/blenkernel/intern/depsgraph.c
source/blender/blenkernel/intern/displist.c
source/blender/blenkernel/intern/dynamicpaint.c
source/blender/blenkernel/intern/group.c
source/blender/blenkernel/intern/library.c
source/blender/blenkernel/intern/mball.c
source/blender/blenkernel/intern/mball_tessellate.c
source/blender/blenkernel/intern/mesh_convert.c
source/blender/blenkernel/intern/object.c
source/blender/blenkernel/intern/object_dupli.c
source/blender/blenkernel/intern/object_update.c
source/blender/blenkernel/intern/pointcache.c
source/blender/blenkernel/intern/scene.c
source/blender/blenkernel/intern/smoke.c
source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
source/blender/depsgraph/intern/builder/deg_builder_relations.cc
source/blender/editors/object/object_add.c
source/blender/editors/object/object_modifier.c
source/blender/editors/physics/dynamicpaint_ops.c
source/blender/editors/space_view3d/drawobject.c
source/blender/editors/space_view3d/view3d_draw.c
source/blender/editors/transform/transform_conversions.c
source/blender/editors/transform/transform_snap_object.c
source/blender/gpu/intern/gpu_material.c
source/blender/makesrna/intern/rna_meta.c
source/blender/makesrna/intern/rna_object_api.c
source/blender/modifiers/intern/MOD_dynamicpaint.c
source/blender/render/intern/source/convertblender.c

index 077ceb4ebef4a96bbf111f2f78fa5cbf4c63fc7e..4919bc4325f722817f4163779ee143f5cbcfca09 100644 (file)
@@ -567,7 +567,7 @@ void BlenderSync::sync_objects(float motion_time)
 
                                if(b_ob.is_duplicator() && !object_render_hide_duplis(b_ob)) {
                                        /* dupli objects */
-                                       b_ob.dupli_list_create(b_scene, dupli_settings);
+                                       b_ob.dupli_list_create(b_data, b_scene, dupli_settings);
 
                                        BL::Object::dupli_list_iterator b_dup;
 
index 67575cb52d5a69aa51aecf225630b209b6724787..7e8f4e3cd15cce3148cff0a41ec7c499706cfe8a 100644 (file)
@@ -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<DupliObject *>(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<DupliObject *>(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;
        }
 
index c5712daf499cfa6e7dafd031bd43d10c2b07941b..05700e6024e44de9a5c854593312daf927992d90 100644 (file)
@@ -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;
 }
index 9a74006f839f66213e9ea522b602c06bd5efda9a..46567ff33865f481ba92f572924565361381312e 100644 (file)
@@ -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();
index 584f0da323aef29aa7bd9d9434b21cb10fee7710..902331f4649ae8b92785138e0aee7f1f978858e6 100644 (file)
  *  \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);
 
index 9625f05192aaa621abfdd356013d7997df791d16..f5c6fb37ccc7d14faeb5ef8287fdd718000eeb9f 100644 (file)
@@ -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);
index 9d738045ad1807c13f69349eff532cf0bc01b116..cc1ff1a2375499566ad3b43461900be214fbe9bc 100644 (file)
@@ -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);
index 45a0a765ce163e3ab3f9f974a300546fcadb8c45..db816cb9e14d40a064ff38f5fcb0db860037653b 100644 (file)
@@ -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
index e07dd259970bf0da05687adb9e586fbc423998b8..9e1ad1bc789c06d1dfe327c8a72fd3133408e007 100644 (file)
@@ -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__ */
index c73dd7260c470473dea6bf0f63c7c9cbd3921260..87bc7b2dfc52430b6ef90ef407e3970e6597ef5b 100644 (file)
@@ -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],
index 361f31b704cdd1fa78339388aa3f5bd88e2ef231..254d5e9248aaef66378e69ac0594bbb880cd9864 100644 (file)
  *  \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);
index f9761ad43348b1fb73be24ff29426cda84063af3..9d99a0ad84b90b42954f84c1ea63ad08b5ae29ba 100644 (file)
@@ -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);
 
index 0e1472b706289b66ea3596135369dd1cf8959524..ae809641480ea7273397a0ac28f2e7e4c1b61d81 100644 (file)
@@ -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);
index a0f069bccf25f4db4b7847dc9e97aeb115a3228e..a09065f8b5d5c83c26862aa5ad547493bdf88149 100644 (file)
@@ -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)
index 80275324da6491603716194314f60332cdd24462..78f564e5e5e05efaa60dd95fae9a4a02594e9889 100644 (file)
@@ -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");
index 00e319efb7ad58ee87d541781c5c1eb980e93969..f59691dd70e5d7d3b3cd6d06544869fe8dab2652 100644 (file)
@@ -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);
index 87fd10c7e7d00d3b7ca9eb4eeea0be0efe1474c2..ab5fe1d45f5983f8741f8915e894f68520e31b7f 100644 (file)
@@ -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);
 }
index 6dc8cc5aff1c30ddfaa8049e276232ff3c6576bf..578aa97c2556d2fedbe230441d1b874d7e1106a6 100644 (file)
@@ -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);
                                }
                        }
                }
index 4982c9a2f61f7914b9fdbc2e7c0d040d61baeb9b..aed86665d64a39e895a7e92159433d542e01d2a6 100644 (file)
@@ -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 ************************ */
index d15275e66ce67dcb481fd9f6b394d0db3716870c..8438957b0efdb02ec1228126e35a868240e5c38e 100644 (file)
@@ -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, '.');
index a1ae3a7f5727adf3fbf7a55fb3b58ec3acd8cd88..cc82d12a776b09556b9343a6948b95993aa6dde7 100644 (file)
 #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);
index 81aeabd2f5ce3a37ddda2b70f23e0e2e26546257..e9ef7638da328302fa59b2d3af3e9604be5ab96f 100644 (file)
@@ -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);
                        }
index ea3ecf29c15c1d33fbad6b65b264748851c8615d..875bc442f8af3360dde9463a1a942d05723dbb3f 100644 (file)
@@ -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
index 56d5cb609fccdd2a4aa1a37ccbcf7ad17baa1425..19450b88947b10903286b862279b77bb80bba0a9 100644 (file)
@@ -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)
index 8ab3028c935da6ed477c5b3def762fa1f29f09b5..bb738033f020e8dbfa9e16d9c40093ec4851d540 100644 (file)
 #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);
 }
index c7dacf97624d17a01fec23d4a06d0ae204ccad6c..61971456df3cc3326694f25c1333cc1ab5dbbdef 100644 (file)
@@ -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 */
index 8fd88b12974b80144ae6f06b3934ff75f14abcd5..24daae2cc717b1e11f9fd6dadfc81bb87bf0f9f3 100644 (file)
@@ -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
 
index 41ee8a4c7e865ff2f8f83d1a0cbede8c4521ac3d..2ab892a02339d7b8218321a41c633e97adff3705 100644 (file)
@@ -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);
index c646d7c20ff2898919383ccf31d505fce53e3de9..b0894101414051e80ed7604c3f91d47850418054 100644 (file)
@@ -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.
                         */
index 3628eede210ea7fea530477fa7c32a0f8b0398be..e8adabb2668512022e373cf68ed60ccc7f82f61d 100644 (file)
@@ -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) {
index cd1632986428d401e7458030a1bb8077a8fdd30a..c6da37d692e23b62ffef18c504f253171cbcf268 100644 (file)
@@ -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);
                                                }
index 368fd4fd98d936e51567c227652a54062fc3fa29..a9b364651e70200926e626652c244ba704171006 100644 (file)
@@ -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);
index d63c28bb0cf873cec7a687be10a200d99f16a4b8..c04fb8d63d10b07d51ad9b5347bec9f04f88964c 100644 (file)
@@ -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;
                }
index 807b240870e3eecb22947cdae9f547a823ea8fd4..b3c4f988f19ffe0cd8760a067e69ea5745286d73 100644 (file)
@@ -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];
index 3c89c9c6ca681627b069ac2905bbf6757621b3f6..b82a841f40e0f715a2585b4636f2edf5fe904e7a 100644 (file)
@@ -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)
index 9f2effde46a24c7d51ca22fdfc3fd455b4619706..606ffa657cec40b94b0fec03715cfaa75e22f569 100644 (file)
@@ -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);
                }
        }
 
index 1293d26bc65267e565081baa1d7f6d9690bd3372..f9c628877c1a25c636d78f53988c3df9ca0f8c79 100644 (file)
@@ -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);
index 40ff9ca629b8ac69d614c510060dc4687a62ac25..2275537506139e9fa3dbcefd74ddb71c7166c9aa 100644 (file)
@@ -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;
index 999dab60bc0787c83cef0044c2d39f9b3ed9a643..07f36b3efffe0a9f9b867c2d9cb9d3cdd6c9523f 100644 (file)
@@ -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);
index d3a1f2a14e7d44409eb5259f8e5f40d8827f3590..356355fa61cea8981aa7f2067b6687d757887a6b 100644 (file)
@@ -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");
index 7dcaba5562c8b85377110a00d281240c383548bb..8fa8ddd3098d2a8f0d9d7893b8147a9674d50288 100644 (file)
@@ -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;
 }
index 8675ffec31312acdee6dbc36a9605dea292242cb..8105f94cb31e9399426a6bcfbd8551f77fd5a69e 100644 (file)
@@ -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