forked from bartvdbraak/blender
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.
This commit is contained in:
parent
95d3286c65
commit
2b946f4297
@ -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;
|
||||
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user