IceShard 1
A personal game engine project, with development focused on 2D/2.5D games.
Loading...
Searching...
No Matches
swizzle.hxx
Go to the documentation of this file.
1
3
4#pragma once
5#include <ice/math/vector.hxx>
6
7namespace ice::math
8{
9
10 namespace detail_math
11 {
12
13 template<u8... Components>
14 struct swizzle{ };
15
16 } // namespace detail
17
18 template<u32 Size, typename T, u8... Components>
19 constexpr auto operator|(mat<Size, 1, T> vec, detail_math::swizzle<Components...>) noexcept -> mat<sizeof...(Components), 1, T>
20 {
21 return { (Components >= Size ? T{} : vec.v[0][Components])... };
22 };
23
25 {
26
27 static constexpr auto xxxx = detail_math::swizzle<0,0,0,0>{};
28 static constexpr auto xxx = detail_math::swizzle<0,0,0>{};
29 static constexpr auto xx = detail_math::swizzle<0,0>{};
30 static constexpr auto x = detail_math::swizzle<0>{};
31
32 static constexpr auto yyyy = detail_math::swizzle<1,1,1,1>{};
33 static constexpr auto yyy = detail_math::swizzle<1,1,1>{};
34 static constexpr auto yy = detail_math::swizzle<1,1>{};
35 static constexpr auto y = detail_math::swizzle<1>{};
36
37 static constexpr auto zzzz = detail_math::swizzle<2,2,2,2>{};
38 static constexpr auto zzz = detail_math::swizzle<2,2,2>{};
39 static constexpr auto zz = detail_math::swizzle<2,2>{};
40 static constexpr auto z = detail_math::swizzle<2>{};
41
42 static constexpr auto wwww = detail_math::swizzle<3,3,3,3>{};
43 static constexpr auto www = detail_math::swizzle<3,3,3>{};
44 static constexpr auto ww = detail_math::swizzle<3,3>{};
45 static constexpr auto w = detail_math::swizzle<3>{};
46
47 static constexpr auto xyzw = detail_math::swizzle<0,1,2,3>{};
48 static constexpr auto xyz = detail_math::swizzle<0,1,2>{};
49 static constexpr auto xy = detail_math::swizzle<0,1>{};
50 static constexpr auto xz = detail_math::swizzle<0,2>{};
51
52 static constexpr auto wzyx = detail_math::swizzle<3,2,1,0>{};
53 static constexpr auto zyx = detail_math::swizzle<2,1,0>{};
54 static constexpr auto yx = detail_math::swizzle<1,0>{};
55 static constexpr auto zx = detail_math::swizzle<2,0>{};
56
57 };
58
59 static constexpr swizzle_definitions sw;
60
61} // namespace ice::math
Definition swizzle.hxx:11
Definition algorithm.hxx:8
mat< Size, 1, T > vec
Definition vector.hxx:172
static constexpr swizzle_definitions sw
Definition swizzle.hxx:59
constexpr auto operator|(mat< Size, 1, T > vec, detail_math::swizzle< Components... >) noexcept -> mat< sizeof...(Components), 1, T >
Definition swizzle.hxx:19
std::uint32_t u32
Definition types.hxx:26
std::uint8_t u8
Definition types.hxx:24
Definition swizzle.hxx:14
Definition matrix.hxx:12
Definition swizzle.hxx:25
static constexpr auto xx
Definition swizzle.hxx:29
static constexpr auto y
Definition swizzle.hxx:35
static constexpr auto xyzw
Definition swizzle.hxx:47
static constexpr auto wwww
Definition swizzle.hxx:42
static constexpr auto yy
Definition swizzle.hxx:34
static constexpr auto x
Definition swizzle.hxx:30
static constexpr auto yx
Definition swizzle.hxx:54
static constexpr auto zzzz
Definition swizzle.hxx:37
static constexpr auto yyy
Definition swizzle.hxx:33
static constexpr auto zyx
Definition swizzle.hxx:53
static constexpr auto www
Definition swizzle.hxx:43
static constexpr auto zx
Definition swizzle.hxx:55
static constexpr auto xxxx
Definition swizzle.hxx:27
static constexpr auto w
Definition swizzle.hxx:45
static constexpr auto zz
Definition swizzle.hxx:39
static constexpr auto ww
Definition swizzle.hxx:44
static constexpr auto xyz
Definition swizzle.hxx:48
static constexpr auto xy
Definition swizzle.hxx:49
static constexpr auto yyyy
Definition swizzle.hxx:32
static constexpr auto xz
Definition swizzle.hxx:50
static constexpr auto wzyx
Definition swizzle.hxx:52
static constexpr auto xxx
Definition swizzle.hxx:28
static constexpr auto zzz
Definition swizzle.hxx:38
static constexpr auto z
Definition swizzle.hxx:40