summaryrefslogtreecommitdiff
path: root/assetFactory/style.cpp
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2023-03-12 01:36:50 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2023-03-12 19:43:14 +0000
commit7bf24d23a7db872f7bd13060da9817a9ee5f816c (patch)
tree8bb9f0c9da747aa5bcb4d0b76230e3f0a1f4a166 /assetFactory/style.cpp
parentDedupe looking up the style stack for colour (diff)
downloadilt-7bf24d23a7db872f7bd13060da9817a9ee5f816c.tar.bz2
ilt-7bf24d23a7db872f7bd13060da9817a9ee5f816c.tar.xz
ilt-7bf24d23a7db872f7bd13060da9817a9ee5f816c.zip
Dedupe applying style to a face
Diffstat (limited to 'assetFactory/style.cpp')
-rw-r--r--assetFactory/style.cpp17
1 files changed, 11 insertions, 6 deletions
diff --git a/assetFactory/style.cpp b/assetFactory/style.cpp
index fa585ac..b5ddcf1 100644
--- a/assetFactory/style.cpp
+++ b/assetFactory/style.cpp
@@ -4,22 +4,27 @@
void
Style::applyStyle(ModelFactoryMesh & mesh, const StyleStack & parents, const Shape::CreatedFaces & faces) const
{
- if (const auto effectiveColour = getColour(parents); effectiveColour.has_value()) {
- for (const auto & face : faces) {
- mesh.set_color(face.second, effectiveColour->get());
- }
+ for (const auto & face : faces) {
+ applyStyle(mesh, face.second, getColour(parents));
}
}
void
Style::applyStyle(ModelFactoryMesh & mesh, const StyleStack & parents, const ModelFactoryMesh::FaceHandle & face) const
{
- if (const auto effectiveColour = getColour(parents); effectiveColour.has_value()) {
+ applyStyle(mesh, face, getColour(parents));
+}
+
+void
+Style::applyStyle(
+ ModelFactoryMesh & mesh, const ModelFactoryMesh::FaceHandle & face, EffectiveColour effectiveColour) const
+{
+ if (effectiveColour.has_value()) {
mesh.set_color(face, effectiveColour->get());
}
}
-std::optional<std::reference_wrapper<const Style::ColourAlpha>>
+Style::EffectiveColour
Style::getColour(const StyleStack & parents)
{
return getProperty(parents, &Style::colour, [](auto && style) {