From ce7409fd13d319ad2035909bda8b3ecd3b0002b8 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 5 Jun 2020 18:57:12 +1000 Subject: [PATCH] Cleanup: use ED_object_ prefix for constraint functions - ED_object_constraint_list_from_constraint was get_constraint_lb - ED_object_constraint_list_from_context was get_active_constraints - ED_object_constraint_active_get was get_active_constraint - ED_object_constraint_active_set was ED_object_constraint_set_active --- source/blender/editors/include/ED_object.h | 12 +++---- .../editors/interface/interface_templates.c | 2 +- .../editors/object/object_constraint.c | 35 +++++++++++-------- .../blender/io/collada/BCAnimationSampler.cpp | 2 +- .../blender/makesrna/intern/rna_constraint.c | 4 +-- source/blender/makesrna/intern/rna_object.c | 4 +-- 6 files changed, 33 insertions(+), 26 deletions(-) diff --git a/source/blender/editors/include/ED_object.h b/source/blender/editors/include/ED_object.h index c99b132ad7c..e027efce1d3 100644 --- a/source/blender/editors/include/ED_object.h +++ b/source/blender/editors/include/ED_object.h @@ -316,15 +316,15 @@ void ED_objects_recalculate_paths(struct bContext *C, eObjectPathCalcRange range); /* constraints */ -struct ListBase *get_active_constraints(struct Object *ob); -struct ListBase *get_constraint_lb(struct Object *ob, - struct bConstraint *con, - struct bPoseChannel **r_pchan); -struct bConstraint *get_active_constraint(struct Object *ob); +struct ListBase *ED_object_constraint_list_from_context(struct Object *ob); +struct ListBase *ED_object_constraint_list_from_constraint(struct Object *ob, + struct bConstraint *con, + struct bPoseChannel **r_pchan); +struct bConstraint *ED_object_constraint_active_get(struct Object *ob); void object_test_constraints(struct Main *bmain, struct Object *ob); -void ED_object_constraint_set_active(struct Object *ob, struct bConstraint *con); +void ED_object_constraint_active_set(struct Object *ob, struct bConstraint *con); void ED_object_constraint_update(struct Main *bmain, struct Object *ob); void ED_object_constraint_dependency_update(struct Main *bmain, struct Object *ob); diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index 6bf2c721c20..6001e1ea1b5 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -2745,7 +2745,7 @@ void uiTemplateOperatorRedoProperties(uiLayout *layout, const bContext *C) static void constraint_active_func(bContext *UNUSED(C), void *ob_v, void *con_v) { - ED_object_constraint_set_active(ob_v, con_v); + ED_object_constraint_active_set(ob_v, con_v); } /* draw panel showing settings for a constraint */ diff --git a/source/blender/editors/object/object_constraint.c b/source/blender/editors/object/object_constraint.c index 236b040fca3..76e95b0105a 100644 --- a/source/blender/editors/object/object_constraint.c +++ b/source/blender/editors/object/object_constraint.c @@ -81,7 +81,7 @@ * \{ */ /* if object in posemode, active bone constraints, else object constraints */ -ListBase *get_active_constraints(Object *ob) +ListBase *ED_object_constraint_list_from_context(Object *ob) { if (ob == NULL) { return NULL; @@ -104,7 +104,9 @@ ListBase *get_active_constraints(Object *ob) /* Find the list that a given constraint belongs to, * and/or also get the posechannel this is from (if applicable) */ -ListBase *get_constraint_lb(Object *ob, bConstraint *con, bPoseChannel **r_pchan) +ListBase *ED_object_constraint_list_from_constraint(Object *ob, + bConstraint *con, + bPoseChannel **r_pchan) { if (r_pchan) { *r_pchan = NULL; @@ -143,9 +145,9 @@ ListBase *get_constraint_lb(Object *ob, bConstraint *con, bPoseChannel **r_pchan } /* single constraint */ -bConstraint *get_active_constraint(Object *ob) +bConstraint *ED_object_constraint_active_get(Object *ob) { - return BKE_constraints_active_get(get_active_constraints(ob)); + return BKE_constraints_active_get(ED_object_constraint_list_from_context(ob)); } /** \} */ @@ -721,7 +723,7 @@ static int edit_constraint_invoke_properties(bContext *C, wmOperator *op) con = ptr.data; RNA_string_set(op->ptr, "constraint", con->name); - list = get_constraint_lb(ob, con, NULL); + list = ED_object_constraint_list_from_constraint(ob, con, NULL); if (&ob->constraints == list) { RNA_enum_set(op->ptr, "owner", EDIT_CONSTRAINT_OWNER_OBJECT); @@ -769,7 +771,7 @@ static bConstraint *edit_constraint_property_get(wmOperator *op, Object *ob, int printf("edit_constraint_property_get: defaulting to getting list in the standard way\n"); } #endif - list = get_active_constraints(ob); + list = ED_object_constraint_list_from_context(ob); } con = BKE_constraints_find_name(list, constraint_name); @@ -1305,9 +1307,9 @@ void CONSTRAINT_OT_objectsolver_clear_inverse(wmOperatorType *ot) /** \name Constraint Management Utilities * \{ */ -void ED_object_constraint_set_active(Object *ob, bConstraint *con) +void ED_object_constraint_active_set(Object *ob, bConstraint *con) { - ListBase *lb = get_constraint_lb(ob, con, NULL); + ListBase *lb = ED_object_constraint_list_from_constraint(ob, con, NULL); /* lets be nice and escape if its active already */ /* NOTE: this assumes that the stack doesn't have other active ones set... */ @@ -1409,7 +1411,7 @@ static int constraint_delete_exec(bContext *C, wmOperator *UNUSED(op)) PointerRNA ptr = CTX_data_pointer_get_type(C, "constraint", &RNA_Constraint); Object *ob = (Object *)ptr.owner_id; bConstraint *con = ptr.data; - ListBase *lb = get_constraint_lb(ob, con, NULL); + ListBase *lb = ED_object_constraint_list_from_constraint(ob, con, NULL); /* free the constraint */ if (BKE_constraint_remove_ex(lb, ob, con, true)) { @@ -1459,7 +1461,7 @@ static int constraint_move_down_exec(bContext *C, wmOperator *op) bConstraint *con = edit_constraint_property_get(op, ob, 0); if (con && con->next) { - ListBase *conlist = get_constraint_lb(ob, con, NULL); + ListBase *conlist = ED_object_constraint_list_from_constraint(ob, con, NULL); bConstraint *nextCon = con->next; /* insert the nominated constraint after the one that used to be after it */ @@ -1515,7 +1517,7 @@ static int constraint_move_up_exec(bContext *C, wmOperator *op) bConstraint *con = edit_constraint_property_get(op, ob, 0); if (con && con->prev) { - ListBase *conlist = get_constraint_lb(ob, con, NULL); + ListBase *conlist = ED_object_constraint_list_from_constraint(ob, con, NULL); bConstraint *prevCon = con->prev; /* insert the nominated constraint before the one that used to be before it */ @@ -2055,7 +2057,8 @@ static int pose_constraint_add_exec(bContext *C, wmOperator *op) with_targets = 1; } - return constraint_add_exec(C, op, ob, get_active_constraints(ob), type, with_targets); + return constraint_add_exec( + C, op, ob, ED_object_constraint_list_from_context(ob), type, with_targets); } /* ------------------ */ @@ -2256,8 +2259,12 @@ static int pose_ik_add_exec(bContext *C, wmOperator *op) /* add the constraint - all necessary checks should have * been done by the invoke() callback already... */ - return constraint_add_exec( - C, op, ob, get_active_constraints(ob), CONSTRAINT_TYPE_KINEMATIC, with_targets); + return constraint_add_exec(C, + op, + ob, + ED_object_constraint_list_from_context(ob), + CONSTRAINT_TYPE_KINEMATIC, + with_targets); } void POSE_OT_ik_add(wmOperatorType *ot) diff --git a/source/blender/io/collada/BCAnimationSampler.cpp b/source/blender/io/collada/BCAnimationSampler.cpp index fc23a58ccbc..4aea74cd82f 100644 --- a/source/blender/io/collada/BCAnimationSampler.cpp +++ b/source/blender/io/collada/BCAnimationSampler.cpp @@ -271,7 +271,7 @@ void BCAnimationSampler::find_depending_animated(std::set &animated_ob std::set::iterator it; for (it = candidates.begin(); it != candidates.end(); ++it) { Object *cob = *it; - ListBase *conlist = get_active_constraints(cob); + ListBase *conlist = ED_object_constraint_list_from_context(cob); if (is_animated_by_constraint(cob, conlist, animated_objects)) { animated_objects.insert(cob); candidates.erase(cob); diff --git a/source/blender/makesrna/intern/rna_constraint.c b/source/blender/makesrna/intern/rna_constraint.c index 07ad8cbb37d..49a7bec7b00 100644 --- a/source/blender/makesrna/intern/rna_constraint.c +++ b/source/blender/makesrna/intern/rna_constraint.c @@ -389,7 +389,7 @@ static void rna_Constraint_name_set(PointerRNA *ptr, const char *value) /* make sure name is unique */ if (ptr->owner_id) { Object *ob = (Object *)ptr->owner_id; - ListBase *list = get_constraint_lb(ob, con, NULL); + ListBase *list = ED_object_constraint_list_from_constraint(ob, con, NULL); /* if we have the list, check for unique name, otherwise give up */ if (list) { @@ -404,7 +404,7 @@ static void rna_Constraint_name_set(PointerRNA *ptr, const char *value) static char *rna_Constraint_do_compute_path(Object *ob, bConstraint *con) { bPoseChannel *pchan; - ListBase *lb = get_constraint_lb(ob, con, &pchan); + ListBase *lb = ED_object_constraint_list_from_constraint(ob, con, &pchan); if (lb == NULL) { printf("%s: internal error, constraint '%s' not found in object '%s'\n", diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c index a27d77df32a..79a9e0be051 100644 --- a/source/blender/makesrna/intern/rna_object.c +++ b/source/blender/makesrna/intern/rna_object.c @@ -1471,7 +1471,7 @@ static void rna_Object_constraints_remove(Object *object, RNA_POINTER_INVALIDATE(con_ptr); ED_object_constraint_update(bmain, object); - ED_object_constraint_set_active(object, NULL); + ED_object_constraint_active_set(object, NULL); WM_main_add_notifier(NC_OBJECT | ND_CONSTRAINT | NA_REMOVED, object); } @@ -1480,7 +1480,7 @@ static void rna_Object_constraints_clear(Object *object, Main *bmain) BKE_constraints_free(&object->constraints); ED_object_constraint_update(bmain, object); - ED_object_constraint_set_active(object, NULL); + ED_object_constraint_active_set(object, NULL); WM_main_add_notifier(NC_OBJECT | ND_CONSTRAINT | NA_REMOVED, object); }