From c22c676dfee583bd48e1f962378f580f8310838b Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Thu, 16 Feb 2023 23:54:22 +0000 Subject: Refactor so ModelFactoryMesh can define the smooth property on faces --- assetFactory/assetFactoryConfig.h | 28 ---------------------------- assetFactory/assetFactoryConfig_fwd.h | 8 -------- assetFactory/cuboid.cpp | 2 +- assetFactory/cylinder.cpp | 2 +- assetFactory/faceController.cpp | 2 +- assetFactory/faceController.h | 2 +- assetFactory/factoryMesh.cpp | 2 +- assetFactory/modelFactory.cpp | 2 +- assetFactory/modelFactoryMesh.cpp | 6 ++++++ assetFactory/modelFactoryMesh.h | 34 ++++++++++++++++++++++++++++++++++ assetFactory/modelFactoryMesh_fwd.h | 3 +++ assetFactory/plane.cpp | 2 +- assetFactory/shape.cpp | 2 +- assetFactory/shape.h | 2 +- assetFactory/use.h | 2 +- 15 files changed, 53 insertions(+), 46 deletions(-) delete mode 100644 assetFactory/assetFactoryConfig.h delete mode 100644 assetFactory/assetFactoryConfig_fwd.h create mode 100644 assetFactory/modelFactoryMesh.cpp create mode 100644 assetFactory/modelFactoryMesh.h create mode 100644 assetFactory/modelFactoryMesh_fwd.h diff --git a/assetFactory/assetFactoryConfig.h b/assetFactory/assetFactoryConfig.h deleted file mode 100644 index 171b81a..0000000 --- a/assetFactory/assetFactoryConfig.h +++ /dev/null @@ -1,28 +0,0 @@ -#pragma once - -#include "assetFactoryConfig_fwd.h" -#include -#include -#include -#include - -namespace OpenMesh { - template struct glmvec : public VectorT { - using VectorT::VectorT; - glmvec(const VectorT & v) : VectorT {v} { } - operator glm::vec() const - { - glm::vec out; - std::copy(this->begin(), this->end(), &out[0]); - return out; - } - }; -} - -struct ModelFactoryTraits : public OpenMesh::DefaultTraits { - FaceAttributes(OpenMesh::Attributes::Normal | OpenMesh::Attributes::Status); - EdgeAttributes(OpenMesh::Attributes::Status); - VertexAttributes(OpenMesh::Attributes::Normal | OpenMesh::Attributes::Status); - using Point = OpenMesh::glmvec; - using Normal = OpenMesh::glmvec; -}; diff --git a/assetFactory/assetFactoryConfig_fwd.h b/assetFactory/assetFactoryConfig_fwd.h deleted file mode 100644 index 28489ff..0000000 --- a/assetFactory/assetFactoryConfig_fwd.h +++ /dev/null @@ -1,8 +0,0 @@ -#pragma once - -namespace OpenMesh { - template class PolyMesh_ArrayKernelT; -} -struct ModelFactoryTraits; - -using ModelFactoryMesh = OpenMesh::PolyMesh_ArrayKernelT; diff --git a/assetFactory/cuboid.cpp b/assetFactory/cuboid.cpp index 90b2108..86114e5 100644 --- a/assetFactory/cuboid.cpp +++ b/assetFactory/cuboid.cpp @@ -1,5 +1,5 @@ #include "cuboid.h" -#include "assetFactoryConfig.h" +#include "modelFactoryMesh.h" Cuboid::CreatedFaces Cuboid::createMesh(ModelFactoryMesh & mesh, const Mutation::Matrix & mutation) const diff --git a/assetFactory/cylinder.cpp b/assetFactory/cylinder.cpp index 66d456d..83cf035 100644 --- a/assetFactory/cylinder.cpp +++ b/assetFactory/cylinder.cpp @@ -1,6 +1,6 @@ #include "cylinder.h" -#include "assetFactoryConfig.h" #include "maths.h" +#include "modelFactoryMesh.h" Cylinder::CreatedFaces Cylinder::createMesh(ModelFactoryMesh & mesh, const Mutation::Matrix & mutation) const diff --git a/assetFactory/faceController.cpp b/assetFactory/faceController.cpp index bdef74b..c04a656 100644 --- a/assetFactory/faceController.cpp +++ b/assetFactory/faceController.cpp @@ -1,6 +1,6 @@ #include "faceController.h" -#include "assetFactoryConfig.h" #include "maths.h" +#include "modelFactoryMesh.h" void FaceController::apply(ModelFactoryMesh & mesh, const std::string & name, Shape::CreatedFaces & faces) const diff --git a/assetFactory/faceController.h b/assetFactory/faceController.h index 64c33f3..9974caf 100644 --- a/assetFactory/faceController.h +++ b/assetFactory/faceController.h @@ -1,6 +1,6 @@ #pragma once -#include "assetFactoryConfig_fwd.h" +#include "modelFactoryMesh_fwd.h" #include "mutation.h" #include "shape.h" #include diff --git a/assetFactory/factoryMesh.cpp b/assetFactory/factoryMesh.cpp index 1b89d14..9d30ac9 100644 --- a/assetFactory/factoryMesh.cpp +++ b/assetFactory/factoryMesh.cpp @@ -1,7 +1,7 @@ #include "factoryMesh.h" -#include "assetFactoryConfig.h" #include "collections.hpp" #include "gfx/models/vertex.hpp" +#include "modelFactoryMesh.h" #include Mesh::Ptr diff --git a/assetFactory/modelFactory.cpp b/assetFactory/modelFactory.cpp index 3a89157..4c25e48 100644 --- a/assetFactory/modelFactory.cpp +++ b/assetFactory/modelFactory.cpp @@ -1,7 +1,7 @@ #include "modelFactory.h" -#include "assetFactoryConfig.h" #include "cuboid.h" #include "cylinder.h" +#include "modelFactoryMesh_fwd.h" #include "plane.h" ModelFactory::ModelFactory() : diff --git a/assetFactory/modelFactoryMesh.cpp b/assetFactory/modelFactoryMesh.cpp new file mode 100644 index 0000000..6c772ad --- /dev/null +++ b/assetFactory/modelFactoryMesh.cpp @@ -0,0 +1,6 @@ +#include "modelFactoryMesh.h" + +ModelFactoryMesh::ModelFactoryMesh() +{ + add_property(smoothFaceProperty); +} diff --git a/assetFactory/modelFactoryMesh.h b/assetFactory/modelFactoryMesh.h new file mode 100644 index 0000000..d0ffc26 --- /dev/null +++ b/assetFactory/modelFactoryMesh.h @@ -0,0 +1,34 @@ +#pragma once + +#include "modelFactoryMesh_fwd.h" +#include +#include +#include +#include + +namespace OpenMesh { + template struct glmvec : public VectorT { + using VectorT::VectorT; + glmvec(const VectorT & v) : VectorT {v} { } + operator glm::vec() const + { + glm::vec out; + std::copy(this->begin(), this->end(), &out[0]); + return out; + } + }; +} + +struct ModelFactoryTraits : public OpenMesh::DefaultTraits { + FaceAttributes(OpenMesh::Attributes::Normal | OpenMesh::Attributes::Status); + EdgeAttributes(OpenMesh::Attributes::Status); + VertexAttributes(OpenMesh::Attributes::Normal | OpenMesh::Attributes::Status); + using Point = OpenMesh::glmvec; + using Normal = OpenMesh::glmvec; +}; + +struct ModelFactoryMesh : public OpenMesh::PolyMesh_ArrayKernelT { + ModelFactoryMesh(); + + OpenMesh::FPropHandleT smoothFaceProperty; +}; diff --git a/assetFactory/modelFactoryMesh_fwd.h b/assetFactory/modelFactoryMesh_fwd.h new file mode 100644 index 0000000..ac10f2d --- /dev/null +++ b/assetFactory/modelFactoryMesh_fwd.h @@ -0,0 +1,3 @@ +#pragma once + +struct ModelFactoryMesh; diff --git a/assetFactory/plane.cpp b/assetFactory/plane.cpp index 1e522ad..37c8194 100644 --- a/assetFactory/plane.cpp +++ b/assetFactory/plane.cpp @@ -1,5 +1,5 @@ #include "plane.h" -#include "assetFactoryConfig.h" +#include "modelFactoryMesh.h" Plane::CreatedFaces Plane::createMesh(ModelFactoryMesh & mesh, const Mutation::Matrix & mutation) const diff --git a/assetFactory/shape.cpp b/assetFactory/shape.cpp index 0994898..f6e55e8 100644 --- a/assetFactory/shape.cpp +++ b/assetFactory/shape.cpp @@ -1,7 +1,7 @@ #include "shape.h" -#include "assetFactoryConfig.h" #include "gfx/models/vertex.hpp" #include "maths.h" +#include "modelFactoryMesh.h" #include "shape.h" std::vector diff --git a/assetFactory/shape.h b/assetFactory/shape.h index 9510538..5a2b59c 100644 --- a/assetFactory/shape.h +++ b/assetFactory/shape.h @@ -1,6 +1,6 @@ #pragma once -#include "assetFactoryConfig_fwd.h" +#include "modelFactoryMesh_fwd.h" #include "mutation.h" #include "stdTypeDefs.hpp" #include diff --git a/assetFactory/use.h b/assetFactory/use.h index 4bfce97..28f5459 100644 --- a/assetFactory/use.h +++ b/assetFactory/use.h @@ -1,7 +1,7 @@ #pragma once -#include "assetFactoryConfig_fwd.h" #include "faceController.h" +#include "modelFactoryMesh_fwd.h" #include "shape.h" #include "stdTypeDefs.hpp" -- cgit v1.2.3