summaryrefslogtreecommitdiff
path: root/assetFactory/assetFactory.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'assetFactory/assetFactory.cpp')
-rw-r--r--assetFactory/assetFactory.cpp18
1 files changed, 11 insertions, 7 deletions
diff --git a/assetFactory/assetFactory.cpp b/assetFactory/assetFactory.cpp
index 46b4642..e27e575 100644
--- a/assetFactory/assetFactory.cpp
+++ b/assetFactory/assetFactory.cpp
@@ -99,21 +99,25 @@ AssetFactory::createTexutre() const
{
if (!textureFragments.empty() && !texture) {
// * layout images
- std::vector<TexturePacker::Image> imageSizes;
+ std::map<std::string_view, std::unique_ptr<const Image>> images;
std::transform(
- textureFragments.begin(), textureFragments.end(), std::back_inserter(imageSizes), [](const auto & tf) {
- return TexturePacker::Image {tf.second->image->width, tf.second->image->height};
+ textureFragments.begin(), textureFragments.end(), std::inserter(images, images.end()), [](auto && tf) {
+ return decltype(images)::value_type {tf.first, tf.second->image->get()};
});
+ std::vector<TexturePacker::Image> imageSizes;
+ std::transform(images.begin(), images.end(), std::back_inserter(imageSizes), [](const auto & i) {
+ return TexturePacker::Image {i.second->width, i.second->height};
+ });
const auto [layout, outSize] = TexturePacker {imageSizes}.pack();
// * create texture
texture = std::make_shared<TextureAtlas>(outSize.x, outSize.y, layout.size());
- std::transform(textureFragments.begin(), textureFragments.end(),
+ std::transform(images.begin(), images.end(),
std::inserter(textureFragmentPositions, textureFragmentPositions.end()),
- [position = layout.begin(), size = imageSizes.begin(), this](const auto & tf) mutable {
- const auto m = texture->add(*position, *size, tf.second->image->data.data());
+ [position = layout.begin(), size = imageSizes.begin(), this](const auto & i) mutable {
+ const auto m = texture->add(*position, *size, i.second->data.data());
position++;
size++;
- return decltype(textureFragmentPositions)::value_type {tf.first, m};
+ return decltype(textureFragmentPositions)::value_type {i.first, m};
});
}
}