diff options
author | Campbell Barton <ideasman42@gmail.com> | 2016-05-06 19:59:19 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2016-05-06 19:59:19 +0300 |
commit | ddbc351dd30f414dd5d8ceb1621c8c4cac3d7e43 (patch) | |
tree | cd0fc709b919357684e50e18926f42984479b888 /source | |
parent | 9c6f33c40587a94ed65bd75c4428907f666ea8b2 (diff) |
Fix recent issue in recent BVH snap/cache
The derivedMesh could free a tree stored by the cache.
Now check the cached tree is valid.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/editors/transform/transform_snap_object.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/source/blender/editors/transform/transform_snap_object.c b/source/blender/editors/transform/transform_snap_object.c index ea34895d3f5..754061c7a8a 100644 --- a/source/blender/editors/transform/transform_snap_object.c +++ b/source/blender/editors/transform/transform_snap_object.c @@ -33,6 +33,7 @@ #include "BLI_kdopbvh.h" #include "BLI_memarena.h" #include "BLI_ghash.h" +#include "BLI_linklist.h" #include "BLI_utildefines.h" #include "DNA_armature_types.h" @@ -659,6 +660,14 @@ static bool snapDerivedMesh( sod->bvh_trees[tree_index] = BLI_memarena_calloc(sctx->cache.mem_arena, sizeof(*treedata)); } treedata = sod->bvh_trees[tree_index]; + + /* the tree is owned by the DM and may have been freed since we last used! */ + if (treedata && treedata->tree) { + if (BLI_linklist_index(dm->bvhCache, treedata->tree) == -1) { + free_bvhtree_from_mesh(treedata); + + } + } } } else { |