Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/object/object_constraint.c
| Show First 20 Lines • Show All 878 Lines • ▼ Show 20 Lines | if (ob) { | ||||
| invert_m4_m4(invmat, workob.obmat); | invert_m4_m4(invmat, workob.obmat); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| /* ChildOf Constraint - set inverse callback */ | /* ChildOf Constraint - set inverse callback */ | ||||
| static int childof_set_inverse_exec(bContext *C, wmOperator *op) | static int childof_set_inverse_exec(bContext *C, wmOperator *op) | ||||
| { | { | ||||
| Main *bmain = CTX_data_main(C); | |||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| Object *ob = ED_object_active_context(C); | Object *ob = ED_object_active_context(C); | ||||
| bConstraint *con = edit_constraint_property_get(op, ob, CONSTRAINT_TYPE_CHILDOF); | bConstraint *con = edit_constraint_property_get(op, ob, CONSTRAINT_TYPE_CHILDOF); | ||||
| bChildOfConstraint *data = (con) ? (bChildOfConstraint *)con->data : NULL; | bChildOfConstraint *data = (con) ? (bChildOfConstraint *)con->data : NULL; | ||||
| const int owner = RNA_enum_get(op->ptr, "owner"); | const int owner = RNA_enum_get(op->ptr, "owner"); | ||||
| /* despite 3 layers of checks, we may still not be able to find a constraint */ | /* despite 3 layers of checks, we may still not be able to find a constraint */ | ||||
| if (data == NULL) { | if (data == NULL) { | ||||
| printf("DEBUG: Child-Of Set Inverse - object = '%s'\n", (ob) ? ob->id.name + 2 : "<None>"); | printf("DEBUG: Child-Of Set Inverse - object = '%s'\n", (ob) ? ob->id.name + 2 : "<None>"); | ||||
| BKE_report(op->reports, RPT_ERROR, "Could not find constraint data for Child-Of Set Inverse"); | BKE_report(op->reports, RPT_ERROR, "Could not find constraint data for Child-Of Set Inverse"); | ||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| } | } | ||||
| child_get_inverse_matrix(C, scene, ob, con, data->invmat, owner); | child_get_inverse_matrix(C, scene, ob, con, data->invmat, owner); | ||||
| ED_object_constraint_update(bmain, ob); | |||||
| WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT, ob); | WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT, ob); | ||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| } | } | ||||
| static int childof_set_inverse_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) | static int childof_set_inverse_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) | ||||
| { | { | ||||
| if (edit_constraint_invoke_properties(C, op)) | if (edit_constraint_invoke_properties(C, op)) | ||||
| Show All 19 Lines | void CONSTRAINT_OT_childof_set_inverse(wmOperatorType *ot) | ||||
| /* properties */ | /* properties */ | ||||
| edit_constraint_properties(ot); | edit_constraint_properties(ot); | ||||
| } | } | ||||
| /* ChildOf Constraint - clear inverse callback */ | /* ChildOf Constraint - clear inverse callback */ | ||||
| static int childof_clear_inverse_exec(bContext *C, wmOperator *op) | static int childof_clear_inverse_exec(bContext *C, wmOperator *op) | ||||
| { | { | ||||
| Main *bmain = CTX_data_main(C); | |||||
| Object *ob = ED_object_active_context(C); | Object *ob = ED_object_active_context(C); | ||||
| bConstraint *con = edit_constraint_property_get(op, ob, CONSTRAINT_TYPE_CHILDOF); | bConstraint *con = edit_constraint_property_get(op, ob, CONSTRAINT_TYPE_CHILDOF); | ||||
| bChildOfConstraint *data = (con) ? (bChildOfConstraint *)con->data : NULL; | bChildOfConstraint *data = (con) ? (bChildOfConstraint *)con->data : NULL; | ||||
| if (data == NULL) { | if (data == NULL) { | ||||
| BKE_report(op->reports, RPT_ERROR, "Child Of constraint not found"); | BKE_report(op->reports, RPT_ERROR, "Child Of constraint not found"); | ||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| } | } | ||||
| /* simply clear the matrix */ | /* simply clear the matrix */ | ||||
| unit_m4(data->invmat); | unit_m4(data->invmat); | ||||
| ED_object_constraint_update(bmain, ob); | |||||
| WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT, ob); | WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT, ob); | ||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| } | } | ||||
| static int childof_clear_inverse_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) | static int childof_clear_inverse_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) | ||||
| { | { | ||||
| if (edit_constraint_invoke_properties(C, op)) | if (edit_constraint_invoke_properties(C, op)) | ||||
| ▲ Show 20 Lines • Show All 1,166 Lines • Show Last 20 Lines | |||||