summaryrefslogtreecommitdiff
path: root/assetFactory/assimp.cpp
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2023-04-14 14:48:59 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2023-04-14 14:48:59 +0100
commit1cdd7753d37bcf8f626298c3df97a02cc73f266c (patch)
treef8e83df70e00c9f7f3588638c756ac66a8ab0199 /assetFactory/assimp.cpp
parentCurrent thread partakes in work effort while waiting (diff)
downloadilt-1cdd7753d37bcf8f626298c3df97a02cc73f266c.tar.bz2
ilt-1cdd7753d37bcf8f626298c3df97a02cc73f266c.tar.xz
ilt-1cdd7753d37bcf8f626298c3df97a02cc73f266c.zip
Load texture images in Worker
Diffstat (limited to 'assetFactory/assimp.cpp')
-rw-r--r--assetFactory/assimp.cpp20
1 files changed, 8 insertions, 12 deletions
diff --git a/assetFactory/assimp.cpp b/assetFactory/assimp.cpp
index 878e7e7..bab052e 100644
--- a/assetFactory/assimp.cpp
+++ b/assetFactory/assimp.cpp
@@ -102,18 +102,14 @@ AssImp::postLoad()
return AssetFactory::Shapes::value_type {m->mName.C_Str(), std::make_shared<AssImpNode>(scene, m)};
});
const auto textures = AIRANGE(scene, Textures);
- auto textureFutures = textures * [](const aiTexture * t) {
- return std::async(std::launch::async, [t]() {
- auto texture = std::make_shared<TextureFragment>();
- texture->id = texture->path = t->mFilename.C_Str();
- texture->image = std::make_unique<Image>(
- std::span {reinterpret_cast<unsigned char *>(t->pcData), t->mWidth}, STBI_rgb_alpha);
- return texture;
- });
- };
- std::transform(textureFutures.begin(), textureFutures.end(),
- std::inserter(mf->textureFragments, mf->textureFragments.end()), [](auto && textureFuture) {
- auto texture = textureFuture.get();
+ std::transform(textures.begin(), textures.end(),
+ std::inserter(mf->textureFragments, mf->textureFragments.end()), [](auto && t) {
+ auto texture = std::make_shared<TextureFragment>();
+ texture->id = texture->path = t->mFilename.C_Str();
+ texture->image = Worker::addWork([t]() {
+ return std::make_unique<Image>(
+ std::span {reinterpret_cast<unsigned char *>(t->pcData), t->mWidth}, STBI_rgb_alpha);
+ });
return AssetFactory::TextureFragments::value_type {texture->id, texture};
});
}