diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2022-10-30 11:40:36 +0100 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2022-10-30 11:40:36 +0100 |
commit | a2dd266dc6f46a267a52f7ad983aa7dd32bc3116 (patch) | |
tree | 92ef94b550104017cb91fae6347374a400044a72 /main/draw.cpp | |
parent | aeae172afefaa7a924610208a757a4c09f15b04f (diff) |
simplify check_chunk_visible()
The new version was broken though.
Diffstat (limited to 'main/draw.cpp')
-rw-r--r-- | main/draw.cpp | 18 |
1 files changed, 3 insertions, 15 deletions
diff --git a/main/draw.cpp b/main/draw.cpp index b6ed0607..2909d952 100644 --- a/main/draw.cpp +++ b/main/draw.cpp @@ -83,24 +83,12 @@ bool main_impl::check_chunk_visible(const Vector2d& offset, const Vector2i& size p10 = tile_shader::project(Vector3d(len[x], 0, 0)), p01 = tile_shader::project(Vector3d(0, len[y], 0)), p11 = tile_shader::project(Vector3d(len[x], len[y], 0)); -#if 1 - constexpr double xs[] = { p00[x], p10[x], p01[x], p11[x], }, ys[] = { p00[y], p10[y], p01[y], p11[y], }; - constexpr double minx = *std::min_element(std::cbegin(xs), std::cend(xs)), - maxx = *std::max_element(std::cbegin(xs), std::cend(xs)), - miny = *std::min_element(std::cbegin(ys), std::cend(ys)), - maxy = *std::max_element(std::cbegin(ys), std::cend(ys)); + constexpr auto xx = std::minmax({ p00[x], p10[x], p01[x], p11[x], }), + yy = std::minmax({ p00[y], p10[y], p01[y], p11[y], }); + constexpr auto minx = xx.first, maxx = xx.second, miny = yy.first, maxy = yy.second; constexpr int W = (int)(maxx - minx + .5 + 1e-16), H = (int)(maxy - miny + .5 + 1e-16); const auto X = (int)(minx + (offset[x] + size[x])*.5), Y = (int)(miny + (offset[y] + size[y])*.5); return X + W > 0 && X < size[x] && Y + H > 0 && Y < size[y]; -#else - constexpr auto xminmax = std::minmax({ p00[x], p10[x], p01[x], p11[x] }), std::minmax({ p00[y], p10[y], p01[y], p11[y] }); - constexpr Vector2d min = {xminmax.first, yminmax.first}, max = {xminmax.second, yminmax.second}; - constexpr Vector2i WH{max - min + Vector2d{.5 + 1e-16}}; - constexpr Vector2i imin{min}; - const Vector2i xy = imin + (Vector2i(offset) + size)/2; - const auto tmp = (xy + WH); - return (tmp > Vector2i{0}).all() && (xy < WH).all(); -#endif } void main_impl::drawEvent() |