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/io | |
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/io')
-rw-r--r-- | source/blender/io/collada/BCAnimationSampler.cpp | 12 | ||||
-rw-r--r-- | source/blender/io/collada/SceneExporter.cpp | 11 |
2 files changed, 10 insertions, 13 deletions
diff --git a/source/blender/io/collada/BCAnimationSampler.cpp b/source/blender/io/collada/BCAnimationSampler.cpp index 29c17b500f3..cbb30ccf51d 100644 --- a/source/blender/io/collada/BCAnimationSampler.cpp +++ b/source/blender/io/collada/BCAnimationSampler.cpp @@ -225,24 +225,26 @@ bool BCAnimationSampler::is_animated_by_constraint(Object *ob, for (con = (bConstraint *)conlist->first; con; con = con->next) { ListBase targets = {nullptr, nullptr}; - const bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(con); - if (!bc_validateConstraints(con)) { continue; } - if (cti && cti->get_constraint_targets) { + if (BKE_constraint_targets_get(con, &targets)) { bConstraintTarget *ct; Object *obtar; - cti->get_constraint_targets(con, &targets); + bool found = false; + for (ct = (bConstraintTarget *)targets.first; ct; ct = ct->next) { obtar = ct->tar; if (obtar) { if (animated_objects.find(obtar) != animated_objects.end()) { - return true; + found = true; + break; } } } + BKE_constraint_targets_flush(con, &targets, true); + return found; } } return false; diff --git a/source/blender/io/collada/SceneExporter.cpp b/source/blender/io/collada/SceneExporter.cpp index ea95729666a..1b1da110573 100644 --- a/source/blender/io/collada/SceneExporter.cpp +++ b/source/blender/io/collada/SceneExporter.cpp @@ -191,24 +191,19 @@ void SceneExporter::writeNode(Object *ob) /* not ideal: add the target object name as another parameter. * No real mapping in the `.dae`. * Need support for multiple target objects also. */ - const bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(con); - ListBase targets = {nullptr, nullptr}; - if (cti && cti->get_constraint_targets) { + ListBase targets = {nullptr, nullptr}; + if (BKE_constraint_targets_get(con, &targets)) { bConstraintTarget *ct; Object *obtar; - cti->get_constraint_targets(con, &targets); - for (ct = (bConstraintTarget *)targets.first; ct; ct = ct->next) { obtar = ct->tar; std::string tar_id((obtar) ? id_name(obtar) : ""); colladaNode.addExtraTechniqueChildParameter("blender", con_tag, "target_id", tar_id); } - if (cti->flush_constraint_targets) { - cti->flush_constraint_targets(con, &targets, true); - } + BKE_constraint_targets_flush(con, &targets, true); } con = con->next; |