mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-15 01:17:00 +00:00
stb_rect_pack.h update to 0.08
This commit is contained in:
parent
0b10bec71f
commit
21f0d64a74
@ -1,4 +1,4 @@
|
|||||||
// stb_rect_pack.h - v0.05 - public domain - rectangle packing
|
// stb_rect_pack.h - v0.08 - 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.
|
||||||
@ -13,6 +13,7 @@
|
|||||||
// More docs to come.
|
// More docs to come.
|
||||||
//
|
//
|
||||||
// No memory allocations; uses qsort() and assert() from stdlib.
|
// No memory allocations; uses qsort() and assert() from stdlib.
|
||||||
|
// Can override those by defining STBRP_SORT and STBRP_ASSERT.
|
||||||
//
|
//
|
||||||
// This library currently uses the Skyline Bottom-Left algorithm.
|
// This library currently uses the Skyline Bottom-Left algorithm.
|
||||||
//
|
//
|
||||||
@ -20,11 +21,29 @@
|
|||||||
// implement them to the same API, but with a different init
|
// implement them to the same API, but with a different init
|
||||||
// function.
|
// function.
|
||||||
//
|
//
|
||||||
|
// Credits
|
||||||
|
//
|
||||||
|
// Library
|
||||||
|
// Sean Barrett
|
||||||
|
// Minor features
|
||||||
|
// Martins Mozeiko
|
||||||
|
// Bugfixes / warning fixes
|
||||||
|
// Jeremy Jaussaud
|
||||||
|
//
|
||||||
// Version history:
|
// Version history:
|
||||||
//
|
//
|
||||||
|
// 0.08 (2015-09-13) really fix bug with empty rects (w=0 or h=0)
|
||||||
|
// 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.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
|
||||||
// 0.01: initial release
|
// 0.01: initial release
|
||||||
|
//
|
||||||
|
// LICENSE
|
||||||
|
//
|
||||||
|
// This software is in the public domain. Where that dedication is not
|
||||||
|
// recognized, you are granted a perpetual, irrevocable license to copy,
|
||||||
|
// distribute, and modify this file as you see fit.
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
@ -169,7 +188,10 @@ struct stbrp_context
|
|||||||
//
|
//
|
||||||
|
|
||||||
#ifdef STB_RECT_PACK_IMPLEMENTATION
|
#ifdef STB_RECT_PACK_IMPLEMENTATION
|
||||||
|
#ifndef STBRP_SORT
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#define STBRP_SORT qsort
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef STBRP_ASSERT
|
#ifndef STBRP_ASSERT
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
@ -525,20 +547,24 @@ STBRP_DEF void stbrp_pack_rects(stbrp_context *context, stbrp_rect *rects, int n
|
|||||||
}
|
}
|
||||||
|
|
||||||
// sort according to heuristic
|
// sort according to heuristic
|
||||||
qsort(rects, num_rects, sizeof(rects[0]), rect_height_compare);
|
STBRP_SORT(rects, num_rects, sizeof(rects[0]), rect_height_compare);
|
||||||
|
|
||||||
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);
|
if (rects[i].w == 0 || rects[i].h == 0) {
|
||||||
if (fr.prev_link) {
|
rects[i].x = rects[i].y = 0; // empty rect needs no space
|
||||||
rects[i].x = (stbrp_coord) fr.x;
|
|
||||||
rects[i].y = (stbrp_coord) fr.y;
|
|
||||||
} else {
|
} else {
|
||||||
rects[i].x = rects[i].y = STBRP__MAXVAL;
|
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;
|
||||||
|
rects[i].y = (stbrp_coord) fr.y;
|
||||||
|
} else {
|
||||||
|
rects[i].x = rects[i].y = STBRP__MAXVAL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// unsort
|
// unsort
|
||||||
qsort(rects, num_rects, sizeof(rects[0]), rect_original_order);
|
STBRP_SORT(rects, num_rects, sizeof(rects[0]), rect_original_order);
|
||||||
|
|
||||||
// set was_packed flags
|
// set was_packed flags
|
||||||
for (i=0; i < num_rects; ++i)
|
for (i=0; i < num_rects; ++i)
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
// [ImGui] this is a slightly modified version of stb_truetype.h 1.4
|
// [ImGui] this is a slightly modified version of stb_truetype.h 1.4
|
||||||
// [ImGui] we made a fix for using the END key on multi-line text edit, see https://github.com/ocornut/imgui/issues/275
|
// [ImGui] we made a fix for using the END key on multi-line text edit, see https://github.com/ocornut/imgui/issues/275
|
||||||
|
// [ImGui] we made a fix for using keyboard while using mouse, see https://github.com/nothings/stb/pull/209
|
||||||
|
|
||||||
// stb_textedit.h - v1.4 - public domain - Sean Barrett
|
// stb_textedit.h - v1.4 - public domain - Sean Barrett
|
||||||
// Development of this library was sponsored by RAD Game Tools
|
// Development of this library was sponsored by RAD Game Tools
|
||||||
|
Loading…
Reference in New Issue
Block a user