[Bf-blender-cvs] [0356c8f25b9] master: Cleanup: remove edit-mode check in vertex coordinate access

Campbell Barton noreply at git.blender.org
Thu Aug 22 05:25:44 CEST 2019


Commit: 0356c8f25b96bf9d8c677e51ad5106b5295cb37f
Author: Campbell Barton
Date:   Thu Aug 22 13:20:05 2019 +1000
Branches: master
https://developer.blender.org/rB0356c8f25b96bf9d8c677e51ad5106b5295cb37f

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.

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

M	source/blender/blenkernel/BKE_lattice.h
M	source/blender/blenkernel/intern/lattice.c

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

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



More information about the Bf-blender-cvs mailing list