diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2018-11-26 13:46:20 +0300 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2018-11-26 23:07:50 +0300 |
commit | ede994c3140b92076a3f398b6889e02231461150 (patch) | |
tree | 77e4f2c870576f09e3d9d76dbe06615288d7c509 /source/blender/blenkernel/intern/lattice.c | |
parent | 8cd5edf8508a00df9791f7b0795b23c74e00c449 (diff) |
MOD_curve: 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, use MOD_get_vgroup() helper in modifier code itself and pass
reluting MDeformVert & index to BKE_curve's curve_deform_verts(),
this is simpler and avoids duplicating vgroup handling code.
Also fixes crash when used on lattice.
Related to T57972.
Diffstat (limited to 'source/blender/blenkernel/intern/lattice.c')
-rw-r--r-- | source/blender/blenkernel/intern/lattice.c | 26 |
1 files changed, 2 insertions, 24 deletions
diff --git a/source/blender/blenkernel/intern/lattice.c b/source/blender/blenkernel/intern/lattice.c index a04f32adece..0fa675639ea 100644 --- a/source/blender/blenkernel/intern/lattice.c +++ b/source/blender/blenkernel/intern/lattice.c @@ -704,14 +704,12 @@ static bool calc_curve_deform(Object *par, float co[3], } void curve_deform_verts( - Object *cuOb, Object *target, Mesh *mesh, float (*vertexCos)[3], - int numVerts, const char *vgroup, short defaxis) + Object *cuOb, Object *target, float (*vertexCos)[3], + int numVerts, MDeformVert *dvert, const int defgrp_index, short defaxis) { Curve *cu; int a; CurveDeform cd; - MDeformVert *dvert = NULL; - int defgrp_index = -1; const bool is_neg_axis = (defaxis > 2); if (cuOb->type != OB_CURVE) @@ -732,26 +730,6 @@ void curve_deform_verts( cd.dmax[0] = cd.dmax[1] = cd.dmax[2] = 0.0f; } - /* Check whether to use vertex groups (only possible if target is a Mesh or Lattice). - * We want either a Mesh/Lattice with no derived data, or derived data with deformverts. - */ - if (vgroup && vgroup[0] && ELEM(target->type, OB_MESH, OB_LATTICE)) { - defgrp_index = defgroup_name_index(target, vgroup); - - if (defgrp_index != -1) { - /* if there's derived data without deformverts, don't use vgroups */ - if (mesh) { - dvert = CustomData_get_layer(&mesh->vdata, CD_MDEFORMVERT); - } - else if (target->type == OB_LATTICE) { - dvert = ((Lattice *)target->data)->dvert; - } - else { - dvert = ((Mesh *)target->data)->dvert; - } - } - } - if (dvert) { MDeformVert *dvert_iter; float vec[3]; |