Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorPhilipp Oeser <info@graphics-engineer.com>2020-09-09 14:52:37 +0300
committerPhilipp Oeser <info@graphics-engineer.com>2020-09-09 15:12:55 +0300
commit9dcae4eb17d7b5a90fda43d0abab1636acf42851 (patch)
tree60dc9706c2bab6e363096baf865b585a46a4d31f /source
parent98eb89be5dd08f3b38f34e7881bae37c3b13e8bb (diff)
Refactor getting constraints
This is the refactoring part of D8805 (should be no functional changes). - exposes pose-related part of former 'get_constraints()' from interface_templates.c to new ED_object_pose_constraint_list - rename ED_object_constraint_list_from_context --> ED_object_constraint_active_list Also clarify comments on both of these. ref T80464 ref https://developer.blender.org/D8805
Diffstat (limited to 'source')
-rw-r--r--source/blender/editors/include/ED_object.h3
-rw-r--r--source/blender/editors/interface/interface_templates.c29
-rw-r--r--source/blender/editors/object/object_constraint.c32
-rw-r--r--source/blender/io/collada/BCAnimationSampler.cpp2
4 files changed, 30 insertions, 36 deletions
diff --git a/source/blender/editors/include/ED_object.h b/source/blender/editors/include/ED_object.h
index 8aa9cd8184b..b0ef22575ee 100644
--- a/source/blender/editors/include/ED_object.h
+++ b/source/blender/editors/include/ED_object.h
@@ -323,7 +323,8 @@ void ED_objects_recalculate_paths(struct bContext *C,
eObjectPathCalcRange range);
/* constraints */
-struct ListBase *ED_object_constraint_list_from_context(struct Object *ob);
+struct ListBase *ED_object_constraint_active_list(struct Object *ob);
+struct ListBase *ED_object_pose_constraint_list(const struct bContext *C);
struct ListBase *ED_object_constraint_list_from_constraint(struct Object *ob,
struct bConstraint *con,
struct bPoseChannel **r_pchan);
diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c
index 671a7865c6a..08d3ad0f23c 100644
--- a/source/blender/editors/interface/interface_templates.c
+++ b/source/blender/editors/interface/interface_templates.c
@@ -1972,27 +1972,6 @@ static bool constraint_panel_is_bone(Panel *panel)
}
/**
- * Get the constraints for the active pose bone or the active / pinned object.
- */
-static ListBase *get_constraints(const bContext *C, bool use_bone_constraints)
-{
- ListBase *constraints = {NULL};
- if (use_bone_constraints) {
- bPoseChannel *pose_bone = CTX_data_pointer_get(C, "pose_bone").data;
- if (pose_bone != NULL) {
- constraints = &pose_bone->constraints;
- }
- }
- else {
- Object *ob = ED_object_active_context(C);
- if (ob != NULL) {
- constraints = &ob->constraints;
- }
- }
- return constraints;
-}
-
-/**
* Move a constraint to the index it's moved to after a drag and drop.
*/
static void constraint_reorder(bContext *C, Panel *panel, int new_index)
@@ -2066,7 +2045,13 @@ void uiTemplateConstraints(uiLayout *UNUSED(layout), bContext *C, bool use_bone_
ARegion *region = CTX_wm_region(C);
Object *ob = ED_object_active_context(C);
- ListBase *constraints = get_constraints(C, use_bone_constraints);
+ ListBase *constraints = {NULL};
+ if (use_bone_constraints) {
+ constraints = ED_object_pose_constraint_list(C);
+ }
+ else {
+ constraints = ED_object_constraint_active_list(ob);
+ }
/* Switch between the bone panel ID function and the object panel ID function. */
uiListPanelIDFromDataFunc panel_id_func = use_bone_constraints ? bone_constraint_panel_id :
diff --git a/source/blender/editors/object/object_constraint.c b/source/blender/editors/object/object_constraint.c
index 2cca3045aee..9da5b774af2 100644
--- a/source/blender/editors/object/object_constraint.c
+++ b/source/blender/editors/object/object_constraint.c
@@ -80,8 +80,9 @@
/** \name Constraint Data Accessors
* \{ */
-/* if object in posemode, active bone constraints, else object constraints */
-ListBase *ED_object_constraint_list_from_context(Object *ob)
+/* If object is in posemode, return active bone constraints, else object constraints. No
+ * constraints are returned for a bone on an inactive bonelayer. */
+ListBase *ED_object_constraint_active_list(Object *ob)
{
if (ob == NULL) {
return NULL;
@@ -102,6 +103,18 @@ ListBase *ED_object_constraint_list_from_context(Object *ob)
return NULL;
}
+/* Get the constraints for the active pose bone. Bone may be on an inactive bonelayer (unlike
+ * ED_object_constraint_active_list, such constraints are not excluded here). */
+ListBase *ED_object_pose_constraint_list(const bContext *C)
+{
+ bPoseChannel *pose_bone = CTX_data_pointer_get(C, "pose_bone").data;
+ if (pose_bone == NULL) {
+ return NULL;
+ }
+
+ 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,
@@ -147,7 +160,7 @@ ListBase *ED_object_constraint_list_from_constraint(Object *ob,
/* single constraint */
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));
}
/** \} */
@@ -813,7 +826,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 = ED_object_constraint_list_from_context(ob);
+ list = ED_object_constraint_active_list(ob);
}
con = BKE_constraints_find_name(list, constraint_name);
@@ -2161,8 +2174,7 @@ static int pose_constraint_add_exec(bContext *C, wmOperator *op)
with_targets = 1;
}
- return constraint_add_exec(
- C, op, ob, ED_object_constraint_list_from_context(ob), type, with_targets);
+ return constraint_add_exec(C, op, ob, ED_object_constraint_active_list(ob), type, with_targets);
}
/* ------------------ */
@@ -2363,12 +2375,8 @@ 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,
- ED_object_constraint_list_from_context(ob),
- CONSTRAINT_TYPE_KINEMATIC,
- with_targets);
+ return constraint_add_exec(
+ C, op, ob, ED_object_constraint_active_list(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 a27bb10f705..b8df98e8acb 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<Object *> &animated_ob
std::set<Object *>::iterator it;
for (it = candidates.begin(); it != candidates.end(); ++it) {
Object *cob = *it;
- ListBase *conlist = ED_object_constraint_list_from_context(cob);
+ ListBase *conlist = ED_object_constraint_active_list(cob);
if (is_animated_by_constraint(cob, conlist, animated_objects)) {
animated_objects.insert(cob);
candidates.erase(cob);