diff options
| author | untodesu <kirill@untode.su> | 2025-09-11 18:18:08 +0500 |
|---|---|---|
| committer | untodesu <kirill@untode.su> | 2025-09-11 18:18:08 +0500 |
| commit | 68694a9c9d7d27d3b79c7b96bb67f56db2f75c45 (patch) | |
| tree | fa306d55b8333ffdb184befd41386830af2c3945 /game/shared/world/chunk.cc | |
| parent | 12947aafcc6a6eb362cc454e2149796ec9265743 (diff) | |
| download | voxelius-68694a9c9d7d27d3b79c7b96bb67f56db2f75c45.tar.bz2 voxelius-68694a9c9d7d27d3b79c7b96bb67f56db2f75c45.zip | |
Metadata voxels!
Diffstat (limited to 'game/shared/world/chunk.cc')
| -rw-r--r-- | game/shared/world/chunk.cc | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/game/shared/world/chunk.cc b/game/shared/world/chunk.cc index e59b68d..b1b19a6 100644 --- a/game/shared/world/chunk.cc +++ b/game/shared/world/chunk.cc @@ -2,6 +2,8 @@ #include "shared/world/chunk.hh"
+#include "shared/world/voxel_registry.hh"
+
#include "shared/coord.hh"
world::Chunk::Chunk(entt::entity entity, Dimension* dimension)
@@ -12,30 +14,35 @@ world::Chunk::Chunk(entt::entity entity, Dimension* dimension) m_biome = BIOME_VOID;
}
-voxel_id world::Chunk::get_voxel(const local_pos& lpos) const
+const world::Voxel* world::Chunk::get_voxel(const local_pos& lpos) const
{
return get_voxel(coord::to_index(lpos));
}
-voxel_id world::Chunk::get_voxel(const std::size_t index) const
+const world::Voxel* world::Chunk::get_voxel(const std::size_t index) const
{
if(index >= CHUNK_VOLUME) {
- return NULL_VOXEL_ID;
- }
- else {
- return m_voxels[index];
+ return nullptr;
}
+
+ return voxel_registry::find(m_voxels[index]);
}
-void world::Chunk::set_voxel(voxel_id voxel, const local_pos& lpos)
+void world::Chunk::set_voxel(const Voxel* voxel, const local_pos& lpos)
{
set_voxel(voxel, coord::to_index(lpos));
}
-void world::Chunk::set_voxel(voxel_id voxel, const std::size_t index)
+void world::Chunk::set_voxel(const Voxel* voxel, const std::size_t index)
{
if(index < CHUNK_VOLUME) {
- m_voxels[index] = voxel;
+ if(voxel == nullptr) {
+ m_voxels[index] = NULL_VOXEL_ID;
+ return;
+ }
+
+ m_voxels[index] = voxel->get_id();
+ return;
}
}
|
