diff options
| author | Ray <[email protected]> | 2019-04-23 16:01:18 +0200 |
|---|---|---|
| committer | Ray <[email protected]> | 2019-04-23 16:01:18 +0200 |
| commit | 372d77957fdc73991dca3f406c71a2c9a24b9e03 (patch) | |
| tree | 66a973cb01758f7cf9ad6eca57d739a0a0cd4769 /src/external/stb_rect_pack.h | |
| parent | 958bf43eac6a71815c2815000b54e40d46e6c419 (diff) | |
| download | raylib-372d77957fdc73991dca3f406c71a2c9a24b9e03.tar.gz raylib-372d77957fdc73991dca3f406c71a2c9a24b9e03.zip | |
Update STB libraries to latest version
Diffstat (limited to 'src/external/stb_rect_pack.h')
| -rw-r--r-- | src/external/stb_rect_pack.h | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/external/stb_rect_pack.h b/src/external/stb_rect_pack.h index 3632c85a..d32c8f9e 100644 --- a/src/external/stb_rect_pack.h +++ b/src/external/stb_rect_pack.h @@ -1,4 +1,4 @@ -// stb_rect_pack.h - v0.99 - public domain - rectangle packing +// stb_rect_pack.h - v1.00 - public domain - rectangle packing // Sean Barrett 2014 // // Useful for e.g. packing rectangular textures into an atlas. @@ -31,9 +31,11 @@ // // Bugfixes / warning fixes // Jeremy Jaussaud +// Fabian Giesen // // Version history: // +// 1.00 (2019-02-25) avoid small space waste; gracefully fail too-wide rectangles // 0.99 (2019-02-07) warning fixes // 0.11 (2017-03-03) return packing success/fail result // 0.10 (2016-10-25) remove cast-away-const to avoid warnings @@ -348,6 +350,13 @@ static stbrp__findresult stbrp__skyline_find_best_pos(stbrp_context *c, int widt width -= width % c->align; STBRP_ASSERT(width % c->align == 0); + // if it can't possibly fit, bail immediately + if (width > c->width || height > c->height) { + fr.prev_link = NULL; + fr.x = fr.y = 0; + return fr; + } + node = c->active_head; prev = &c->active_head; while (node->x + width <= c->width) { @@ -411,7 +420,7 @@ static stbrp__findresult stbrp__skyline_find_best_pos(stbrp_context *c, int widt } STBRP_ASSERT(node->next->x > xpos && node->x <= xpos); y = stbrp__skyline_find_min_y(c, node, xpos, width, &waste); - if (y + height < c->height) { + if (y + height <= c->height) { if (y <= best_y) { if (y < best_y || waste < best_waste || (waste==best_waste && xpos < best_x)) { best_x = xpos; |
