Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/physics/rigidbody_object.c
| Show First 20 Lines • Show All 458 Lines • ▼ Show 20 Lines | static const EnumPropertyItem *rigidbody_materials_itemf(bContext *UNUSED(C), | ||||
| return item; | return item; | ||||
| } | } | ||||
| /* ------------------------------------------ */ | /* ------------------------------------------ */ | ||||
| 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); | Depsgraph *depsgraph = CTX_data_ensure_evaluated_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; | ||||
| /* get density (kg/m^3) to apply */ | /* get density (kg/m^3) to apply */ | ||||
| if (material >= 0) { | if (material >= 0) { | ||||
| /* get density from table, and store in props for later repeating */ | /* get density from table, and store in props for later repeating */ | ||||
| if (material >= NUM_RB_MATERIAL_PRESETS) { | if (material >= NUM_RB_MATERIAL_PRESETS) { | ||||
| ▲ Show 20 Lines • Show All 56 Lines • ▼ Show 20 Lines | void RIGIDBODY_OT_mass_calculate(wmOperatorType *ot) | ||||
| ot->description = "Automatically calculate mass values for Rigid Body Objects based on volume"; | ot->description = "Automatically calculate mass values for Rigid Body Objects based on volume"; | ||||
| /* callbacks */ | /* callbacks */ | ||||
| ot->invoke = WM_menu_invoke; // XXX | ot->invoke = WM_menu_invoke; // XXX | ||||
| ot->exec = rigidbody_objects_calc_mass_exec; | ot->exec = rigidbody_objects_calc_mass_exec; | ||||
| ot->poll = ED_operator_scene_editable; | ot->poll = ED_operator_scene_editable; | ||||
| /* flags */ | /* flags */ | ||||
| ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_USE_EVAL_DATA; | ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; | ||||
| /* properties */ | /* properties */ | ||||
| ot->prop = prop = RNA_def_enum( | ot->prop = prop = RNA_def_enum( | ||||
| ot->srna, | ot->srna, | ||||
| "material", | "material", | ||||
| DummyRNA_DEFAULT_items, | DummyRNA_DEFAULT_items, | ||||
| 0, | 0, | ||||
| "Material Preset", | "Material Preset", | ||||
| Show All 16 Lines | |||||