mirror of
				https://github.com/ciphervance/supercell-wx.git
				synced 2025-10-31 14:10:05 +00:00 
			
		
		
		
	If no images are able to be packed into a texture atlas layer, don't create more
This commit is contained in:
		
							parent
							
								
									94a5898755
								
							
						
					
					
						commit
						e013b9a77f
					
				
					 1 changed files with 13 additions and 4 deletions
				
			
		|  | @ -211,8 +211,7 @@ void TextureAtlas::BuildAtlas(std::size_t width, std::size_t height) | ||||||
|       } |       } | ||||||
| 
 | 
 | ||||||
|       // Clear atlas
 |       // Clear atlas
 | ||||||
|       auto& atlas = |       boost::gil::rgba8_image_t atlas(width, height); | ||||||
|          newAtlasArray.emplace_back(boost::gil::rgba8_image_t(width, height)); |  | ||||||
|       boost::gil::rgba8_view_t  atlasView = boost::gil::view(atlas); |       boost::gil::rgba8_view_t  atlasView = boost::gil::view(atlas); | ||||||
|       boost::gil::fill_pixels(atlasView, |       boost::gil::fill_pixels(atlasView, | ||||||
|                               boost::gil::rgba8_pixel_t {255, 0, 255, 255}); |                               boost::gil::rgba8_pixel_t {255, 0, 255, 255}); | ||||||
|  | @ -220,6 +219,8 @@ void TextureAtlas::BuildAtlas(std::size_t width, std::size_t height) | ||||||
|       // Populate atlas
 |       // Populate atlas
 | ||||||
|       logger_->trace("Populating atlas"); |       logger_->trace("Populating atlas"); | ||||||
| 
 | 
 | ||||||
|  |       std::size_t numPackedImages = 0u; | ||||||
|  | 
 | ||||||
|       for (std::size_t i = 0; i < images.size(); ++i) |       for (std::size_t i = 0; i < images.size(); ++i) | ||||||
|       { |       { | ||||||
|          // If the image was packed successfully
 |          // If the image was packed successfully
 | ||||||
|  | @ -273,6 +274,8 @@ void TextureAtlas::BuildAtlas(std::size_t width, std::size_t height) | ||||||
|                   sRight, |                   sRight, | ||||||
|                   tTop, |                   tTop, | ||||||
|                   tBottom)); |                   tBottom)); | ||||||
|  | 
 | ||||||
|  |             numPackedImages++; | ||||||
|          } |          } | ||||||
|          else |          else | ||||||
|          { |          { | ||||||
|  | @ -281,12 +284,18 @@ void TextureAtlas::BuildAtlas(std::size_t width, std::size_t height) | ||||||
|          } |          } | ||||||
|       } |       } | ||||||
| 
 | 
 | ||||||
|  |       if (numPackedImages > 0u) | ||||||
|  |       { | ||||||
|  |          // The new atlas layer has images that were able to be packed
 | ||||||
|  |          newAtlasArray.emplace_back(std::move(atlas)); | ||||||
|  |       } | ||||||
|  | 
 | ||||||
|       if (unpackedImages.empty()) |       if (unpackedImages.empty()) | ||||||
|       { |       { | ||||||
|          // All images have been packed into the texture atlas
 |          // All images have been packed into the texture atlas
 | ||||||
|          break; |          break; | ||||||
|       } |       } | ||||||
|       else if (layer == kMaxLayers - 1u) |       else if (layer == kMaxLayers - 1u || numPackedImages == 0u) | ||||||
|       { |       { | ||||||
|          // Some images were unable to be packed into the texture atlas
 |          // Some images were unable to be packed into the texture atlas
 | ||||||
|          for (auto& image : unpackedImages) |          for (auto& image : unpackedImages) | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Dan Paulat
						Dan Paulat