Cleanup: remove G.main from BKE object
authorBastien Montagne <montagne29@wanadoo.fr>
Thu, 31 May 2018 10:27:47 +0000 (12:27 +0200)
committerBastien Montagne <montagne29@wanadoo.fr>
Thu, 31 May 2018 10:27:47 +0000 (12:27 +0200)
Had to add some G.main to modifiers, but in 2.8 we do not need that
anymore, so it's not that bad! ;)

19 files changed:
source/blender/blenkernel/BKE_camera.h
source/blender/blenkernel/BKE_dynamicpaint.h
source/blender/blenkernel/BKE_object.h
source/blender/blenkernel/intern/camera.c
source/blender/blenkernel/intern/dynamicpaint.c
source/blender/blenkernel/intern/object.c
source/blender/blenkernel/intern/smoke.c
source/blender/editors/include/ED_object.h
source/blender/editors/object/object_constraint.c
source/blender/editors/object/object_transform.c
source/blender/editors/physics/dynamicpaint_ops.c
source/blender/editors/space_outliner/outliner_tools.c
source/blender/editors/space_view3d/view3d_edit.c
source/blender/editors/space_view3d/view3d_view.c
source/blender/makesrna/intern/rna_constraint.c
source/blender/makesrna/intern/rna_object.c
source/blender/makesrna/intern/rna_pose.c
source/blender/modifiers/intern/MOD_dynamicpaint.c
source/blenderplayer/bad_level_call_stubs/stubs.c

index 04dee70..3695aa4 100644 (file)
@@ -128,7 +128,7 @@ void BKE_camera_view_frame(
         float r_vec[4][3]);
 
 bool BKE_camera_view_frame_fit_to_scene(
-        struct Scene *scene, struct View3D *v3d, struct Object *camera_ob,
+        struct Main *bmain, struct Scene *scene, struct View3D *v3d, struct Object *camera_ob,
         float r_co[3], float *r_scale);
 bool BKE_camera_view_frame_fit_to_coords(
         const struct Scene *scene,
index 5bf9dd8..9d73804 100644 (file)
@@ -27,6 +27,7 @@
  *  \ingroup bke
  */
 
+struct EvaluationContext;
 struct Scene;
 
 /* Actual surface point        */
@@ -60,7 +61,9 @@ typedef struct PaintWavePoint {
        short state;
 } PaintWavePoint;
 
-struct DerivedMesh *dynamicPaint_Modifier_do(struct DynamicPaintModifierData *pmd, struct Scene *scene, struct Object *ob, struct DerivedMesh *dm);
+struct DerivedMesh *dynamicPaint_Modifier_do(
+        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);
 
@@ -83,7 +86,9 @@ 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 DynamicPaintSurface *surface, struct Scene *scene, struct Object *cObject, int frame);
+int dynamicPaint_calculateFrame(
+        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);
 
 /* PaintPoint state */
index 7cc43f3..f9761ad 100644 (file)
@@ -78,7 +78,7 @@ void BKE_object_free_modifiers(struct Object *ob, const int flag);
 void BKE_object_make_proxy(struct Object *ob, struct Object *target, struct Object *gob);
 void BKE_object_copy_proxy_drivers(struct Object *ob, struct Object *target);
 
-bool BKE_object_exists_check(const struct Object *obtest);
+bool BKE_object_exists_check(struct Main *bmain, const struct Object *obtest);
 bool BKE_object_is_in_editmode(const struct Object *ob);
 bool BKE_object_is_in_editmode_vgroup(const struct Object *ob);
 bool BKE_object_is_in_wpaint_select_vert(const struct Object *ob);
@@ -149,13 +149,15 @@ void BKE_object_empty_draw_type_set(struct Object *ob, const int value);
 void BKE_object_boundbox_flag(struct Object *ob, int flag, const bool set);
 void BKE_object_minmax(struct Object *ob, float r_min[3], float r_max[3], const bool use_hidden);
 bool BKE_object_minmax_dupli(
-        struct Scene *scene, struct Object *ob, float r_min[3], float r_max[3], const bool use_hidden);
+        struct Main *bmain, struct Scene *scene,
+        struct Object *ob, float r_min[3], float r_max[3], const bool use_hidden);
 
 /* sometimes min-max isn't enough, we need to loop over each point */
 void BKE_object_foreach_display_point(
         struct Object *ob, float obmat[4][4],
         void (*func_cb)(const float[3], void *), void *user_data);
 void BKE_scene_foreach_display_point(
+        struct Main *bmain,
         struct Scene *scene,
         struct View3D *v3d,
         const short flag,
@@ -282,7 +284,7 @@ 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 Scene *scene, struct Object *ob, bool update_mesh,
+        struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob, bool update_mesh,
         int parent_recursion, float frame,
         int type);
 
