Changeset 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 in posemode, active bone constraints, else object constraints */ | /* If object in posemode, active bone constraints, else object constraints. No constraints are | ||||
sybren: This sentence is missing a verb. | |||||
| ListBase *ED_object_constraint_list_from_context(Object *ob) | * returned for a bone on an inactive bonelayer (BKE_pose_channel_active checks on this). */ | ||||
sybrenUnsubmitted Not Done Inline ActionsThe part between parentheses can be removed, or moved down into the function itself. It only means something when you know the exact implementation of the function. sybren: The part between parentheses can be removed, or moved down into the function itself. It only… | |||||
| 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 context pose bone. Bone may be on an inactive bonelayer (unlike | |||||
sybrenUnsubmitted Not Done Inline Actions"the context pose bone" is a weird concept. Probably clearer to write "the active pose bone". The fact that it comes from the context is already clear as that's the only parameter given. sybren: "the context pose bone" is a weird concept. Probably clearer to write "the active pose bone". | |||||
| * ED_object_constraint_active_list, such constraints are not excluded here). */ | |||||
| ListBase *ED_object_pose_constraint_list(const bContext *C) | |||||
| { | |||||
Not Done Inline ActionsThis boolean indicates that this function is actually two functions in disguise. Functions should do one thing, and if there is a boolean that makes it switch between two things, it should be two functions. sybren: This boolean indicates that this function is actually two functions in disguise. Functions… | |||||
| ListBase *constraints = {NULL}; | |||||
| bPoseChannel *pose_bone = CTX_data_pointer_get(C, "pose_bone").data; | |||||
| if (pose_bone != NULL) { | |||||
| constraints = &pose_bone->constraints; | |||||
| } | |||||
| return constraints; | |||||
sybrenUnsubmitted Not Done Inline ActionsThis function is now too complex. The initialisation of constraints looks like it initialises a ListBase, but it's actually just setting constraints = NULL. The only case in which the function can actually return NULL is when pose_bone == NULL. This seems much simpler to me: bPoseChannel *pose_bone = CTX_data_pointer_get(C, "pose_bone").data;
if (pose_bone == NULL) {
return NULL;
}
return &pose_bone->constraints;sybren: This function is now too complex. The initialisation of `constraints` looks like it initialises… | |||||
| } | |||||
| /* Find the list that a given constraint belongs to, | /* Find the list that a given constraint belongs to, | ||||
| * and/or also get the posechannel this is from (if applicable) */ | * 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 29 Lines | ListBase *ED_object_constraint_list_from_constraint(Object *ob, | ||||
| /* done */ | /* done */ | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| /* single constraint */ | /* 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_list_from_context(ob)); | return BKE_constraints_active_get(ED_object_constraint_active_list(ob)); | ||||
| } | } | ||||
| /** \} */ | /** \} */ | ||||
| /* ------------------------------------------------------------------- */ | /* ------------------------------------------------------------------- */ | ||||
| /** \name PyConstraints (Unused) | /** \name PyConstraints (Unused) | ||||
| * \{ */ | * \{ */ | ||||
| ▲ Show 20 Lines • Show All 616 Lines • ▼ Show 20 Lines | if (!(panel_ptr == NULL || RNA_pointer_is_null(panel_ptr))) { | ||||
| } | } | ||||
| return false; | return false; | ||||
| } | } | ||||
| } | } | ||||
| return false; | return false; | ||||
| } | } | ||||
| static bConstraint *edit_constraint_property_get(wmOperator *op, Object *ob, int type) | static bConstraint *edit_constraint_property_get(bContext *C, wmOperator *op, Object *ob, int type) | ||||
| { | { | ||||
| char constraint_name[MAX_NAME]; | char constraint_name[MAX_NAME]; | ||||
| int owner = RNA_enum_get(op->ptr, "owner"); | int owner = RNA_enum_get(op->ptr, "owner"); | ||||
| bConstraint *con; | bConstraint *con; | ||||
| ListBase *list = NULL; | ListBase *list = NULL; | ||||
| RNA_string_get(op->ptr, "constraint", constraint_name); | RNA_string_get(op->ptr, "constraint", constraint_name); | ||||
| if (owner == EDIT_CONSTRAINT_OWNER_OBJECT) { | if (owner == EDIT_CONSTRAINT_OWNER_BONE) { | ||||
| list = &ob->constraints; | list = ED_object_pose_constraint_list(C); | ||||
| } | |||||
| else if (owner == EDIT_CONSTRAINT_OWNER_BONE) { | |||||
| bPoseChannel *pchan = BKE_pose_channel_active(ob); | |||||
| if (pchan) { | |||||
| list = &pchan->constraints; | |||||
| } | } | ||||
| else { | else { | ||||
| #if 0 | list = ED_object_constraint_active_list(ob); | ||||
| if (G.debug & G_DEBUG) { | |||||
| printf("edit_constraint_property_get: No active bone for object '%s'\n", | |||||
| (ob) ? ob->id.name + 2 : "<None>"); | |||||
| } | |||||
| #endif | |||||
| return NULL; | |||||
| } | |||||
| } | |||||
| else { | |||||
| #if 0 | |||||
| if (G.debug & G_DEBUG) { | |||||
| printf("edit_constraint_property_get: defaulting to getting list in the standard way\n"); | |||||
| } | |||||
| #endif | |||||
| list = ED_object_constraint_list_from_context(ob); | |||||
| } | } | ||||
| con = BKE_constraints_find_name(list, constraint_name); | con = BKE_constraints_find_name(list, constraint_name); | ||||
| #if 0 | #if 0 | ||||
| if (G.debug & G_DEBUG) { | if (G.debug & G_DEBUG) { | ||||
| printf("constraint found = %p, %s\n", (void *)con, (con) ? con->name : "<Not found>"); | printf("constraint found = %p, %s\n", (void *)con, (con) ? con->name : "<Not found>"); | ||||
| } | } | ||||
| #endif | #endif | ||||
| Show All 12 Lines | |||||
| * | * | ||||
| * For Stretch-To & Limit-Distance constraints. | * For Stretch-To & Limit-Distance constraints. | ||||
| * \{ */ | * \{ */ | ||||
| static int stretchto_reset_exec(bContext *C, wmOperator *op) | static int stretchto_reset_exec(bContext *C, wmOperator *op) | ||||
| { | { | ||||
| Main *bmain = CTX_data_main(C); | 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_STRETCHTO); | bConstraint *con = edit_constraint_property_get(C, op, ob, CONSTRAINT_TYPE_STRETCHTO); | ||||
| bStretchToConstraint *data = (con) ? (bStretchToConstraint *)con->data : NULL; | bStretchToConstraint *data = (con) ? (bStretchToConstraint *)con->data : NULL; | ||||
| /* 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) { | ||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| } | } | ||||
| /* just set original length to 0.0, which will cause a reset on next recalc */ | /* just set original length to 0.0, which will cause a reset on next recalc */ | ||||
| Show All 38 Lines | |||||
| * | * | ||||
| * For Limit-Distance constraint. | * For Limit-Distance constraint. | ||||
| * \{ */ | * \{ */ | ||||
| static int limitdistance_reset_exec(bContext *C, wmOperator *op) | static int limitdistance_reset_exec(bContext *C, wmOperator *op) | ||||
| { | { | ||||
| Main *bmain = CTX_data_main(C); | 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_DISTLIMIT); | bConstraint *con = edit_constraint_property_get(C, op, ob, CONSTRAINT_TYPE_DISTLIMIT); | ||||
| bDistLimitConstraint *data = (con) ? (bDistLimitConstraint *)con->data : NULL; | bDistLimitConstraint *data = (con) ? (bDistLimitConstraint *)con->data : NULL; | ||||
| /* 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) { | ||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| } | } | ||||
| /* just set original length to 0.0, which will cause a reset on next recalc */ | /* just set original length to 0.0, which will cause a reset on next recalc */ | ||||
| ▲ Show 20 Lines • Show All 55 Lines • ▼ Show 20 Lines | static void force_evaluation_if_constraint_disabled(bContext *C, Object *ob, bConstraint *con) | ||||
| con->flag = flag_backup; | con->flag = flag_backup; | ||||
| } | } | ||||
| /* 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); | 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(C, op, ob, CONSTRAINT_TYPE_CHILDOF); | ||||
| bChildOfConstraint *data = (con) ? (bChildOfConstraint *)con->data : NULL; | bChildOfConstraint *data = (con) ? (bChildOfConstraint *)con->data : NULL; | ||||
| /* 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; | ||||
| } | } | ||||
| Show All 37 Lines | void CONSTRAINT_OT_childof_set_inverse(wmOperatorType *ot) | ||||
| 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); | 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(C, 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 */ | ||||
| Show All 37 Lines | |||||
| /* ------------------------------------------------------------------- */ | /* ------------------------------------------------------------------- */ | ||||
| /** \name Follow Path Constraint (Auto Animate Path Operator) | /** \name Follow Path Constraint (Auto Animate Path Operator) | ||||
| * \{ */ | * \{ */ | ||||
| static int followpath_path_animate_exec(bContext *C, wmOperator *op) | static int followpath_path_animate_exec(bContext *C, wmOperator *op) | ||||
| { | { | ||||
| Main *bmain = CTX_data_main(C); | 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_FOLLOWPATH); | bConstraint *con = edit_constraint_property_get(C, op, ob, CONSTRAINT_TYPE_FOLLOWPATH); | ||||
| bFollowPathConstraint *data = (con) ? (bFollowPathConstraint *)con->data : NULL; | bFollowPathConstraint *data = (con) ? (bFollowPathConstraint *)con->data : NULL; | ||||
| bAction *act = NULL; | bAction *act = NULL; | ||||
| FCurve *fcu = NULL; | FCurve *fcu = NULL; | ||||
| int sfra = RNA_int_get(op->ptr, "frame_start"); | int sfra = RNA_int_get(op->ptr, "frame_start"); | ||||
| int len = RNA_int_get(op->ptr, "length"); | int len = RNA_int_get(op->ptr, "length"); | ||||
| float standardRange = 1.0; | float standardRange = 1.0; | ||||
| ▲ Show 20 Lines • Show All 127 Lines • ▼ Show 20 Lines | |||||
| /* ------------------------------------------------------------------- */ | /* ------------------------------------------------------------------- */ | ||||
| /** \name Object Solver Constraint (Set Inverse Operator) | /** \name Object Solver Constraint (Set Inverse Operator) | ||||
| * \{ */ | * \{ */ | ||||
| static int objectsolver_set_inverse_exec(bContext *C, wmOperator *op) | static int objectsolver_set_inverse_exec(bContext *C, wmOperator *op) | ||||
| { | { | ||||
| Main *bmain = CTX_data_main(C); | 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_OBJECTSOLVER); | bConstraint *con = edit_constraint_property_get(C, op, ob, CONSTRAINT_TYPE_OBJECTSOLVER); | ||||
| bObjectSolverConstraint *data = (con) ? (bObjectSolverConstraint *)con->data : NULL; | bObjectSolverConstraint *data = (con) ? (bObjectSolverConstraint *)con->data : NULL; | ||||
| /* 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: ObjectSolver Set Inverse - object = '%s'\n", (ob) ? ob->id.name + 2 : "<None>"); | printf("DEBUG: ObjectSolver Set Inverse - object = '%s'\n", (ob) ? ob->id.name + 2 : "<None>"); | ||||
| BKE_report( | BKE_report( | ||||
| op->reports, RPT_ERROR, "Could not find constraint data for ObjectSolver Set Inverse"); | op->reports, RPT_ERROR, "Could not find constraint data for ObjectSolver Set Inverse"); | ||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| ▲ Show 20 Lines • Show All 45 Lines • ▼ Show 20 Lines | |||||
| /* ------------------------------------------------------------------- */ | /* ------------------------------------------------------------------- */ | ||||
| /** \name Object Solver Constraint (Clear Inverse Operator) | /** \name Object Solver Constraint (Clear Inverse Operator) | ||||
| * \{ */ | * \{ */ | ||||
| static int objectsolver_clear_inverse_exec(bContext *C, wmOperator *op) | static int objectsolver_clear_inverse_exec(bContext *C, wmOperator *op) | ||||
| { | { | ||||
| Main *bmain = CTX_data_main(C); | 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_OBJECTSOLVER); | bConstraint *con = edit_constraint_property_get(C, op, ob, CONSTRAINT_TYPE_OBJECTSOLVER); | ||||
| bObjectSolverConstraint *data = (con) ? (bObjectSolverConstraint *)con->data : NULL; | bObjectSolverConstraint *data = (con) ? (bObjectSolverConstraint *)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 */ | ||||
| ▲ Show 20 Lines • Show All 131 Lines • ▼ Show 20 Lines | |||||
| /* ------------------------------------------------------------------- */ | /* ------------------------------------------------------------------- */ | ||||
| /** \name Delete Constraint Operator | /** \name Delete Constraint Operator | ||||
| * \{ */ | * \{ */ | ||||
| static int constraint_delete_exec(bContext *C, wmOperator *op) | static int constraint_delete_exec(bContext *C, wmOperator *op) | ||||
| { | { | ||||
| Main *bmain = CTX_data_main(C); | 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, 0); | bConstraint *con = edit_constraint_property_get(C, op, ob, 0); | ||||
| ListBase *lb = ED_object_constraint_list_from_constraint(ob, con, NULL); | ListBase *lb = ED_object_constraint_list_from_constraint(ob, con, NULL); | ||||
| /* Store name temporarily for report. */ | /* Store name temporarily for report. */ | ||||
| char name[MAX_NAME]; | char name[MAX_NAME]; | ||||
| strcpy(name, con->name); | strcpy(name, con->name); | ||||
| /* free the constraint */ | /* free the constraint */ | ||||
| if (BKE_constraint_remove_ex(lb, ob, con, true)) { | if (BKE_constraint_remove_ex(lb, ob, con, true)) { | ||||
| ▲ Show 20 Lines • Show All 49 Lines • ▼ Show 20 Lines | |||||
| /* ------------------------------------------------------------------- */ | /* ------------------------------------------------------------------- */ | ||||
| /** \name Move Down Constraint Operator | /** \name Move Down Constraint Operator | ||||
| * \{ */ | * \{ */ | ||||
| static int constraint_move_down_exec(bContext *C, wmOperator *op) | static int constraint_move_down_exec(bContext *C, wmOperator *op) | ||||
| { | { | ||||
| Object *ob = ED_object_active_context(C); | Object *ob = ED_object_active_context(C); | ||||
| bConstraint *con = edit_constraint_property_get(op, ob, 0); | bConstraint *con = edit_constraint_property_get(C, op, ob, 0); | ||||
| if (con && con->next) { | if (con && con->next) { | ||||
| ListBase *conlist = ED_object_constraint_list_from_constraint(ob, con, NULL); | ListBase *conlist = ED_object_constraint_list_from_constraint(ob, con, NULL); | ||||
| bConstraint *nextCon = con->next; | bConstraint *nextCon = con->next; | ||||
| /* insert the nominated constraint after the one that used to be after it */ | /* insert the nominated constraint after the one that used to be after it */ | ||||
| BLI_remlink(conlist, con); | BLI_remlink(conlist, con); | ||||
| BLI_insertlinkafter(conlist, nextCon, con); | BLI_insertlinkafter(conlist, nextCon, con); | ||||
| Show All 38 Lines | |||||
| /* ------------------------------------------------------------------- */ | /* ------------------------------------------------------------------- */ | ||||
| /** \name Move Up Constraint Operator | /** \name Move Up Constraint Operator | ||||
| * \{ */ | * \{ */ | ||||
| static int constraint_move_up_exec(bContext *C, wmOperator *op) | static int constraint_move_up_exec(bContext *C, wmOperator *op) | ||||
| { | { | ||||
| Object *ob = ED_object_active_context(C); | Object *ob = ED_object_active_context(C); | ||||
| bConstraint *con = edit_constraint_property_get(op, ob, 0); | bConstraint *con = edit_constraint_property_get(C, op, ob, 0); | ||||
| if (con && con->prev) { | if (con && con->prev) { | ||||
| ListBase *conlist = ED_object_constraint_list_from_constraint(ob, con, NULL); | ListBase *conlist = ED_object_constraint_list_from_constraint(ob, con, NULL); | ||||
| bConstraint *prevCon = con->prev; | bConstraint *prevCon = con->prev; | ||||
| /* insert the nominated constraint before the one that used to be before it */ | /* insert the nominated constraint before the one that used to be before it */ | ||||
| BLI_remlink(conlist, con); | BLI_remlink(conlist, con); | ||||
| BLI_insertlinkbefore(conlist, prevCon, con); | BLI_insertlinkbefore(conlist, prevCon, con); | ||||
| Show All 36 Lines | |||||
| /* ------------------------------------------------------------------- */ | /* ------------------------------------------------------------------- */ | ||||
| /** \name Move Constraint To Index Operator | /** \name Move Constraint To Index Operator | ||||
| * \{ */ | * \{ */ | ||||
| static int constraint_move_to_index_exec(bContext *C, wmOperator *op) | static int constraint_move_to_index_exec(bContext *C, wmOperator *op) | ||||
| { | { | ||||
| Object *ob = ED_object_active_context(C); | Object *ob = ED_object_active_context(C); | ||||
| bConstraint *con = edit_constraint_property_get(op, ob, 0); | bConstraint *con = edit_constraint_property_get(C, op, ob, 0); | ||||
| int new_index = RNA_int_get(op->ptr, "index"); | int new_index = RNA_int_get(op->ptr, "index"); | ||||
| if (new_index < 0) { | if (new_index < 0) { | ||||
| new_index = 0; | new_index = 0; | ||||
| } | } | ||||
| if (con) { | if (con) { | ||||
| ListBase *conlist = ED_object_constraint_list_from_constraint(ob, con, NULL); | ListBase *conlist = ED_object_constraint_list_from_constraint(ob, con, NULL); | ||||
| ▲ Show 20 Lines • Show All 539 Lines • ▼ Show 20 Lines | static int pose_constraint_add_exec(bContext *C, wmOperator *op) | ||||
| /* hack: set constraint targets from selected objects in context is allowed when | /* hack: set constraint targets from selected objects in context is allowed when | ||||
| * operator name included 'with_targets', since the menu doesn't allow multiple properties | * operator name included 'with_targets', since the menu doesn't allow multiple properties | ||||
| */ | */ | ||||
| if (strstr(op->idname, "with_targets")) { | if (strstr(op->idname, "with_targets")) { | ||||
| with_targets = 1; | with_targets = 1; | ||||
| } | } | ||||
| return constraint_add_exec( | return constraint_add_exec(C, op, ob, ED_object_constraint_active_list(ob), type, with_targets); | ||||
| C, op, ob, ED_object_constraint_list_from_context(ob), type, with_targets); | |||||
| } | } | ||||
| /* ------------------ */ | /* ------------------ */ | ||||
| /* Filters constraints that are only compatible with bones */ | /* Filters constraints that are only compatible with bones */ | ||||
| static const EnumPropertyItem *object_constraint_add_itemf(bContext *UNUSED(C), | static const EnumPropertyItem *object_constraint_add_itemf(bContext *UNUSED(C), | ||||
| PointerRNA *UNUSED(ptr), | PointerRNA *UNUSED(ptr), | ||||
| PropertyRNA *UNUSED(prop), | PropertyRNA *UNUSED(prop), | ||||
| ▲ Show 20 Lines • Show All 184 Lines • ▼ Show 20 Lines | |||||
| /* 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); | ||||
| const bool with_targets = RNA_boolean_get(op->ptr, "with_targets"); | const bool with_targets = RNA_boolean_get(op->ptr, "with_targets"); | ||||
| /* add the constraint - all necessary checks should have | /* add the constraint - all necessary checks should have | ||||
| * been done by the invoke() callback already... */ | * been done by the invoke() callback already... */ | ||||
| return constraint_add_exec(C, | return constraint_add_exec( | ||||
| op, | C, op, ob, ED_object_constraint_active_list(ob), CONSTRAINT_TYPE_KINEMATIC, with_targets); | ||||
| ob, | |||||
| ED_object_constraint_list_from_context(ob), | |||||
| CONSTRAINT_TYPE_KINEMATIC, | |||||
| with_targets); | |||||
| } | } | ||||
| void POSE_OT_ik_add(wmOperatorType *ot) | void POSE_OT_ik_add(wmOperatorType *ot) | ||||
| { | { | ||||
| /* identifiers */ | /* identifiers */ | ||||
| ot->name = "Add IK to Bone"; | ot->name = "Add IK to Bone"; | ||||
| ot->description = "Add IK Constraint to the active Bone"; | ot->description = "Add IK Constraint to the active Bone"; | ||||
| ot->idname = "POSE_OT_ik_add"; | ot->idname = "POSE_OT_ik_add"; | ||||
| ▲ Show 20 Lines • Show All 74 Lines • Show Last 20 Lines | |||||
This sentence is missing a verb.