diff options
| author | untodesu <kirill@untode.su> | 2025-03-15 16:22:09 +0500 |
|---|---|---|
| committer | untodesu <kirill@untode.su> | 2025-03-15 16:22:09 +0500 |
| commit | 3bf42c6ff3805a0d42bbc661794a95ff31bedc26 (patch) | |
| tree | 05049955847504808d6bed2bb7b155f8b03807bb /game/shared/types.hh | |
| parent | 02294547dcde0d4ad76e229106702261e9f10a51 (diff) | |
| download | voxelius-3bf42c6ff3805a0d42bbc661794a95ff31bedc26.tar.bz2 voxelius-3bf42c6ff3805a0d42bbc661794a95ff31bedc26.zip | |
Add whatever I was working on for the last month
Diffstat (limited to 'game/shared/types.hh')
| -rw-r--r-- | game/shared/types.hh | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/game/shared/types.hh b/game/shared/types.hh new file mode 100644 index 0000000..dace85e --- /dev/null +++ b/game/shared/types.hh @@ -0,0 +1,44 @@ +#ifndef SHARED_TYPES_HH +#define SHARED_TYPES_HH 1 +#pragma once + +using item_id = std::uint32_t; +constexpr static item_id NULL_ITEM_ID = UINT32_C(0x00000000); +constexpr static item_id MAX_ITEM_ID = UINT32_C(0xFFFFFFFF); + +using voxel_id = std::uint16_t; +constexpr static voxel_id NULL_VOXEL_ID = UINT16_C(0x0000); +constexpr static voxel_id MAX_VOXEL_ID = UINT16_C(0xFFFF); + +using chunk_pos = glm::vec<3, std::int32_t>; +using local_pos = glm::vec<3, std::int16_t>; +using voxel_pos = glm::vec<3, std::int64_t>; + +// A special 2D chunk coordinate used by world generation code +// to cache things like 2D noise and terrain heightmap for performance reasons +using worldgen_chunk_pos = glm::vec<2, chunk_pos::value_type>; + +template<> +struct std::hash<chunk_pos> final { + constexpr inline std::size_t operator()(const chunk_pos &cpos) const + { + std::size_t value = 0; + value ^= cpos.x * 73856093; + value ^= cpos.y * 19349663; + value ^= cpos.z * 83492791; + return value; + } +}; + +template<> +struct std::hash<worldgen_chunk_pos> final { + constexpr inline std::size_t operator()(const worldgen_chunk_pos &cwpos) const + { + std::size_t value = 0; + value ^= cwpos.x * 73856093; + value ^= cwpos.y * 19349663; + return value; + } +}; + +#endif /* SHARED_TYPES_HH */ |
