mirror of
https://github.com/Relintai/voxelman.git
synced 2025-04-15 21:06:06 +02:00
Fix set_chunks, and enter_tree.
This commit is contained in:
parent
b046db78ed
commit
d717c9886b
@ -364,14 +364,27 @@ Vector<Variant> VoxelWorld::get_chunks() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void VoxelWorld::set_chunks(const Vector<Variant> &chunks) {
|
void VoxelWorld::set_chunks(const Vector<Variant> &chunks) {
|
||||||
clear();
|
|
||||||
|
|
||||||
for (int i = 0; i < chunks.size(); i++) {
|
for (int i = 0; i < _chunks_vector.size(); ++i) {
|
||||||
|
Ref<VoxelChunk> chunk = Ref<VoxelChunk>(_chunks_vector[i]);
|
||||||
|
|
||||||
|
if (chunks.find(chunk) == -1) {
|
||||||
|
remove_chunk_index(i);
|
||||||
|
_generation_queue.erase(chunk);
|
||||||
|
_generating.erase(chunk);
|
||||||
|
--i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < chunks.size(); ++i) {
|
||||||
Ref<VoxelChunk> chunk = Ref<VoxelChunk>(chunks[i]);
|
Ref<VoxelChunk> chunk = Ref<VoxelChunk>(chunks[i]);
|
||||||
|
|
||||||
if (!chunk.is_valid())
|
if (!chunk.is_valid())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
if (_chunks_vector.find(chunk) != -1)
|
||||||
|
continue;
|
||||||
|
|
||||||
add_chunk(chunk, chunk->get_position_x(), chunk->get_position_y(), chunk->get_position_z());
|
add_chunk(chunk, chunk->get_position_x(), chunk->get_position_y(), chunk->get_position_z());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -434,7 +447,16 @@ void VoxelWorld::_notification(int p_what) {
|
|||||||
Ref<VoxelChunk> chunk = _chunks_vector[i];
|
Ref<VoxelChunk> chunk = _chunks_vector[i];
|
||||||
|
|
||||||
if (chunk.is_valid()) {
|
if (chunk.is_valid()) {
|
||||||
|
IntPos pos(chunk->get_position_x(), chunk->get_position_y(), chunk->get_position_z());
|
||||||
|
|
||||||
|
chunk->set_voxel_world(this);
|
||||||
|
chunk->world_transform_changed();
|
||||||
|
|
||||||
|
_chunks.set(pos, chunk);
|
||||||
|
|
||||||
chunk->enter_tree();
|
chunk->enter_tree();
|
||||||
|
|
||||||
|
chunk->build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
|
@ -35,7 +35,7 @@ SOFTWARE.
|
|||||||
#include "voxel_chunk.h"
|
#include "voxel_chunk.h"
|
||||||
|
|
||||||
bool VoxelWorldEditor::forward_spatial_input_event(Camera *p_camera, const Ref<InputEvent> &p_event) {
|
bool VoxelWorldEditor::forward_spatial_input_event(Camera *p_camera, const Ref<InputEvent> &p_event) {
|
||||||
if (!_world && !_world->get_editable()) {
|
if (!_world || !_world->get_editable()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user