Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/object/object_constraint.c
| Show First 20 Lines • Show All 1,891 Lines • ▼ Show 20 Lines | for (con = pchan->constraints.first; con; con = con->next) { | ||||
| if (con->type == CONSTRAINT_TYPE_KINEMATIC) break; | if (con->type == CONSTRAINT_TYPE_KINEMATIC) break; | ||||
| } | } | ||||
| if (con) { | if (con) { | ||||
| BKE_report(op->reports, RPT_ERROR, "Bone already has an IK constraint"); | BKE_report(op->reports, RPT_ERROR, "Bone already has an IK constraint"); | ||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| } | } | ||||
| /* prepare popup menu to choose targetting options */ | /* prepare popup menu to choose targetting options */ | ||||
| pup = uiPupMenuBegin(C, IFACE_("Add IK"), ICON_NONE); | pup = UI_popup_menu_begin(C, IFACE_("Add IK"), ICON_NONE); | ||||
| layout = uiPupMenuLayout(pup); | layout = UI_popup_menu_layout(pup); | ||||
| /* the type of targets we'll set determines the menu entries to show... */ | /* the type of targets we'll set determines the menu entries to show... */ | ||||
| if (get_new_constraint_target(C, CONSTRAINT_TYPE_KINEMATIC, &tar_ob, &tar_pchan, 0)) { | if (get_new_constraint_target(C, CONSTRAINT_TYPE_KINEMATIC, &tar_ob, &tar_pchan, 0)) { | ||||
| /* bone target, or object target? | /* bone target, or object target? | ||||
| * - the only thing that matters is that we want a target... | * - the only thing that matters is that we want a target... | ||||
| */ | */ | ||||
| if (tar_pchan) | if (tar_pchan) | ||||
| uiItemBooleanO(layout, IFACE_("To Active Bone"), ICON_NONE, "POSE_OT_ik_add", "with_targets", 1); | uiItemBooleanO(layout, IFACE_("To Active Bone"), ICON_NONE, "POSE_OT_ik_add", "with_targets", 1); | ||||
| else | else | ||||
| uiItemBooleanO(layout, IFACE_("To Active Object"), ICON_NONE, "POSE_OT_ik_add", "with_targets", 1); | uiItemBooleanO(layout, IFACE_("To Active Object"), ICON_NONE, "POSE_OT_ik_add", "with_targets", 1); | ||||
| } | } | ||||
| else { | else { | ||||
| /* we have a choice of adding to a new empty, or not setting any target (targetless IK) */ | /* we have a choice of adding to a new empty, or not setting any target (targetless IK) */ | ||||
| uiItemBooleanO(layout, IFACE_("To New Empty Object"), ICON_NONE, "POSE_OT_ik_add", "with_targets", 1); | uiItemBooleanO(layout, IFACE_("To New Empty Object"), ICON_NONE, "POSE_OT_ik_add", "with_targets", 1); | ||||
| uiItemBooleanO(layout, IFACE_("Without Targets"), ICON_NONE, "POSE_OT_ik_add", "with_targets", 0); | uiItemBooleanO(layout, IFACE_("Without Targets"), ICON_NONE, "POSE_OT_ik_add", "with_targets", 0); | ||||
| } | } | ||||
| /* finish building the menu, and process it (should result in calling self again) */ | /* finish building the menu, and process it (should result in calling self again) */ | ||||
| uiPupMenuEnd(C, pup); | UI_popup_menu_end(C, pup); | ||||
| return OPERATOR_INTERFACE; | return OPERATOR_INTERFACE; | ||||
| } | } | ||||
| /* call constraint_add_exec() to add the IK constraint */ | /* call constraint_add_exec() to add the IK constraint */ | ||||
| static int pose_ik_add_exec(bContext *C, wmOperator *op) | static int pose_ik_add_exec(bContext *C, wmOperator *op) | ||||
| { | { | ||||
| Object *ob = CTX_data_active_object(C); | Object *ob = CTX_data_active_object(C); | ||||
| ▲ Show 20 Lines • Show All 72 Lines • Show Last 20 Lines | |||||