Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/object/object_constraint.c
| Show First 20 Lines • Show All 83 Lines • ▼ Show 20 Lines | |||||
| { | { | ||||
| if (ob == NULL) { | if (ob == NULL) { | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| if (ob->mode & OB_MODE_POSE) { | if (ob->mode & OB_MODE_POSE) { | ||||
| bPoseChannel *pchan; | bPoseChannel *pchan; | ||||
| pchan = BKE_pose_channel_active(ob); | pchan = BKE_pose_channel_active_if_layer_visible(ob); | ||||
| if (pchan) { | if (pchan) { | ||||
| return &pchan->constraints; | return &pchan->constraints; | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| return &ob->constraints; | return &ob->constraints; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 2,109 Lines • ▼ Show 20 Lines | |||||
| /** \name Add Constraints Operator | /** \name Add Constraints Operator | ||||
| * \{ */ | * \{ */ | ||||
| /* get the Object and/or PoseChannel to use as target */ | /* get the Object and/or PoseChannel to use as target */ | ||||
| static bool get_new_constraint_target( | static bool get_new_constraint_target( | ||||
| bContext *C, int con_type, Object **tar_ob, bPoseChannel **tar_pchan, bool add) | bContext *C, int con_type, Object **tar_ob, bPoseChannel **tar_pchan, bool add) | ||||
| { | { | ||||
| Object *obact = ED_object_active_context(C); | Object *obact = ED_object_active_context(C); | ||||
| bPoseChannel *pchanact = BKE_pose_channel_active(obact); | bPoseChannel *pchanact = BKE_pose_channel_active_if_layer_visible(obact); | ||||
| bool only_curve = false, only_mesh = false, only_ob = false; | bool only_curve = false, only_mesh = false, only_ob = false; | ||||
| bool found = false; | bool found = false; | ||||
| /* clear tar_ob and tar_pchan fields before use | /* clear tar_ob and tar_pchan fields before use | ||||
| * - assume for now that both always exist... | * - assume for now that both always exist... | ||||
| */ | */ | ||||
| *tar_ob = NULL; | *tar_ob = NULL; | ||||
| *tar_pchan = NULL; | *tar_pchan = NULL; | ||||
| ▲ Show 20 Lines • Show All 138 Lines • ▼ Show 20 Lines | static int constraint_add_exec( | ||||
| Main *bmain = CTX_data_main(C); | Main *bmain = CTX_data_main(C); | ||||
| bPoseChannel *pchan; | bPoseChannel *pchan; | ||||
| bConstraint *con; | bConstraint *con; | ||||
| if (list == &ob->constraints) { | if (list == &ob->constraints) { | ||||
| pchan = NULL; | pchan = NULL; | ||||
| } | } | ||||
| else { | else { | ||||
| pchan = BKE_pose_channel_active(ob); | pchan = BKE_pose_channel_active_if_layer_visible(ob); | ||||
| /* ensure not to confuse object/pose adding */ | /* ensure not to confuse object/pose adding */ | ||||
| if (pchan == NULL) { | if (pchan == NULL) { | ||||
| BKE_report(op->reports, RPT_ERROR, "No active pose bone to add a constraint to"); | BKE_report(op->reports, RPT_ERROR, "No active pose bone to add a constraint to"); | ||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| } | } | ||||
| } | } | ||||
| /* check if constraint to be added is valid for the given constraints stack */ | /* check if constraint to be added is valid for the given constraints stack */ | ||||
| ▲ Show 20 Lines • Show All 263 Lines • ▼ Show 20 Lines | |||||
| * \{ */ | * \{ */ | ||||
| /* TODO: should these be here, or back in editors/armature/poseobject.c again? */ | /* TODO: should these be here, or back in editors/armature/poseobject.c again? */ | ||||
| /* present menu with options + validation for targets to use */ | /* present menu with options + validation for targets to use */ | ||||
| static int pose_ik_add_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) | static int pose_ik_add_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) | ||||
| { | { | ||||
| Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); | Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); | ||||
| bPoseChannel *pchan = BKE_pose_channel_active(ob); | bPoseChannel *pchan = BKE_pose_channel_active_if_layer_visible(ob); | ||||
| bConstraint *con = NULL; | bConstraint *con = NULL; | ||||
| uiPopupMenu *pup; | uiPopupMenu *pup; | ||||
| uiLayout *layout; | uiLayout *layout; | ||||
| Object *tar_ob = NULL; | Object *tar_ob = NULL; | ||||
| bPoseChannel *tar_pchan = NULL; | bPoseChannel *tar_pchan = NULL; | ||||
| /* must have active bone */ | /* must have active bone */ | ||||
| ▲ Show 20 Lines • Show All 140 Lines • Show Last 20 Lines | |||||