summaryrefslogtreecommitdiff
path: root/assetFactory/style.h
diff options
context:
space:
mode:
Diffstat (limited to 'assetFactory/style.h')
-rw-r--r--assetFactory/style.h34
1 files changed, 34 insertions, 0 deletions
diff --git a/assetFactory/style.h b/assetFactory/style.h
new file mode 100644
index 0000000..e8fd012
--- /dev/null
+++ b/assetFactory/style.h
@@ -0,0 +1,34 @@
+#pragma once
+
+#include "modelFactoryMesh.h"
+#include "persistence.h"
+#include "shape.h"
+#include <optional>
+#include <string>
+#include <utility>
+
+class Style {
+public:
+ using StyleStack = std::vector<const Style *>;
+ using Colour = glm::vec3;
+ using ColourAlpha = glm::vec4;
+
+ void applyStyle(ModelFactoryMesh &, const StyleStack & parents, const Shape::CreatedFaces &) const;
+ void applyStyle(ModelFactoryMesh &, const StyleStack & parents, const ModelFactoryMesh::FaceHandle &) const;
+
+ template<typename T>
+ static std::optional<std::reference_wrapper<const T>>
+ getProperty(const StyleStack & parents, T Style::*member, auto && test)
+ {
+ if (const auto itr = std::find_if(parents.rbegin(), parents.rend(), std::forward<decltype(test)>(test));
+ itr != parents.rend()) {
+ return (*itr)->*member;
+ }
+ return {};
+ }
+
+ ColourAlpha colour {};
+
+protected:
+ bool persist(Persistence::PersistenceStore & store);
+};