Fix T59884: Rigidbody Calculate Mass Sets Mass to 0
rigidbody_get_mesh() needs an evaluated object Reviewers: sergey, brecht Maniphest Tasks: T59884 Differential Revision: https://developer.blender.org/D4125
This commit is contained in:
@@ -51,6 +51,7 @@
|
|||||||
|
|
||||||
#include "DEG_depsgraph.h"
|
#include "DEG_depsgraph.h"
|
||||||
#include "DEG_depsgraph_build.h"
|
#include "DEG_depsgraph_build.h"
|
||||||
|
#include "DEG_depsgraph_query.h"
|
||||||
|
|
||||||
#include "RNA_access.h"
|
#include "RNA_access.h"
|
||||||
#include "RNA_define.h"
|
#include "RNA_define.h"
|
||||||
@@ -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)
|
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");
|
int material = RNA_enum_get(op->ptr, "material");
|
||||||
float density;
|
float density;
|
||||||
bool changed = false;
|
bool changed = false;
|
||||||
@@ -520,7 +522,8 @@ static int rigidbody_objects_calc_mass_exec(bContext *C, wmOperator *op)
|
|||||||
/* mass is calculated from the approximate volume of the object,
|
/* mass is calculated from the approximate volume of the object,
|
||||||
* and the density of the material we're simulating
|
* 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;
|
mass = volume * density;
|
||||||
|
|
||||||
/* use RNA-system to change the property and perform all necessary changes */
|
/* use RNA-system to change the property and perform all necessary changes */
|
||||||
@@ -561,7 +564,7 @@ void RIGIDBODY_OT_mass_calculate(wmOperatorType *ot)
|
|||||||
ot->poll = ED_operator_scene_editable;
|
ot->poll = ED_operator_scene_editable;
|
||||||
|
|
||||||
/* flags */
|
/* flags */
|
||||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_USE_EVAL_DATA;
|
||||||
|
|
||||||
/* properties */
|
/* properties */
|
||||||
ot->prop = prop = RNA_def_enum(ot->srna, "material",
|
ot->prop = prop = RNA_def_enum(ot->srna, "material",
|
||||||
|
|||||||
Reference in New Issue
Block a user