diff options
author | Philipp Oeser <info@graphics-engineer.com> | 2018-05-09 16:08:13 +0300 |
---|---|---|
committer | Philipp Oeser <info@graphics-engineer.com> | 2018-05-09 16:08:13 +0300 |
commit | e8d9b7c95428f2d3efea344adda93098721dab6c (patch) | |
tree | 49c788ff6d0dfc517f3c82f674dd4aa2853ae971 /source | |
parent | 6f891e2b87fa44714ce66c7aff1b402603f48ff9 (diff) | |
parent | 69f2305415a224c277fe4fa9c81f846ba60cbb17 (diff) |
Merge branch 'master' into blender2.8
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenkernel/intern/lattice.c | 53 |
1 files changed, 24 insertions, 29 deletions
diff --git a/source/blender/blenkernel/intern/lattice.c b/source/blender/blenkernel/intern/lattice.c index 30c839bf766..b9b894db9a5 100644 --- a/source/blender/blenkernel/intern/lattice.c +++ b/source/blender/blenkernel/intern/lattice.c @@ -853,45 +853,40 @@ void lattice_deform_verts(Object *laOb, Object *target, Mesh *mesh, float (*vertexCos)[3], int numVerts, const char *vgroup, float fac) { LatticeDeformData *lattice_deform_data; + MDeformVert *dvert = NULL; + int defgrp_index = -1; int a; - bool use_vgroups; if (laOb->type != OB_LATTICE) return; lattice_deform_data = init_latt_deform(laOb, target); - /* check whether to use vertex groups (only possible if target is a Mesh) - * we want either a Mesh with no derived data, or derived data with - * deformverts + /* 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 (target && target->type == OB_MESH) { - /* if there's derived data without deformverts, don't use vgroups */ - if (mesh) { - use_vgroups = (mesh->dvert != NULL); - } - else { - Mesh *me = target->data; - use_vgroups = (me->dvert != NULL); + if (vgroup && vgroup[0] && target && 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; + } } } - else { - use_vgroups = false; - } - - if (vgroup && vgroup[0] && use_vgroups) { - Mesh *me = target->data; - const int defgrp_index = defgroup_name_index(target, vgroup); - float weight; - - if (defgrp_index >= 0 && (me->dvert || mesh)) { - MDeformVert *dvert = mesh ? mesh->dvert : me->dvert; - - for (a = 0; a < numVerts; a++, dvert++) { - weight = defvert_find_weight(dvert, defgrp_index); - - if (weight > 0.0f) - calc_latt_deform(lattice_deform_data, vertexCos[a], weight * fac); + if (dvert) { + MDeformVert *dvert_iter; + for (a = 0, dvert_iter = dvert; a < numVerts; a++, dvert_iter++) { + const float weight = defvert_find_weight(dvert_iter, defgrp_index); + if (weight > 0.0f) { + calc_latt_deform(lattice_deform_data, vertexCos[a], weight * fac); } } } |