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
This commit is contained in:
Campbell Barton 2020-06-05 18:57:12 +10:00
parent 5e55153c89
commit ce7409fd13
6 changed files with 33 additions and 26 deletions

@ -316,15 +316,15 @@ void ED_objects_recalculate_paths(struct bContext *C,
eObjectPathCalcRange range); eObjectPathCalcRange range);
/* constraints */ /* constraints */
struct ListBase *get_active_constraints(struct Object *ob); struct ListBase *ED_object_constraint_list_from_context(struct Object *ob);
struct ListBase *get_constraint_lb(struct Object *ob, struct ListBase *ED_object_constraint_list_from_constraint(struct Object *ob,
struct bConstraint *con, struct bConstraint *con,
struct bPoseChannel **r_pchan); struct bPoseChannel **r_pchan);
struct bConstraint *get_active_constraint(struct Object *ob); struct bConstraint *ED_object_constraint_active_get(struct Object *ob);
void object_test_constraints(struct Main *bmain, 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_update(struct Main *bmain, struct Object *ob);
void ED_object_constraint_dependency_update(struct Main *bmain, struct Object *ob); void ED_object_constraint_dependency_update(struct Main *bmain, struct Object *ob);

@ -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) 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 */ /* draw panel showing settings for a constraint */

@ -81,7 +81,7 @@
* \{ */ * \{ */
/* if object in posemode, active bone constraints, else object constraints */ /* 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) { if (ob == NULL) {
return NULL; return NULL;
@ -104,7 +104,9 @@ ListBase *get_active_constraints(Object *ob)
/* 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 *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) { if (r_pchan) {
*r_pchan = NULL; *r_pchan = NULL;
@ -143,9 +145,9 @@ ListBase *get_constraint_lb(Object *ob, bConstraint *con, bPoseChannel **r_pchan
} }
/* single constraint */ /* 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; con = ptr.data;
RNA_string_set(op->ptr, "constraint", con->name); 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) { if (&ob->constraints == list) {
RNA_enum_set(op->ptr, "owner", EDIT_CONSTRAINT_OWNER_OBJECT); 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"); printf("edit_constraint_property_get: defaulting to getting list in the standard way\n");
} }
#endif #endif
list = get_active_constraints(ob); list = ED_object_constraint_list_from_context(ob);
} }
con = BKE_constraints_find_name(list, constraint_name); con = BKE_constraints_find_name(list, constraint_name);
@ -1305,9 +1307,9 @@ void CONSTRAINT_OT_objectsolver_clear_inverse(wmOperatorType *ot)
/** \name Constraint Management Utilities /** \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 */ /* lets be nice and escape if its active already */
/* NOTE: this assumes that the stack doesn't have other active ones set... */ /* 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); PointerRNA ptr = CTX_data_pointer_get_type(C, "constraint", &RNA_Constraint);
Object *ob = (Object *)ptr.owner_id; Object *ob = (Object *)ptr.owner_id;
bConstraint *con = ptr.data; 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 */ /* free the constraint */
if (BKE_constraint_remove_ex(lb, ob, con, true)) { 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); bConstraint *con = edit_constraint_property_get(op, ob, 0);
if (con && con->next) { 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; 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 */
@ -1515,7 +1517,7 @@ static int constraint_move_up_exec(bContext *C, wmOperator *op)
bConstraint *con = edit_constraint_property_get(op, ob, 0); bConstraint *con = edit_constraint_property_get(op, ob, 0);
if (con && con->prev) { 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; 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 */
@ -2055,7 +2057,8 @@ static int pose_constraint_add_exec(bContext *C, wmOperator *op)
with_targets = 1; 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 /* 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( return constraint_add_exec(C,
C, op, ob, get_active_constraints(ob), CONSTRAINT_TYPE_KINEMATIC, with_targets); op,
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)

@ -271,7 +271,7 @@ void BCAnimationSampler::find_depending_animated(std::set<Object *> &animated_ob
std::set<Object *>::iterator it; std::set<Object *>::iterator it;
for (it = candidates.begin(); it != candidates.end(); ++it) { for (it = candidates.begin(); it != candidates.end(); ++it) {
Object *cob = *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)) { if (is_animated_by_constraint(cob, conlist, animated_objects)) {
animated_objects.insert(cob); animated_objects.insert(cob);
candidates.erase(cob); candidates.erase(cob);

@ -389,7 +389,7 @@ static void rna_Constraint_name_set(PointerRNA *ptr, const char *value)
/* make sure name is unique */ /* make sure name is unique */
if (ptr->owner_id) { if (ptr->owner_id) {
Object *ob = (Object *)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 we have the list, check for unique name, otherwise give up */
if (list) { 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) static char *rna_Constraint_do_compute_path(Object *ob, bConstraint *con)
{ {
bPoseChannel *pchan; bPoseChannel *pchan;
ListBase *lb = get_constraint_lb(ob, con, &pchan); ListBase *lb = ED_object_constraint_list_from_constraint(ob, con, &pchan);
if (lb == NULL) { if (lb == NULL) {
printf("%s: internal error, constraint '%s' not found in object '%s'\n", printf("%s: internal error, constraint '%s' not found in object '%s'\n",

@ -1471,7 +1471,7 @@ static void rna_Object_constraints_remove(Object *object,
RNA_POINTER_INVALIDATE(con_ptr); RNA_POINTER_INVALIDATE(con_ptr);
ED_object_constraint_update(bmain, object); 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); 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); BKE_constraints_free(&object->constraints);
ED_object_constraint_update(bmain, object); 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); WM_main_add_notifier(NC_OBJECT | ND_CONSTRAINT | NA_REMOVED, object);
} }