diff options
| author | untodesu <kirill@untode.su> | 2025-09-12 13:33:52 +0500 |
|---|---|---|
| committer | untodesu <kirill@untode.su> | 2025-09-12 13:33:52 +0500 |
| commit | e9076f22fe2a49d1cd8933e54b7b00c5dd943269 (patch) | |
| tree | 89b8a4ca1861196e067dcba218fad1d7f889b860 /game/shared/world/feature.cc | |
| parent | 68694a9c9d7d27d3b79c7b96bb67f56db2f75c45 (diff) | |
| download | voxelius-e9076f22fe2a49d1cd8933e54b7b00c5dd943269.tar.bz2 voxelius-e9076f22fe2a49d1cd8933e54b7b00c5dd943269.zip | |
It compiles
Diffstat (limited to 'game/shared/world/feature.cc')
| -rw-r--r-- | game/shared/world/feature.cc | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/game/shared/world/feature.cc b/game/shared/world/feature.cc index cbf660e..e704ced 100644 --- a/game/shared/world/feature.cc +++ b/game/shared/world/feature.cc @@ -4,6 +4,7 @@ #include "shared/world/chunk.hh"
#include "shared/world/dimension.hh"
+#include "shared/world/voxel.hh"
#include "shared/coord.hh"
@@ -50,3 +51,30 @@ void world::Feature::place(const voxel_pos& vpos, const chunk_pos& cpos, Chunk& }
}
}
+
+void world::Feature::place(const voxel_pos& vpos, const chunk_pos& cpos, VoxelStorage& voxels) 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(voxels[it_index] && !overwrite) {
+ // There is something in the way
+ // and the called intentionally requested
+ // we do not force feature to overwrite voxels
+ continue;
+ }
+
+ if(voxel == nullptr) {
+ voxels[it_index] = NULL_VOXEL_ID;
+ }
+ else {
+ voxels[it_index] = voxel->get_id();
+ }
+ }
+ }
+}
|
