[Bf-blender-cvs] [8cd5edf8508] blender2.8: MOD_cast: do not compute mesh when not needed.

Bastien Montagne noreply at git.blender.org
Mon Nov 26 21:08:04 CET 2018


Commit: 8cd5edf8508a00df9791f7b0795b23c74e00c449
Author: Bastien Montagne
Date:   Mon Nov 26 11:30:46 2018 +0100
Branches: blender2.8
https://developer.blender.org/rB8cd5edf8508a00df9791f7b0795b23c74e00c449

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.

===================================================================

M	source/blender/modifiers/intern/MOD_cast.c

===================================================================

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);
 	}
 }



More information about the Bf-blender-cvs mailing list