Skip to content
Myr

Merge branch 'rect-pack-fail' of https://github.com/IntellectualKitty/stb into working

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 · parents c918a6b, 07fefa3 · Browse files · 1 file+14 added−5 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+14 added−5 removed

  • other:+14 added−5 removed

1 file+14 added−5 removed

modified:stb_rect_pack.h+14 added-5 removed
73 unmodified lines
74#else75typedef unsigned short stbrp_coord;76#endif7778STBRP_DEF void stbrp_pack_rects (stbrp_context *context, stbrp_rect *rects, int num_rects);78STBRP_DEF int stbrp_pack_rects (stbrp_context *context, stbrp_rect *rects, int num_rects);79// Assign packed locations to rectangles. The rectangles are of type80// 'stbrp_rect' defined below, stored in the array 'rects', and there81// are 'num_rects' many of them.82//
12 unmodified lines
95// this function again. Calling this multiple times with multiple rect96// arrays will probably produce worse packing results than calling it97// a single time with the full rectangle array, but the option is98// available.99//100// The function returns 1 if all of the rectangles were successfully101// packed and 0 otherwise.102103struct stbrp_rect104{105 // reserved for your use:
438 unmodified lines
544#else545#define STBRP__MAXVAL 0xffff546#endif547545STBRP_DEF void stbrp_pack_rects(stbrp_context *context, stbrp_rect *rects, int num_rects)548STBRP_DEF int stbrp_pack_rects(stbrp_context *context, stbrp_rect *rects, int num_rects)549{547 int i;550 int i, all_rects_packed = 1;551552 // we use the 'was_packed' field internally to allow sorting/unsorting553 for (i=0; i < num_rects; ++i) {554 rects[i].was_packed = i;
21 unmodified lines
576577 // unsort578 STBRP_SORT(rects, num_rects, sizeof(rects[0]), rect_original_order);579577 // set was_packed flags580 // set was_packed flags and all_rects_packed status581 for (i=0; i < num_rects; ++i)579 rects[i].was_packed = !(rects[i].x == STBRP__MAXVAL && rects[i].y == STBRP__MAXVAL);582 {583 if (!(rects[i].was_packed = !(rects[i].x == STBRP__MAXVAL && rects[i].y == STBRP__MAXVAL)))584 all_rects_packed = 0;585 }586587 // return the all_rects_packed status588 return all_rects_packed;589}590#endif591592/*
40 unmodified lines