diff options
| author | untodesu <kirill@untode.su> | 2025-09-12 16:16:06 +0500 |
|---|---|---|
| committer | untodesu <kirill@untode.su> | 2025-09-12 16:16:06 +0500 |
| commit | fc80fa024fc93dac6ea89461ef36f455c5e468a2 (patch) | |
| tree | 7c4ea8f03b6778572d59784dc28b600e3f8f2268 /game/shared/world/feature.cc | |
| parent | 12947aafcc6a6eb362cc454e2149796ec9265743 (diff) | |
| parent | 522a7514012da86f7b9643179f0763746f3b232e (diff) | |
| download | voxelius-fc80fa024fc93dac6ea89461ef36f455c5e468a2.tar.bz2 voxelius-fc80fa024fc93dac6ea89461ef36f455c5e468a2.zip | |
Merge pull request #15 from untodesu/metavoxels
Metavoxels
Diffstat (limited to 'game/shared/world/feature.cc')
| -rw-r--r-- | game/shared/world/feature.cc | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/game/shared/world/feature.cc b/game/shared/world/feature.cc index 4212043..8fe95f1 100644 --- a/game/shared/world/feature.cc +++ b/game/shared/world/feature.cc @@ -4,7 +4,7 @@ #include "shared/world/chunk.hh"
#include "shared/world/dimension.hh"
-#include "shared/world/voxel_storage.hh"
+#include "shared/world/voxel.hh"
#include "shared/coord.hh"
@@ -30,6 +30,28 @@ void world::Feature::place(const voxel_pos& vpos, Dimension* dimension) const }
}
+void world::Feature::place(const voxel_pos& vpos, const chunk_pos& cpos, Chunk& chunk) const
+{
+ for(const auto [rpos, voxel, overwrite] : (*this)) {
+ auto it_vpos = vpos + rpos;
+ auto it_cpos = coord::to_chunk(it_vpos);
+
+ if(it_cpos == cpos) {
+ auto it_lpos = coord::to_local(it_vpos);
+ auto it_index = coord::to_index(it_lpos);
+
+ if(chunk.get_voxel(it_index) && !overwrite) {
+ // There is something in the way
+ // and the called intentionally requested
+ // we do not force feature to overwrite voxels
+ continue;
+ }
+
+ chunk.set_voxel(voxel, it_index);
+ }
+ }
+}
+
void world::Feature::place(const voxel_pos& vpos, const chunk_pos& cpos, VoxelStorage& voxels) const
{
for(const auto [rpos, voxel, overwrite] : (*this)) {
@@ -47,7 +69,7 @@ void world::Feature::place(const voxel_pos& vpos, const chunk_pos& cpos, VoxelSt continue;
}
- voxels[it_index] = voxel;
+ voxels[it_index] = voxel ? voxel->get_id() : NULL_VOXEL_ID;
}
}
}
|
