Modifiers: cleanup/harmonize deform modifiers code re. mesh source.
Also fixes a few issues (like meshdeform's EM variant not using editmesh data), and adds a few optimizations (like only generating that source mesh when we do have a vgroup defined in parameters, for modifiers only using it to access vgroup)...
This commit is contained in:
@@ -388,10 +388,9 @@ static void deformVerts(
|
||||
SimpleDeformModifierData *sdmd = (SimpleDeformModifierData *)md;
|
||||
Mesh *mesh_src = NULL;
|
||||
|
||||
if (ctx->object->type == OB_MESH) {
|
||||
if (ctx->object->type == OB_MESH && sdmd->vgroup_name[0] != '\0') {
|
||||
/* mesh_src is only needed for vgroups. */
|
||||
mesh_src = MOD_deform_mesh_eval_get(ctx->object, NULL, mesh, NULL, numVerts, false, false);
|
||||
BLI_assert(mesh_src->totvert == numVerts);
|
||||
}
|
||||
|
||||
SimpleDeformModifier_do(sdmd, ctx->object, mesh_src, vertexCos, numVerts);
|
||||
@@ -408,11 +407,17 @@ static void deformVertsEM(
|
||||
float (*vertexCos)[3],
|
||||
int numVerts)
|
||||
{
|
||||
Mesh *mesh_src = MOD_deform_mesh_eval_get(ctx->object, editData, mesh, NULL, numVerts, false, false);
|
||||
SimpleDeformModifierData *sdmd = (SimpleDeformModifierData *)md;
|
||||
Mesh *mesh_src = NULL;
|
||||
|
||||
SimpleDeformModifier_do((SimpleDeformModifierData *)md, ctx->object, mesh_src, vertexCos, numVerts);
|
||||
if (ctx->object->type == OB_MESH && sdmd->vgroup_name[0] != '\0') {
|
||||
/* mesh_src is only needed for vgroups. */
|
||||
mesh_src = MOD_deform_mesh_eval_get(ctx->object, editData, mesh, NULL, numVerts, false, false);
|
||||
}
|
||||
|
||||
if (mesh_src != mesh) {
|
||||
SimpleDeformModifier_do(sdmd, ctx->object, mesh_src, vertexCos, numVerts);
|
||||
|
||||
if (!ELEM(mesh_src, NULL, mesh)) {
|
||||
BKE_id_free(NULL, mesh_src);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user