mirror of
https://github.com/Relintai/voxelman.git
synced 2024-11-12 10:15:12 +01:00
Added is_inside_tree() property to VoxelChunk.
This commit is contained in:
parent
b970c86264
commit
9475986ee0
@ -586,6 +586,7 @@ void VoxelChunkDefault::free_meshes(const int mesh_index) {
|
||||
void VoxelChunkDefault::create_colliders(const int mesh_index, const int layer_mask) {
|
||||
ERR_FAIL_COND(_voxel_world == NULL);
|
||||
ERR_FAIL_COND(PhysicsServer::get_singleton()->is_flushing_queries());
|
||||
//ERR_FAIL_COND(!get_voxel_world()->is_inside_tree());
|
||||
|
||||
if (!_rids.has(mesh_index))
|
||||
_rids[mesh_index] = Dictionary();
|
||||
|
@ -79,6 +79,10 @@ _FORCE_INLINE_ void VoxelChunk::set_is_generating(const bool value) {
|
||||
_is_generating = value;
|
||||
}
|
||||
|
||||
bool VoxelChunk::is_in_tree() const {
|
||||
return _is_in_tree;
|
||||
}
|
||||
|
||||
_FORCE_INLINE_ bool VoxelChunk::get_dirty() const {
|
||||
return _dirty;
|
||||
}
|
||||
@ -542,6 +546,9 @@ void VoxelChunk::create_meshers() {
|
||||
}
|
||||
|
||||
void VoxelChunk::build(const bool immediate) {
|
||||
ERR_FAIL_COND(!ObjectDB::instance_validate(get_voxel_world()));
|
||||
ERR_FAIL_COND(!get_voxel_world()->is_inside_tree());
|
||||
ERR_FAIL_COND(!is_in_tree());
|
||||
ERR_FAIL_COND_MSG(!has_method("_build"), "VoxelChunk: _build(immediate : bool) is missing! Please implement it!");
|
||||
|
||||
call("_build", immediate);
|
||||
@ -711,10 +718,14 @@ void VoxelChunk::clear_props() {
|
||||
}
|
||||
|
||||
void VoxelChunk::enter_tree() {
|
||||
_is_in_tree = true;
|
||||
|
||||
if (has_method("_enter_tree"))
|
||||
call("_enter_tree");
|
||||
}
|
||||
void VoxelChunk::exit_tree() {
|
||||
_is_in_tree = false;
|
||||
|
||||
if (has_method("_exit_tree"))
|
||||
call("_exit_tree");
|
||||
}
|
||||
@ -753,6 +764,7 @@ VoxelChunk::VoxelChunk() {
|
||||
_is_build_threaded = false;
|
||||
_is_processing = false;
|
||||
_is_phisics_processing = false;
|
||||
_is_in_tree = false;
|
||||
|
||||
_is_visible = true;
|
||||
|
||||
@ -892,6 +904,8 @@ void VoxelChunk::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_physics_process"), &VoxelChunk::get_physics_process);
|
||||
ClassDB::bind_method(D_METHOD("set_physics_process", "value"), &VoxelChunk::set_physics_process);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("is_in_tree"), &VoxelChunk::is_in_tree);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_is_build_threaded"), &VoxelChunk::get_is_build_threaded);
|
||||
ClassDB::bind_method(D_METHOD("set_is_build_threaded", "value"), &VoxelChunk::set_is_build_threaded);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "is_build_threaded", PROPERTY_HINT_NONE, "", 0), "set_is_build_threaded", "get_is_build_threaded");
|
||||
|
@ -87,6 +87,8 @@ public:
|
||||
bool get_is_generating() const;
|
||||
void set_is_generating(const bool value);
|
||||
|
||||
bool is_in_tree() const;
|
||||
|
||||
bool get_dirty() const;
|
||||
void set_dirty(const bool value);
|
||||
|
||||
@ -234,6 +236,8 @@ protected:
|
||||
bool _dirty;
|
||||
int _state;
|
||||
|
||||
bool _is_in_tree;
|
||||
|
||||
VoxelWorld *_voxel_world;
|
||||
|
||||
int _position_x;
|
||||
|
@ -272,7 +272,8 @@ void VoxelWorld::add_chunk(Ref<VoxelChunk> chunk, const int x, const int y, cons
|
||||
_chunks.set(pos, chunk);
|
||||
_chunks_vector.push_back(chunk);
|
||||
|
||||
chunk->enter_tree();
|
||||
if (is_inside_tree())
|
||||
chunk->enter_tree();
|
||||
|
||||
if (has_method("_chunk_added"))
|
||||
call("_chunk_added", chunk);
|
||||
|
Loading…
Reference in New Issue
Block a user