diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2021-02-20 15:12:25 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2021-02-20 15:12:25 +0000 |
commit | e85db91c6b6a326e3339020bc434063db6c957f9 (patch) | |
tree | afbed715e697fd265d14c58b8fbd2b077334e697 /gfx/models/obj.impl.cpp | |
parent | Fix constness of Mesh constructor params (diff) | |
download | ilt-e85db91c6b6a326e3339020bc434063db6c957f9.tar.bz2 ilt-e85db91c6b6a326e3339020bc434063db6c957f9.tar.xz ilt-e85db91c6b6a326e3339020bc434063db6c957f9.zip |
Fix test-obj by splitting mesh processing
Don't invoke GL parts from test code
Diffstat (limited to 'gfx/models/obj.impl.cpp')
-rw-r--r-- | gfx/models/obj.impl.cpp | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/gfx/models/obj.impl.cpp b/gfx/models/obj.impl.cpp index 0c1303a..5ac15ac 100644 --- a/gfx/models/obj.impl.cpp +++ b/gfx/models/obj.impl.cpp @@ -1,6 +1,6 @@ #include "obj.h" #include <algorithm> -#include <gfx/models/mesh.h> +#include <gfx/models/mesh.h> // IWYU pragma: keep #include <gfx/models/vertex.hpp> #include <glm/glm.hpp> #include <iterator> @@ -12,8 +12,19 @@ std::vector<ObjParser::NamedMesh> ObjParser::createMeshes() const { std::vector<ObjParser::NamedMesh> out; + const auto data {createMeshData()}; + std::transform(data.begin(), data.end(), std::back_inserter(out), [](auto && obj) { + return std::make_pair(obj.first, std::make_shared<Mesh>(obj.second.first, obj.second.second)); + }); + return out; +} + +std::vector<ObjParser::NamedMeshData> +ObjParser::createMeshData() const +{ + std::vector<ObjParser::NamedMeshData> out; out.reserve(objects.size()); - for (const auto & obj : objects) { + std::transform(objects.begin(), objects.end(), std::back_inserter(out), [this](auto && obj) { std::vector<Vertex> overtices; std::vector<ObjParser::FaceElement> vertexOrder; std::vector<unsigned int> indices; @@ -36,7 +47,7 @@ ObjParser::createMeshes() const f(idx - 1); } } - out.emplace_back(obj.first, std::make_shared<Mesh>(overtices, indices)); - } + return std::make_pair(obj.first, std::make_pair(overtices, indices)); + }); return out; } |