diff options
author | Campbell Barton <ideasman42@gmail.com> | 2019-08-22 06:20:05 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2019-08-22 06:23:27 +0300 |
commit | 0356c8f25b96bf9d8c677e51ad5106b5295cb37f (patch) | |
tree | 8971ebe7dc35e3ef7a80e765e52dc7a2da5815ed /source/blender | |
parent | c2442541a62e48bd10499438c84d20bf21cac2c0 (diff) |
Cleanup: remove edit-mode check in vertex coordinate access
This makes the function more predictable since other object
types don't access edit-mode data.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenkernel/BKE_lattice.h | 1 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/lattice.c | 31 |
2 files changed, 19 insertions, 13 deletions
diff --git a/source/blender/blenkernel/BKE_lattice.h b/source/blender/blenkernel/BKE_lattice.h index fbb98b290f0..8395b182171 100644 --- a/source/blender/blenkernel/BKE_lattice.h +++ b/source/blender/blenkernel/BKE_lattice.h @@ -89,6 +89,7 @@ void armature_deform_verts(struct Object *armOb, struct bGPDstroke *gps); float (*BKE_lattice_vert_coords_alloc(const struct Lattice *lt, int *r_vert_len))[3]; +void BKE_lattice_vert_coords_get(const struct Lattice *lt, float (*vert_coords)[3]); void BKE_lattice_vert_coords_apply(struct Lattice *lt, const float (*vert_coords)[3]); void BKE_lattice_modifiers_calc(struct Depsgraph *depsgraph, struct Scene *scene, diff --git a/source/blender/blenkernel/intern/lattice.c b/source/blender/blenkernel/intern/lattice.c index 64ba02db30d..0ceca1206f6 100644 --- a/source/blender/blenkernel/intern/lattice.c +++ b/source/blender/blenkernel/intern/lattice.c @@ -1057,22 +1057,19 @@ void outside_lattice(Lattice *lt) } } -float (*BKE_lattice_vert_coords_alloc(const Lattice *lt, int *r_vert_len))[3] +void BKE_lattice_vert_coords_get(const Lattice *lt, float (*vert_coords)[3]) { - int vert_len; - float(*vert_coords)[3]; - - if (lt->editlatt) { - lt = lt->editlatt->latt; - } - vert_len = *r_vert_len = lt->pntsu * lt->pntsv * lt->pntsw; - - vert_coords = MEM_mallocN(sizeof(*vert_coords) * vert_len, __func__); - + const int vert_len = lt->pntsu * lt->pntsv * lt->pntsw; for (int i = 0; i < vert_len; i++) { copy_v3_v3(vert_coords[i], lt->def[i].vec); } +} +float (*BKE_lattice_vert_coords_alloc(const Lattice *lt, int *r_vert_len))[3] +{ + const int vert_len = *r_vert_len = lt->pntsu * lt->pntsv * lt->pntsw; + float(*vert_coords)[3] = MEM_mallocN(sizeof(*vert_coords) * vert_len, __func__); + BKE_lattice_vert_coords_get(lt, vert_coords); return vert_coords; } @@ -1123,7 +1120,11 @@ void BKE_lattice_modifiers_calc(struct Depsgraph *depsgraph, Scene *scene, Objec } if (!vert_coords) { - vert_coords = BKE_lattice_vert_coords_alloc(ob_orig->data, &numVerts); + Lattice *lt_orig = ob_orig->data; + if (lt_orig->editlatt) { + lt_orig = lt_orig->editlatt->latt; + } + vert_coords = BKE_lattice_vert_coords_alloc(lt_orig, &numVerts); } mti->deformVerts(md, &mectx, NULL, vert_coords, numVerts); } @@ -1137,7 +1138,11 @@ void BKE_lattice_modifiers_calc(struct Depsgraph *depsgraph, Scene *scene, Objec else { /* Displist won't do anything; this is just for posterity's sake until we remove it. */ if (!vert_coords) { - vert_coords = BKE_lattice_vert_coords_alloc(ob_orig->data, &numVerts); + Lattice *lt_orig = ob_orig->data; + if (lt_orig->editlatt) { + lt_orig = lt_orig->editlatt->latt; + } + vert_coords = BKE_lattice_vert_coords_alloc(lt_orig, &numVerts); } DispList *dl = MEM_callocN(sizeof(*dl), "lt_dl"); |