diff options
author | Campbell Barton <ideasman42@gmail.com> | 2013-11-19 07:31:26 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2013-11-19 07:31:26 +0400 |
commit | 2b946f42970bf4f3b8ce8e5c9b79451745309d89 (patch) | |
tree | a645788cfc92cbd34398eeae43843b1283e89d04 | |
parent | 95d3286c65e034d9801c2623e81ef92a06e6cc8c (diff) |
Fix T37445: Crash with snapping and shrink-wrap modifier.
Developer note:
BVHTREE_FROM_FACES was being used for both edit-mesh and derived-mesh
bvh-trees, this could cause index lookup errors in editmode.
Fix by adding a new type for editmesh so theres no confusion.
-rw-r--r-- | source/blender/blenkernel/BKE_bvhutils.h | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/bvhutils.c | 5 |
2 files changed, 5 insertions, 2 deletions
diff --git a/source/blender/blenkernel/BKE_bvhutils.h b/source/blender/blenkernel/BKE_bvhutils.h index 8d4c9e782db..9e1bca45432 100644 --- a/source/blender/blenkernel/BKE_bvhutils.h +++ b/source/blender/blenkernel/BKE_bvhutils.h @@ -116,6 +116,8 @@ float nearest_point_in_tri_surface(const float v0[3], const float v1[3], const f #define BVHTREE_FROM_VERTICES 1 #define BVHTREE_FROM_EDGES 2 +#define BVHTREE_FROM_FACES_EDITMESH 3 + typedef struct LinkNode *BVHCache; diff --git a/source/blender/blenkernel/intern/bvhutils.c b/source/blender/blenkernel/intern/bvhutils.c index dba7a291a46..cce511aedcb 100644 --- a/source/blender/blenkernel/intern/bvhutils.c +++ b/source/blender/blenkernel/intern/bvhutils.c @@ -573,8 +573,9 @@ BVHTree *bvhtree_from_mesh_verts(BVHTreeFromMesh *data, DerivedMesh *dm, float e /* Builds a bvh tree.. where nodes are the faces of the given dm. */ BVHTree *bvhtree_from_mesh_faces(BVHTreeFromMesh *data, DerivedMesh *dm, float epsilon, int tree_type, int axis) { - BVHTree *tree = bvhcache_find(&dm->bvhCache, BVHTREE_FROM_FACES); BMEditMesh *em = data->em_evil; + const int bvhcache_type = em ? BVHTREE_FROM_FACES_EDITMESH : BVHTREE_FROM_FACES; + BVHTree *tree = bvhcache_find(&dm->bvhCache, bvhcache_type); /* Not in cache */ if (tree == NULL) { @@ -682,7 +683,7 @@ BVHTree *bvhtree_from_mesh_faces(BVHTreeFromMesh *data, DerivedMesh *dm, float e /* Save on cache for later use */ // printf("BVHTree built and saved on cache\n"); - bvhcache_insert(&dm->bvhCache, tree, BVHTREE_FROM_FACES); + bvhcache_insert(&dm->bvhCache, tree, bvhcache_type); } } } |