From 3e510d2e93df1487c2a232a745202ce3d310738f Mon Sep 17 00:00:00 2001 From: Marc Gilleron Date: Wed, 30 Dec 2020 20:09:31 +0000 Subject: [PATCH] `get_voxel` may be `const` --- edition/voxel_tool.cpp | 8 ++++---- edition/voxel_tool.h | 8 ++++---- edition/voxel_tool_buffer.cpp | 4 ++-- edition/voxel_tool_buffer.h | 4 ++-- edition/voxel_tool_lod_terrain.cpp | 4 ++-- edition/voxel_tool_lod_terrain.h | 4 ++-- edition/voxel_tool_terrain.cpp | 4 ++-- edition/voxel_tool_terrain.h | 4 ++-- 8 files changed, 20 insertions(+), 20 deletions(-) diff --git a/edition/voxel_tool.cpp b/edition/voxel_tool.cpp index 7aa41203..deb79dd3 100644 --- a/edition/voxel_tool.cpp +++ b/edition/voxel_tool.cpp @@ -60,11 +60,11 @@ Ref VoxelTool::raycast(Vector3 pos, Vector3 dir, float max_d return Ref(); } -uint64_t VoxelTool::get_voxel(Vector3i pos) { +uint64_t VoxelTool::get_voxel(Vector3i pos) const { return _get_voxel(pos); } -float VoxelTool::get_voxel_f(Vector3i pos) { +float VoxelTool::get_voxel_f(Vector3i pos) const { return _get_voxel_f(pos); } @@ -109,12 +109,12 @@ void VoxelTool::do_circle(Vector3i pos, int radius, Vector3i direction) { ERR_PRINT("Not implemented"); } -uint64_t VoxelTool::_get_voxel(Vector3i pos) { +uint64_t VoxelTool::_get_voxel(Vector3i pos) const { ERR_PRINT("Not implemented"); return 0; } -float VoxelTool::_get_voxel_f(Vector3i pos) { +float VoxelTool::_get_voxel_f(Vector3i pos) const { ERR_PRINT("Not implemented"); return 0; } diff --git a/edition/voxel_tool.h b/edition/voxel_tool.h index 865277a9..957605ab 100644 --- a/edition/voxel_tool.h +++ b/edition/voxel_tool.h @@ -46,8 +46,8 @@ public: void set_eraser_value(uint64_t value); uint64_t get_eraser_value() const; - uint64_t get_voxel(Vector3i pos); - float get_voxel_f(Vector3i pos); + uint64_t get_voxel(Vector3i pos) const; + float get_voxel_f(Vector3i pos) const; // TODO Methods working on a whole area must use an implementation that minimizes locking! @@ -77,8 +77,8 @@ protected: // These methods never go alone, but may be used in others. // They don't represent an edit, they only abstract the lower-level API - virtual uint64_t _get_voxel(Vector3i pos); - virtual float _get_voxel_f(Vector3i pos); + virtual uint64_t _get_voxel(Vector3i pos) const; + virtual float _get_voxel_f(Vector3i pos) const; virtual void _set_voxel(Vector3i pos, uint64_t v); virtual void _set_voxel_f(Vector3i pos, float v); virtual void _post_edit(const Rect3i &box); diff --git a/edition/voxel_tool_buffer.cpp b/edition/voxel_tool_buffer.cpp index b8f13209..a81990b3 100644 --- a/edition/voxel_tool_buffer.cpp +++ b/edition/voxel_tool_buffer.cpp @@ -11,12 +11,12 @@ bool VoxelToolBuffer::is_area_editable(const Rect3i &box) const { return Rect3i(Vector3i(), _buffer->get_size()).encloses(box); } -uint64_t VoxelToolBuffer::_get_voxel(Vector3i pos) { +uint64_t VoxelToolBuffer::_get_voxel(Vector3i pos) const { ERR_FAIL_COND_V(_buffer.is_null(), 0); return _buffer->get_voxel(pos, _channel); } -float VoxelToolBuffer::_get_voxel_f(Vector3i pos) { +float VoxelToolBuffer::_get_voxel_f(Vector3i pos) const { ERR_FAIL_COND_V(_buffer.is_null(), 0); return _buffer->get_voxel_f(pos.x, pos.y, pos.z, _channel); } diff --git a/edition/voxel_tool_buffer.h b/edition/voxel_tool_buffer.h index d22be622..39cd631c 100644 --- a/edition/voxel_tool_buffer.h +++ b/edition/voxel_tool_buffer.h @@ -17,8 +17,8 @@ public: Variant get_voxel_metadata(Vector3i pos) override; protected: - uint64_t _get_voxel(Vector3i pos) override; - float _get_voxel_f(Vector3i pos) override; + uint64_t _get_voxel(Vector3i pos) const override; + float _get_voxel_f(Vector3i pos) const override; void _set_voxel(Vector3i pos, uint64_t v) override; void _set_voxel_f(Vector3i pos, float v) override; void _post_edit(const Rect3i &box) override; diff --git a/edition/voxel_tool_lod_terrain.cpp b/edition/voxel_tool_lod_terrain.cpp index c6b1d4ef..1c58f539 100644 --- a/edition/voxel_tool_lod_terrain.cpp +++ b/edition/voxel_tool_lod_terrain.cpp @@ -15,12 +15,12 @@ bool VoxelToolLodTerrain::is_area_editable(const Rect3i &box) const { return _map.is_area_fully_loaded(box.padded(1)); } -uint64_t VoxelToolLodTerrain::_get_voxel(Vector3i pos) { +uint64_t VoxelToolLodTerrain::_get_voxel(Vector3i pos) const { ERR_FAIL_COND_V(_terrain == nullptr, 0); return _map.get_voxel(pos, _channel); } -float VoxelToolLodTerrain::_get_voxel_f(Vector3i pos) { +float VoxelToolLodTerrain::_get_voxel_f(Vector3i pos) const { ERR_FAIL_COND_V(_terrain == nullptr, 0); return _map.get_voxel_f(pos, _channel); } diff --git a/edition/voxel_tool_lod_terrain.h b/edition/voxel_tool_lod_terrain.h index fd40ba68..9661de71 100644 --- a/edition/voxel_tool_lod_terrain.h +++ b/edition/voxel_tool_lod_terrain.h @@ -14,8 +14,8 @@ public: bool is_area_editable(const Rect3i &box) const override; protected: - uint64_t _get_voxel(Vector3i pos) override; - float _get_voxel_f(Vector3i pos) override; + uint64_t _get_voxel(Vector3i pos) const override; + float _get_voxel_f(Vector3i pos) const override; void _set_voxel(Vector3i pos, uint64_t v) override; void _set_voxel_f(Vector3i pos, float v) override; void _post_edit(const Rect3i &box) override; diff --git a/edition/voxel_tool_terrain.cpp b/edition/voxel_tool_terrain.cpp index 7210ce5a..fa335978 100644 --- a/edition/voxel_tool_terrain.cpp +++ b/edition/voxel_tool_terrain.cpp @@ -80,12 +80,12 @@ Ref VoxelToolTerrain::raycast(Vector3 pos, Vector3 dir, floa return res; } -uint64_t VoxelToolTerrain::_get_voxel(Vector3i pos) { +uint64_t VoxelToolTerrain::_get_voxel(Vector3i pos) const { ERR_FAIL_COND_V(_terrain == nullptr, 0); return _terrain->get_storage().get_voxel(pos, _channel); } -float VoxelToolTerrain::_get_voxel_f(Vector3i pos) { +float VoxelToolTerrain::_get_voxel_f(Vector3i pos) const { ERR_FAIL_COND_V(_terrain == nullptr, 0); return _terrain->get_storage().get_voxel_f(pos, _channel); } diff --git a/edition/voxel_tool_terrain.h b/edition/voxel_tool_terrain.h index b89640c8..97f6c4e9 100644 --- a/edition/voxel_tool_terrain.h +++ b/edition/voxel_tool_terrain.h @@ -24,8 +24,8 @@ public: void run_blocky_random_tick(AABB voxel_area, int voxel_count, Ref callback, int block_batch_count) const; protected: - uint64_t _get_voxel(Vector3i pos) override; - float _get_voxel_f(Vector3i pos) override; + uint64_t _get_voxel(Vector3i pos) const override; + float _get_voxel_f(Vector3i pos) const override; void _set_voxel(Vector3i pos, uint64_t v) override; void _set_voxel_f(Vector3i pos, float v) override; void _post_edit(const Rect3i &box) override;