[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [57861] trunk/blender/source/blender: replace LATTICE_PT macro with BKE_lattice_index_from_uvw().
Campbell Barton
ideasman42 at gmail.com
Fri Jun 28 23:24:38 CEST 2013
Revision: 57861
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=57861
Author: campbellbarton
Date: 2013-06-28 21:24:38 +0000 (Fri, 28 Jun 2013)
Log Message:
-----------
replace LATTICE_PT macro with BKE_lattice_index_from_uvw().
Modified Paths:
--------------
trunk/blender/source/blender/blenkernel/intern/lattice.c
trunk/blender/source/blender/editors/object/object_lattice.c
Modified: trunk/blender/source/blender/blenkernel/intern/lattice.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/lattice.c 2013-06-28 19:33:58 UTC (rev 57860)
+++ trunk/blender/source/blender/blenkernel/intern/lattice.c 2013-06-28 21:24:38 UTC (rev 57861)
@@ -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)
Modified: trunk/blender/source/blender/editors/object/object_lattice.c
===================================================================
--- trunk/blender/source/blender/editors/object/object_lattice.c 2013-06-28 19:33:58 UTC (rev 57860)
+++ trunk/blender/source/blender/editors/object/object_lattice.c 2013-06-28 21:24:38 UTC (rev 57861)
@@ -368,22 +368,6 @@
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 @@
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 @@
}
/* 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.
More information about the Bf-blender-cvs
mailing list