diff options
author | Alexander Gavrilov <angavrilov@gmail.com> | 2020-11-23 23:42:05 +0300 |
---|---|---|
committer | Alexander Gavrilov <angavrilov@gmail.com> | 2022-06-03 16:18:26 +0300 |
commit | d040e1da4f6133a8b81a1016b4e80220bed8ace3 (patch) | |
tree | 2dc7d2ca4e7fe0d06766e81bd8eb204fee65745b /source/blender/blenkernel/intern/object.cc | |
parent | 284a3431aeee3e6a922d26415afcb50d0bf30b66 (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/object.cc')
-rw-r--r-- | source/blender/blenkernel/intern/object.cc | 17 |
1 files changed, 4 insertions, 13 deletions
diff --git a/source/blender/blenkernel/intern/object.cc b/source/blender/blenkernel/intern/object.cc index 52b25399e32..c8b87c27697 100644 --- a/source/blender/blenkernel/intern/object.cc +++ b/source/blender/blenkernel/intern/object.cc @@ -2483,21 +2483,16 @@ static void copy_object_pose(Object *obn, const Object *ob, const int flag) * BKE_library_remap stuff, but... * the flush_constraint_targets callback am not sure about, so will delay that for now. */ LISTBASE_FOREACH (bConstraint *, con, &chan->constraints) { - const bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(con); ListBase targets = {nullptr, nullptr}; - if (cti && cti->get_constraint_targets) { - cti->get_constraint_targets(con, &targets); - + if (BKE_constraint_targets_get(con, &targets)) { LISTBASE_FOREACH (bConstraintTarget *, ct, &targets) { if (ct->tar == ob) { ct->tar = obn; } } - if (cti->flush_constraint_targets) { - cti->flush_constraint_targets(con, &targets, false); - } + BKE_constraint_targets_flush(con, &targets, false); } } } @@ -5488,11 +5483,9 @@ bool BKE_object_modifier_update_subframe(Depsgraph *depsgraph, /* also update constraint targets */ LISTBASE_FOREACH (bConstraint *, con, &ob->constraints) { - const bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(con); ListBase targets = {nullptr, nullptr}; - if (cti && cti->get_constraint_targets) { - cti->get_constraint_targets(con, &targets); + if (BKE_constraint_targets_get(con, &targets)) { LISTBASE_FOREACH (bConstraintTarget *, ct, &targets) { if (ct->tar) { BKE_object_modifier_update_subframe( @@ -5500,9 +5493,7 @@ bool BKE_object_modifier_update_subframe(Depsgraph *depsgraph, } } /* free temp targets */ - if (cti->flush_constraint_targets) { - cti->flush_constraint_targets(con, &targets, false); - } + BKE_constraint_targets_flush(con, &targets, false); } } } |