index 132cbd0..ed4938c 100644 (file)
@@ -641,7 +641,7 @@ static bool camera_frame_fit_calc_from_data(
 /* don't move the camera, just yield the fit location */
 /* r_scale only valid/useful for ortho cameras */
 bool BKE_camera_view_frame_fit_to_scene(
-        Scene *scene, struct View3D *v3d, Object *camera_ob, float r_co[3], float *r_scale)
+        Main *bmain, Scene *scene, struct View3D *v3d, Object *camera_ob, float r_co[3], float *r_scale)
 {
        CameraParams params;
        CameraViewFrameData data_cb;
@@ -652,7 +652,7 @@ bool BKE_camera_view_frame_fit_to_scene(
        camera_frame_fit_data_init(scene, camera_ob, &params, &data_cb);
 
        /* run callback on all visible points */
-       BKE_scene_foreach_display_point(scene, v3d, BA_SELECT, camera_to_frame_view_cb, &data_cb);
+       BKE_scene_foreach_display_point(bmain, scene, v3d, BA_SELECT, camera_to_frame_view_cb, &data_cb);
 
        return camera_frame_fit_calc_from_data(&params, &data_cb, r_co, r_scale);
 }
index a1f5570..954bfc9 100644 (file)
@@ -60,6 +60,7 @@
 #include "BKE_constraint.h"
 #include "BKE_customdata.h"
 #include "BKE_deform.h"
+#include "BKE_depsgraph.h"
 #include "BKE_DerivedMesh.h"
 #include "BKE_dynamicpaint.h"
 #include "BKE_effect.h"
@@ -2071,7 +2072,8 @@ static void canvas_copyDerivedMesh(DynamicPaintCanvasSettings *canvas, DerivedMe
 /*
  *     Updates derived mesh copy and processes dynamic paint step / caches.
  */
-static void dynamicPaint_frameUpdate(DynamicPaintModifierData *pmd, Scene *scene, Object *ob, DerivedMesh *dm)
+static void dynamicPaint_frameUpdate(
+        EvaluationContext *eval_ctx, DynamicPaintModifierData *pmd, Scene *scene, Object *ob, DerivedMesh *dm)
 {
        if (pmd->canvas) {
                DynamicPaintCanvasSettings *canvas = pmd->canvas;
@@ -2134,7 +2136,7 @@ static void dynamicPaint_frameUpdate(DynamicPaintModifierData *pmd, Scene *scene
                                else if (can_simulate) {
                                        /* calculate surface frame */
                                        canvas->flags |= MOD_DPAINT_BAKING;
-                                       dynamicPaint_calculateFrame(surface, scene, ob, current_frame);
+                                       dynamicPaint_calculateFrame(eval_ctx, surface, scene, ob, current_frame);
                                        canvas->flags &= ~MOD_DPAINT_BAKING;
 
                                        /* restore canvas derivedmesh if required */
@@ -2153,13 +2155,14 @@ static void dynamicPaint_frameUpdate(DynamicPaintModifierData *pmd, Scene *scene
 }
 
 /* Modifier call. Processes dynamic paint modifier step. */
-DerivedMesh *dynamicPaint_Modifier_do(DynamicPaintModifierData *pmd, Scene *scene, Object *ob, DerivedMesh *dm)
+DerivedMesh *dynamicPaint_Modifier_do(
+        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(pmd, scene, ob, dm);
+               dynamicPaint_frameUpdate(eval_ctx, pmd, scene, ob, dm);
 
                /* Return output mesh */
                ret = dynamicPaint_Modifier_apply(pmd, ob, dm);
@@ -2168,7 +2171,7 @@ DerivedMesh *dynamicPaint_Modifier_do(DynamicPaintModifierData *pmd, Scene *scen
        }
        else {
                /* Update canvas data for a new frame */
-               dynamicPaint_frameUpdate(pmd, scene, ob, dm);
+               dynamicPaint_frameUpdate(eval_ctx, pmd, scene, ob, dm);
 
                /* Return output mesh */
                return dynamicPaint_Modifier_apply(pmd, ob, dm);
@@ -3743,7 +3746,8 @@ static void dynamic_paint_brush_velocity_compute_cb(
 }
 
 static void dynamicPaint_brushMeshCalculateVelocity(
-        Scene *scene, Object *ob, DynamicPaintBrushSettings *brush, Vec3f **brushVel, float timescale)
+        EvaluationContext *eval_ctx, Scene *scene,
+        Object *ob, DynamicPaintBrushSettings *brush, Vec3f **brushVel, float timescale)
 {
        float prev_obmat[4][4];
        DerivedMesh *dm_p, *dm_c;
@@ -3765,7 +3769,7 @@ static void dynamicPaint_brushMeshCalculateVelocity(
        scene->r.subframe = prev_sfra;
 
        BKE_object_modifier_update_subframe(
-                   scene, ob, true, SUBFRAME_RECURSION, BKE_scene_frame_get(scene), eModifierType_DynamicPaint);
+                   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);
@@ -3776,7 +3780,7 @@ static void dynamicPaint_brushMeshCalculateVelocity(
        scene->r.subframe = cur_sfra;
 
        BKE_object_modifier_update_subframe(
-                   scene, ob, true, SUBFRAME_RECURSION, BKE_scene_frame_get(scene), eModifierType_DynamicPaint);
+                   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);
@@ -3807,7 +3811,8 @@ static void dynamicPaint_brushMeshCalculateVelocity(
 }
 
 /* calculate velocity for object center point */
-static void dynamicPaint_brushObjectCalculateVelocity(Scene *scene, Object *ob, Vec3f *brushVel, float timescale)
+static void dynamicPaint_brushObjectCalculateVelocity(
+        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};
@@ -3826,14 +3831,14 @@ static void dynamicPaint_brushObjectCalculateVelocity(Scene *scene, Object *ob,
        scene->r.cfra = prev_fra;
        scene->r.subframe = prev_sfra;
        BKE_object_modifier_update_subframe(
-                   scene, ob, false, SUBFRAME_RECURSION, BKE_scene_frame_get(scene), eModifierType_DynamicPaint);
+                   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(
-                   scene, ob, false, SUBFRAME_RECURSION, BKE_scene_frame_get(scene), eModifierType_DynamicPaint);
+                   eval_ctx, scene, ob, false, SUBFRAME_RECURSION, BKE_scene_frame_get(scene), eModifierType_DynamicPaint);
 
        /* calculate speed */
        mul_m4_v3(prev_obmat, prev_loc);
@@ -4205,7 +4210,8 @@ static void dynamic_paint_paint_mesh_cell_point_cb_ex(
        }
 }
 
-static int dynamicPaint_paintMesh(DynamicPaintSurface *surface,
+static int dynamicPaint_paintMesh(EvaluationContext *eval_ctx,
+                                  DynamicPaintSurface *surface,
                                   DynamicPaintBrushSettings *brush,
                                   Object *brushOb,
                                   BrushMaterials *bMats,
@@ -4221,7 +4227,7 @@ static int dynamicPaint_paintMesh(DynamicPaintSurface *surface,
        const MLoop *mloop = NULL;
 
        if (brush->flags & MOD_DPAINT_USES_VELOCITY)
-               dynamicPaint_brushMeshCalculateVelocity(scene, brushOb, brush, &brushVelocity, timescale);
+               dynamicPaint_brushMeshCalculateVelocity(eval_ctx, scene, brushOb, brush, &brushVelocity, timescale);
 
        if (!brush->dm)
                return 0;
@@ -4711,7 +4717,7 @@ static void dynamic_paint_paint_single_point_cb_ex(
 }
 
 static int dynamicPaint_paintSinglePoint(
-        DynamicPaintSurface *surface, float *pointCoord, DynamicPaintBrushSettings *brush,
+        EvaluationContext *eval_ctx, DynamicPaintSurface *surface, float *pointCoord, DynamicPaintBrushSettings *brush,
         Object *brushOb, BrushMaterials *bMats, Scene *scene, float timescale)
 {
        PaintSurfaceData *sData = surface->data;
@@ -4719,7 +4725,7 @@ static int dynamicPaint_paintSinglePoint(
        Vec3f brushVel;
 
        if (brush->flags & MOD_DPAINT_USES_VELOCITY)
-               dynamicPaint_brushObjectCalculateVelocity(scene, brushOb, &brushVel, timescale);
+               dynamicPaint_brushObjectCalculateVelocity(eval_ctx, scene, brushOb, &brushVel, timescale);
 
        const MVert *mvert = brush->dm->getVertArray(brush->dm);
 
@@ -6009,7 +6015,9 @@ 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(Scene *scene, Object *ob, DynamicPaintSurface *surface, float timescale, float subframe)
+static int dynamicPaint_doStep(
+        EvaluationContext *eval_ctx, Scene *scene,
+        Object *ob, DynamicPaintSurface *surface, float timescale, float subframe)
 {
        PaintSurfaceData *sData = surface->data;
        PaintBakeData *bData = sData->bData;
@@ -6092,7 +6100,7 @@ static int dynamicPaint_doStep(Scene *scene, Object *ob, DynamicPaintSurface *su
                                        /* update object data on this subframe */
                                        if (subframe) {
                                                scene_setSubframe(scene, subframe);
-                                               BKE_object_modifier_update_subframe(scene, brushObj, true, SUBFRAME_RECURSION,
+                                               BKE_object_modifier_update_subframe(eval_ctx, scene, brushObj, true, SUBFRAME_RECURSION,
                                                                                    BKE_scene_frame_get(scene), eModifierType_DynamicPaint);
                                        }
                                        /* Prepare materials if required        */
@@ -6114,11 +6122,12 @@ static int dynamicPaint_doStep(Scene *scene, Object *ob, DynamicPaintSurface *su
                                        }
                                        /* Object center distance: */
                                        else if (brush->collision == MOD_DPAINT_COL_POINT && brushObj != ob) {
-                                               dynamicPaint_paintSinglePoint(surface, brushObj->loc, brush, brushObj, &bMats, scene, timescale);
+                                               dynamicPaint_paintSinglePoint(
+                                                           eval_ctx, surface, brushObj->loc, brush, brushObj, &bMats, scene, timescale);
                                        }
                                        /* Mesh volume/proximity: */
                                        else if (brushObj != ob) {
-                                               dynamicPaint_paintMesh(surface, brush, brushObj, &bMats, scene, timescale);
+                                               dynamicPaint_paintMesh(eval_ctx, surface, brush, brushObj, &bMats, scene, timescale);
                                        }
 
                                        /* free temp material data */
@@ -6128,7 +6137,7 @@ static int dynamicPaint_doStep(Scene *scene, Object *ob, DynamicPaintSurface *su
                                        if (subframe) {
                                                scene->r.cfra = scene_frame;
                                                scene->r.subframe = scene_subframe;
-                                               BKE_object_modifier_update_subframe(scene, brushObj, true, SUBFRAME_RECURSION,
+                                               BKE_object_modifier_update_subframe(eval_ctx, scene, brushObj, true, SUBFRAME_RECURSION,
                                                                                    BKE_scene_frame_get(scene), eModifierType_DynamicPaint);
                                        }
 
@@ -6187,7 +6196,8 @@ static int dynamicPaint_doStep(Scene *scene, Object *ob, DynamicPaintSurface *su
 /*
  * Calculate a single frame and included subframes for surface
  */
-int dynamicPaint_calculateFrame(DynamicPaintSurface *surface, Scene *scene, Object *cObject, int frame)
+int dynamicPaint_calculateFrame(
+        EvaluationContext *eval_ctx, DynamicPaintSurface *surface, Scene *scene, Object *cObject, int frame)
 {
        float timescale = 1.0f;
 
@@ -6205,10 +6215,10 @@ int dynamicPaint_calculateFrame(DynamicPaintSurface *surface, Scene *scene, Obje
 
                for (st = 1; st <= surface->substeps; st++) {
                        float subframe = ((float) st) / (surface->substeps + 1);
-                       if (!dynamicPaint_doStep(scene, cObject, surface, timescale, subframe))
+                       if (!dynamicPaint_doStep(eval_ctx, scene, cObject, surface, timescale, subframe))
                                return 0;
                }
        }
 
-       return dynamicPaint_doStep(scene, cObject, surface, timescale, 0.0f);
+       return dynamicPaint_doStep(eval_ctx, scene, cObject, surface, timescale, 0.0f);
 }
index 22a4db9..02578a7 100644 (file)
@@ -529,13 +529,13 @@ bool BKE_object_is_in_wpaint_select_vert(const Object *ob)
        return false;
 }
 
-bool BKE_object_exists_check(const Object *obtest)
+bool BKE_object_exists_check(Main *bmain, const Object *obtest)
 {
        Object *ob;
        
        if (obtest == NULL) return false;
        
-       ob = G.main->object.first;
+       ob = bmain->object.first;
        while (ob) {
                if (ob == obtest) return true;
                ob = ob->id.next;
@@ -2421,7 +2421,9 @@ void BKE_object_empty_draw_type_set(Object *ob, const int value)
        }
 }
 
-bool BKE_object_minmax_dupli(Scene *scene, Object *ob, float r_min[3], float r_max[3], const bool use_hidden)
+bool BKE_object_minmax_dupli(
+        Main *bmain, Scene *scene,
+        Object *ob, float r_min[3], float r_max[3], const bool use_hidden)
 {
        bool ok = false;
        if ((ob->transflag & OB_DUPLI) == 0) {
@@ -2430,7 +2432,7 @@ bool BKE_object_minmax_dupli(Scene *scene, Object *ob, float r_min[3], float r_m
        else {
                ListBase *lb;
                DupliObject *dob;
-               lb = object_duplilist(G.main->eval_ctx, scene, ob);
+               lb = object_duplilist(bmain->eval_ctx, scene, ob);
                for (dob = lb->first; dob; dob = dob->next) {
                        if ((use_hidden == false) && (dob->no_draw != 0)) {
                                /* pass */
@@ -2490,7 +2492,7 @@ void BKE_object_foreach_display_point(
 }
 
 void BKE_scene_foreach_display_point(
-        Scene *scene, View3D *v3d, const short flag,
+        Main *bmain, Scene *scene, View3D *v3d, const short flag,
         void (*func_cb)(const float[3], void *), void *user_data)
 {
        Base *base;
@@ -2507,7 +2509,7 @@ void BKE_scene_foreach_display_point(
                                ListBase *lb;
                                DupliObject *dob;
 
-                               lb = object_duplilist(G.main->eval_ctx, scene, ob);
+                               lb = object_duplilist(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);
@@ -3603,7 +3605,7 @@ 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(Scene *scene, Object *ob, bool update_mesh,
+bool BKE_object_modifier_update_subframe(EvaluationContext *eval_ctx, Scene *scene, Object *ob, bool update_mesh,
                                          int parent_recursion, float frame,
                                          int type)
 {
@@ -3628,8 +3630,8 @@ bool BKE_object_modifier_update_subframe(Scene *scene, Object *ob, bool update_m
        if (parent_recursion) {
                int recursion = parent_recursion - 1;
                bool no_update = false;
-               if (ob->parent) no_update |= BKE_object_modifier_update_subframe(scene, ob->parent, 0, recursion, frame, type);
-               if (ob->track) no_update |= BKE_object_modifier_update_subframe(scene, ob->track, 0, recursion, frame, type);
+               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);
 
                /* skip subframe if object is parented
                 *  to vertex of a dynamic paint canvas */
@@ -3646,7 +3648,7 @@ bool BKE_object_modifier_update_subframe(Scene *scene, Object *ob, bool update_m
                                cti->get_constraint_targets(con, &targets);
                                for (ct = targets.first; ct; ct = ct->next) {
                                        if (ct->tar)
-                                               BKE_object_modifier_update_subframe(scene, ct->tar, 0, recursion, frame, type);
+                                               BKE_object_modifier_update_subframe(eval_ctx, scene, ct->tar, 0, recursion, frame, type);
                                }
                                /* free temp targets */
                                if (cti->flush_constraint_targets)
@@ -3662,7 +3664,7 @@ bool BKE_object_modifier_update_subframe(Scene *scene, Object *ob, bool update_m
                /* ignore cache clear during subframe updates
                 *  to not mess up cache validity */
                object_cacheIgnoreClear(ob, 1);
-               BKE_object_handle_update(G.main->eval_ctx, scene, ob);
+               BKE_object_handle_update(eval_ctx, scene, ob);
                object_cacheIgnoreClear(ob, 0);
        }
        else
index a8db1ac..41ee8a4 100644 (file)
 #include "BKE_constraint.h"
 #include "BKE_customdata.h"
 #include "BKE_deform.h"
+#include "BKE_depsgraph.h"
 #include "BKE_DerivedMesh.h"
 #include "BKE_effect.h"
+#include "BKE_global.h"
 #include "BKE_main.h"
 #include "BKE_modifier.h"
 #include "BKE_object.h"
@@ -2104,7 +2106,7 @@ BLI_INLINE void apply_inflow_fields(SmokeFlowSettings *sfs, float emission_value
        }
 }
 
-static void update_flowsfluids(Scene *scene, Object *ob, SmokeDomainSettings *sds, float dt)
+static void update_flowsfluids(EvaluationContext *eval_ctx, Scene *scene, Object *ob, SmokeDomainSettings *sds, float dt)
 {
        Object **flowobjs = NULL;
        EmissionMap *emaps = NULL;
@@ -2211,7 +2213,7 @@ static void update_flowsfluids(Scene *scene, Object *ob, SmokeDomainSettings *sd
                                        else { /* MOD_SMOKE_FLOW_SOURCE_MESH */
                                                /* update flow object frame */
                                                BLI_mutex_lock(&object_update_lock);
-                                               BKE_object_modifier_update_subframe(scene, collob, true, 5, BKE_scene_frame_get(scene), eModifierType_Smoke);
+                                               BKE_object_modifier_update_subframe(eval_ctx, scene, collob, true, 5, BKE_scene_frame_get(scene), eModifierType_Smoke);
                                                BLI_mutex_unlock(&object_update_lock);
 
                                                /* apply flow */
@@ -2558,7 +2560,8 @@ static void update_effectors(Scene *scene, Object *ob, SmokeDomainSettings *sds,
        pdEndEffectors(&effectors);
 }
 
-static void step(Scene *scene, Object *ob, SmokeModifierData *smd, DerivedMesh *domain_dm, float fps)
+static void step(
+        EvaluationContext *eval_ctx, Scene *scene, Object *ob, SmokeModifierData *smd, DerivedMesh *domain_dm, float fps)
 {
        SmokeDomainSettings *sds = smd->domain;
        /* stability values copied from wturbulence.cpp */
@@ -2628,7 +2631,7 @@ static void step(Scene *scene, Object *ob, SmokeModifierData *smd, DerivedMesh *
        for (substep = 0; substep < totalSubsteps; substep++)
        {
                // calc animated obstacle velocities
-               update_flowsfluids(scene, ob, sds, dtSubdiv);
+               update_flowsfluids(eval_ctx, scene, ob, sds, dtSubdiv);
                update_obstacles(scene, ob, sds, dtSubdiv, substep, totalSubsteps);
 
                if (sds->total_cells > 1) {
@@ -2725,7 +2728,7 @@ static DerivedMesh *createDomainGeometry(SmokeDomainSettings *sds, Object *ob)
        return result;
 }
 
-static void smokeModifier_process(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedMesh *dm)
+static void smokeModifier_process(EvaluationContext *eval_ctx, SmokeModifierData *smd, Scene *scene, Object *ob, DerivedMesh *dm)
 {
        if ((smd->type & MOD_SMOKE_TYPE_FLOW))
        {
@@ -2846,7 +2849,7 @@ static void smokeModifier_process(SmokeModifierData *smd, Scene *scene, Object *
 
                        }
 
-                       step(scene, ob, smd, dm, scene->r.frs_sec / scene->r.frs_sec_base);
+                       step(eval_ctx, scene, ob, smd, dm, scene->r.frs_sec / scene->r.frs_sec_base);
                }
 
                // create shadows before writing cache so they get stored
@@ -2873,7 +2876,8 @@ struct DerivedMesh *smokeModifier_do(SmokeModifierData *smd, Scene *scene, Objec
        if ((smd->type & MOD_SMOKE_TYPE_DOMAIN) && smd->domain)
                BLI_rw_mutex_lock(smd->domain->fluid_mutex, THREAD_LOCK_WRITE);
 
-       smokeModifier_process(smd, scene, ob, dm);
+       /* Ugly G.main, hopefully won't be needed anymore in 2.8 */
+       smokeModifier_process(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 f94927c..448e0ef 100644 (file)
@@ -184,13 +184,13 @@ struct ListBase *get_active_constraints(struct Object *ob);
 struct ListBase *get_constraint_lb(struct Object *ob, struct bConstraint *con, struct bPoseChannel **r_pchan);
 struct bConstraint *get_active_constraint(struct Object *ob);
 
-void object_test_constraints(struct Object *ob);
+void object_test_constraints(struct Main *bmain, struct Object *ob);
 
 void ED_object_constraint_set_active(struct Object *ob, struct bConstraint *con);
-void ED_object_constraint_update(struct Object *ob);
+void ED_object_constraint_update(struct Main *bmain, struct Object *ob);
 void ED_object_constraint_dependency_update(struct Main *bmain, struct Object *ob);
 
-void ED_object_constraint_tag_update(struct Object *ob, struct bConstraint *con);
+void ED_object_constraint_tag_update(struct Main *bmain, struct Object *ob, struct bConstraint *con);
 void ED_object_constraint_dependency_tag_update(struct Main *bmain, struct Object *ob, struct bConstraint *con);
 
 /* object_modes.c */
index 94caaed..1ec47cd 100644 (file)
@@ -260,7 +260,7 @@ static void set_constraint_nth_target(bConstraint *con, Object *target, const ch
 
 /* ------------- Constraint Sanity Testing ------------------- */
 
-static void test_constraint(Object *owner, bPoseChannel *pchan, bConstraint *con, int type)
+static void test_constraint(Main *bmain, Object *owner, bPoseChannel *pchan, bConstraint *con, int type)
 {
        const bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(con);
        ListBase targets = {NULL, NULL};
@@ -278,7 +278,7 @@ static void test_constraint(Object *owner, bPoseChannel *pchan, bConstraint *con
                 *              the constraint is deemed invalid
                 */
                /* default IK check ... */
-               if (BKE_object_exists_check(data->tar) == 0) {
+               if (BKE_object_exists_check(bmain, data->tar) == 0) {
                        data->tar = NULL;
                        con->flag |= CONSTRAINT_DISABLE;
                }
@@ -289,7 +289,7 @@ static void test_constraint(Object *owner, bPoseChannel *pchan, bConstraint *con
                }
 
                if (data->poletar) {
-                       if (BKE_object_exists_check(data->poletar) == 0) {
+                       if (BKE_object_exists_check(bmain, data->poletar) == 0) {
                                data->poletar = NULL;
                                con->flag |= CONSTRAINT_DISABLE;
                        }
@@ -308,7 +308,7 @@ static void test_constraint(Object *owner, bPoseChannel *pchan, bConstraint *con
                bPivotConstraint *data = con->data;
 
                /* target doesn't have to exist, but if it is non-null, it must exist! */
-               if (data->tar && BKE_object_exists_check(data->tar) == 0) {
+               if (data->tar && BKE_object_exists_check(bmain, data->tar) == 0) {
                        data->tar = NULL;
                        con->flag |= CONSTRAINT_DISABLE;
                }
@@ -431,7 +431,7 @@ static void test_constraint(Object *owner, bPoseChannel *pchan, bConstraint *con
                /* disable and clear constraints targets that are incorrect */
                for (ct = targets.first; ct; ct = ct->next) {
                        /* general validity checks (for those constraints that need this) */
-                       if (BKE_object_exists_check(ct->tar) == 0) {
+                       if (BKE_object_exists_check(bmain, ct->tar) == 0) {
                                /* object doesn't exist, but constraint requires target */
                                ct->tar = NULL;
                                con->flag |= CONSTRAINT_DISABLE;
@@ -501,7 +501,7 @@ static int constraint_type_get(Object *owner, bPoseChannel *pchan)
 /* checks validity of object pointers, and NULLs,
  * if Bone doesnt exist it sets the CONSTRAINT_DISABLE flag.
  */
-static void test_constraints(Object *owner, bPoseChannel *pchan)
+static void test_constraints(Main *bmain, Object *owner, bPoseChannel *pchan)
 {
        bConstraint *curcon;
        ListBase *conlist = NULL;
@@ -524,44 +524,44 @@ static void test_constraints(Object *owner, bPoseChannel *pchan)
        /* Check all constraints - is constraint valid? */
        if (conlist) {
                for (curcon = conlist->first; curcon; curcon = curcon->next) {
-                       test_constraint(owner, pchan, curcon, type);
+                       test_constraint(bmain, owner, pchan, curcon, type);
                }
        }
 }
 
-void object_test_constraints(Object *owner)
+void object_test_constraints(Main *bmain, Object *owner)
 {
        if (owner->constraints.first)
-               test_constraints(owner, NULL);
+               test_constraints(bmain, owner, NULL);
        
        if (owner->type == OB_ARMATURE && owner->pose) {
                bPoseChannel *pchan;
                
                for (pchan = owner->pose->chanbase.first; pchan; pchan = pchan->next) {
                        if (pchan->constraints.first)
-                               test_constraints(owner, pchan);
+                               test_constraints(bmain, owner, pchan);
                }
        }
 }
 
-static void object_test_constraint(Object *owner, bConstraint *con)
+static void object_test_constraint(Main *bmain, Object *owner, bConstraint *con)
 {
        if (owner->type == OB_ARMATURE && owner->pose) {
                if (BLI_findindex(&owner->constraints, con) != -1) {
-                       test_constraint(owner, NULL, con, CONSTRAINT_OBTYPE_OBJECT);
+                       test_constraint(bmain, owner, NULL, con, CONSTRAINT_OBTYPE_OBJECT);
                }
                else {
                        bPoseChannel *pchan;
                        for (pchan = owner->pose->chanbase.first; pchan; pchan = pchan->next) {
                                if (BLI_findindex(&pchan->constraints, con) != -1) {
-                                       test_constraint(owner, pchan, con, CONSTRAINT_OBTYPE_BONE);
+                                       test_constraint(bmain, owner, pchan, con, CONSTRAINT_OBTYPE_BONE);
                                        break;
                                }
                        }
                }
        }
        else {
-               test_constraint(owner, NULL, con, CONSTRAINT_OBTYPE_OBJECT);
+               test_constraint(bmain, owner, NULL, con, CONSTRAINT_OBTYPE_OBJECT);
        }
 }
 
@@ -682,6 +682,7 @@ static bConstraint *edit_constraint_property_get(wmOperator *op, Object *ob, int
 
 static int stretchto_reset_exec(bContext *C, wmOperator *op)
 {
+       Main *bmain = CTX_data_main(C);
        Object *ob = ED_object_active_context(C);
        bConstraint *con = edit_constraint_property_get(op, ob, CONSTRAINT_TYPE_STRETCHTO);
        bStretchToConstraint *data = (con) ? (bStretchToConstraint *)con->data : NULL;
@@ -692,7 +693,7 @@ static int stretchto_reset_exec(bContext *C, wmOperator *op)
        
        /* just set original length to 0.0, which will cause a reset on next recalc */
        data->orglength = 0.0f;
-       ED_object_constraint_update(ob);
+       ED_object_constraint_update(bmain, ob);
        
        WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT, NULL);
        return OPERATOR_FINISHED;
@@ -728,6 +729,7 @@ void CONSTRAINT_OT_stretchto_reset(wmOperatorType *ot)
 
 static int limitdistance_reset_exec(bContext *C, wmOperator *op)
 {
+       Main *bmain = CTX_data_main(C);
        Object *ob = ED_object_active_context(C);
        bConstraint *con = edit_constraint_property_get(op, ob, CONSTRAINT_TYPE_DISTLIMIT);
        bDistLimitConstraint *data = (con) ? (bDistLimitConstraint *)con->data : NULL;
@@ -738,7 +740,7 @@ static int limitdistance_reset_exec(bContext *C, wmOperator *op)
        
        /* just set original length to 0.0, which will cause a reset on next recalc */
        data->dist = 0.0f;
-       ED_object_constraint_update(ob);
+       ED_object_constraint_update(bmain, ob);
        
        WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT, NULL);
        return OPERATOR_FINISHED;
@@ -1189,11 +1191,11 @@ void ED_object_constraint_set_active(Object *ob, bConstraint *con)
        BKE_constraints_active_set(lb, con);
 }
 
-void ED_object_constraint_update(Object *ob)
+void ED_object_constraint_update(Main *bmain, Object *ob)
 {
        if (ob->pose) BKE_pose_update_constraint_flags(ob->pose);
 
-       object_test_constraints(ob);
+       object_test_constraints(bmain, ob);
 
        if (ob->type == OB_ARMATURE) 
                DAG_id_tag_update(&ob->id, OB_RECALC_DATA | OB_RECALC_OB);
@@ -1216,7 +1218,7 @@ static void object_pose_tag_update(Main *bmain, Object *ob)
 
 void ED_object_constraint_dependency_update(Main *bmain, Object *ob)
 {
-       ED_object_constraint_update(ob);
+       ED_object_constraint_update(bmain, ob);
 
        if (ob->pose) {
                object_pose_tag_update(bmain, ob);
@@ -1224,13 +1226,13 @@ void ED_object_constraint_dependency_update(Main *bmain, Object *ob)
        DAG_relations_tag_update(bmain);
 }
 
-void ED_object_constraint_tag_update(Object *ob, bConstraint *con)
+void ED_object_constraint_tag_update(Main *bmain, Object *ob, bConstraint *con)
 {
        if (ob->pose) {
                BKE_pose_tag_update_constraint_flags(ob->pose);
        }
 
-       object_test_constraint(ob, con);
+       object_test_constraint(bmain, ob, con);
 
        if (ob->type == OB_ARMATURE)
                DAG_id_tag_update(&ob->id, OB_RECALC_DATA | OB_RECALC_OB);
@@ -1240,7 +1242,7 @@ void ED_object_constraint_tag_update(Object *ob, bConstraint *con)
 
 void ED_object_constraint_dependency_tag_update(Main *bmain, Object *ob, bConstraint *con)
 {
-       ED_object_constraint_tag_update(ob, con);
+       ED_object_constraint_tag_update(bmain, ob, con);
 
        if (ob->pose) {
                object_pose_tag_update(bmain, ob);
@@ -1257,6 +1259,7 @@ static int constraint_poll(bContext *C)
 
 static int constraint_delete_exec(bContext *C, wmOperator *UNUSED(op))
 {
+       Main *bmain = CTX_data_main(C);
        PointerRNA ptr = CTX_data_pointer_get_type(C, "constraint", &RNA_Constraint);
        Object *ob = ptr.id.data;
        bConstraint *con = ptr.data;
@@ -1266,7 +1269,7 @@ static int constraint_delete_exec(bContext *C, wmOperator *UNUSED(op))
        if (BKE_constraint_remove_ex(lb, ob, con, true)) {
                /* there's no active constraint now, so make sure this is the case */
                BKE_constraints_active_set(&ob->constraints, NULL);
-               ED_object_constraint_update(ob); /* needed to set the flags on posebones correctly */
+               ED_object_constraint_update(bmain, ob); /* needed to set the flags on posebones correctly */
 
                /* relatiols */
                DAG_relations_tag_update(CTX_data_main(C));
@@ -1810,7 +1813,7 @@ static int constraint_add_exec(bContext *C, wmOperator *op, Object *ob, ListBase
        }
        
        /* make sure all settings are valid - similar to above checks, but sometimes can be wrong */
-       object_test_constraints(ob);
+       object_test_constraints(bmain, ob);
 
        if (pchan)
                BKE_pose_update_constraint_flags(ob->pose);
index e29d49d..080710e 100644 (file)
@@ -883,7 +883,7 @@ static int object_origin_set_exec(bContext *C, wmOperator *op)
                                                        float min[3], max[3];
                                                        /* only bounds support */
                                                        INIT_MINMAX(min, max);
-                                                       BKE_object_minmax_dupli(scene, ob, min, max, true);
+                                                       BKE_object_minmax_dupli(bmain, scene, ob, min, max, true);
                                                        mid_v3_v3v3(cent, min, max);
                                                        invert_m4_m4(ob->imat, ob->obmat);
                                                        mul_m4_v3(ob->imat, cent);
index 86db76b..92f4ef8 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(surface, scene, cObject, frame)) {
+               if (!dynamicPaint_calculateFrame(job->bmain->eval_ctx, surface, scene, cObject, frame)) {
                        job->success = 0;
                        return;
                }
index 20e011d..dda54f8 100644 (file)
@@ -745,18 +745,19 @@ static void data_select_linked_cb(int event, TreeElement *te, TreeStoreElem *UNU
 static void constraint_cb(int event, TreeElement *te, TreeStoreElem *UNUSED(tselem), void *C_v)
 {
        bContext *C = C_v;
+       Main *bmain = CTX_data_main(C);
        SpaceOops *soops = CTX_wm_space_outliner(C);
        bConstraint *constraint = (bConstraint *)te->directdata;
        Object *ob = (Object *)outliner_search_back(soops, te, ID_OB);
 
        if (event == OL_CONSTRAINTOP_ENABLE) {
                constraint->flag &= ~CONSTRAINT_OFF;
-               ED_object_constraint_update(ob);
+               ED_object_constraint_update(bmain, ob);
                WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT, ob);
        }
        else if (event == OL_CONSTRAINTOP_DISABLE) {
                constraint->flag = CONSTRAINT_OFF;
-               ED_object_constraint_update(ob);
+               ED_object_constraint_update(bmain, ob);
                WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT, ob);
        }
        else if (event == OL_CONSTRAINTOP_DELETE) {
@@ -772,7 +773,7 @@ static void constraint_cb(int event, TreeElement *te, TreeStoreElem *UNUSED(tsel
                if (BKE_constraint_remove_ex(lb, ob, constraint, true)) {
                        /* there's no active constraint now, so make sure this is the case */
                        BKE_constraints_active_set(&ob->constraints, NULL);
-                       ED_object_constraint_update(ob); /* needed to set the flags on posebones correctly */
+                       ED_object_constraint_update(bmain, ob); /* needed to set the flags on posebones correctly */
                        WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT | NA_REMOVED, ob);
                        te->store_elem->flag &= ~TSE_SELECTED;
                }
index 8573bb3..b175ee0 100644 (file)
@@ -51,6 +51,7 @@
 #include "BKE_context.h"
 #include "BKE_font.h"
 #include "BKE_library.h"
+#include "BKE_main.h"
 #include "BKE_object.h"
 #include "BKE_paint.h"
 #include "BKE_report.h"
@@ -2779,6 +2780,7 @@ void VIEW3D_OT_view_all(wmOperatorType *ot)
 /* like a localview without local!, was centerview() in 2.4x */
 static int viewselected_exec(bContext *C, wmOperator *op)
 {
+       Main *bmain = CTX_data_main(C);
        ARegion *ar = CTX_wm_region(C);
        View3D *v3d = CTX_wm_view3d(C);
        Scene *scene = CTX_data_scene(C);
@@ -2858,7 +2860,7 @@ static int viewselected_exec(bContext *C, wmOperator *op)
                                }
 
                                /* account for duplis */
-                               if (BKE_object_minmax_dupli(scene, base->object, min, max, false) == 0)
+                               if (BKE_object_minmax_dupli(bmain, scene, base->object, min, max, false) == 0)
                                        BKE_object_minmax(base->object, min, max, false);  /* use if duplis not found */
 
                                ok = 1;
index 56f0e39..365465f 100644 (file)
@@ -504,6 +504,7 @@ void VIEW3D_OT_camera_to_view(wmOperatorType *ot)
  * meant to take into account vertex/bone selection for eg. */
 static int view3d_camera_to_view_selected_exec(bContext *C, wmOperator *op)
 {
+       Main *bmain = CTX_data_main(C);
        Scene *scene = CTX_data_scene(C);
        View3D *v3d = CTX_wm_view3d(C);  /* can be NULL */
        Object *camera_ob = v3d ? v3d->camera : scene->camera;
@@ -517,7 +518,7 @@ static int view3d_camera_to_view_selected_exec(bContext *C, wmOperator *op)
        }
 
        /* this function does all the important stuff */
-       if (BKE_camera_view_frame_fit_to_scene(scene, v3d, camera_ob, r_co, &r_scale)) {
+       if (BKE_camera_view_frame_fit_to_scene(bmain, scene, v3d, camera_ob, r_co, &r_scale)) {
                ObjectTfmProtectedChannels obtfm;
                float obmat_new[4][4];
 
index b602c90..55153c2 100644 (file)
@@ -278,9 +278,9 @@ static char *rna_Constraint_path(PointerRNA *ptr)
        }
 }
 
-static void rna_Constraint_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
+static void rna_Constraint_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr)
 {
-       ED_object_constraint_tag_update(ptr->id.data, ptr->data);
+       ED_object_constraint_tag_update(bmain, ptr->id.data, ptr->data);
 }
 
 static void rna_Constraint_dependency_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr)
index b1fcfcb..f3ff88c 100644 (file)
@@ -1323,17 +1323,17 @@ static void rna_Object_active_constraint_set(PointerRNA *ptr, PointerRNA value)
        BKE_constraints_active_set(&ob->constraints, (bConstraint *)value.data);
 }
 
-static bConstraint *rna_Object_constraints_new(Object *object, int type)
+static bConstraint *rna_Object_constraints_new(Object *object, Main *bmain, int type)
 {
        bConstraint *new_con = BKE_constraint_add_for_object(object, NULL, type);
 
-       ED_object_constraint_tag_update(object, new_con);
+       ED_object_constraint_tag_update(bmain, object, new_con);
        WM_main_add_notifier(NC_OBJECT | ND_CONSTRAINT | NA_ADDED, object);
 
        return new_con;
 }
 
-static void rna_Object_constraints_remove(Object *object, ReportList *reports, PointerRNA *con_ptr)
+static void rna_Object_constraints_remove(Object *object, Main *bmain, ReportList *reports, PointerRNA *con_ptr)
 {
        bConstraint *con = con_ptr->data;
        if (BLI_findindex(&object->constraints, con) == -1) {
@@ -1344,16 +1344,16 @@ static void rna_Object_constraints_remove(Object *object, ReportList *reports, P
        BKE_constraint_remove(&object->constraints, con);
        RNA_POINTER_INVALIDATE(con_ptr);
 
-       ED_object_constraint_update(object);
+       ED_object_constraint_update(bmain, object);
        ED_object_constraint_set_active(object, NULL);
        WM_main_add_notifier(NC_OBJECT | ND_CONSTRAINT | NA_REMOVED, object);
 }
 
-static void rna_Object_constraints_clear(Object *object)
+static void rna_Object_constraints_clear(Object *object, Main *bmain)
 {
        BKE_constraints_free(&object->constraints);
 
-       ED_object_constraint_update(object);
+       ED_object_constraint_update(bmain, object);
        ED_object_constraint_set_active(object, NULL);
 
        WM_main_add_notifier(NC_OBJECT | ND_CONSTRAINT | NA_REMOVED, object);
@@ -1962,6 +1962,7 @@ static void rna_def_object_constraints(BlenderRNA *brna, PropertyRNA *cprop)
        /* Constraint collection */
        func = RNA_def_function(srna, "new", "rna_Object_constraints_new");
        RNA_def_function_ui_description(func, "Add a new constraint to this object");
+       RNA_def_function_flag(func, FUNC_USE_MAIN);
        /* object to add */
        parm = RNA_def_enum(func, "type", rna_enum_constraint_type_items, 1, "", "Constraint type to add");
        RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
@@ -1971,13 +1972,14 @@ static void rna_def_object_constraints(BlenderRNA *brna, PropertyRNA *cprop)
 
        func = RNA_def_function(srna, "remove", "rna_Object_constraints_remove");
        RNA_def_function_ui_description(func, "Remove a constraint from this object");
-       RNA_def_function_flag(func, FUNC_USE_REPORTS);
+       RNA_def_function_flag(func, FUNC_USE_MAIN | FUNC_USE_REPORTS);
        /* constraint to remove */
        parm = RNA_def_pointer(func, "constraint", "Constraint", "", "Removed constraint");
        RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
        RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0);
 
        func = RNA_def_function(srna, "clear", "rna_Object_constraints_clear");
+       RNA_def_function_flag(func, FUNC_USE_MAIN);
        RNA_def_function_ui_description(func, "Remove all constraint from this object");
 }
 
index ac27a6c..d891170 100644 (file)
@@ -237,7 +237,7 @@ static void rna_Pose_ik_solver_update(Main *bmain, Scene *UNUSED(scene), Pointer
        
        BKE_pose_update_constraint_flags(pose);
        
-       object_test_constraints(ob);
+       object_test_constraints(bmain, ob);
 
        DAG_id_tag_update(&ob->id, OB_RECALC_DATA | OB_RECALC_OB);
 }
@@ -535,7 +535,8 @@ static bConstraint *rna_PoseChannel_constraints_new(ID *id, bPoseChannel *pchan,
        return new_con;
 }
 
-static void rna_PoseChannel_constraints_remove(ID *id, bPoseChannel *pchan, ReportList *reports, PointerRNA *con_ptr)
+static void rna_PoseChannel_constraints_remove(
+        ID *id, bPoseChannel *pchan, Main *bmain, ReportList *reports, PointerRNA *con_ptr)
 {
        bConstraint *con = con_ptr->data;
        const bool is_ik = ELEM(con->type, CONSTRAINT_TYPE_KINEMATIC, CONSTRAINT_TYPE_SPLINEIK);
@@ -549,7 +550,7 @@ static void rna_PoseChannel_constraints_remove(ID *id, bPoseChannel *pchan, Repo
        BKE_constraint_remove(&pchan->constraints, con);
        RNA_POINTER_INVALIDATE(con_ptr);
 
-       ED_object_constraint_update(ob);
+       ED_object_constraint_update(bmain, ob);
 
        BKE_constraints_active_set(&pchan->constraints, NULL);  /* XXX, is this really needed? - Campbell */
 
@@ -777,7 +778,7 @@ static void rna_def_pose_channel_constraints(BlenderRNA *brna, PropertyRNA *cpro
 
        func = RNA_def_function(srna, "remove", "rna_PoseChannel_constraints_remove");
        RNA_def_function_ui_description(func, "Remove a constraint from this object");
-       RNA_def_function_flag(func, FUNC_USE_REPORTS | FUNC_USE_SELF_ID); /* ID needed for refresh */
+       RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_MAIN | FUNC_USE_REPORTS ); /* ID needed for refresh */
        /* constraint to remove */
        parm = RNA_def_pointer(func, "constraint", "Constraint", "", "Removed constraint");
        RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
index 2c1a1a3..7dcaba5 100644 (file)
 
 #include "BKE_cdderivedmesh.h"
 #include "BKE_dynamicpaint.h"
+#include "BKE_global.h"
 #include "BKE_library.h"
 #include "BKE_library_query.h"
+#include "BKE_main.h"
 #include "BKE_modifier.h"
 
 #include "depsgraph_private.h"
@@ -112,7 +114,7 @@ static DerivedMesh *applyModifier(
 
        /* dont apply dynamic paint on orco dm stack */
        if (!(flag & MOD_APPLY_ORCO)) {
-               return dynamicPaint_Modifier_do(pmd, md->scene, ob, dm);
+               return dynamicPaint_Modifier_do(G.main->eval_ctx, pmd, md->scene, ob, dm);
        }
        return dm;
 }
index 1fc240b..bf89ffd 100644 (file)
@@ -365,7 +365,7 @@ void WM_event_remove_timer(struct wmWindowManager *wm, struct wmWindow *win, str
 float WM_event_tablet_data(const struct wmEvent *event, int *pen_flip, float tilt[2]) RET_ZERO
 bool WM_event_is_tablet(const struct wmEvent *event) RET_ZERO
 void ED_armature_ebone_remove(struct bArmature *arm, struct EditBone *exBone) RET_NONE
-void object_test_constraints(struct Object *owner) RET_NONE
+void object_test_constraints(struct Main *bmain, struct Object *owner) RET_NONE
 void ED_armature_ebone_to_mat4(struct EditBone *ebone, float mat[4][4]) RET_NONE
 void ED_armature_ebone_from_mat4(EditBone *ebone, float mat[4][4]) RET_NONE
 void ED_object_parent(struct Object *ob, struct Object *par, int type, const char *substr) RET_NONE
@@ -528,8 +528,8 @@ bool ED_mesh_color_remove_named(struct Mesh *me, const char *name) RET_ZERO
 bool ED_mesh_uv_texture_remove_named(struct Mesh *me, const char *name) RET_ZERO
 void ED_object_constraint_dependency_update(struct Main *bmain, struct Object *ob) RET_NONE
 void ED_object_constraint_dependency_tag_update(struct Main *bmain, struct Object *ob, struct bConstraint *con) RET_NONE
-void ED_object_constraint_update(struct Object *ob) RET_NONE
-void ED_object_constraint_tag_update(struct Object *ob, struct bConstraint *con) RET_NONE
+void ED_object_constraint_update(struct Main *bmain, struct Object *ob) RET_NONE
+void ED_object_constraint_tag_update(struct Main *bmain, struct Object *ob, struct bConstraint *con) RET_NONE
 void ED_vgroup_vert_add(struct Object *ob, struct bDeformGroup *dg, int vertnum, float weight, int assignmode) RET_NONE
 void ED_vgroup_vert_remove(struct Object *ob, struct bDeformGroup *dg, int vertnum) RET_NONE
 float ED_vgroup_vert_weight(struct Object *ob, struct bDeformGroup *dg, int vertnum) RET_ZERO