diff options
author | Campbell Barton <ideasman42@gmail.com> | 2014-04-24 19:19:06 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2014-04-24 21:13:35 +0400 |
commit | 72e905271316dfe7674648830da518f156fe4386 (patch) | |
tree | ee179ff5e590c833412e24e97ba8fb7e69748541 | |
parent | 6c57ee53bfff5c06edafa30c9893dbc1841a8688 (diff) |
BoxPack: remove quad_flags array, replace with inline bit-shift
-rw-r--r-- | source/blender/blenlib/intern/boxpack2d.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/source/blender/blenlib/intern/boxpack2d.c b/source/blender/blenlib/intern/boxpack2d.c index 52d746c3af4..aa90b5e0eb9 100644 --- a/source/blender/blenlib/intern/boxpack2d.c +++ b/source/blender/blenlib/intern/boxpack2d.c @@ -45,7 +45,8 @@ typedef struct BoxVert { float x; float y; - int free; /* could be a char */ + int free : 8; /* vert status */ + int pad : 24; unsigned int index; struct BoxPack *trb; /* top right box */ @@ -67,6 +68,12 @@ typedef struct BoxVert { #define BRF 8 #define CORNERFLAGS (BLF | TRF | TLF | BRF) +BLI_INLINE int quad_flag(unsigned int q) +{ + BLI_assert(q < 4 && q >= 0); + return (1 << q); +} + #define BL 0 #define TR 1 #define TL 2 @@ -165,7 +172,6 @@ static int vertex_sort(const void *p1, const void *p2) * */ void BLI_box_pack_2d(BoxPack *boxarray, const unsigned int len, float *tot_width, float *tot_height) { - const int quad_flags[4] = {BLF, TRF, TLF, BRF}; /* use for looping */ unsigned int box_index, verts_pack_len, i, j, k; unsigned int *vertex_pack_indices; /* an array of indices used for sorting verts */ bool isect; @@ -269,7 +275,7 @@ void BLI_box_pack_2d(BoxPack *boxarray, const unsigned int len, float *tot_width * */ for (j = 0; (j < 4) && isect; j++) { - if (vert->free & quad_flags[j]) { + if (vert->free & quad_flag(j)) { switch (j) { case BL: SET_BOXRIGHT(box, vert->x); @@ -329,7 +335,7 @@ void BLI_box_pack_2d(BoxPack *boxarray, const unsigned int len, float *tot_width (*tot_height) = max_ff(BOXTOP(box), (*tot_height)); /* Place the box */ - vert->free &= ~quad_flags[j]; + vert->free &= (signed char)(~quad_flag(j)); switch (j) { case TR: |