Skip to content
Myr

fix bug in handling rectangle with width or height of 0

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Sean Barrett · committed by Sean Barrett · parent 6b89381 · Browse files · 1 file+12 added−6 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+12 added−6 removed

  • other:+12 added−6 removed

1 file+12 added−6 removed

modified:stb_rect_pack.h+12 added-6 removed
1// stb_rect_pack.h - v0.06 - public domain - rectangle packing1// stb_rect_pack.h - v0.07 - public domain - rectangle packing2// Sean Barrett 20143//4// Useful for e.g. packing rectangular textures into an atlas.5// Does not do rotation.
21 unmodified lines
27// Sean Barrett28// Minor features29// Martins Mozeiko30// Bugfixes / warning fixes31// [your name could be here]31// Jeremy Jaussaud32//33// Version history:34//35// 0.07 (2015-09-13) fix bug with empty rects (w=0 or h=0)36// 0.06 (2015-04-15) added STBRP_SORT to allow replacing qsort37// 0.05: added STBRP_ASSERT to allow replacing assert38// 0.04: fixed minor bug in STBRP_LARGE_RECTS support39// 0.01: initial release
508 unmodified lines
548 STBRP_SORT(rects, num_rects, sizeof(rects[0]), rect_height_compare);549550 for (i=0; i < num_rects; ++i) {551 stbrp__findresult fr = stbrp__skyline_pack_rectangle(context, rects[i].w, rects[i].h);551 if (fr.prev_link) {552 rects[i].x = (stbrp_coord) fr.x;553 rects[i].y = (stbrp_coord) fr.y;552553 if (rects[i].w == 0 || rects[i].h == 0) {554 rects[i].x = rects[i].y = 0; // empty rect needs no space555 } else {556 if (fr.prev_link) {557 rects[i].x = (stbrp_coord) fr.x;558 rects[i].y = (stbrp_coord) fr.y;559 } else {555 rects[i].x = rects[i].y = STBRP__MAXVAL;560 rects[i].x = rects[i].y = STBRP__MAXVAL;561 }562 }563 }564565 // unsort
7 unmodified lines