Oxygen Engine
Modern C++ 3D Engine using OpenGL
Loading...
Searching...
No Matches
concept.h
1#ifndef OE_UTIL_CONCEPT_H
2#define OE_UTIL_CONCEPT_H
3
4#include <concepts>
5#include <glm/vec3.hpp>
6#include <glm/gtx/quaternion.hpp>
7
8namespace oe::scene
9{
10 template<class V>
11 concept Vector3Type = requires(V v)
12 {
13 {v.x} -> std::convertible_to<float>;
14 {v.y} -> std::convertible_to<float>;
15 {v.z} -> std::convertible_to<float>;
16 };
17
18 template<class V>
19 concept Vector4Type = requires(V v)
20 {
21 {v.x} -> std::convertible_to<float>;
22 {v.y} -> std::convertible_to<float>;
23 {v.z} -> std::convertible_to<float>;
24 {v.w} -> std::convertible_to<float>;
25 };
26
27 template<class T>
28 struct IsPosition : std::false_type {};
29
30 template<class S>
31 struct IsScale : std::false_type {};
32
33 template<class R>
34 struct IsRotation : std::false_type {};
35
36 // Abstract compile time concepts to allow generic types to be used in Transform
37 template<class T>
38 concept TranslationType = IsPosition<T>::value == true && Vector3Type<T>;
39
40 template<class R>
41 concept RotationType = IsRotation<R>::value == true && Vector4Type<R>;
42
43 template<class S>
44 concept ScaleType = IsScale<S>::value == true && Vector3Type<S>;
45
46 // Default specializations to allow glm types
47 template<>struct IsPosition<glm::vec3> : std::true_type {};
48 template<>struct IsRotation<glm::quat> : std::true_type {};
49 template<>struct IsScale<glm::vec3> : std::true_type {};
50}
51
52
53#endif
Definition concept.h:41
Definition concept.h:44
Definition concept.h:38
Definition concept.h:11
Definition concept.h:19
Scene related management (Render-agnostic Geometry, Manger, etc...)
Definition debug.h:19
Definition concept.h:28
Definition concept.h:34
Definition concept.h:31