blob: 80eba817fe608a4639a6fcb54d225e7151d23f80 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
#include "shared/math.hh"
namespace shared {
namespace math {
glm::vec3 angle_to_dir(const angles& ang) noexcept {
const float x = std::cos(ang.pitch) * std::cos(ang.yaw);
const float y = std::sin(ang.pitch);
const float z = std::cos(ang.pitch) * std::sin(ang.yaw);
return {x, y, z};
}
bool 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);
}
} // namespace math
} // namespace shared
|