diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2023-04-14 14:49:52 +0100 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2023-04-14 14:49:52 +0100 |
commit | 70bddc3f8ef3eeb020b4d6114f3abf4ab160003f (patch) | |
tree | f8e83df70e00c9f7f3588638c756ac66a8ab0199 /assetFactory/assimp.cpp | |
parent | Externalise a neater definition of TGAHead (diff) | |
parent | Load texture images in Worker (diff) | |
download | ilt-70bddc3f8ef3eeb020b4d6114f3abf4ab160003f.tar.bz2 ilt-70bddc3f8ef3eeb020b4d6114f3abf4ab160003f.tar.xz ilt-70bddc3f8ef3eeb020b4d6114f3abf4ab160003f.zip |
Merge branch 'worker' into assimp
Diffstat (limited to 'assetFactory/assimp.cpp')
-rw-r--r-- | assetFactory/assimp.cpp | 20 |
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}; }); } |