#include "style.h" #include "assetFactory.h" 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()) { for (const auto & face : faces) { mesh.set_color(face.second, effectiveColour->get()); } } } 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()) { mesh.set_color(face, effectiveColour->get()); } } bool Style::persist(Persistence::PersistenceStore & store) { struct ColourParser : public Persistence::SelectionV { using Persistence::SelectionV::SelectionV; using Persistence::SelectionV::setValue; void setValue(std::string && str) override { if (auto mf = std::dynamic_pointer_cast(Persistence::sharedObjects.at("assetFactory"))) { v = mf->parseColour(str); } } }; return STORE_HELPER(colour, ColourParser); }