Skip to content

Commit

Permalink
Fixes T84928 : Lattice vertices at unexpected positions when changing…
Browse files Browse the repository at this point in the history
… 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
  • Loading branch information
Pratik Borhade authored and lichtwerk committed Feb 16, 2021
1 parent 2e81f2c commit c13754e
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions source/blender/blenkernel/intern/lattice.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down

0 comments on commit c13754e

Please sign in to comment.