From 8cd5edf8508a00df9791f7b0795b23c74e00c449 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Mon, 26 Nov 2018 11:30:46 +0100 Subject: MOD_cast: do not compute mesh when not needed. This modifier only uses mesh to get vgroup, which is only needed in case modified object is indeed a mesh! Building a mesh from curve here is not only useless and time-consuming, it will also easily fail the assert about same number of vertices! Also fixes crash when used on lattice. Related to T57972. --- source/blender/modifiers/intern/MOD_cast.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'source/blender/modifiers') diff --git a/source/blender/modifiers/intern/MOD_cast.c b/source/blender/modifiers/intern/MOD_cast.c index 74e19f3254a..959f77b0718 100644 --- a/source/blender/modifiers/intern/MOD_cast.c +++ b/source/blender/modifiers/intern/MOD_cast.c @@ -429,9 +429,13 @@ static void deformVerts( int numVerts) { CastModifierData *cmd = (CastModifierData *)md; - Mesh *mesh_src = MOD_get_mesh_eval(ctx->object, NULL, mesh, NULL, false, false); + Mesh *mesh_src = NULL; - BLI_assert(mesh_src->totvert == numVerts); + if (ctx->object->type == OB_MESH) { + /* mesh_src is only needed for vgroups. */ + mesh_src = MOD_get_mesh_eval(ctx->object, NULL, mesh, NULL, false, false); + BLI_assert(mesh_src->totvert == numVerts); + } if (cmd->type == MOD_CAST_TYPE_CUBOID) { cuboid_do(cmd, ctx->object, mesh_src, vertexCos, numVerts); @@ -440,7 +444,7 @@ static void deformVerts( sphere_do(cmd, ctx->object, mesh_src, vertexCos, numVerts); } - if (mesh_src != mesh) { + if (!ELEM(mesh_src, NULL, mesh)) { BKE_id_free(NULL, mesh_src); } } -- cgit v1.2.3