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
diff options
context:
space:
mode:
authorAlexander Gavrilov <angavrilov@gmail.com>2020-11-23 23:42:05 +0300
committerAlexander Gavrilov <angavrilov@gmail.com>2022-06-03 16:18:26 +0300
commitd040e1da4f6133a8b81a1016b4e80220bed8ace3 (patch)
tree2dc7d2ca4e7fe0d06766e81bd8eb204fee65745b /source/blender/blenkernel/intern/constraint.c
parent284a3431aeee3e6a922d26415afcb50d0bf30b66 (diff)
Constraints: introduce wrapper functions to access target lists.
Instead of directly accessing constraint-specific callbacks in code all over blender, introduce two wrappers to retrieve and free the target list. This incidentally revealed a place within the Collada exporter in BCAnimationSampler.cpp that didn't clean up after retrieving the targets, resulting in a small memory leak. Fixing this should be the only functional change in this commit. This was split off from D9732. Differential Revision: https://developer.blender.org/D13844
Diffstat (limited to 'source/blender/blenkernel/intern/constraint.c')
-rw-r--r--source/blender/blenkernel/intern/constraint.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c
index 35f2f94bc91..6ffb3299869 100644
--- a/source/blender/blenkernel/intern/constraint.c
+++ b/source/blender/blenkernel/intern/constraint.c
@@ -6191,6 +6191,40 @@ bool BKE_constraint_is_nonlocal_in_liboverride(const Object *ob, const bConstrai
/* -------- Target-Matrix Stuff ------- */
+int BKE_constraint_targets_get(struct bConstraint *con, struct ListBase *r_targets)
+{
+ BLI_listbase_clear(r_targets);
+
+ const bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(con);
+
+ if (!cti) {
+ return 0;
+ }
+
+ int count = 0;
+
+ /* Constraint-specific targets. */
+ if (cti->get_constraint_targets) {
+ count = cti->get_constraint_targets(con, r_targets);
+ }
+
+ return count;
+}
+
+void BKE_constraint_targets_flush(struct bConstraint *con, struct ListBase *targets, bool no_copy)
+{
+ const bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(con);
+
+ if (!cti) {
+ return;
+ }
+
+ /* Release the constraint-specific targets. */
+ if (cti->flush_constraint_targets) {
+ cti->flush_constraint_targets(con, targets, no_copy);
+ }
+}
+
void BKE_constraint_target_matrix_get(struct Depsgraph *depsgraph,
Scene *scene,
bConstraint *con,