get_voxel may be const

This commit is contained in:
Marc Gilleron 2020-12-30 20:09:31 +00:00
parent fd6125df67
commit 3e510d2e93
8 changed files with 20 additions and 20 deletions

View File

@ -60,11 +60,11 @@ Ref<VoxelRaycastResult> VoxelTool::raycast(Vector3 pos, Vector3 dir, float max_d
return Ref<VoxelRaycastResult>();
}
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;
}

View File

@ -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);

View File

@ -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);
}

View File

@ -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;

View File

@ -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);
}

View File

@ -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;

View File

@ -80,12 +80,12 @@ Ref<VoxelRaycastResult> 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);
}

View File

@ -24,8 +24,8 @@ public:
void run_blocky_random_tick(AABB voxel_area, int voxel_count, Ref<FuncRef> 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;