Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/physics/rigidbody_constraint.c
| Show First 20 Lines • Show All 113 Lines • ▼ Show 20 Lines | |||||
| /* Active Object Add/Remove Operators */ | /* Active Object Add/Remove Operators */ | ||||
| /* ************ Add Rigid Body Constraint ************** */ | /* ************ Add Rigid Body Constraint ************** */ | ||||
| static int rigidbody_con_add_exec(bContext *C, wmOperator *op) | static int rigidbody_con_add_exec(bContext *C, wmOperator *op) | ||||
| { | { | ||||
| Main *bmain = CTX_data_main(C); | Main *bmain = CTX_data_main(C); | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| SceneLayer *sl = CTX_data_scene_layer(C); | ViewLayer *sl = CTX_data_view_layer(C); | ||||
| RigidBodyWorld *rbw = BKE_rigidbody_get_world(scene); | RigidBodyWorld *rbw = BKE_rigidbody_get_world(scene); | ||||
| Object *ob = OBACT(sl); | Object *ob = OBACT(sl); | ||||
| int type = RNA_enum_get(op->ptr, "type"); | int type = RNA_enum_get(op->ptr, "type"); | ||||
| bool changed; | bool changed; | ||||
| /* sanity checks */ | /* sanity checks */ | ||||
| if (ELEM(NULL, scene, rbw)) { | if (ELEM(NULL, scene, rbw)) { | ||||
| BKE_report(op->reports, RPT_ERROR, "No Rigid Body World to add Rigid Body Constraint to"); | BKE_report(op->reports, RPT_ERROR, "No Rigid Body World to add Rigid Body Constraint to"); | ||||
| Show All 33 Lines | |||||
| } | } | ||||
| /* ************ Remove Rigid Body Constraint ************** */ | /* ************ Remove Rigid Body Constraint ************** */ | ||||
| static int rigidbody_con_remove_exec(bContext *C, wmOperator *op) | static int rigidbody_con_remove_exec(bContext *C, wmOperator *op) | ||||
| { | { | ||||
| Main *bmain = CTX_data_main(C); | Main *bmain = CTX_data_main(C); | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| SceneLayer *sl = CTX_data_scene_layer(C); | ViewLayer *sl = CTX_data_view_layer(C); | ||||
| Object *ob = OBACT(sl); | Object *ob = OBACT(sl); | ||||
| /* apply to active object */ | /* apply to active object */ | ||||
| if (ELEM(NULL, ob, ob->rigidbody_constraint)) { | if (ELEM(NULL, ob, ob->rigidbody_constraint)) { | ||||
| BKE_report(op->reports, RPT_ERROR, "Object has no Rigid Body Constraint to remove"); | BKE_report(op->reports, RPT_ERROR, "Object has no Rigid Body Constraint to remove"); | ||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| } | } | ||||
| else { | else { | ||||
| Show All 24 Lines | |||||