Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/object/object_constraint.c
| Show First 20 Lines • Show All 74 Lines • ▼ Show 20 Lines | |||||
| #include "UI_resources.h" | #include "UI_resources.h" | ||||
| #include "object_intern.h" | #include "object_intern.h" | ||||
| /* ------------------------------------------------------------------- */ | /* ------------------------------------------------------------------- */ | ||||
| /** \name Constraint Data Accessors | /** \name Constraint Data Accessors | ||||
| * \{ */ | * \{ */ | ||||
| /** | |||||
| * If object is in pose-mode, return active bone constraints, else object constraints. | |||||
| * No constraints are returned for a bone on an inactive bone-layer. | |||||
| */ | |||||
| ListBase *ED_object_constraint_active_list(Object *ob) | ListBase *ED_object_constraint_active_list(Object *ob) | ||||
| { | { | ||||
| 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(ob); | ||||
| if (pchan) { | if (pchan) { | ||||
| return &pchan->constraints; | return &pchan->constraints; | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| return &ob->constraints; | return &ob->constraints; | ||||
| } | } | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| /** | |||||
| * Get the constraints for the active pose bone. Bone may be on an inactive bone-layer | |||||
| * (unlike #ED_object_constraint_active_list, such constraints are not excluded here). | |||||
| */ | |||||
| ListBase *ED_object_pose_constraint_list(const bContext *C) | ListBase *ED_object_pose_constraint_list(const bContext *C) | ||||
| { | { | ||||
| bPoseChannel *pose_bone = CTX_data_pointer_get(C, "pose_bone").data; | bPoseChannel *pose_bone = CTX_data_pointer_get(C, "pose_bone").data; | ||||
| if (pose_bone == NULL) { | if (pose_bone == NULL) { | ||||
| pose_bone = CTX_data_pointer_get(C, "active_pose_bone").data; | pose_bone = CTX_data_pointer_get(C, "active_pose_bone").data; | ||||
| if (pose_bone == NULL) { | if (pose_bone == NULL) { | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| } | } | ||||
| return &pose_bone->constraints; | return &pose_bone->constraints; | ||||
| } | } | ||||
| /* Find the list that a given constraint belongs to, | |||||
| * and/or also get the posechannel this is from (if applicable) */ | |||||
| ListBase *ED_object_constraint_list_from_constraint(Object *ob, | ListBase *ED_object_constraint_list_from_constraint(Object *ob, | ||||
| bConstraint *con, | bConstraint *con, | ||||
| bPoseChannel **r_pchan) | bPoseChannel **r_pchan) | ||||
| { | { | ||||
| if (r_pchan) { | if (r_pchan) { | ||||
| *r_pchan = NULL; | *r_pchan = NULL; | ||||
| } | } | ||||
| Show All 24 Lines | for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| /* done */ | /* done */ | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| /* single constraint */ | |||||
| bConstraint *ED_object_constraint_active_get(Object *ob) | bConstraint *ED_object_constraint_active_get(Object *ob) | ||||
| { | { | ||||
| return BKE_constraints_active_get(ED_object_constraint_active_list(ob)); | return BKE_constraints_active_get(ED_object_constraint_active_list(ob)); | ||||
| } | } | ||||
| /** \} */ | /** \} */ | ||||
| /* ------------------------------------------------------------------- */ | /* ------------------------------------------------------------------- */ | ||||
| ▲ Show 20 Lines • Show All 2,637 Lines • Show Last 20 Lines | |||||