mirror of
https://github.com/vcmi/vcmi.git
synced 2025-04-17 11:56:46 +02:00
Improved zone placer - zones on different levels are allowed to overlap completely.
This commit is contained in:
parent
27974786e3
commit
fb3adf762a
@ -138,11 +138,18 @@ void CZonePlacer::placeZones(const CMapGenOptions * mapGenOptions, CRandomGenera
|
|||||||
auto otherZone = zones[con];
|
auto otherZone = zones[con];
|
||||||
float3 otherZoneCenter = otherZone->getCenter();
|
float3 otherZoneCenter = otherZone->getCenter();
|
||||||
float distance = pos.dist2d (otherZoneCenter);
|
float distance = pos.dist2d (otherZoneCenter);
|
||||||
float minDistance = (zone.second->getSize() + otherZone->getSize())/mapSize * zoneScale; //scale down to (0,1) coordinates
|
float minDistance = 0;
|
||||||
|
|
||||||
|
if (pos.z != otherZoneCenter.z)
|
||||||
|
minDistance = 0; //zones on different levels can overlap completely
|
||||||
|
else
|
||||||
|
minDistance = (zone.second->getSize() + otherZone->getSize()) / mapSize * zoneScale; //scale down to (0,1) coordinates
|
||||||
|
|
||||||
if (distance > minDistance)
|
if (distance > minDistance)
|
||||||
{
|
{
|
||||||
//WARNING: compiler used to 'optimize' that line so it never actually worked
|
//WARNING: compiler used to 'optimize' that line so it never actually worked
|
||||||
forceVector += (((otherZoneCenter - pos)*(pos.z == otherZoneCenter.z ? (minDistance/distance) : 1)/ getDistance(distance))) * gravityConstant; //positive value
|
float overlapMultiplier = (pos.z == otherZoneCenter.z) ? (minDistance / distance) : 1.0f;
|
||||||
|
forceVector += (((otherZoneCenter - pos)* overlapMultiplier / getDistance(distance))) * gravityConstant; //positive value
|
||||||
totalDistance += (distance - minDistance);
|
totalDistance += (distance - minDistance);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user