mirror of
https://github.com/vcmi/vcmi.git
synced 2025-08-13 19:54:17 +02:00
Randomize starting positions a bit so zones don't fall exactly on the grid.
(cherry picked from commit 33eb28b570
)
This commit is contained in:
@@ -276,10 +276,10 @@ void CZonePlacer::placeOnGrid(CRandomGenerator* rand)
|
|||||||
if (zone)
|
if (zone)
|
||||||
{
|
{
|
||||||
//i.e. for grid size 5 we get range (0.5 - 4.5)
|
//i.e. for grid size 5 we get range (0.5 - 4.5)
|
||||||
auto targetX = rand->nextDouble(x + 0.5f, x + 0.5f);
|
auto targetX = rand->nextDouble(x + 0.25f, x + 0.75f);
|
||||||
std::clamp(targetX, 0.5, gridSize - 0.5);
|
vstd::abetween(targetX, 0.5, gridSize - 0.5);
|
||||||
auto targetY = rand->nextDouble(y + 0.5f, y + 0.5f);
|
auto targetY = rand->nextDouble(y + 0.25f, y + 0.75f);
|
||||||
std::clamp(targetY, 0.5, gridSize - 0.5);
|
vstd::abetween(targetY, 0.5, gridSize - 0.5);
|
||||||
|
|
||||||
zone->setCenter(float3(targetX / gridSize, targetY / gridSize, zone->getPos().z));
|
zone->setCenter(float3(targetX / gridSize, targetY / gridSize, zone->getPos().z));
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user