@@ -45,13 +45,19 @@ using Wall::Frame;
45
45
template <typename T> using Vec2_ = VectorTypeFor<2 , T>;
46
46
template <typename T> using Vec3_ = VectorTypeFor<3 , T>;
47
47
48
+ template <typename F, uint32_t N>
49
+ struct minmax_v
50
+ {
51
+ VectorTypeFor<N, F> min, max;
52
+ };
53
+
48
54
template <Group_ G, bool IsWest, typename F = float >
49
- constexpr std::array<Vec3_<F>, 4 > get_quad (F depth )
55
+ constexpr std::array<Vec3_<F>, 4 > get_quadʹ(minmax_v<F, 3 > bounds, F d )
50
56
{
51
57
static_assert (G < Group_::COUNT);
52
58
53
- constexpr auto half_tile = Vec2_<F>(TILE_SIZE2*. 5f );
54
- constexpr auto X = half_tile. x (), Y = half_tile. y (), Z = F (TILE_SIZE. z () );
59
+ const auto x0 = bounds. min . x (), y0 = bounds. min . y (), z0 = bounds. min . z (),
60
+ x1 = bounds. max . x (), y1 = bounds. max . y (), z1 = bounds. max . z ( );
55
61
56
62
switch (G)
57
63
{
@@ -60,67 +66,76 @@ constexpr std::array<Vec3_<F>, 4> get_quad(F depth)
60
66
case wall:
61
67
if (!IsWest)
62
68
return {{
63
- { X, -Y, 0 },
64
- { X, -Y, Z },
65
- {-X, -Y, 0 },
66
- {-X, -Y, Z },
69
+ { x1, y0 , z0 },
70
+ { x1, y0 , z1 },
71
+ { x0, y0 , z0 },
72
+ { x0, y0 , z1 },
67
73
}};
68
74
else
69
75
return {{
70
- {-X, -Y, 0 },
71
- {-X, -Y, Z },
72
- {-X, Y, 0 },
73
- {-X, Y, Z },
76
+ { x0, y0 , z0 },
77
+ { x0, y0 , z1 },
78
+ { x0, y1 , z0 },
79
+ { x0, y1 , z1 },
74
80
}};
75
81
case side:
76
82
if (!IsWest)
77
83
return {{
78
- { X, -Y - depth, 0 },
79
- { X, -Y - depth, Z },
80
- { X, -Y, 0 },
81
- { X, -Y, Z },
84
+ { x1, y0 - d, z0 },
85
+ { x1, y0 - d, z1 },
86
+ { x1, y0 , z0 },
87
+ { x1, y0 , z1 },
82
88
}};
83
89
else
84
90
return {{
85
- { -X, Y, 0 },
86
- { -X, Y, Z },
87
- { -X - depth, Y, 0 },
88
- { -X - depth, Y, Z },
91
+ { x0, y1 , z0 },
92
+ { x0, y1 , z1 },
93
+ { x0 - d, y1 , z0 },
94
+ { x0 - d, y1 , z1 },
89
95
}};
90
96
case top:
91
97
if (!IsWest)
92
98
return {{
93
- { -X, -Y - depth, Z },
94
- { X, -Y - depth, Z },
95
- { -X, -Y, Z },
96
- { X, -Y, Z },
99
+ { x0, y0 - d, z1 },
100
+ { x1, y0 - d, z1 },
101
+ { x0, y0 , z1 },
102
+ { x1, y0 , z1 },
97
103
}};
98
104
else
99
105
return {{
100
- { -X, -Y, Z },
101
- { -X , Y, Z },
102
- { -X - depth, -Y, Z },
103
- { -X - depth, Y, Z },
106
+ { x0, y0 , z1 },
107
+ { x0 , y1 , z1 },
108
+ { x0 - d, y0 , z1 },
109
+ { x0 - d, y1 , z1 },
104
110
}};
105
111
case corner:
106
112
if (!IsWest)
107
113
return {{
108
- {-X, -Y, 0 },
109
- {-X, -Y, Z },
110
- {-X - depth, -Y, 0 },
111
- {-X - depth, -Y, Z },
114
+ { x0, y0 , z0 },
115
+ { x0, y0 , z1 },
116
+ { x0 - d, y0 , z0 },
117
+ { x0 - d, y0 , z1 },
112
118
}};
113
119
else
114
120
return {{
115
- {-X, -Y - depth, 0 },
116
- {-X, -Y - depth, Z },
117
- {-X, -Y, 0 },
118
- {-X, -Y, Z },
121
+ { x0, y0 - d, z0 },
122
+ { x0, y0 - d, z1 },
123
+ { x0, y0 , z0 },
124
+ { x0, y0 , z1 },
119
125
}};
120
126
}
121
127
std::unreachable ();
122
128
}
123
129
130
+ template <Group_ G, bool IsWest, typename F = float >
131
+ constexpr std::array<Vec3_<F>, 4 > get_quad (F d)
132
+ {
133
+ constexpr auto half_tile = Vec2_<F>(TILE_SIZE2*.5f );
134
+ constexpr auto X = half_tile.x (), Y = half_tile.y (), Z = F (TILE_SIZE.z ());
135
+
136
+ return get_quadʹ<G, IsWest, F>({ { -X, -Y, 0 , }, { X, Y, Z, }, }, d);
137
+ }
138
+
124
139
template <bool IsWest>
125
140
CutResult<Int>::rect get_wall_rect (local_coords tile)
126
141
{
0 commit comments