|
|
@ -1,4 +1,4 @@ |
|
|
|
// stb_rect_pack.h - v0.06 - public domain - rectangle packing
|
|
|
|
// stb_rect_pack.h - v0.07 - public domain - rectangle packing
|
|
|
|
// Sean Barrett 2014
|
|
|
|
// Sean Barrett 2014
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// Useful for e.g. packing rectangular textures into an atlas.
|
|
|
|
// Useful for e.g. packing rectangular textures into an atlas.
|
|
|
@ -28,10 +28,11 @@ |
|
|
|
// Minor features
|
|
|
|
// Minor features
|
|
|
|
// Martins Mozeiko
|
|
|
|
// Martins Mozeiko
|
|
|
|
// Bugfixes / warning fixes
|
|
|
|
// Bugfixes / warning fixes
|
|
|
|
// [your name could be here]
|
|
|
|
// Jeremy Jaussaud
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// Version history:
|
|
|
|
// Version history:
|
|
|
|
//
|
|
|
|
//
|
|
|
|
|
|
|
|
// 0.07 (2015-09-13) fix bug with empty rects (w=0 or h=0)
|
|
|
|
// 0.06 (2015-04-15) added STBRP_SORT to allow replacing qsort
|
|
|
|
// 0.06 (2015-04-15) added STBRP_SORT to allow replacing qsort
|
|
|
|
// 0.05: added STBRP_ASSERT to allow replacing assert
|
|
|
|
// 0.05: added STBRP_ASSERT to allow replacing assert
|
|
|
|
// 0.04: fixed minor bug in STBRP_LARGE_RECTS support
|
|
|
|
// 0.04: fixed minor bug in STBRP_LARGE_RECTS support
|
|
|
@ -548,11 +549,16 @@ STBRP_DEF void stbrp_pack_rects(stbrp_context *context, stbrp_rect *rects, int n |
|
|
|
|
|
|
|
|
|
|
|
for (i=0; i < num_rects; ++i) { |
|
|
|
for (i=0; i < num_rects; ++i) { |
|
|
|
stbrp__findresult fr = stbrp__skyline_pack_rectangle(context, rects[i].w, rects[i].h); |
|
|
|
stbrp__findresult fr = stbrp__skyline_pack_rectangle(context, rects[i].w, rects[i].h); |
|
|
|
if (fr.prev_link) { |
|
|
|
|
|
|
|
rects[i].x = (stbrp_coord) fr.x; |
|
|
|
if (rects[i].w == 0 || rects[i].h == 0) { |
|
|
|
rects[i].y = (stbrp_coord) fr.y; |
|
|
|
rects[i].x = rects[i].y = 0; // empty rect needs no space
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
rects[i].x = rects[i].y = STBRP__MAXVAL; |
|
|
|
if (fr.prev_link) { |
|
|
|
|
|
|
|
rects[i].x = (stbrp_coord) fr.x; |
|
|
|
|
|
|
|
rects[i].y = (stbrp_coord) fr.y; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
rects[i].x = rects[i].y = STBRP__MAXVAL; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|