@@ -636,11 +636,16 @@ inline void schedule_mesh_load(std::vector<VoxelLodTerrainUpdateData::MeshToUpda
636
636
637
637
void view_mesh_box (const Box3i box_to_add, VoxelLodTerrainUpdateData::Lod &lod, unsigned int lod_index,
638
638
bool is_full_load_mode, int mesh_to_data_factor, const VoxelData &voxel_data, bool require_visuals) {
639
+ ZN_PROFILE_SCOPE ();
640
+
641
+ const Box3i bounds_in_data_blocks = voxel_data.get_bounds ().downscaled (voxel_data.get_block_size () << lod_index);
642
+
639
643
box_to_add.for_each_cell ([&lod, //
640
644
is_full_load_mode, //
641
645
mesh_to_data_factor, //
642
646
&voxel_data, lod_index, //
643
- require_visuals](Vector3i bpos) {
647
+ require_visuals, //
648
+ bounds_in_data_blocks](Vector3i bpos) {
644
649
VoxelLodTerrainUpdateData::MeshBlockState *mesh_block;
645
650
auto mesh_block_it = lod.mesh_map_state .map .find (bpos);
646
651
@@ -694,13 +699,14 @@ void view_mesh_box(const Box3i box_to_add, VoxelLodTerrainUpdateData::Lod &lod,
694
699
// or modified, so changing block size or viewer flags did not make meshes appear. Having two viewer
695
700
// regions meet also caused problems.
696
701
697
- const Box3i data_box =
698
- Box3i (bpos * mesh_to_data_factor, Vector3iUtil::create (mesh_to_data_factor)).padded (1 );
702
+ const Box3i data_box = Box3i (bpos * mesh_to_data_factor, Vector3iUtil::create (mesh_to_data_factor))
703
+ .padded (1 )
704
+ .clipped (bounds_in_data_blocks);
699
705
700
706
// If we get an empty box at this point, something is wrong with the caller
701
707
ZN_ASSERT_RETURN (!data_box.is_empty ());
702
708
703
- const bool data_available = voxel_data.has_all_blocks_in_area (data_box, lod_index);
709
+ const bool data_available = voxel_data.has_all_blocks_in_area_unbound (data_box, lod_index);
704
710
705
711
if (data_available) {
706
712
schedule_mesh_load (lod.mesh_blocks_pending_update , bpos, *mesh_block, require_visuals);
@@ -1043,6 +1049,8 @@ void process_loaded_data_blocks_trigger_meshing(const VoxelData &data, VoxelLodT
1043
1049
1044
1050
data_neighboring.for_each_cell ([data_to_mesh_shift, &checked_mesh_blocks, &lod, &data, lod_index,
1045
1051
&bounds_in_data_blocks](Vector3i data_bpos) {
1052
+ // ZN_PROFILE_SCOPE_NAMED("Cell");
1053
+
1046
1054
const Vector3i mesh_block_pos = data_bpos >> data_to_mesh_shift;
1047
1055
if (!checked_mesh_blocks.insert (mesh_block_pos).second ) {
1048
1056
// Already checked
@@ -1073,7 +1081,7 @@ void process_loaded_data_blocks_trigger_meshing(const VoxelData &data, VoxelLodT
1073
1081
Vector3iUtil::create ((1 << data_to_mesh_shift) + 2 ))
1074
1082
.clipped (bounds_in_data_blocks);
1075
1083
// TODO Do a single grid query up-front, they will overlap so we do redundant lookups!
1076
- data_available = data.has_all_blocks_in_area (data_box, lod_index);
1084
+ data_available = data.has_all_blocks_in_area_unbound (data_box, lod_index);
1077
1085
// } else {
1078
1086
// if (!data.is_full_load_completed()) {
1079
1087
// ZN_PRINT_ERROR("This function should not run until full load has completed");
0 commit comments