neoGFX
Cross-platform C++ app/game engine
swizzle_array.hpp
Go to the documentation of this file.
1 // swizzle_array.hpp
2 /*
3  neogfx C++ GUI Library
4  Copyright (c) 2019 Leigh Johnston. All Rights Reserved.
5 
6  This program is free software: you can redistribute it and / or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19 
20 #pragma once
21 
22 #include <neogfx/neogfx.hpp>
23 #include <neogfx/core/swizzle.hpp>
24 
25 namespace neogfx
26 {
27  namespace math
28  {
29  template <typename V, typename T, uint32_t Size>
31  {
32  typedef T value_type;
33  typedef std::array<value_type, Size> array_type;
34  typedef V vector_type;
35 
36  union
37  {
38  array_type v;
39  struct // todo: alignment, padding?
40  {
41  value_type x;
42  value_type y;
43  value_type z;
44  };
78  };
79  };
80 
81  template <typename V, typename T>
82  struct swizzle_array<V, T, 1>
83  {
84  typedef T value_type;
85  typedef std::array<value_type, 1> array_type;
86  typedef V vector_type;
87 
88  union
89  {
90  array_type v;
91  struct // todo: alignment, padding?
92  {
93  value_type x;
94  };
97  };
98  };
99 
100  template <typename V, typename T>
101  struct swizzle_array<V, T, 2>
102  {
103  typedef T value_type;
104  typedef std::array<value_type, 2> array_type;
105  typedef V vector_type;
106 
107  union
108  {
109  array_type v;
110  struct // todo: alignment, padding?
111  {
112  value_type x;
113  value_type y;
114  };
127  };
128  };
129 
130  template <typename V, typename T>
131  struct swizzle_array<V, T, 3>
132  {
133  typedef T value_type;
134  typedef std::array<value_type, 3> array_type;
135  typedef V vector_type;
136 
137  union
138  {
139  array_type v;
140  struct // todo: alignment, padding?
141  {
142  value_type x;
143  value_type y;
144  value_type z;
145  };
179  };
180  };
181  }
182 }
swizzle< vector_type, array_type, 3, 0, 0, 0 > xxx
swizzle< vector_type, array_type, 3, 1, 1, 2 > yyz
swizzle< vector_type, array_type, 3, 2, 2, 1 > zzy
swizzle< vector_type, array_type, 3, 0, 0, 2 > xxz
swizzle< vector_type, array_type, 3, 2, 1, 0 > zyx
swizzle< vector_type, array_type, 3, 1, 2, 1 > yzy
swizzle< vector_type, array_type, 3, 2, 0, 2 > zxz
swizzle< vector_type, array_type, 3, 2, 1, 1 > zyy
swizzle< vector_type, array_type, 2, 1, 0 > yx
swizzle< vector_type, array_type, 2, 2, 2 > zz
swizzle< vector_type, array_type, 3, 0, 0, 0 > xxx
swizzle< vector_type, array_type, 2, 1, 2 > yz
swizzle< vector_type, array_type, 3, 2, 1, 2 > zyz
swizzle< vector_type, array_type, 2, 0, 2 > xz
swizzle< vector_type, array_type, 3, 1, 0, 1 > yxy
swizzle< vector_type, array_type, 3, 2, 2, 2 > zzz
swizzle< vector_type, array_type, 3, 0, 0, 2 > xxz
swizzle< vector_type, array_type, 2, 1, 1 > yy
swizzle< vector_type, array_type, 3, 0, 0, 1 > xxy
swizzle< vector_type, array_type, 3, 2, 1, 0 > zyx
swizzle< vector_type, array_type, 3, 1, 0, 2 > yxz
swizzle< vector_type, array_type, 3, 1, 1, 0 > yyx
swizzle< vector_type, array_type, 3, 0, 0, 1 > xxy
swizzle< vector_type, array_type, 3, 2, 2, 2 > zzz
swizzle< vector_type, array_type, 2, 0, 0 > xx
swizzle< vector_type, array_type, 2, 0, 1 > xy
swizzle< vector_type, array_type, 3, 1, 1, 2 > yyz
swizzle< vector_type, array_type, 3, 2, 2, 0 > zzx
swizzle< vector_type, array_type, 3, 0, 1, 2 > xyz
swizzle< vector_type, array_type, 3, 1, 0, 1 > yxy
swizzle< vector_type, array_type, 3, 0, 1, 0 > xyx
swizzle< vector_type, array_type, 3, 1, 2, 2 > yzz
std::array< value_type, 3 > array_type
swizzle< vector_type, array_type, 3, 1, 0, 1 > yxy
swizzle< vector_type, array_type, 3, 0, 0, 1 > xxy
swizzle< vector_type, array_type, 3, 0, 0, 0 > xxx
swizzle< vector_type, array_type, 3, 0, 0, 0 > xxx
swizzle< vector_type, array_type, 2, 2, 0 > zx
swizzle< vector_type, array_type, 2, 0, 0 > xx
swizzle< vector_type, array_type, 3, 0, 1, 2 > xyz
swizzle< vector_type, array_type, 2, 1, 2 > yz
swizzle< vector_type, array_type, 3, 1, 0, 0 > yxx
swizzle< vector_type, array_type, 3, 2, 2, 0 > zzx
swizzle< vector_type, array_type, 3, 1, 0, 0 > yxx
swizzle< vector_type, array_type, 2, 2, 0 > zx
swizzle< vector_type, array_type, 2, 1, 1 > yy
swizzle< vector_type, array_type, 2, 1, 1 > yy
swizzle< vector_type, array_type, 3, 1, 2, 2 > yzz
swizzle< vector_type, array_type, 2, 0, 0 > xx
swizzle< vector_type, array_type, 3, 0, 1, 1 > xyy
swizzle< vector_type, array_type, 3, 2, 0, 0 > zxx
swizzle< vector_type, array_type, 2, 2, 2 > zz
swizzle< vector_type, array_type, 3, 1, 0, 0 > yxx
swizzle< vector_type, array_type, 3, 2, 0, 2 > zxz
swizzle< vector_type, array_type, 3, 1, 1, 1 > yyy
swizzle< vector_type, array_type, 3, 2, 0, 1 > zxy
swizzle< vector_type, array_type, 3, 0, 1, 0 > xyx
swizzle< vector_type, array_type, 3, 1, 1, 1 > yyy
swizzle< vector_type, array_type, 3, 0, 1, 0 > xyx
swizzle< vector_type, array_type, 2, 0, 1 > xy
swizzle< vector_type, array_type, 3, 0, 1, 1 > xyy
swizzle< vector_type, array_type, 3, 2, 0, 0 > zxx
swizzle< vector_type, array_type, 3, 2, 1, 1 > zyy
swizzle< vector_type, array_type, 3, 2, 2, 1 > zzy
swizzle< vector_type, array_type, 3, 1, 1, 1 > yyy
std::array< value_type, 2 > array_type
swizzle< vector_type, array_type, 2, 2, 1 > zy
swizzle< vector_type, array_type, 3, 1, 0, 2 > yxz
swizzle< vector_type, array_type, 2, 1, 0 > yx
std::array< value_type, Size > array_type
swizzle< vector_type, array_type, 2, 0, 0 > xx
swizzle< vector_type, array_type, 2, 0, 1 > xy
swizzle< vector_type, array_type, 3, 0, 1, 1 > xyy
std::array< value_type, 1 > array_type
swizzle< vector_type, array_type, 2, 0, 2 > xz
swizzle< vector_type, array_type, 3, 1, 2, 1 > yzy
swizzle< vector_type, array_type, 3, 1, 2, 0 > yzx
swizzle< vector_type, array_type, 3, 1, 1, 0 > yyx
swizzle< vector_type, array_type, 2, 2, 1 > zy
swizzle< vector_type, array_type, 3, 1, 1, 0 > yyx
swizzle< vector_type, array_type, 3, 1, 2, 0 > yzx
swizzle< vector_type, array_type, 3, 2, 1, 2 > zyz
swizzle< vector_type, array_type, 3, 2, 0, 1 > zxy
swizzle< vector_type, array_type, 2, 1, 0 > yx