Commit: 6899dcab5339d1f17dd2ea665a38e4ab28ab23fc Author: Philipp Oeser Date: Sun May 30 22:26:31 2021 +0200 Branches: master https://developer.blender.org/rB6899dcab5339d1f17dd2ea665a38e4ab28ab23fc
Fix T88658: Force Fields of curve shape can crash if curve has only one point `bvhtree_from_mesh_edges_create_tree` can actually leave the BVHTree NULL (e.g. if no edges are present). Now dont allocate `BVHTreeFromMesh` on the `SurfaceModifierData` at all in case the tree would be NULL anyways. Places like `get_effector_data` check for `SurfaceModifierData`- >`BVHTreeFromMesh` and dont try to stuff like getting a closest point on surface, which would crash as soon as BVHNodes would need to be accessed (from the NULL BVHTree). Maniphest Tasks: T88658 Differential Revision: https://developer.blender.org/D11443 =================================================================== M source/blender/modifiers/intern/MOD_surface.c =================================================================== diff --git a/source/blender/modifiers/intern/MOD_surface.c b/source/blender/modifiers/intern/MOD_surface.c index d2c011a21d3..bfd4cd81803 100644 --- a/source/blender/modifiers/intern/MOD_surface.c +++ b/source/blender/modifiers/intern/MOD_surface.c @@ -184,13 +184,17 @@ static void deformVerts(ModifierData *md, surmd->cfra = cfra; - surmd->bvhtree = MEM_callocN(sizeof(BVHTreeFromMesh), "BVHTreeFromMesh"); + const bool has_poly = surmd->mesh->totpoly > 0; + const bool has_edge = surmd->mesh->totedge > 0; + if (has_poly || has_edge) { + surmd->bvhtree = MEM_callocN(sizeof(BVHTreeFromMesh), "BVHTreeFromMesh"); - if (surmd->mesh->totpoly) { - BKE_bvhtree_from_mesh_get(surmd->bvhtree, surmd->mesh, BVHTREE_FROM_LOOPTRI, 2); - } - else { - BKE_bvhtree_from_mesh_get(surmd->bvhtree, surmd->mesh, BVHTREE_FROM_EDGES, 2); + if (has_poly) { + BKE_bvhtree_from_mesh_get(surmd->bvhtree, surmd->mesh, BVHTREE_FROM_LOOPTRI, 2); + } + else if (has_edge) { + BKE_bvhtree_from_mesh_get(surmd->bvhtree, surmd->mesh, BVHTREE_FROM_EDGES, 2); + } } } } _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs