From d9a0bcf532a44e94f11f23b910d117ec41c92ec8 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Fri, 10 Mar 2023 01:41:19 +0000 Subject: Swap messy glmvec wrapper for OpenMesh Point/Normal with real glm::vec and a custom vector_traits implementation Simplify code previously messy as a result of the original hack. --- assetFactory/modelFactoryMesh.h | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) (limited to 'assetFactory/modelFactoryMesh.h') diff --git a/assetFactory/modelFactoryMesh.h b/assetFactory/modelFactoryMesh.h index ea5f011..149ff1a 100644 --- a/assetFactory/modelFactoryMesh.h +++ b/assetFactory/modelFactoryMesh.h @@ -7,16 +7,27 @@ #include #include +namespace glm { + template + auto + norm(const vec & v) + { + return length(v); + } + + template + auto + vectorize(vec & v, S scalar) + { + v = vec {static_cast(scalar)}; + } +} + 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; - } + template struct vector_traits> { + using vector_type = glm::vec; + using value_type = T; + static constexpr glm::length_t size_ = L; }; } @@ -24,8 +35,8 @@ struct ModelFactoryTraits : public OpenMesh::DefaultTraits { FaceAttributes(OpenMesh::Attributes::Normal | OpenMesh::Attributes::Status | OpenMesh::Attributes::Color); EdgeAttributes(OpenMesh::Attributes::Status); VertexAttributes(OpenMesh::Attributes::Normal | OpenMesh::Attributes::Status); - using Point = OpenMesh::glmvec; - using Normal = OpenMesh::glmvec; + using Point = glm::vec3; + using Normal = glm::vec3; using Color = glm::vec4; }; -- cgit v1.2.3