mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-26 22:57:00 +02:00
Improved zone sizes for two-level maps.
This commit is contained in:
parent
7ac3713d32
commit
afaf74a05b
@ -68,7 +68,7 @@ void CZonePlacer::placeZones(const CMapGenOptions * mapGenOptions, CRandomGenera
|
|||||||
TRmgTemplateZoneId firstZone = zones.begin()->first; //we want lowest ID here
|
TRmgTemplateZoneId firstZone = zones.begin()->first; //we want lowest ID here
|
||||||
bool undergroundFlag = false;
|
bool undergroundFlag = false;
|
||||||
|
|
||||||
float totalSize = 0;
|
std::vector<float> totalSize = { 0, 0 }; //make sure that sum of zone sizes on surface and uderground match size of the map
|
||||||
for (auto zone : zonesVector)
|
for (auto zone : zonesVector)
|
||||||
{
|
{
|
||||||
//even distribution for surface / underground zones. Surface zones always have priority.
|
//even distribution for surface / underground zones. Surface zones always have priority.
|
||||||
@ -86,17 +86,17 @@ void CZonePlacer::placeZones(const CMapGenOptions * mapGenOptions, CRandomGenera
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
totalSize += (zone.second->getSize() * zone.second->getSize());
|
totalSize[level] += (zone.second->getSize() * zone.second->getSize());
|
||||||
zone.second->setCenter (float3(rand->nextDouble(0.2, 0.8), rand->nextDouble(0.2, 0.8), level)); //start away from borders
|
zone.second->setCenter (float3(rand->nextDouble(0.2, 0.8), rand->nextDouble(0.2, 0.8), level)); //start away from borders
|
||||||
}
|
}
|
||||||
//prescale zones
|
//prescale zones
|
||||||
if (underground) //map is twice as big, so zones occupy only half of normal space
|
std::vector<float> prescaler = { 0, 0 };
|
||||||
totalSize /= 2;
|
for (int i = 0; i < 2; i++)
|
||||||
float prescaler = sqrt ((width * height) / (totalSize * 3.14f));
|
prescaler[i] = sqrt((width * height) / (totalSize[i] * 3.14f));
|
||||||
float mapSize = sqrt (width * height);
|
float mapSize = sqrt (width * height);
|
||||||
for (auto zone : zones)
|
for (auto zone : zones)
|
||||||
{
|
{
|
||||||
zone.second->setSize (zone.second->getSize() * prescaler);
|
zone.second->setSize (zone.second->getSize() * prescaler[zone.second->getCenter().z]);
|
||||||
}
|
}
|
||||||
|
|
||||||
//gravity-based algorithm. connected zones attract, intersceting zones and map boundaries push back
|
//gravity-based algorithm. connected zones attract, intersceting zones and map boundaries push back
|
||||||
|
Loading…
Reference in New Issue
Block a user