diff options
| author | untodesu <kirill@untode.su> | 2025-07-01 03:08:39 +0500 |
|---|---|---|
| committer | untodesu <kirill@untode.su> | 2025-07-01 03:08:39 +0500 |
| commit | 458e0005690ea9d579588a0a12368fc2c2c9a93a (patch) | |
| tree | 588a9ca6cb3c76d9193b5bd4601d64f0e50e8c8c /src/core/angles.hh | |
| parent | c7b0c8e0286a1b2bb7ec55e579137dfc3b22eeb9 (diff) | |
| download | voxelius-458e0005690ea9d579588a0a12368fc2c2c9a93a.tar.bz2 voxelius-458e0005690ea9d579588a0a12368fc2c2c9a93a.zip | |
I hyper-focued on refactoring again
- I put a cool-sounding "we are number one" remix on repeat and straight
up grinded the entire repository to a better state until 03:09 AM. I
guess I have something wrong in my brain that makes me do this shit
Diffstat (limited to 'src/core/angles.hh')
| -rw-r--r-- | src/core/angles.hh | 107 |
1 files changed, 0 insertions, 107 deletions
diff --git a/src/core/angles.hh b/src/core/angles.hh deleted file mode 100644 index 95e42dc..0000000 --- a/src/core/angles.hh +++ /dev/null @@ -1,107 +0,0 @@ -#ifndef CORE_ANGLES_HH -#define CORE_ANGLES_HH 1 -#pragma once - -#include "core/constexpr.hh" - -constexpr float A180 = vx::radians(180.0f); -constexpr float A360 = vx::radians(360.0f); - -namespace cxangles -{ -float wrap_180(float angle); -float wrap_360(float angle); -} // namespace cxangles - -namespace cxangles -{ -glm::fvec3 wrap_180(const glm::fvec3& angles); -glm::fvec3 wrap_360(const glm::fvec3& angles); -} // namespace cxangles - -namespace cxangles -{ -void vectors(const glm::fvec3& angles, glm::fvec3& forward); -void vectors(const glm::fvec3& angles, glm::fvec3* forward, glm::fvec3* right, glm::fvec3* up); -} // namespace cxangles - -inline float cxangles::wrap_180(float angle) -{ - const auto result = std::fmod(angle + A180, A360); - - if(result < 0.0f) { - return result + A180; - } - - return result - A180; -} - -inline float cxangles::wrap_360(float angle) -{ - return std::fmod(std::fmod(angle, A360) + A360, A360); -} - -inline glm::fvec3 cxangles::wrap_180(const glm::fvec3& angles) -{ - return glm::fvec3 { - cxangles::wrap_180(angles.x), - cxangles::wrap_180(angles.y), - cxangles::wrap_180(angles.z), - }; -} - -inline glm::fvec3 cxangles::wrap_360(const glm::fvec3& angles) -{ - return glm::fvec3 { - cxangles::wrap_360(angles.x), - cxangles::wrap_360(angles.y), - cxangles::wrap_360(angles.z), - }; -} - -inline void cxangles::vectors(const glm::fvec3& angles, glm::fvec3& forward) -{ - const float cosp = std::cos(angles.x); - const float cosy = std::cos(angles.y); - const float sinp = std::sin(angles.x); - const float siny = std::sin(angles.y); - - forward.x = cosp * siny * (-1.0f); - forward.y = sinp; - forward.z = cosp * cosy * (-1.0f); -} - -inline void cxangles::vectors(const glm::fvec3& angles, glm::fvec3* forward, glm::fvec3* right, glm::fvec3* up) -{ - if(!forward && !right && !up) { - // There's no point in figuring out - // direction vectors if nothing is passed - // in the function to store that stuff in - return; - } - - const auto pcv = glm::cos(angles); - const auto psv = glm::sin(angles); - const auto ncv = pcv * (-1.0f); - const auto nsv = psv * (-1.0f); - - if(forward) { - forward->x = pcv.x * nsv.y; - forward->y = psv.x; - forward->z = pcv.x * ncv.y; - } - - if(right) { - right->x = pcv.z * pcv.y; - right->y = psv.z * pcv.y; - right->z = nsv.y; - } - - if(up) { - up->x = psv.x * psv.y * pcv.z + ncv.y * psv.z; - up->y = pcv.x * pcv.z; - up->z = nsv.x * ncv.y * pcv.z + psv.y * psv.z; - } -} - -#endif // CORE_ANGLES_HH |
