Changeset View
Changeset View
Standalone View
Standalone View
source/blender/modifiers/intern/MOD_surface.c
| Context not available. | |||||
| int numVerts) | int numVerts) | ||||
| { | { | ||||
| SurfaceModifierData *surmd = (SurfaceModifierData *) md; | SurfaceModifierData *surmd = (SurfaceModifierData *) md; | ||||
| BVHTreeFromMesh *bvhtree = surmd->bvhtree; | |||||
| const int cfra = (int)DEG_get_ctime(ctx->depsgraph); | const int cfra = (int)DEG_get_ctime(ctx->depsgraph); | ||||
| if (surmd->mesh) { | if (surmd->mesh) { | ||||
| // freeing the mesh also frees the bvh cache, which invalidates the bvhtree. | |||||
brecht: Blender comment style uses `/* */`. | |||||
| surmd->bvhtree->tree = NULL; | |||||
| surmd->bvhtree = NULL; // fix for T55974 | |||||
| BKE_id_free(NULL, surmd->mesh); | BKE_id_free(NULL, surmd->mesh); | ||||
| } | } | ||||
| Context not available. | |||||
| surmd->cfra = cfra; | surmd->cfra = cfra; | ||||
| if (surmd->bvhtree) | if (bvhtree) | ||||
| free_bvhtree_from_mesh(surmd->bvhtree); | free_bvhtree_from_mesh(bvhtree); | ||||
brechtUnsubmitted Not Done Inline ActionsIf allocation of surmd->mesh fails, this bvhtree will not be freed. brecht: If allocation of `surmd->mesh` fails, this bvhtree will not be freed. | |||||
| else | else | ||||
| surmd->bvhtree = MEM_callocN(sizeof(BVHTreeFromMesh), "BVHTreeFromMesh"); | bvhtree = MEM_callocN(sizeof(BVHTreeFromMesh), "BVHTreeFromMesh"); | ||||
| if (surmd->mesh->totpoly) | if (surmd->mesh->totpoly) | ||||
| BKE_bvhtree_from_mesh_get(surmd->bvhtree, surmd->mesh, BVHTREE_FROM_LOOPTRI, 2); | BKE_bvhtree_from_mesh_get(bvhtree, surmd->mesh, BVHTREE_FROM_LOOPTRI, 2); | ||||
| else | else | ||||
| BKE_bvhtree_from_mesh_get(surmd->bvhtree, surmd->mesh, BVHTREE_FROM_EDGES, 2); | BKE_bvhtree_from_mesh_get(bvhtree, surmd->mesh, BVHTREE_FROM_EDGES, 2); | ||||
| surmd->bvhtree = bvhtree; | |||||
| } | } | ||||
| } | } | ||||
| ModifierTypeInfo modifierType_Surface = { | ModifierTypeInfo modifierType_Surface = { | ||||
| /* name */ "Surface", | /* name */ "Surface", | ||||
| /* structName */ "SurfaceModifierData", | /* structName */ "SurfaceModifierData", | ||||
| Context not available. | |||||
Blender comment style uses /* */.