11 template <
size_t dimensions>
16 using type = unsigned;
17 static constexpr
auto numbered_dimensions = type{0};
21 using type = glm::uvec2;
22 static constexpr
auto numbered_dimensions = type{0, 1};
26 using type = glm::uvec3;
27 static constexpr
auto numbered_dimensions = type{0, 1, 2};
39 inline index_t<n> relative_position(
size_t i) {
40 const auto mask = index_t<n>(1) << numbered_dimensions_t<n>;
41 return (mask & static_cast<unsigned>(i)) / mask;
47 inline auto front(index_t<n> i) {
52 inline auto back(index_t<n> i) {
59 index_t<n - 1> reduce(index_t<n> i);
62 inline index_t<1> reduce<2>(index_t<2> i) {
66 inline index_t<2> reduce<3>(index_t<3> i) {
73 index_t<n - 1> tail(index_t<n> i);
76 inline index_t<1> tail<2>(index_t<2> i) {
81 inline index_t<2> tail<3>(index_t<3> i) {
82 return index_t<2>{i[1], i[2]};
88 inline unsigned product(index_t<n> i) {
89 return front<n>(i) * product<n - 1>(tail<n>(i));
93 inline unsigned product<1>(index_t<1> i) {
101 inline unsigned flatten(index_t<n> i, index_t<n> size) {
102 auto to_find_prod = size;
103 to_find_prod[0] = i[0];
104 return product<n>(to_find_prod) + flatten<n - 1>(tail<n>(i), tail<n>(size));
108 inline unsigned flatten<1>(index_t<1> i, index_t<1>) {
types for indexing into n-dimensional data
Definition: indexing.h:12
Definition: capsule_base.h:9