From 9cdb5f02ecec347fc90ee593f4403b4ae4733165 Mon Sep 17 00:00:00 2001 From: Egor Zelenkov Date: Sat, 16 Mar 2024 06:17:32 +0000 Subject: [PATCH] Backward compatibility fixes (#818) --- Editor/TerrainWindow.cpp | 22 ++++++++++++++-------- Editor/TerrainWindow.h | 2 +- WickedEngine/wiTerrain.cpp | 18 ++++++++++++------ 3 files changed, 27 insertions(+), 15 deletions(-) diff --git a/Editor/TerrainWindow.cpp b/Editor/TerrainWindow.cpp index bd6892a8e..8d640a8d0 100644 --- a/Editor/TerrainWindow.cpp +++ b/Editor/TerrainWindow.cpp @@ -509,13 +509,8 @@ PropsWindow::PropsWindow(EditorComponent* editor) SetSize(XMFLOAT2(420, 332)); } -void PropsWindow::SetTerrain(wi::terrain::Terrain* t) +void PropsWindow::Rebuild() { - terrain = t; - generation_callback = [&] { - terrain->Generation_Restart(); - }; - for(auto& window : windows) { RemoveWidget(window.get()); @@ -524,6 +519,15 @@ void PropsWindow::SetTerrain(wi::terrain::Terrain* t) windows.clear(); windows_to_remove.clear(); + if(terrain == nullptr) + { + return; + } + + generation_callback = [&] { + terrain->Generation_Restart(); + }; + for(auto i = terrain->props.begin(); i != terrain->props.end(); ++i) { AddWindow(*i); @@ -549,7 +553,7 @@ void PropsWindow::Update(const wi::Canvas& canvas, float dt) if(windows.size() != terrain->props.size()) { // recreate all windows - SetTerrain(terrain); + Rebuild(); } else { @@ -1281,6 +1285,8 @@ void TerrainWindow::SetEntity(Entity entity) terrain = &terrain_preset; } + propsWindow->terrain = terrain; + if (this->entity == entity) return; @@ -1371,7 +1377,7 @@ void TerrainWindow::SetEntity(Entity entity) } } - propsWindow->SetTerrain(terrain); + propsWindow->Rebuild(); } void TerrainWindow::AddModifier(ModifierWindow* modifier_window) { diff --git a/Editor/TerrainWindow.h b/Editor/TerrainWindow.h index c9408f762..0afcb856c 100644 --- a/Editor/TerrainWindow.h +++ b/Editor/TerrainWindow.h @@ -77,7 +77,7 @@ struct PropsWindow : public wi::gui::Window PropsWindow(EditorComponent* editor); - void SetTerrain(wi::terrain::Terrain*); + void Rebuild(); void AddWindow(wi::terrain::Prop& prop); void Update(const wi::Canvas& canvas, float dt) override; diff --git a/WickedEngine/wiTerrain.cpp b/WickedEngine/wiTerrain.cpp index 643ef5fe9..fa1d4a52e 100644 --- a/WickedEngine/wiTerrain.cpp +++ b/WickedEngine/wiTerrain.cpp @@ -635,6 +635,11 @@ namespace wi::terrain return; } + if (chunkGroupEntity == INVALID_ENTITY) + { + chunkGroupEntity = terrainEntity; + } + WeatherComponent* weather_component = scene->weathers.GetComponent(terrainEntity); if (weather_component != nullptr) { @@ -2116,18 +2121,19 @@ namespace wi::terrain materialEntities[MATERIAL_HIGH_ALTITUDE] = CreateEntity(); grassEntity = CreateEntity(); - seri.remap[materialEntities[MATERIAL_BASE]] = materialEntities[MATERIAL_BASE]; - seri.remap[materialEntities[MATERIAL_SLOPE]] = materialEntities[MATERIAL_SLOPE]; - seri.remap[materialEntities[MATERIAL_LOW_ALTITUDE]] = materialEntities[MATERIAL_LOW_ALTITUDE]; - seri.remap[materialEntities[MATERIAL_HIGH_ALTITUDE]] = materialEntities[MATERIAL_HIGH_ALTITUDE]; - seri.remap[grassEntity] = grassEntity; - ComponentManager* scene_materials = library.Get("wi::scene::Scene::materials"); scene_materials->Create(materialEntities[MATERIAL_BASE]) = materials[MATERIAL_BASE]; scene_materials->Create(materialEntities[MATERIAL_SLOPE]) = materials[MATERIAL_SLOPE]; scene_materials->Create(materialEntities[MATERIAL_LOW_ALTITUDE]) = materials[MATERIAL_LOW_ALTITUDE]; scene_materials->Create(materialEntities[MATERIAL_HIGH_ALTITUDE]) = materials[MATERIAL_HIGH_ALTITUDE]; scene_materials->Create(grassEntity) = grass_material; + + ComponentManager* scene_names = library.Get("wi::scene::Scene::names"); + scene_names->Create(materialEntities[MATERIAL_BASE]).name = "material_base"; + scene_names->Create(materialEntities[MATERIAL_SLOPE]).name = "material_slope"; + scene_names->Create(materialEntities[MATERIAL_LOW_ALTITUDE]).name = "material_low_altitude"; + scene_names->Create(materialEntities[MATERIAL_HIGH_ALTITUDE]).name = "material_high_altitude"; + scene_names->Create(grassEntity).name = "grass"; } seri.version = weather_version;