summaryrefslogtreecommitdiff
path: root/gfx
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2021-02-21 16:43:56 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2021-02-21 16:48:04 +0000
commit605db8cd3778bd2f58a956a0776c1001d7286def (patch)
treef7cad28fb8480cf6b7f11353907c4fed9856f04c /gfx
parentfix.arc (diff)
downloadilt-605db8cd3778bd2f58a956a0776c1001d7286def.tar.bz2
ilt-605db8cd3778bd2f58a956a0776c1001d7286def.tar.xz
ilt-605db8cd3778bd2f58a956a0776c1001d7286def.zip
Named model parts, fix bogie spelling, new brush47 model
Diffstat (limited to 'gfx')
-rw-r--r--gfx/models/obj.h9
-rw-r--r--gfx/models/obj.impl.cpp14
2 files changed, 12 insertions, 11 deletions
diff --git a/gfx/models/obj.h b/gfx/models/obj.h
index 71733fe..a2d874f 100644
--- a/gfx/models/obj.h
+++ b/gfx/models/obj.h
@@ -8,6 +8,7 @@
#include <filesystem>
#include <fstream>
#include <glm/glm.hpp>
+#include <map>
#include <memory>
#include <vector>
@@ -39,10 +40,10 @@ public:
std::vector<Object> objects;
glm::length_t axis {0};
- using NamedMeshData = std::pair<std::string, std::pair<std::vector<Vertex>, std::vector<unsigned int>>>;
- [[nodiscard]] std::vector<NamedMeshData> createMeshData() const;
- using NamedMesh = std::pair<std::string, std::shared_ptr<const Mesh>>;
- [[nodiscard]] std::vector<NamedMesh> createMeshes() const;
+ using NamedMeshesData = std::map<std::string, std::pair<std::vector<Vertex>, std::vector<unsigned int>>>;
+ [[nodiscard]] NamedMeshesData createMeshData() const;
+ using NamedMeshes = std::map<std::string, std::shared_ptr<const Mesh>>;
+ [[nodiscard]] NamedMeshes createMeshes() const;
};
#endif
diff --git a/gfx/models/obj.impl.cpp b/gfx/models/obj.impl.cpp
index 5ac15ac..330e851 100644
--- a/gfx/models/obj.impl.cpp
+++ b/gfx/models/obj.impl.cpp
@@ -4,27 +4,27 @@
#include <gfx/models/vertex.hpp>
#include <glm/glm.hpp>
#include <iterator>
+#include <map>
#include <memory>
#include <utility>
#include <vector>
-std::vector<ObjParser::NamedMesh>
+ObjParser::NamedMeshes
ObjParser::createMeshes() const
{
- std::vector<ObjParser::NamedMesh> out;
+ NamedMeshes out;
const auto data {createMeshData()};
- std::transform(data.begin(), data.end(), std::back_inserter(out), [](auto && obj) {
+ std::transform(data.begin(), data.end(), std::inserter(out, out.end()), [](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::NamedMeshesData
ObjParser::createMeshData() const
{
- std::vector<ObjParser::NamedMeshData> out;
- out.reserve(objects.size());
- std::transform(objects.begin(), objects.end(), std::back_inserter(out), [this](auto && obj) {
+ NamedMeshesData out;
+ std::transform(objects.begin(), objects.end(), std::inserter(out, out.end()), [this](auto && obj) {
std::vector<Vertex> overtices;
std::vector<ObjParser::FaceElement> vertexOrder;
std::vector<unsigned int> indices;