Skip to content

Commit

Permalink
Fix "empty buffer" warnings and potential empty chunks
Browse files Browse the repository at this point in the history
  • Loading branch information
Zylann committed Aug 30, 2024
1 parent a371e13 commit 8ca295d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions doc/source/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Primarily developped with Godot 4.3.
- `VoxelTerrain`: edits and copies across fixed bounds no longer behave as if terrain generates beyond (was causing "walls" to appear).
- `VoxelGeneratorGraph`: fix wrong values when using `OutputWeight` with optimized execution map enabled, when weights are determined to be locally constant
- `VoxelMesherTransvoxel`: revert texturing logic that attempted to prevent air voxels from contributing, but was lowering quality. It is now optional as an experimental property.
- `VoxelStreamSQLite`: Fixed "empty size" errors when loading areas with edited `VoxelInstancer` data

- Breaking changes
- `VoxelInstanceLibrary`: Items should no longer be accessed using generated properties (`item1`, `item2` etc). Use `get_item` instead.
Expand Down
12 changes: 10 additions & 2 deletions streams/voxel_stream_cache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,17 @@ bool VoxelStreamCache::load_voxel_block(Vector3i position, uint8_t lod_index, Vo
return false;

} else {
const Block &block = it->second;
if (!block.has_voxels) {
// Has a block in cache but there is no voxel data
return false;
}
// In cache, serve it

const VoxelBuffer &vb = it->second.voxels;

// Copying is required since the cache has ownership on its data,
// and the requests wants us to populate the buffer it provides
vb.copy_to(out_voxels, true);
block.voxels.copy_to(out_voxels, true);

return true;
}
Expand All @@ -31,6 +35,10 @@ void VoxelStreamCache::save_voxel_block(Vector3i position, uint8_t lod_index, Vo
RWLockWrite wlock(lod.rw_lock);
auto it = lod.blocks.find(position);

ZN_ASSERT_RETURN_MSG(
!Vector3iUtil::is_empty_size(voxels.get_size()), "Saving voxel buffer with empty size is not expected. Bug?"
);

if (it == lod.blocks.end()) {
// Not cached yet, create an entry
Block b;
Expand Down

0 comments on commit 8ca295d

Please sign in to comment.