| 
																	
																	
																	
																 | 
																@ -1,4 +1,4 @@ | 
															
														
														
													
														
															
																 | 
																 | 
																// stb_rect_pack.h - v0.08 - public domain - rectangle packing | 
																 | 
																 | 
																 | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																// stb_rect_pack.h - v0.10 - 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. | 
															
														
														
													
												
													
														
															
																| 
																	
																		
																			
																		
																	
																	
																		
																			
																		
																	
																	
																 | 
																@ -32,6 +32,8 @@ | 
															
														
														
													
														
															
																 | 
																 | 
																// | 
																 | 
																 | 
																// | 
															
														
														
													
														
															
																 | 
																 | 
																// Version history: | 
																 | 
																 | 
																// Version history: | 
															
														
														
													
														
															
																 | 
																 | 
																// | 
																 | 
																 | 
																// | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																//     0.10  (2016-10-25)  remove cast-away-const to avoid warnings | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																//     0.09  (2016-08-27)  fix compiler warnings | 
															
														
														
													
														
															
																 | 
																 | 
																//     0.08  (2015-09-13)  really fix bug with empty rects (w=0 or h=0) | 
																 | 
																 | 
																//     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.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.06  (2015-04-15)  added STBRP_SORT to allow replacing qsort | 
															
														
														
													
												
													
														
															
																| 
																	
																		
																			
																		
																	
																	
																		
																			
																		
																	
																	
																 | 
																@ -148,7 +150,7 @@ enum | 
															
														
														
													
														
															
																 | 
																 | 
																{ | 
																 | 
																 | 
																{ | 
															
														
														
													
														
															
																 | 
																 | 
																   STBRP_HEURISTIC_Skyline_default=0, | 
																 | 
																 | 
																   STBRP_HEURISTIC_Skyline_default=0, | 
															
														
														
													
														
															
																 | 
																 | 
																   STBRP_HEURISTIC_Skyline_BL_sortHeight = STBRP_HEURISTIC_Skyline_default, | 
																 | 
																 | 
																   STBRP_HEURISTIC_Skyline_BL_sortHeight = STBRP_HEURISTIC_Skyline_default, | 
															
														
														
													
														
															
																 | 
																 | 
																   STBRP_HEURISTIC_Skyline_BF_sortHeight, | 
																 | 
																 | 
																 | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																   STBRP_HEURISTIC_Skyline_BF_sortHeight | 
															
														
														
													
														
															
																 | 
																 | 
																}; | 
																 | 
																 | 
																}; | 
															
														
														
													
														
															
																 | 
																 | 
																
 | 
																 | 
																 | 
																
 | 
															
														
														
													
														
															
																 | 
																 | 
																
 | 
																 | 
																 | 
																
 | 
															
														
														
													
												
													
														
															
																| 
																	
																		
																			
																		
																	
																	
																		
																			
																		
																	
																	
																 | 
																@ -198,9 +200,15 @@ struct stbrp_context | 
															
														
														
													
														
															
																 | 
																 | 
																#define STBRP_ASSERT assert | 
																 | 
																 | 
																#define STBRP_ASSERT assert | 
															
														
														
													
														
															
																 | 
																 | 
																#endif | 
																 | 
																 | 
																#endif | 
															
														
														
													
														
															
																 | 
																 | 
																
 | 
																 | 
																 | 
																
 | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																#ifdef _MSC_VER | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																#define STBRP__NOTUSED(v)  (void)(v) | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																#else | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																#define STBRP__NOTUSED(v)  (void)sizeof(v) | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																#endif | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																
 | 
															
														
														
													
														
															
																 | 
																 | 
																enum | 
																 | 
																 | 
																enum | 
															
														
														
													
														
															
																 | 
																 | 
																{ | 
																 | 
																 | 
																{ | 
															
														
														
													
														
															
																 | 
																 | 
																   STBRP__INIT_skyline = 1, | 
																 | 
																 | 
																 | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																   STBRP__INIT_skyline = 1 | 
															
														
														
													
														
															
																 | 
																 | 
																}; | 
																 | 
																 | 
																}; | 
															
														
														
													
														
															
																 | 
																 | 
																
 | 
																 | 
																 | 
																
 | 
															
														
														
													
														
															
																 | 
																 | 
																STBRP_DEF void stbrp_setup_heuristic(stbrp_context *context, int heuristic) | 
																 | 
																 | 
																STBRP_DEF void stbrp_setup_heuristic(stbrp_context *context, int heuristic) | 
															
														
														
													
												
													
														
															
																| 
																	
																		
																			
																		
																	
																	
																		
																			
																		
																	
																	
																 | 
																@ -273,6 +281,9 @@ static int stbrp__skyline_find_min_y(stbrp_context *c, stbrp_node *first, int x0 | 
															
														
														
													
														
															
																 | 
																 | 
																   stbrp_node *node = first; | 
																 | 
																 | 
																   stbrp_node *node = first; | 
															
														
														
													
														
															
																 | 
																 | 
																   int x1 = x0 + width; | 
																 | 
																 | 
																   int x1 = x0 + width; | 
															
														
														
													
														
															
																 | 
																 | 
																   int min_y, visited_width, waste_area; | 
																 | 
																 | 
																   int min_y, visited_width, waste_area; | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																
 | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																   STBRP__NOTUSED(c); | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																
 | 
															
														
														
													
														
															
																 | 
																 | 
																   STBRP_ASSERT(first->x <= x0); | 
																 | 
																 | 
																   STBRP_ASSERT(first->x <= x0); | 
															
														
														
													
														
															
																 | 
																 | 
																
 | 
																 | 
																 | 
																
 | 
															
														
														
													
														
															
																 | 
																 | 
																   #if 0 | 
																 | 
																 | 
																   #if 0 | 
															
														
														
													
												
													
														
															
																| 
																	
																		
																			
																		
																	
																	
																		
																			
																		
																	
																	
																 | 
																@ -500,8 +511,8 @@ static stbrp__findresult stbrp__skyline_pack_rectangle(stbrp_context *context, i | 
															
														
														
													
														
															
																 | 
																 | 
																
 | 
																 | 
																 | 
																
 | 
															
														
														
													
														
															
																 | 
																 | 
																static int rect_height_compare(const void *a, const void *b) | 
																 | 
																 | 
																static int rect_height_compare(const void *a, const void *b) | 
															
														
														
													
														
															
																 | 
																 | 
																{ | 
																 | 
																 | 
																{ | 
															
														
														
													
														
															
																 | 
																 | 
																   stbrp_rect *p = (stbrp_rect *) a; | 
																 | 
																 | 
																 | 
															
														
														
													
														
															
																 | 
																 | 
																   stbrp_rect *q = (stbrp_rect *) b; | 
																 | 
																 | 
																 | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																   k">const stbrp_rect *p = (const stbrp_rect *) a; | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																   k">const stbrp_rect *q = (const stbrp_rect *) b; | 
															
														
														
													
														
															
																 | 
																 | 
																   if (p->h > q->h) | 
																 | 
																 | 
																   if (p->h > q->h) | 
															
														
														
													
														
															
																 | 
																 | 
																      return -1; | 
																 | 
																 | 
																      return -1; | 
															
														
														
													
														
															
																 | 
																 | 
																   if (p->h < q->h) | 
																 | 
																 | 
																   if (p->h < q->h) | 
															
														
														
													
												
													
														
															
																| 
																	
																	
																	
																		
																			
																		
																	
																 | 
																@ -511,8 +522,8 @@ static int rect_height_compare(const void *a, const void *b) | 
															
														
														
													
														
															
																 | 
																 | 
																
 | 
																 | 
																 | 
																
 | 
															
														
														
													
														
															
																 | 
																 | 
																static int rect_width_compare(const void *a, const void *b) | 
																 | 
																 | 
																static int rect_width_compare(const void *a, const void *b) | 
															
														
														
													
														
															
																 | 
																 | 
																{ | 
																 | 
																 | 
																{ | 
															
														
														
													
														
															
																 | 
																 | 
																   stbrp_rect *p = (stbrp_rect *) a; | 
																 | 
																 | 
																 | 
															
														
														
													
														
															
																 | 
																 | 
																   stbrp_rect *q = (stbrp_rect *) b; | 
																 | 
																 | 
																 | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																   k">const stbrp_rect *p = (const stbrp_rect *) a; | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																   k">const stbrp_rect *q = (const stbrp_rect *) b; | 
															
														
														
													
														
															
																 | 
																 | 
																   if (p->w > q->w) | 
																 | 
																 | 
																   if (p->w > q->w) | 
															
														
														
													
														
															
																 | 
																 | 
																      return -1; | 
																 | 
																 | 
																      return -1; | 
															
														
														
													
														
															
																 | 
																 | 
																   if (p->w < q->w) | 
																 | 
																 | 
																   if (p->w < q->w) | 
															
														
														
													
												
													
														
															
																| 
																	
																	
																	
																		
																			
																		
																	
																 | 
																@ -522,8 +533,8 @@ static int rect_width_compare(const void *a, const void *b) | 
															
														
														
													
														
															
																 | 
																 | 
																
 | 
																 | 
																 | 
																
 | 
															
														
														
													
														
															
																 | 
																 | 
																static int rect_original_order(const void *a, const void *b) | 
																 | 
																 | 
																static int rect_original_order(const void *a, const void *b) | 
															
														
														
													
														
															
																 | 
																 | 
																{ | 
																 | 
																 | 
																{ | 
															
														
														
													
														
															
																 | 
																 | 
																   stbrp_rect *p = (stbrp_rect *) a; | 
																 | 
																 | 
																 | 
															
														
														
													
														
															
																 | 
																 | 
																   stbrp_rect *q = (stbrp_rect *) b; | 
																 | 
																 | 
																 | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																   k">const stbrp_rect *p = (const stbrp_rect *) a; | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																   k">const stbrp_rect *q = (const stbrp_rect *) b; | 
															
														
														
													
														
															
																 | 
																 | 
																   return (p->was_packed < q->was_packed) ? -1 : (p->was_packed > q->was_packed); | 
																 | 
																 | 
																   return (p->was_packed < q->was_packed) ? -1 : (p->was_packed > q->was_packed); | 
															
														
														
													
														
															
																 | 
																 | 
																} | 
																 | 
																 | 
																} | 
															
														
														
													
														
															
																 | 
																 | 
																
 | 
																 | 
																 | 
																
 | 
															
														
														
													
												
													
														
															
																| 
																	
																		
																			
																		
																	
																	
																	
																 | 
																
 |