diff options
-rw-r--r-- | assetFactory/style.cpp | 20 | ||||
-rw-r--r-- | assetFactory/style.h | 2 |
2 files changed, 12 insertions, 10 deletions
diff --git a/assetFactory/style.cpp b/assetFactory/style.cpp index 5303d96..fa585ac 100644 --- a/assetFactory/style.cpp +++ b/assetFactory/style.cpp @@ -4,11 +4,7 @@ void Style::applyStyle(ModelFactoryMesh & mesh, const StyleStack & parents, const Shape::CreatedFaces & faces) const { - if (const auto effectiveColour = getProperty(parents, &Style::colour, - [](auto && style) { - return style->colour.a > 0; - }); - effectiveColour.has_value()) { + if (const auto effectiveColour = getColour(parents); effectiveColour.has_value()) { for (const auto & face : faces) { mesh.set_color(face.second, effectiveColour->get()); } @@ -18,15 +14,19 @@ Style::applyStyle(ModelFactoryMesh & mesh, const StyleStack & parents, const Sha void Style::applyStyle(ModelFactoryMesh & mesh, const StyleStack & parents, const ModelFactoryMesh::FaceHandle & face) const { - if (const auto effectiveColour = getProperty(parents, &Style::colour, - [](auto && style) { - return style->colour.a > 0; - }); - effectiveColour.has_value()) { + if (const auto effectiveColour = getColour(parents); effectiveColour.has_value()) { mesh.set_color(face, effectiveColour->get()); } } +std::optional<std::reference_wrapper<const Style::ColourAlpha>> +Style::getColour(const StyleStack & parents) +{ + return getProperty(parents, &Style::colour, [](auto && style) { + return style->colour.a > 0; + }); +} + bool Style::persist(Persistence::PersistenceStore & store) { diff --git a/assetFactory/style.h b/assetFactory/style.h index 84e5dab..8c64276 100644 --- a/assetFactory/style.h +++ b/assetFactory/style.h @@ -27,6 +27,8 @@ public: return {}; } + static std::optional<std::reference_wrapper<const ColourAlpha>> getColour(const StyleStack & parents); + ColourAlpha colour {}; std::string texture; std::string textureRotation; // Multiples of 90deg, no int/enum support |