game: fix selection when not in natural terrain mode

This commit is contained in:
Crypto City 2023-03-13 18:49:27 +00:00
parent b93a764100
commit f3a7f643ad

View File

@ -2407,14 +2407,22 @@ void CityMeshSection::ConfigureGroundShader()
else if (groundMode[0] == GroundNeutral)
{
ResourceCache* cache = node->GetSubsystem<ResourceCache>();
groundMaterial = cache->GetResource<Material>("Materials/TownforgeTerrainNeutral.xml")->Clone();
groundMaterial->SetTexture(TU_DIFFUSE, terrainTexture.Get());
if (!groundMaterial || groundMaterial->GetName() != "Materials/TownforgeTerrainNeutral.xml")
{
groundMaterial = cache->GetResource<Material>("Materials/TownforgeTerrainNeutral.xml")->Clone("Materials/TownforgeTerrainNeutral.xml");
groundMaterial->SetTexture(TU_DIFFUSE, terrainTexture.Get());
forceHighlightRefresh = true;
}
}
else
{
ResourceCache* cache = node->GetSubsystem<ResourceCache>();
groundMaterial = cache->GetResource<Material>("Materials/Potential.xml")->Clone();
groundMaterial->SetTexture(TU_DIFFUSE, terrainTexture.Get());
if (!groundMaterial || groundMaterial->GetName() != "Materials/Potential.xml")
{
groundMaterial = cache->GetResource<Material>("Materials/Potential.xml")->Clone("Materials/Potential.xml");
groundMaterial->SetTexture(TU_DIFFUSE, terrainTexture.Get());
forceHighlightRefresh = true;
}
}
if (groundObject)
groundObject->SetMaterial(groundMaterial);
@ -2431,13 +2439,14 @@ void CityMeshSection::SetTemperature(float temperature, float temperature_altitu
this->temperature_altitude_floor = temperature_altitude_floor;
this->temperature_altitude_decrease = temperature_altitude_decrease;
ConfigureGroundShader();
if (groundMode[0] == GroundNatural && terrain && groundMaterial)
{
const float max_height = (max_terrain_height + HEIGHT_UNITS_PER_BLOCK - 1) / HEIGHT_UNITS_PER_BLOCK;
const float temperature_modifier = cc::get_base_height_temperature_modifier(max_height) / 10.0f;
const float min_temperature = temperature + temperature_modifier;
snow_possible = min_temperature < groundMaterial->GetShaderParameter("SnowinessMaxTemperature").GetFloat();
ConfigureGroundShader();
}
// ConfigureGroundShader might have earlied out so make sure we update these here