Skip to content
Myr

Return all_rects_packed status from stbrp_pack_rects.

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

authored by IntellectualKitty · committed by GitHub · parent 996ccf2 · 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
75 unmodified lines
76#else77typedef unsigned short stbrp_coord;78#endif7980STBRP_DEF void stbrp_pack_rects (stbrp_context *context, stbrp_rect *rects, int num_rects);80STBRP_DEF int stbrp_pack_rects (stbrp_context *context, stbrp_rect *rects, int num_rects);81// Assign packed locations to rectangles. The rectangles are of type82// 'stbrp_rect' defined below, stored in the array 'rects', and there83// are 'num_rects' many of them.84//
12 unmodified lines
97// this function again. Calling this multiple times with multiple rect98// arrays will probably produce worse packing results than calling it99// a single time with the full rectangle array, but the option is100// available.101//102// The function returns 1 if all of the rectangles were successfully103// packed and 0 otherwise.104105struct stbrp_rect106{107 // reserved for your use:
438 unmodified lines
546#else547#define STBRP__MAXVAL 0xffff548#endif549547STBRP_DEF void stbrp_pack_rects(stbrp_context *context, stbrp_rect *rects, int num_rects)550STBRP_DEF int stbrp_pack_rects(stbrp_context *context, stbrp_rect *rects, int num_rects)551{549 int i;552 int i, all_rects_packed = 1;553554 // we use the 'was_packed' field internally to allow sorting/unsorting555 for (i=0; i < num_rects; ++i) {556 rects[i].was_packed = i;
21 unmodified lines
578579 // unsort580 STBRP_SORT(rects, num_rects, sizeof(rects[0]), rect_original_order);581579 // set was_packed flags582 // set was_packed flags and all_rects_packed status583 for (i=0; i < num_rects; ++i)581 rects[i].was_packed = !(rects[i].x == STBRP__MAXVAL && rects[i].y == STBRP__MAXVAL);584 {585 if (!(rects[i].was_packed = !(rects[i].x == STBRP__MAXVAL && rects[i].y == STBRP__MAXVAL)))586 all_rects_packed = 0;587 }588589 // return the all_rects_packed status590 return all_rects_packed;591}592#endif