summaryrefslogtreecommitdiff
path: root/thirdparty/openmesh/glmcompat.h
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2024-01-01 17:56:26 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2024-01-01 17:56:26 +0000
commitd5cdbbf38380239524e351cb69aec94090884ca5 (patch)
tree5d7dff2f2775701069806eceb4eaef23b22eba3f /thirdparty/openmesh/glmcompat.h
parentReformat with new clang-format (diff)
parentRemove more use of legacy types (diff)
downloadilt-d5cdbbf38380239524e351cb69aec94090884ca5.tar.bz2
ilt-d5cdbbf38380239524e351cb69aec94090884ca5.tar.xz
ilt-d5cdbbf38380239524e351cb69aec94090884ca5.zip
Merge remote-tracking branch 'origin/terrain'
Diffstat (limited to 'thirdparty/openmesh/glmcompat.h')
-rw-r--r--thirdparty/openmesh/glmcompat.h42
1 files changed, 42 insertions, 0 deletions
diff --git a/thirdparty/openmesh/glmcompat.h b/thirdparty/openmesh/glmcompat.h
new file mode 100644
index 0000000..dc5a96e
--- /dev/null
+++ b/thirdparty/openmesh/glmcompat.h
@@ -0,0 +1,42 @@
+#pragma once
+
+#include <OpenMesh/Core/Mesh/Traits.hh>
+#include <OpenMesh/Core/Utils/vector_cast.hh>
+#include <glm/geometric.hpp>
+#include <glm/vec3.hpp>
+
+namespace glm {
+ template<length_t L, typename T, qualifier Q>
+ auto
+ norm(const vec<L, T, Q> & v)
+ {
+ return length(v);
+ }
+
+ template<length_t L, typename T, qualifier Q, typename S>
+ auto
+ vectorize(vec<L, T, Q> & v, S scalar)
+ {
+ v = vec<L, T, Q> {static_cast<T>(scalar)};
+ }
+}
+
+namespace OpenMesh {
+ template<typename dst_t, typename src_t, glm::length_t n, glm::qualifier Q>
+ struct vector_caster<glm::vec<n, dst_t, Q>, glm::vec<n, src_t, Q>> {
+ using source_type = glm::vec<n, src_t, Q>;
+ using return_type = glm::vec<n, dst_t, Q>;
+
+ inline static return_type
+ cast(const source_type & _src)
+ {
+ return return_type {_src};
+ }
+ };
+
+ template<glm::length_t L, typename T, glm::qualifier Q> struct vector_traits<glm::vec<L, T, Q>> {
+ using vector_type = glm::vec<L, T, Q>;
+ using value_type = T;
+ static constexpr glm::length_t size_ = L;
+ };
+}