Backward compatibility fixes (#818)
This commit is contained in:
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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<MaterialComponent>* scene_materials = library.Get<MaterialComponent>("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<NameComponent>* scene_names = library.Get<NameComponent>("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;
|
||||
|
||||
Reference in New Issue
Block a user