#include "DEG_depsgraph.h"
#include "DEG_depsgraph_build.h"
+#include "DEG_depsgraph_query.h"
#include "RNA_access.h"
#include "RNA_define.h"
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;
/* 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 */
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",