From 6cd00aacfa22fed6a54a9b812f6b069ad16feec0 Mon Sep 17 00:00:00 2001 From: untodesu Date: Sun, 29 Jun 2025 22:24:42 +0500 Subject: Move game sources into src subdirectory --- game/shared/coord.hh | 149 --------------------------------------------------- 1 file changed, 149 deletions(-) delete mode 100644 game/shared/coord.hh (limited to 'game/shared/coord.hh') diff --git a/game/shared/coord.hh b/game/shared/coord.hh deleted file mode 100644 index f1a2e70..0000000 --- a/game/shared/coord.hh +++ /dev/null @@ -1,149 +0,0 @@ -#ifndef SHARED_COORD_HH -#define SHARED_COORD_HH 1 -#pragma once - -#include "shared/const.hh" -#include "shared/types.hh" - -namespace coord -{ -constexpr chunk_pos to_chunk(const voxel_pos& vpos); -} // namespace coord - -namespace coord -{ -constexpr local_pos to_local(const voxel_pos& vpos); -constexpr local_pos to_local(const glm::fvec3& fvec); -constexpr local_pos to_local(std::size_t index); -} // namespace coord - -namespace coord -{ -constexpr voxel_pos to_voxel(const chunk_pos& cpos, const local_pos& lpos); -constexpr voxel_pos to_voxel(const chunk_pos& cpos, const glm::fvec3& fvec); -} // namespace coord - -namespace coord -{ -constexpr std::size_t to_index(const local_pos& lpos); -} // namespace coord - -namespace coord -{ -constexpr glm::fvec3 to_relative(const chunk_pos& pivot_cpos, const chunk_pos& cpos, const glm::fvec3& fvec); -constexpr glm::fvec3 to_relative(const chunk_pos& pivot_cpos, const glm::fvec3& pivot_fvec, const chunk_pos& cpos); -constexpr glm::fvec3 to_relative(const chunk_pos& pivot_cpos, const glm::fvec3& pivot_fvec, const chunk_pos& cpos, const glm::fvec3& fvec); -} // namespace coord - -namespace coord -{ -constexpr glm::fvec3 to_fvec3(const chunk_pos& cpos); -constexpr glm::fvec3 to_fvec3(const chunk_pos& cpos, const glm::fvec3& fpos); -} // namespace coord - -inline constexpr chunk_pos coord::to_chunk(const voxel_pos& vpos) -{ - return chunk_pos { - static_cast(vpos.x >> CHUNK_BITSHIFT), - static_cast(vpos.y >> CHUNK_BITSHIFT), - static_cast(vpos.z >> CHUNK_BITSHIFT), - }; -} - -inline constexpr local_pos coord::to_local(const voxel_pos& vpos) -{ - return local_pos { - static_cast(vx::mod_signed(vpos.x, CHUNK_SIZE)), - static_cast(vx::mod_signed(vpos.y, CHUNK_SIZE)), - static_cast(vx::mod_signed(vpos.z, CHUNK_SIZE)), - }; -} - -inline constexpr local_pos coord::to_local(const glm::fvec3& fvec) -{ - return local_pos { - static_cast(fvec.x), - static_cast(fvec.y), - static_cast(fvec.z), - }; -} - -inline constexpr local_pos coord::to_local(std::size_t index) -{ - return local_pos { - static_cast((index % CHUNK_SIZE)), - static_cast((index / CHUNK_SIZE) / CHUNK_SIZE), - static_cast((index / CHUNK_SIZE) % CHUNK_SIZE), - }; -} - -inline constexpr voxel_pos coord::to_voxel(const chunk_pos& cpos, const local_pos& lpos) -{ - return voxel_pos { - lpos.x + (static_cast(cpos.x) << CHUNK_BITSHIFT), - lpos.y + (static_cast(cpos.y) << CHUNK_BITSHIFT), - lpos.z + (static_cast(cpos.z) << CHUNK_BITSHIFT), - }; -} - -inline constexpr voxel_pos coord::to_voxel(const chunk_pos& cpos, const glm::fvec3& fvec) -{ - return voxel_pos { - static_cast(fvec.x) + (static_cast(cpos.x) << CHUNK_BITSHIFT), - static_cast(fvec.y) + (static_cast(cpos.y) << CHUNK_BITSHIFT), - static_cast(fvec.z) + (static_cast(cpos.z) << CHUNK_BITSHIFT), - }; -} - -inline constexpr std::size_t coord::to_index(const local_pos& lpos) -{ - return static_cast((lpos.y * CHUNK_SIZE + lpos.z) * CHUNK_SIZE + lpos.x); -} - -inline constexpr glm::fvec3 coord::to_relative(const chunk_pos& pivot_cpos, const chunk_pos& cpos, const glm::fvec3& fvec) -{ - return glm::fvec3 { - static_cast((cpos.x - pivot_cpos.x) << CHUNK_BITSHIFT) + fvec.x, - static_cast((cpos.y - pivot_cpos.y) << CHUNK_BITSHIFT) + fvec.y, - static_cast((cpos.z - pivot_cpos.z) << CHUNK_BITSHIFT) + fvec.z, - }; -} - -inline constexpr glm::fvec3 coord::to_relative(const chunk_pos& pivot_cpos, const glm::fvec3& pivot_fvec, const chunk_pos& cpos) -{ - return glm::fvec3 { - static_cast((cpos.x - pivot_cpos.x) << CHUNK_BITSHIFT) - pivot_fvec.x, - static_cast((cpos.y - pivot_cpos.y) << CHUNK_BITSHIFT) - pivot_fvec.y, - static_cast((cpos.z - pivot_cpos.z) << CHUNK_BITSHIFT) - pivot_fvec.z, - }; -} - -inline constexpr glm::fvec3 coord::to_relative( - const chunk_pos& pivot_cpos, const glm::fvec3& pivot_fvec, const chunk_pos& cpos, const glm::fvec3& fvec) -{ - return glm::fvec3 { - static_cast((cpos.x - pivot_cpos.x) << CHUNK_BITSHIFT) + (fvec.x - pivot_fvec.x), - static_cast((cpos.y - pivot_cpos.y) << CHUNK_BITSHIFT) + (fvec.y - pivot_fvec.y), - static_cast((cpos.z - pivot_cpos.z) << CHUNK_BITSHIFT) + (fvec.z - pivot_fvec.z), - }; -} - -inline constexpr glm::fvec3 coord::to_fvec3(const chunk_pos& cpos) -{ - return glm::fvec3 { - static_cast(cpos.x << CHUNK_BITSHIFT), - static_cast(cpos.y << CHUNK_BITSHIFT), - static_cast(cpos.z << CHUNK_BITSHIFT), - }; -} - -inline constexpr glm::fvec3 coord::to_fvec3(const chunk_pos& cpos, const glm::fvec3& fpos) -{ - return glm::fvec3 { - fpos.x + static_cast(cpos.x << CHUNK_BITSHIFT), - fpos.y + static_cast(cpos.y << CHUNK_BITSHIFT), - fpos.z + static_cast(cpos.z << CHUNK_BITSHIFT), - }; -} - -#endif /* SHARED_COORD_HH */ -- cgit