From 2508112e2853e1a6c012b19c7232aa09f98d3969 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Mon, 20 Mar 2023 23:30:21 +0000 Subject: Move smooth property into Style and make it optional This allows it to cascade down as faces are created and also be overridden as required --- assetFactory/faceController.cpp | 8 ++------ assetFactory/faceController.h | 1 - assetFactory/style.cpp | 6 +++++- assetFactory/style.h | 1 + 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/assetFactory/faceController.cpp b/assetFactory/faceController.cpp index bafbee2..2367f8d 100644 --- a/assetFactory/faceController.cpp +++ b/assetFactory/faceController.cpp @@ -48,12 +48,10 @@ FaceController::applySingle(ModelFactoryMesh & mesh, const StyleStack & parents, faces.merge(std::move(newFaces)); } else { - mesh.property(mesh.smoothFaceProperty, faceHandle) = smooth; applyStyle(mesh, parents + this, faceHandle); } } for (const auto & [faceName, faceHandle] : controlledFaces) { - mesh.property(mesh.smoothFaceProperty, faceHandle) = smooth; applyStyle(mesh, parents + this, faceHandle); } } @@ -89,9 +87,8 @@ FaceController::extrude(ModelFactoryMesh & mesh, const std::string & faceName, O auto & newFaceName = mesh.property(mesh.nameFaceProperty, newFace); newFaceName = getAdjacentFaceName(mesh, ofrange, newFace); newFaces.emplace(newFaceName, newFace); - mesh.property(mesh.smoothFaceProperty, newFace) = smooth; } - mesh.property(mesh.smoothFaceProperty, newFaces.emplace(faceName, mesh.add_face(vertices))->second) = smooth; + newFaces.emplace(faceName, mesh.add_face(vertices)); return newFaces; } @@ -99,7 +96,6 @@ FaceController::extrude(ModelFactoryMesh & mesh, const std::string & faceName, O bool FaceController::persist(Persistence::PersistenceStore & store) { - return STORE_TYPE && STORE_MEMBER(id) && Style::persist(store) && STORE_MEMBER(type) && STORE_MEMBER(smooth) - && Mutation::persist(store) + return STORE_TYPE && STORE_MEMBER(id) && Style::persist(store) && STORE_MEMBER(type) && Mutation::persist(store) && STORE_NAME_HELPER("face", faceControllers, Persistence::MapByMember); } diff --git a/assetFactory/faceController.h b/assetFactory/faceController.h index 962a516..851292a 100644 --- a/assetFactory/faceController.h +++ b/assetFactory/faceController.h @@ -17,7 +17,6 @@ public: std::string id; std::string type; - bool smooth {false}; FaceControllers faceControllers; private: diff --git a/assetFactory/style.cpp b/assetFactory/style.cpp index d1d4adc..12346a6 100644 --- a/assetFactory/style.cpp +++ b/assetFactory/style.cpp @@ -19,6 +19,9 @@ void Style::applyStyle( ModelFactoryMesh & mesh, const ModelFactoryMesh::FaceHandle & face, EffectiveColour effectiveColour) const { + if (smooth.has_value()) { + mesh.property(mesh.smoothFaceProperty, face) = smooth.value(); + } if (texture.empty()) { if (effectiveColour.has_value()) { mesh.set_color(face, effectiveColour->get()); @@ -60,5 +63,6 @@ Style::persist(Persistence::PersistenceStore & store) } }; - return STORE_HELPER(colour, ColourParser) && STORE_MEMBER(texture) && STORE_MEMBER(textureRotation); + return STORE_HELPER(colour, ColourParser) && STORE_MEMBER(smooth) && STORE_MEMBER(texture) + && STORE_MEMBER(textureRotation); } diff --git a/assetFactory/style.h b/assetFactory/style.h index f3bc707..d931f98 100644 --- a/assetFactory/style.h +++ b/assetFactory/style.h @@ -31,6 +31,7 @@ public: static EffectiveColour getColour(const StyleStack & parents); ColourAlpha colour {}; + std::optional smooth; std::string texture; std::string textureRotation; // Multiples of 90deg, no int/enum support -- cgit v1.2.3