Merge branch 'blender2.7'
[blender.git] / source / blender / editors / physics / rigidbody_object.c
index 1b7f426ac5ff8d3e57b2026ca5d1a3d56f53f45f..1c0ceed245516d68aa546a7691d97b6737af5344 100644 (file)
@@ -51,6 +51,7 @@
 
 #include "DEG_depsgraph.h"
 #include "DEG_depsgraph_build.h"
+#include "DEG_depsgraph_query.h"
 
 #include "RNA_access.h"
 #include "RNA_define.h"
@@ -125,8 +126,8 @@ bool ED_rigidbody_object_add(Main *bmain, Scene *scene, Object *ob, int type, Re
        BKE_collection_object_add(bmain, rbw->group, ob);
 
        DEG_relations_tag_update(bmain);
-       DEG_id_tag_update(&ob->id, OB_RECALC_OB);
-       DEG_id_tag_update(&rbw->group->id, DEG_TAG_COPY_ON_WRITE);
+       DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM);
+       DEG_id_tag_update(&rbw->group->id, ID_RECALC_COPY_ON_WRITE);
 
        return true;
 }
@@ -136,7 +137,7 @@ void ED_rigidbody_object_remove(Main *bmain, Scene *scene, Object *ob)
        BKE_rigidbody_remove_object(bmain, scene, ob);
 
        DEG_relations_tag_update(bmain);
-       DEG_id_tag_update(&ob->id, OB_RECALC_OB);
+       DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM);
 }
 
 /* ********************************************** */
@@ -345,7 +346,7 @@ static int rigidbody_objects_shape_change_exec(bContext *C, wmOperator *op)
                        RNA_pointer_create(&ob->id, &RNA_RigidBodyObject, ob->rigidbody_object, &ptr);
                        RNA_enum_set(&ptr, "collision_shape", shape);
 
-                       DEG_id_tag_update(&ob->id, OB_RECALC_OB);
+                       DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM);
 
                        changed = true;
                }
@@ -490,6 +491,7 @@ static const EnumPropertyItem *rigidbody_materials_itemf(bContext *UNUSED(C), Po
 
 static int rigidbody_objects_calc_mass_exec(bContext *C, wmOperator *op)
 {
+       Depsgraph *depsgraph = CTX_data_depsgraph(C);
        int material = RNA_enum_get(op->ptr, "material");
        float density;
        bool changed = false;
@@ -520,14 +522,15 @@ static int rigidbody_objects_calc_mass_exec(bContext *C, wmOperator *op)
                        /* mass is calculated from the approximate volume of the object,
                         * and the density of the material we're simulating
                         */
-                       BKE_rigidbody_calc_volume(ob, &volume);
+                       Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob);
+                       BKE_rigidbody_calc_volume(ob_eval, &volume);
                        mass = volume * density;
 
                        /* use RNA-system to change the property and perform all necessary changes */
                        RNA_pointer_create(&ob->id, &RNA_RigidBodyObject, ob->rigidbody_object, &ptr);
                        RNA_float_set(&ptr, "mass", mass);
 
-                       DEG_id_tag_update(&ob->id, OB_RECALC_OB);
+                       DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM);
 
                        changed = true;
                }
@@ -561,7 +564,7 @@ void RIGIDBODY_OT_mass_calculate(wmOperatorType *ot)
        ot->poll = ED_operator_scene_editable;
 
        /* flags */
-       ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+       ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_USE_EVAL_DATA;
 
        /* properties */
        ot->prop = prop = RNA_def_enum(ot->srna, "material",