Correct check for tree being in BVH cache
This commit is contained in:
parent
79d01de6b0
commit
725a088ef9
@ -184,6 +184,7 @@ enum {
|
||||
typedef struct LinkNode BVHCache;
|
||||
|
||||
BVHTree *bvhcache_find(BVHCache *cache, int type);
|
||||
bool bvhcache_has_tree(const BVHCache *cache, const BVHTree *tree);
|
||||
void bvhcache_insert(BVHCache **cache_p, BVHTree *tree, int type);
|
||||
void bvhcache_init(BVHCache **cache_p);
|
||||
void bvhcache_free(BVHCache **cache_p);
|
||||
|
@ -1162,6 +1162,18 @@ BVHTree *bvhcache_find(BVHCache *cache, int type)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool bvhcache_has_tree(const BVHCache *cache, const BVHTree *tree)
|
||||
{
|
||||
while (cache) {
|
||||
const BVHCacheItem *item = cache->link;
|
||||
if (item->tree == tree) {
|
||||
return true;
|
||||
}
|
||||
cache = cache->next;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Inserts a BVHTree of the given type under the cache
|
||||
* After that the caller no longer needs to worry when to free the BVHTree
|
||||
|
@ -786,9 +786,8 @@ static bool snapDerivedMesh(
|
||||
|
||||
/* 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) {
|
||||
if (treedata->cached && !bvhcache_has_tree(&dm->bvhCache, treedata->tree)) {
|
||||
free_bvhtree_from_mesh(treedata);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user