blob: 37fb19adfec076e5abe5c79ee44e98d6741e7850 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
#include "shared/math/coords.hh"
namespace shared {
namespace math {
bool coords::is_inside_draw(const coords& a, const coords& b,
const std::int32_t draw_distance) noexcept {
const auto x2 = (a.x - b.x) * (a.x - b.x);
const auto z2 = (a.z - b.z) * (a.z - b.z);
const auto dd2 = draw_distance * draw_distance;
return (x2 < dd2 - z2) && (z2 < dd2 - x2);
}
coords coords::operator+(const coords& c) const noexcept {
auto ret = *this;
ret.x += c.x;
ret.z += c.z;
return ret;
}
coords coords::operator-(const coords& c) const noexcept {
auto ret = *this;
ret.x -= c.x;
ret.z -= c.z;
return ret;
}
} // namespace math
} // namespace shared
|