Skip to content

Commit e135e9b

Browse files
committed
Don't reload storage files if already initialized
1 parent 59b3f5a commit e135e9b

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/terrain_3d_storage.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,16 @@ void Terrain3DStorage::_clear() {
3131
///////////////////////////
3232

3333
void Terrain3DStorage::initialize(Terrain3D *p_terrain) {
34-
if (p_terrain != nullptr) {
35-
_terrain = p_terrain;
36-
} else {
34+
if (p_terrain == nullptr) {
3735
LOG(ERROR, "Initialization failed, p_terrain is null");
3836
return;
3937
}
4038
LOG(INFO, "Initializing storage");
39+
bool initialized = _terrain != nullptr;
40+
_terrain = p_terrain;
4141
_region_map.resize(REGION_MAP_SIZE * REGION_MAP_SIZE);
4242
_mesh_vertex_spacing = _terrain->get_mesh_vertex_spacing();
43-
if (!_terrain->get_storage_directory().is_empty()) {
43+
if (!initialized && !_terrain->get_storage_directory().is_empty()) {
4444
load_directory(_terrain->get_storage_directory());
4545
}
4646
}

0 commit comments

Comments
 (0)