Commit: c13754e6475e438ebd2fbafa2e51aa58504dc5f9
Author: Pratik Borhade
Date:   Tue Feb 16 13:21:28 2021 +0100
Branches: blender-v2.92-release
https://developer.blender.org/rBc13754e6475e438ebd2fbafa2e51aa58504dc5f9

Fixes T84928 : Lattice vertices at unexpected positions when changing lattice 
resolution from 1 to 3 or more.

Fix for T84928 .
Considering the changes , issue is resolved ( Ignoring readability issues) .

**Changes **:

  - `Change in value assignment of fu/v/w :`  Observing previous code , I 
noticed ,value assigned to them is equivalent to -0.5 ( i.e. co-ordinate of 
left most vertex of lattice size =1 where  centre of lattice is origin ) .

  - `Change in value assignment of du/v/w :`    Margin ( distance ) between 
each division of surface along any axis is equivalent to **( (length of surface 
along axis ) / (no of division line - 1) )** . that's why is changed it to 
(default_size/unew -1) .

  - ` New variable declared "default_size"  :`  As far as I gone through the 
code , I noticed values  1 < du ,fu < 1  , which indicates these values were 
calculated with respect to default lattice of size 1 .

  - `removed pntsu/v/w != 1 check :`  Following changes inside the if block 
worked properly for pntsu/v/w = 1 .

Reviewed By: lichtwerk, campbellbarton

Differential Revision: https://developer.blender.org/D10353

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

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

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

diff --git a/source/blender/blenkernel/intern/lattice.c 
b/source/blender/blenkernel/intern/lattice.c
index 74f78106be5..84ffd8c636b 100644
--- a/source/blender/blenkernel/intern/lattice.c
+++ b/source/blender/blenkernel/intern/lattice.c
@@ -319,19 +319,21 @@ void BKE_lattice_resize(Lattice *lt, int uNew, int vNew, 
int wNew, Object *ltOb)
    * size first.
    */
   if (ltOb) {
-    if (uNew != 1 && lt->pntsu != 1) {
-      fu = lt->fu;
-      du = (lt->pntsu - 1) * lt->du / (uNew - 1);
+    const float default_size = 1.0;
+
+    if (uNew != 1) {
+      fu = -default_size / 2.0;
+      du = default_size / (uNew - 1);
     }
 
-    if (vNew != 1 && lt->pntsv != 1) {
-      fv = lt->fv;
-      dv = (lt->pntsv - 1) * lt->dv / (vNew - 1);
+    if (vNew != 1) {
+      fv = -default_size / 2.0;
+      dv = default_size / (vNew - 1);
     }
 
-    if (wNew != 1 && lt->pntsw != 1) {
-      fw = lt->fw;
-      dw = (lt->pntsw - 1) * lt->dw / (wNew - 1);
+    if (wNew != 1) {
+      fw = -default_size / 2.0;
+      dw = default_size / (wNew - 1);
     }
   }

_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to