Skip to content

Commit

Permalink
Fixed incorrect loading of chunks near terrain borders with Clipbox
Browse files Browse the repository at this point in the history
  • Loading branch information
Zylann committed Sep 27, 2024
1 parent 1fcdf60 commit 75bb4cd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
1 change: 1 addition & 0 deletions doc/source/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Primarily developped with Godot 4.3.
- `VoxelLodTerrain`:
- Fixed potential crash when when using the Clipbox streaming system with threaded update (thanks to lenesxy, issue #692)
- Fixed blocks were saved with incorrect LOD index when they get unloaded using Clipbox, leading to holes and mismatched terrain (#691)
- Fixed incorrect loading of chunks near terrain borders when viewers are far away from bounds, when using the Clipbox streaming system
- `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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,6 @@ void process_viewers(
const int lod_mesh_block_size_po2 = volume_settings.mesh_block_size_po2 + lod_index;
const int lod_mesh_block_size = 1 << lod_mesh_block_size_po2;

const Box3i volume_bounds_in_mesh_blocks = volume_bounds_in_voxels.downscaled(lod_mesh_block_size);

const Vector3i ld = get_relative_lod_distance_in_chunks(
lod_index,
lod_count,
Expand Down Expand Up @@ -301,12 +299,19 @@ void process_viewers(
new_mesh_box = enforce_neighboring_rule(new_mesh_box, child_box, even_coordinates_required);
}

// Clip last
new_mesh_box.clip(volume_bounds_in_mesh_blocks);

paired_viewer.state.mesh_box_per_lod[lod_index] = new_mesh_box;
}

// Clip all mesh boxes in a second pass, because `enforce_neighboring_rule` depends on the child LOD box
for (unsigned int lod_index = 0; lod_index < lod_count; ++lod_index) {
const int lod_mesh_block_size_po2 = volume_settings.mesh_block_size_po2 + lod_index;
const int lod_mesh_block_size = 1 << lod_mesh_block_size_po2;
const Box3i volume_bounds_in_mesh_blocks = volume_bounds_in_voxels.downscaled(lod_mesh_block_size);

Box3i &box = paired_viewer.state.mesh_box_per_lod[lod_index];
box.clip(volume_bounds_in_mesh_blocks);
}

// TODO We should have a flag server side to force data boxes to be based on mesh boxes, even though the
// server might not actually need meshes. That would help the server to provide data chunks to clients,
// which need them for visual meshes
Expand Down

0 comments on commit 75bb4cd

Please sign in to comment.