diff options
author | Campbell Barton <ideasman42@gmail.com> | 2013-06-29 01:24:38 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2013-06-29 01:24:38 +0400 |
commit | 62ab3baea43a7ab37f761330978f2b3d0a84e11f (patch) | |
tree | 0eb97f3d1561f39f724f847de48690ce9654089e | |
parent | f55ef8b3fc405f630ecb59e3c21b2676451f448f (diff) |
replace LATTICE_PT macro with BKE_lattice_index_from_uvw().
-rw-r--r-- | source/blender/blenkernel/intern/lattice.c | 14 | ||||
-rw-r--r-- | source/blender/editors/object/object_lattice.c | 22 |
2 files changed, 13 insertions, 23 deletions
diff --git a/source/blender/blenkernel/intern/lattice.c b/source/blender/blenkernel/intern/lattice.c index 23368446675..c9b904e76ac 100644 --- a/source/blender/blenkernel/intern/lattice.c +++ b/source/blender/blenkernel/intern/lattice.c @@ -65,15 +65,21 @@ int BKE_lattice_index_from_uvw(struct Lattice *lt, const int u, const int v, const int w) { - return (w * (lt->pntsu * lt->pntsv) + (v * lt->pntsu) + u); + const int totu = lt->pntsu; + const int totv = lt->pntsv; + + return (w * (totu * totv) + (v * totu) + u); } void BKE_lattice_index_to_uvw(struct Lattice *lt, const int index, int *r_u, int *r_v, int *r_w) { - *r_u = (index % lt->pntsu); - *r_v = (index / lt->pntsu) % lt->pntsv; - *r_w = (index / (lt->pntsu * lt->pntsv)); + const int totu = lt->pntsu; + const int totv = lt->pntsv; + + *r_u = (index % totu); + *r_v = (index / totu) % totv; + *r_w = (index / (totu * totv)); } void calc_lat_fudu(int flag, int res, float *r_fu, float *r_du) diff --git a/source/blender/editors/object/object_lattice.c b/source/blender/editors/object/object_lattice.c index d3537051861..0e220357d30 100644 --- a/source/blender/editors/object/object_lattice.c +++ b/source/blender/editors/object/object_lattice.c @@ -368,22 +368,6 @@ typedef enum eLattice_FlipAxes { LATTICE_FLIP_W = 2 } eLattice_FlipAxes; -/* Helper macro for accessing item at index (u, v, w) - * < lt: (Lattice) - * < U: (int) u-axis coordinate of point - * < V: (int) v-axis coordinate of point - * < W: (int) w-axis coordinate of point - * < dimU: (int) number of points per row or number of columns (U-Axis) - * < dimV: (int) number of rows (V-Axis) - * > returns: (BPoint *) pointer to BPoint at this index - */ -#define LATTICE_PT(lt, U, V, W, dimU, dimV) \ - ( (lt)->def + \ - ((dimU) * (dimV)) * (W) + \ - (dimU) * (V) + \ - (U) \ - ) - /* Flip midpoint value so that relative distances between midpoint and neighbour-pair is maintained * ! Assumes that uvw <=> xyz (i.e. axis-aligned index-axes with coordinate-axes) * - Helper for lattice_flip_exec() @@ -394,7 +378,7 @@ static void lattice_flip_point_value(Lattice *lt, int u, int v, int w, float mid float diff; /* just the point in the middle (unpaired) */ - bp = LATTICE_PT(lt, u, v, w, lt->pntsu, lt->pntsv); + bp = <->def[BKE_lattice_index_from_uvw(lt, u, v, w)]; /* flip over axis */ diff = mid - bp->vec[axis]; @@ -432,8 +416,8 @@ static void lattice_swap_point_pairs(Lattice *lt, int u, int v, int w, float mid } /* get points to operate on */ - bpA = LATTICE_PT(lt, u0, v0, w0, numU, numV); - bpB = LATTICE_PT(lt, u1, v1, w1, numU, numV); + bpA = <->def[BKE_lattice_index_from_uvw(lt, u0, v0, w0)]; + bpB = <->def[BKE_lattice_index_from_uvw(lt, u1, v1, w1)]; /* Swap all coordinates, so that flipped coordinates belong to * the indices on the correct side of the lattice. |