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:
authorBastien Montagne <montagne29@wanadoo.fr>2018-10-02 18:59:11 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2018-10-02 19:00:42 +0300
commit9c02f6b1ed6fea5352ee161b146abff033a085e4 (patch)
tree4e482aef47bc7f834bea52604181df13489f6092 /source/blender/ikplugin/intern/iksolver_plugin.c
parent9d104f57b60c8a82337e38bb44b2aef6a93ac840 (diff)
Fix (unreported) memleak with legacy IKsolver.
Looks like new depsgraph may initialize some IK trees, without ever executing them (which also frees them with legacy IKSolver code)...
Diffstat (limited to 'source/blender/ikplugin/intern/iksolver_plugin.c')
-rw-r--r--source/blender/ikplugin/intern/iksolver_plugin.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/source/blender/ikplugin/intern/iksolver_plugin.c b/source/blender/ikplugin/intern/iksolver_plugin.c
index 9248d85c809..0baaa406201 100644
--- a/source/blender/ikplugin/intern/iksolver_plugin.c
+++ b/source/blender/ikplugin/intern/iksolver_plugin.c
@@ -582,3 +582,27 @@ void iksolver_execute_tree(struct Depsgraph *depsgraph, struct Scene *scene, Obj
free_posetree(tree);
}
}
+
+void iksolver_release_tree(struct Scene *UNUSED(scene), struct Object *ob, float UNUSED(ctime))
+{
+ iksolver_clear_data(ob->pose);
+}
+
+void iksolver_clear_data(bPose *pose)
+{
+ for (bPoseChannel *pchan = pose->chanbase.first; pchan; pchan = pchan->next) {
+ if ((pchan->flag & POSE_IKTREE) == 0)
+ continue;
+
+ while (pchan->iktree.first) {
+ PoseTree *tree = pchan->iktree.first;
+
+ /* stop on the first tree that isn't a standard IK chain */
+ if (tree->type != CONSTRAINT_TYPE_KINEMATIC)
+ break;
+
+ BLI_remlink(&pchan->iktree, tree);
+ free_posetree(tree);
+ }
+ }
+}