Skip to content

Commit

Permalink
Fix run_blocky_random_tick
Browse files Browse the repository at this point in the history
  • Loading branch information
Zylann committed Oct 17, 2023
1 parent 60690b3 commit 54ce116
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
2 changes: 2 additions & 0 deletions edition/voxel_tool_terrain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,8 @@ void VoxelToolTerrain::for_each_voxel_metadata_in_area(AABB voxel_area, const Ca
const Vector3i block_origin = block_pos * data.get_block_size();
const Box3i rel_voxel_box(voxel_box.pos - block_origin, voxel_box.size);
// TODO Worth it locking blocks for metadata?
// For read or write? We'd have to specify as argument and trust the user... since metadata can contain
// reference types.

#if defined(ZN_GODOT)
voxels_ptr->for_each_voxel_metadata_in_area(
Expand Down
4 changes: 3 additions & 1 deletion storage/voxel_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -988,7 +988,9 @@ void VoxelData::unview_area(Box3i blocks_box, std::vector<Vector3i> &missing_blo
std::shared_ptr<VoxelBufferInternal> VoxelData::try_get_block_voxels(Vector3i bpos) {
Lod &lod = _lods[0];

SpatialLock3D::Read srlock(lod.spatial_lock, BoxBounds3i::from_position(bpos));
// The caller must lock the spatial lock and keep it locked until done accessing blocks
// SpatialLock3D::Read srlock(lod.spatial_lock, BoxBounds3i::from_position(bpos));

RWLockRead rlock(lod.map_lock);

VoxelDataBlock *block = lod.map.get_block(bpos);
Expand Down
4 changes: 4 additions & 0 deletions storage/voxel_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,12 @@ class VoxelData {
// Tests the presence of edited blocks in the given area by looking up LOD mips. It can report false positives due
// to the broad nature of the check, but runs a lot faster than a full test. This is only usable with volumes
// using LOD mips (edited blocks have half-resolution counterparts all the way up to maximum LOD).

bool has_blocks_with_voxels_in_area_broad_mip_test(Box3i box_in_voxels) const;

// Access voxels of a specific block.
// WARNING: you must hold the spatial lock before calling this, and until you're done working on such blocks.
// Can return null.
std::shared_ptr<VoxelBufferInternal> try_get_block_voxels(Vector3i bpos);

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down

0 comments on commit 54ce116

Please sign in to comment.