Added lots of const qualifiers to world and chunk.

This commit is contained in:
Relintai 2020-04-16 17:10:04 +02:00
parent 135b34c8a8
commit 367c203cc6
4 changed files with 133 additions and 133 deletions

View File

@ -68,40 +68,40 @@ void VoxelChunk::set_visible(const bool value) {
_FORCE_INLINE_ bool VoxelChunk::get_is_generating() const { _FORCE_INLINE_ bool VoxelChunk::get_is_generating() const {
return _is_generating; return _is_generating;
} }
_FORCE_INLINE_ void VoxelChunk::set_is_generating(bool value) { _FORCE_INLINE_ void VoxelChunk::set_is_generating(const bool value) {
_is_generating = value; _is_generating = value;
} }
_FORCE_INLINE_ bool VoxelChunk::get_dirty() const { _FORCE_INLINE_ bool VoxelChunk::get_dirty() const {
return _dirty; return _dirty;
} }
_FORCE_INLINE_ void VoxelChunk::set_dirty(bool value) { _FORCE_INLINE_ void VoxelChunk::set_dirty(const bool value) {
_dirty = value; _dirty = value;
} }
_FORCE_INLINE_ int VoxelChunk::get_state() const { _FORCE_INLINE_ int VoxelChunk::get_state() const {
return _state; return _state;
} }
_FORCE_INLINE_ void VoxelChunk::set_state(int value) { _FORCE_INLINE_ void VoxelChunk::set_state(const int value) {
_state = value; _state = value;
} }
_FORCE_INLINE_ int VoxelChunk::get_position_x() { _FORCE_INLINE_ int VoxelChunk::get_position_x() const {
return _position_x; return _position_x;
} }
void VoxelChunk::set_position_x(int value) { void VoxelChunk::set_position_x(const int value) {
_position_x = value; _position_x = value;
} }
_FORCE_INLINE_ int VoxelChunk::get_position_y() { _FORCE_INLINE_ int VoxelChunk::get_position_y() const {
return _position_y; return _position_y;
} }
void VoxelChunk::set_position_y(int value) { void VoxelChunk::set_position_y(const int value) {
_position_y = value; _position_y = value;
} }
_FORCE_INLINE_ int VoxelChunk::get_position_z() { _FORCE_INLINE_ int VoxelChunk::get_position_z() const {
return _position_z; return _position_z;
} }
void VoxelChunk::set_position_z(int value) { void VoxelChunk::set_position_z(const int value) {
_position_z = value; _position_z = value;
} }
@ -109,23 +109,23 @@ _FORCE_INLINE_ Vector3 VoxelChunk::get_position() const {
return Vector3(_position_x, _position_y, _position_z); return Vector3(_position_x, _position_y, _position_z);
} }
_FORCE_INLINE_ int VoxelChunk::get_size_x() { _FORCE_INLINE_ int VoxelChunk::get_size_x() const {
return _size_x; return _size_x;
} }
_FORCE_INLINE_ int VoxelChunk::get_size_y() { _FORCE_INLINE_ int VoxelChunk::get_size_y() const {
return _size_y; return _size_y;
} }
_FORCE_INLINE_ int VoxelChunk::get_size_z() { _FORCE_INLINE_ int VoxelChunk::get_size_z() const {
return _size_z; return _size_z;
} }
_FORCE_INLINE_ void VoxelChunk::set_size_x(int value) { _FORCE_INLINE_ void VoxelChunk::set_size_x(const int value) {
_size_x = value; _size_x = value;
} }
_FORCE_INLINE_ void VoxelChunk::set_size_y(int value) { _FORCE_INLINE_ void VoxelChunk::set_size_y(const int value) {
_size_y = value; _size_y = value;
} }
_FORCE_INLINE_ void VoxelChunk::set_size_z(int value) { _FORCE_INLINE_ void VoxelChunk::set_size_z(const int value) {
_size_z = value; _size_z = value;
} }
@ -133,27 +133,27 @@ _FORCE_INLINE_ Vector3 VoxelChunk::get_size() const {
return Vector3(_size_x, _size_y, _size_z); return Vector3(_size_x, _size_y, _size_z);
} }
_FORCE_INLINE_ int VoxelChunk::get_data_size_x() { _FORCE_INLINE_ int VoxelChunk::get_data_size_x() const {
return _data_size_x; return _data_size_x;
} }
_FORCE_INLINE_ int VoxelChunk::get_data_size_y() { _FORCE_INLINE_ int VoxelChunk::get_data_size_y() const {
return _data_size_y; return _data_size_y;
} }
_FORCE_INLINE_ int VoxelChunk::get_data_size_z() { _FORCE_INLINE_ int VoxelChunk::get_data_size_z() const {
return _data_size_z; return _data_size_z;
} }
_FORCE_INLINE_ void VoxelChunk::set_data_size_x(int value) { _FORCE_INLINE_ void VoxelChunk::set_data_size_x(const int value) {
_data_size_x = value; _data_size_x = value;
} }
_FORCE_INLINE_ void VoxelChunk::set_data_size_y(int value) { _FORCE_INLINE_ void VoxelChunk::set_data_size_y(const int value) {
_data_size_y = value; _data_size_y = value;
} }
_FORCE_INLINE_ void VoxelChunk::set_data_size_z(int value) { _FORCE_INLINE_ void VoxelChunk::set_data_size_z(const int value) {
_data_size_z = value; _data_size_z = value;
} }
void VoxelChunk::set_position(int x, int y, int z) { void VoxelChunk::set_position(const int x, const int y, const int z) {
_position_x = x; _position_x = x;
_position_y = y; _position_y = y;
_position_z = z; _position_z = z;
@ -166,10 +166,10 @@ _FORCE_INLINE_ int VoxelChunk::get_margin_end() const {
return _margin_end; return _margin_end;
} }
_FORCE_INLINE_ void VoxelChunk::set_margin_start(int value) { _FORCE_INLINE_ void VoxelChunk::set_margin_start(const int value) {
_margin_start = value; _margin_start = value;
} }
_FORCE_INLINE_ void VoxelChunk::set_margin_end(int value) { _FORCE_INLINE_ void VoxelChunk::set_margin_end(const int value) {
_margin_end = value; _margin_end = value;
} }
@ -183,7 +183,7 @@ void VoxelChunk::set_library(const Ref<VoxelmanLibrary> &value) {
float VoxelChunk::get_voxel_scale() const { float VoxelChunk::get_voxel_scale() const {
return _voxel_scale; return _voxel_scale;
} }
void VoxelChunk::set_voxel_scale(float value) { void VoxelChunk::set_voxel_scale(const float value) {
_voxel_scale = value; _voxel_scale = value;
for (int i = 0; i < _meshers.size(); ++i) { for (int i = 0; i < _meshers.size(); ++i) {
@ -215,20 +215,20 @@ Ref<VoxelMesher> VoxelChunk::get_mesher(int index) const {
return _meshers.get(index); return _meshers.get(index);
} }
void VoxelChunk::set_mesher(int index, Ref<VoxelMesher> mesher) { void VoxelChunk::set_mesher(int index, const Ref<VoxelMesher> &mesher) {
ERR_FAIL_INDEX(index, _meshers.size()); ERR_FAIL_INDEX(index, _meshers.size());
_meshers.set(index, mesher); _meshers.set(index, mesher);
} }
void VoxelChunk::remove_mesher(int index) { void VoxelChunk::remove_mesher(const int index) {
ERR_FAIL_INDEX(index, _meshers.size()); ERR_FAIL_INDEX(index, _meshers.size());
_meshers.remove(index); _meshers.remove(index);
} }
void VoxelChunk::add_mesher(Ref<VoxelMesher> mesher) { void VoxelChunk::add_mesher(const Ref<VoxelMesher> &mesher) {
_meshers.push_back(mesher); _meshers.push_back(mesher);
} }
int VoxelChunk::get_mesher_count() { int VoxelChunk::get_mesher_count() const {
return _meshers.size(); return _meshers.size();
} }
@ -239,7 +239,7 @@ void VoxelChunk::setup_channels() {
call("_setup_channels"); call("_setup_channels");
} }
void VoxelChunk::set_size(int size_x, int size_y, int size_z, int margin_start, int margin_end) { void VoxelChunk::set_size(const int size_x, const int size_y, const int size_z, const int margin_start, const int margin_end) {
if (_size_x == size_x && _size_y == size_y && _size_z == size_z && _margin_start == margin_start && _margin_end == margin_end) { if (_size_x == size_x && _size_y == size_y && _size_z == size_z && _margin_start == margin_start && _margin_end == margin_end) {
return; return;
} }
@ -266,11 +266,11 @@ void VoxelChunk::set_size(int size_x, int size_y, int size_z, int margin_start,
_margin_end = margin_end; _margin_end = margin_end;
} }
bool VoxelChunk::validate_channel_data_position(int x, int y, int z) const { bool VoxelChunk::validate_channel_data_position(const int x, const int y, const int z) const {
return x < _data_size_x && y < _data_size_y && z < _data_size_z; return x < _data_size_x && y < _data_size_y && z < _data_size_z;
} }
uint8_t VoxelChunk::get_voxel(int p_x, int p_y, int p_z, int p_channel_index) const { uint8_t VoxelChunk::get_voxel(const int p_x, const int p_y, const int p_z, const int p_channel_index) const {
int x = p_x + _margin_start; int x = p_x + _margin_start;
int y = p_y + _margin_start; int y = p_y + _margin_start;
int z = p_z + _margin_start; int z = p_z + _margin_start;
@ -285,7 +285,7 @@ uint8_t VoxelChunk::get_voxel(int p_x, int p_y, int p_z, int p_channel_index) co
return ch[get_data_index(x, y, z)]; return ch[get_data_index(x, y, z)];
} }
void VoxelChunk::set_voxel(uint8_t p_value, int p_x, int p_y, int p_z, int p_channel_index) { void VoxelChunk::set_voxel(const uint8_t p_value, const int p_x, const int p_y, const int p_z, const int p_channel_index) {
int x = p_x + _margin_start; int x = p_x + _margin_start;
int y = p_y + _margin_start; int y = p_y + _margin_start;
int z = p_z + _margin_start; int z = p_z + _margin_start;
@ -298,11 +298,11 @@ void VoxelChunk::set_voxel(uint8_t p_value, int p_x, int p_y, int p_z, int p_cha
ch[get_data_index(x, y, z)] = p_value; ch[get_data_index(x, y, z)] = p_value;
} }
int VoxelChunk::get_channel_count() { int VoxelChunk::get_channel_count() const {
return _channels.size(); return _channels.size();
} }
void VoxelChunk::set_channel_count(int count) { void VoxelChunk::set_channel_count(const int count) {
if (count == _channels.size()) if (count == _channels.size())
return; return;
@ -326,7 +326,7 @@ void VoxelChunk::set_channel_count(int count) {
_channels.set(i, NULL); _channels.set(i, NULL);
} }
} }
void VoxelChunk::allocate_channel(int channel_index, uint8_t default_value) { void VoxelChunk::allocate_channel(const int channel_index, const uint8_t default_value) {
ERR_FAIL_INDEX(channel_index, _channels.size()); ERR_FAIL_INDEX(channel_index, _channels.size());
if (_channels[channel_index] != NULL) if (_channels[channel_index] != NULL)
@ -339,7 +339,7 @@ void VoxelChunk::allocate_channel(int channel_index, uint8_t default_value) {
_channels.set(channel_index, ch); _channels.set(channel_index, ch);
} }
void VoxelChunk::fill_channel(uint8_t value, int channel_index) { void VoxelChunk::fill_channel(const uint8_t value, const int channel_index) {
ERR_FAIL_INDEX(channel_index, _channels.size()); ERR_FAIL_INDEX(channel_index, _channels.size());
uint8_t *ch = _channels.get(channel_index); uint8_t *ch = _channels.get(channel_index);
@ -355,7 +355,7 @@ void VoxelChunk::fill_channel(uint8_t value, int channel_index) {
ch[i] = value; ch[i] = value;
} }
} }
void VoxelChunk::dealloc_channel(int channel_index) { void VoxelChunk::dealloc_channel(const int channel_index) {
ERR_FAIL_INDEX(channel_index, _channels.size()); ERR_FAIL_INDEX(channel_index, _channels.size());
uint8_t *ch = _channels.get(channel_index); uint8_t *ch = _channels.get(channel_index);
@ -367,12 +367,12 @@ void VoxelChunk::dealloc_channel(int channel_index) {
} }
} }
uint8_t *VoxelChunk::get_channel(int channel_index) { uint8_t *VoxelChunk::get_channel(const int channel_index) {
ERR_FAIL_INDEX_V(channel_index, _channels.size(), NULL); ERR_FAIL_INDEX_V(channel_index, _channels.size(), NULL);
return _channels.get(channel_index); return _channels.get(channel_index);
} }
uint8_t *VoxelChunk::get_valid_channel(int channel_index, uint8_t default_value) { uint8_t *VoxelChunk::get_valid_channel(const int channel_index, const uint8_t default_value) {
ERR_FAIL_INDEX_V(channel_index, _channels.size(), 0); ERR_FAIL_INDEX_V(channel_index, _channels.size(), 0);
uint8_t *ch = _channels.get(channel_index); uint8_t *ch = _channels.get(channel_index);
@ -386,7 +386,7 @@ uint8_t *VoxelChunk::get_valid_channel(int channel_index, uint8_t default_value)
return ch; return ch;
} }
PoolByteArray VoxelChunk::get_channel_array(int channel_index) const { PoolByteArray VoxelChunk::get_channel_array(const int channel_index) const {
PoolByteArray arr; PoolByteArray arr;
uint32_t size = _data_size_x * _data_size_y * _data_size_z; uint32_t size = _data_size_x * _data_size_y * _data_size_z;
@ -407,7 +407,7 @@ PoolByteArray VoxelChunk::get_channel_array(int channel_index) const {
return arr; return arr;
} }
void VoxelChunk::set_channel_array(int channel_index, const PoolByteArray &array) { void VoxelChunk::set_channel_array(const int channel_index, const PoolByteArray &array) {
if (array.size() == 0) if (array.size() == 0)
return; return;
@ -429,7 +429,7 @@ void VoxelChunk::set_channel_array(int channel_index, const PoolByteArray &array
} }
} }
PoolByteArray VoxelChunk::get_channel_compressed(int channel_index) const { PoolByteArray VoxelChunk::get_channel_compressed(const int channel_index) const {
PoolByteArray arr; PoolByteArray arr;
int size = _data_size_x * _data_size_y * _data_size_z; int size = _data_size_x * _data_size_y * _data_size_z;
@ -458,7 +458,7 @@ PoolByteArray VoxelChunk::get_channel_compressed(int channel_index) const {
return arr; return arr;
} }
void VoxelChunk::set_channel_compressed(int channel_index, const PoolByteArray &data) { void VoxelChunk::set_channel_compressed(const int channel_index, const PoolByteArray &data) {
if (data.size() == 0) if (data.size() == 0)
return; return;
@ -575,7 +575,7 @@ Array VoxelChunk::merge_mesh_array(Array arr) const {
return arr; return arr;
} }
Array VoxelChunk::bake_mesh_array_uv(Array arr, Ref<Texture> tex, float mul_color) const { Array VoxelChunk::bake_mesh_array_uv(Array arr, Ref<Texture> tex, const float mul_color) const {
ERR_FAIL_COND_V(arr.size() != VisualServer::ARRAY_MAX, arr); ERR_FAIL_COND_V(arr.size() != VisualServer::ARRAY_MAX, arr);
ERR_FAIL_COND_V(!tex.is_valid(), arr); ERR_FAIL_COND_V(!tex.is_valid(), arr);
@ -641,10 +641,10 @@ Ref<VoxelChunkPropData> VoxelChunk::get_prop(int index) {
return _props.get(index); return _props.get(index);
} }
int VoxelChunk::get_prop_count() { int VoxelChunk::get_prop_count() const {
return _props.size(); return _props.size();
} }
void VoxelChunk::remove_prop(int index) { void VoxelChunk::remove_prop(const int index) {
ERR_FAIL_INDEX(index, _props.size()); ERR_FAIL_INDEX(index, _props.size());
Ref<VoxelChunkPropData> prop = _props.get(index); Ref<VoxelChunkPropData> prop = _props.get(index);
@ -673,18 +673,18 @@ void VoxelChunk::exit_tree() {
if (has_method("_exit_tree")) if (has_method("_exit_tree"))
call("_exit_tree"); call("_exit_tree");
} }
void VoxelChunk::process(float delta) { void VoxelChunk::process(const float delta) {
if (has_method("_process")) if (has_method("_process"))
call("_process", delta); call("_process", delta);
} }
void VoxelChunk::physics_process(float delta) { void VoxelChunk::physics_process(const float delta) {
if (has_method("_physics_process")) if (has_method("_physics_process"))
call("_physics_process", delta); call("_physics_process", delta);
} }
void VoxelChunk::world_transform_changed() { void VoxelChunk::world_transform_changed() {
call("_world_transform_changed"); call("_world_transform_changed");
} }
void VoxelChunk::visibility_changed(bool visible) { void VoxelChunk::visibility_changed(const bool visible) {
if (has_method("_visibility_changed")) if (has_method("_visibility_changed"))
call("_visibility_changed", _is_visible); call("_visibility_changed", _is_visible);
} }

View File

@ -82,94 +82,94 @@ public:
void set_visible(const bool value); void set_visible(const bool value);
bool get_is_generating() const; bool get_is_generating() const;
void set_is_generating(bool value); void set_is_generating(const bool value);
bool get_dirty() const; bool get_dirty() const;
void set_dirty(bool value); void set_dirty(const bool value);
int get_state() const; int get_state() const;
void set_state(int value); void set_state(int value);
int get_position_x(); int get_position_x() const;
void set_position_x(int value); void set_position_x(const int value);
int get_position_y(); int get_position_y() const;
void set_position_y(int value); void set_position_y(const int value);
int get_position_z(); int get_position_z() const;
void set_position_z(int value); void set_position_z(const int value);
int get_size_x(); int get_size_x() const;
int get_size_y(); int get_size_y() const;
int get_size_z(); int get_size_z() const;
void set_size_x(int value); void set_size_x(const int value);
void set_size_y(int value); void set_size_y(const int value);
void set_size_z(int value); void set_size_z(const int value);
int get_data_size_x(); int get_data_size_x() const;
int get_data_size_y(); int get_data_size_y() const;
int get_data_size_z(); int get_data_size_z() const;
void set_data_size_x(int value); void set_data_size_x(const int value);
void set_data_size_y(int value); void set_data_size_y(const int value);
void set_data_size_z(int value); void set_data_size_z(const int value);
Vector3 get_position() const; Vector3 get_position() const;
Vector3 get_size() const; Vector3 get_size() const;
void set_position(int x, int y, int z); void set_position(const int x, const int y, const int z);
int get_margin_start() const; int get_margin_start() const;
int get_margin_end() const; int get_margin_end() const;
void set_margin_start(int value); void set_margin_start(const int value);
void set_margin_end(int value); void set_margin_end(const int value);
Ref<VoxelmanLibrary> get_library(); Ref<VoxelmanLibrary> get_library();
void set_library(const Ref<VoxelmanLibrary> &value); void set_library(const Ref<VoxelmanLibrary> &value);
float get_voxel_scale() const; float get_voxel_scale() const;
void set_voxel_scale(float value); void set_voxel_scale(const float value);
VoxelWorld *get_voxel_world() const; VoxelWorld *get_voxel_world() const;
void set_voxel_world(VoxelWorld *world); void set_voxel_world(VoxelWorld *world);
void set_voxel_world_bind(Node *world); void set_voxel_world_bind(Node *world);
//Meshers //Meshers
Ref<VoxelMesher> get_mesher(int index) const; Ref<VoxelMesher> get_mesher(const int index) const;
void set_mesher(int index, Ref<VoxelMesher> mesher); void set_mesher(const int index, const Ref<VoxelMesher> &mesher);
void remove_mesher(int index); void remove_mesher(const int index);
void add_mesher(Ref<VoxelMesher> mesher); void add_mesher(const Ref<VoxelMesher> &mesher);
int get_mesher_count(); int get_mesher_count() const;
//Channels //Channels
void setup_channels(); void setup_channels();
void set_size(int size_x, int size_y, int size_z, int margin_start = 0, int margin_end = 0); void set_size(const int size_x, const int size_y, const int size_z, const int margin_start = 0, const int margin_end = 0);
bool validate_channel_data_position(int x, int y, int z) const; bool validate_channel_data_position(const int x, const int y, const int z) const;
uint8_t get_voxel(int p_x, int p_y, int p_z, int p_channel_index) const; uint8_t get_voxel(const int p_x, const int p_y, const int p_z, const int p_channel_index) const;
void set_voxel(uint8_t p_value, int p_x, int p_y, int p_z, int p_channel_index); void set_voxel(const uint8_t p_value, const int p_x, const int p_y, const int p_z, const int p_channel_index);
int get_channel_count(); int get_channel_count() const;
void set_channel_count(int count); void set_channel_count(const int count);
void allocate_channel(int channel_index, uint8_t default_value = 0); void allocate_channel(const int channel_index, const uint8_t default_value = 0);
void fill_channel(uint8_t value, int channel_index); void fill_channel(const uint8_t value, const int channel_index);
void dealloc_channel(int channel_index); void dealloc_channel(const int channel_index);
uint8_t *get_channel(int channel_index); uint8_t *get_channel(const int channel_index);
uint8_t *get_valid_channel(int channel_index, uint8_t default_value = 0); uint8_t *get_valid_channel(const int channel_index, const uint8_t default_value = 0);
PoolByteArray get_channel_array(int channel_index) const; PoolByteArray get_channel_array(const int channel_index) const;
void set_channel_array(int channel_index, const PoolByteArray &array); void set_channel_array(const int channel_index, const PoolByteArray &array);
PoolByteArray get_channel_compressed(int channel_index) const; PoolByteArray get_channel_compressed(const int channel_index) const;
void set_channel_compressed(int channel_index, const PoolByteArray &data); void set_channel_compressed(const int channel_index, const PoolByteArray &data);
int get_index(int x, int y, int z) const; int get_index(const int x, const int y, const int z) const;
int get_data_index(int x, int y, int z) const; int get_data_index(const int x, const int y, const int z) const;
int get_data_size() const; int get_data_size() const;
//Meshing //Meshing
void create_meshers(); void create_meshers();
void build(bool immediate = false); void build(const bool immediate = false);
void clear(); void clear();
Array merge_mesh_array(Array arr) const; Array merge_mesh_array(Array arr) const;
@ -182,18 +182,18 @@ public:
//props //props
void add_prop(Ref<VoxelChunkPropData> prop); void add_prop(Ref<VoxelChunkPropData> prop);
Ref<VoxelChunkPropData> get_prop(int index); Ref<VoxelChunkPropData> get_prop(const int index);
int get_prop_count(); int get_prop_count() const;
void remove_prop(int index); void remove_prop(const int index);
void clear_props(); void clear_props();
//handlers //handlers
void enter_tree(); void enter_tree();
void exit_tree(); void exit_tree();
void process(float delta); void process(const float delta);
void physics_process(float delta); void physics_process(const float delta);
void world_transform_changed(); void world_transform_changed();
void visibility_changed(bool visible); void visibility_changed(const bool visible);
void world_light_added(const Ref<VoxelLight> &light); void world_light_added(const Ref<VoxelLight> &light);
void world_light_removed(const Ref<VoxelLight> &light); void world_light_removed(const Ref<VoxelLight> &light);

View File

@ -81,10 +81,10 @@ void VoxelWorld::set_current_seed(const int value) {
_current_seed = value; _current_seed = value;
} }
bool VoxelWorld::get_use_threads() { bool VoxelWorld::get_use_threads() const {
return _use_threads; return _use_threads;
} }
void VoxelWorld::set_use_threads(bool value) { void VoxelWorld::set_use_threads(const bool value) {
_use_threads = OS::get_singleton()->can_use_threads() ? value : false; _use_threads = OS::get_singleton()->can_use_threads() ? value : false;
} }
@ -105,14 +105,14 @@ void VoxelWorld::set_max_frame_chunk_build_steps(const int value) {
Ref<VoxelmanLibrary> VoxelWorld::get_library() { Ref<VoxelmanLibrary> VoxelWorld::get_library() {
return _library; return _library;
} }
void VoxelWorld::set_library(const Ref<VoxelmanLibrary> library) { void VoxelWorld::set_library(const Ref<VoxelmanLibrary> &library) {
_library = library; _library = library;
} }
Ref<VoxelmanLevelGenerator> VoxelWorld::get_level_generator() const { Ref<VoxelmanLevelGenerator> VoxelWorld::get_level_generator() const {
return _level_generator; return _level_generator;
} }
void VoxelWorld::set_level_generator(const Ref<VoxelmanLevelGenerator> level_generator) { void VoxelWorld::set_level_generator(const Ref<VoxelmanLevelGenerator> &level_generator) {
_level_generator = level_generator; _level_generator = level_generator;
} }
@ -130,11 +130,11 @@ void VoxelWorld::set_chunk_spawn_range(const int value) {
_chunk_spawn_range = value; _chunk_spawn_range = value;
} }
NodePath VoxelWorld::get_player_path() { NodePath VoxelWorld::get_player_path() const {
return _player_path; return _player_path;
} }
void VoxelWorld::set_player_path(NodePath player_path) { void VoxelWorld::set_player_path(const NodePath &player_path) {
_player_path = player_path; _player_path = player_path;
} }
@ -302,7 +302,7 @@ int VoxelWorld::get_chunk_count() const {
return _chunks_vector.size(); return _chunks_vector.size();
} }
void VoxelWorld::add_to_generation_queue(Ref<VoxelChunk> chunk) { void VoxelWorld::add_to_generation_queue(const Ref<VoxelChunk> &chunk) {
ERR_FAIL_COND(!chunk.is_valid()); ERR_FAIL_COND(!chunk.is_valid());
set_process_internal(true); set_process_internal(true);
@ -319,26 +319,26 @@ void VoxelWorld::remove_generation_queue_index(int index) {
_generation_queue.remove(index); _generation_queue.remove(index);
} }
int VoxelWorld::get_generation_queue_size() { int VoxelWorld::get_generation_queue_size() const {
return _generation_queue.size(); return _generation_queue.size();
} }
void VoxelWorld::add_to_generation(Ref<VoxelChunk> chunk) { void VoxelWorld::add_to_generation(const Ref<VoxelChunk> &chunk) {
ERR_FAIL_COND(!chunk.is_valid()); ERR_FAIL_COND(!chunk.is_valid());
_generating.push_back(chunk); _generating.push_back(chunk);
} }
Ref<VoxelChunk> VoxelWorld::get_generation_index(int index) { Ref<VoxelChunk> VoxelWorld::get_generation_index(const int index) {
ERR_FAIL_INDEX_V(index, _generating.size(), NULL); ERR_FAIL_INDEX_V(index, _generating.size(), NULL);
return _generating.get(index); return _generating.get(index);
} }
void VoxelWorld::remove_generation_index(int index) { void VoxelWorld::remove_generation_index(const int index) {
ERR_FAIL_INDEX(index, _generating.size()); ERR_FAIL_INDEX(index, _generating.size());
_generating.remove(index); _generating.remove(index);
} }
int VoxelWorld::get_generation_size() { int VoxelWorld::get_generation_size() const {
return _generating.size(); return _generating.size();
} }
@ -365,12 +365,12 @@ Ref<VoxelChunk> VoxelWorld::get_or_create_chunk(int x, int y, int z) {
return chunk; return chunk;
} }
Ref<VoxelChunk> VoxelWorld::create_chunk(int x, int y, int z) { Ref<VoxelChunk> VoxelWorld::create_chunk(const int x, const int y, const int z) {
Ref<VoxelChunk> c = call("_create_chunk", x, y, z, Ref<VoxelChunk>()); Ref<VoxelChunk> c = call("_create_chunk", x, y, z, Ref<VoxelChunk>());
return c; return c;
} }
Ref<VoxelChunk> VoxelWorld::_create_chunk(int x, int y, int z, Ref<VoxelChunk> chunk) { Ref<VoxelChunk> VoxelWorld::_create_chunk(const int x, const int y, const int z, Ref<VoxelChunk> chunk) {
if (!chunk.is_valid()) { if (!chunk.is_valid()) {
chunk.instance(); chunk.instance();
} }

View File

@ -74,8 +74,8 @@ public:
int get_current_seed() const; int get_current_seed() const;
void set_current_seed(const int value); void set_current_seed(const int value);
bool get_use_threads(); bool get_use_threads() const;
void set_use_threads(bool value); void set_use_threads(const bool value);
int get_max_concurrent_generations() const; int get_max_concurrent_generations() const;
void set_max_concurrent_generations(const int value); void set_max_concurrent_generations(const int value);
@ -84,10 +84,10 @@ public:
void set_max_frame_chunk_build_steps(const int value); void set_max_frame_chunk_build_steps(const int value);
Ref<VoxelmanLibrary> get_library(); Ref<VoxelmanLibrary> get_library();
void set_library(const Ref<VoxelmanLibrary> library); void set_library(const Ref<VoxelmanLibrary> &library);
Ref<VoxelmanLevelGenerator> get_level_generator() const; Ref<VoxelmanLevelGenerator> get_level_generator() const;
void set_level_generator(const Ref<VoxelmanLevelGenerator> level_generator); void set_level_generator(const Ref<VoxelmanLevelGenerator> &level_generator);
float get_voxel_scale() const; float get_voxel_scale() const;
void set_voxel_scale(const float value); void set_voxel_scale(const float value);
@ -95,8 +95,8 @@ public:
int get_chunk_spawn_range() const; int get_chunk_spawn_range() const;
void set_chunk_spawn_range(const int value); void set_chunk_spawn_range(const int value);
NodePath get_player_path(); NodePath get_player_path() const;
void set_player_path(NodePath player_path); void set_player_path(const NodePath &player_path);
Spatial *get_player() const; Spatial *get_player() const;
void set_player(Spatial *player); void set_player(Spatial *player);
@ -131,20 +131,20 @@ public:
int get_chunk_count() const; int get_chunk_count() const;
void add_to_generation_queue(Ref<VoxelChunk> chunk); void add_to_generation_queue(const Ref<VoxelChunk> &chunk);
Ref<VoxelChunk> get_generation_queue_index(int index); Ref<VoxelChunk> get_generation_queue_index(const int index);
void remove_generation_queue_index(int index); void remove_generation_queue_index(const int index);
int get_generation_queue_size(); int get_generation_queue_size() const;
void add_to_generation(Ref<VoxelChunk> chunk); void add_to_generation(const Ref<VoxelChunk> &chunk);
Ref<VoxelChunk> get_generation_index(int index); Ref<VoxelChunk> get_generation_index(const int index);
void remove_generation_index(int index); void remove_generation_index(const int index);
int get_generation_size(); int get_generation_size() const;
void clear_chunks(); void clear_chunks();
Ref<VoxelChunk> get_or_create_chunk(int x, int y, int z); Ref<VoxelChunk> get_or_create_chunk(const int x, const int y, const int z);
Ref<VoxelChunk> create_chunk(int x, int y, int z); Ref<VoxelChunk> create_chunk(const int x, const int y, const int z);
void generate_chunk(Ref<VoxelChunk> chunk); void generate_chunk(Ref<VoxelChunk> chunk);