mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-26 03:52:01 +02:00
Tweaking parameters, cleanup
This commit is contained in:
parent
178f960533
commit
e6f0afd586
@ -27,7 +27,7 @@ VCMI_LIB_NAMESPACE_BEGIN
|
||||
class CRandomGenerator;
|
||||
|
||||
CZonePlacer::CZonePlacer(RmgMap & map)
|
||||
: width(0), height(0), scaleX(0), scaleY(0), mapSize(0),
|
||||
: width(0), height(0), mapSize(0),
|
||||
gravityConstant(1e-3f),
|
||||
stiffnessConstant(3e-3f),
|
||||
stifness(0),
|
||||
@ -803,22 +803,6 @@ void CZonePlacer::moveOneZone(TZoneMap& zones, TForceVector& totalForces, TDista
|
||||
|
||||
float CZonePlacer::metric (const int3 &A, const int3 &B) const
|
||||
{
|
||||
/*
|
||||
float dx = abs(A.x - B.x) * scaleX;
|
||||
float dy = abs(A.y - B.y) * scaleY;
|
||||
|
||||
/*
|
||||
1. Normal euclidean distance
|
||||
2. Sinus for extra curves
|
||||
3. Nonlinear mess for fuzzy edges
|
||||
*/
|
||||
|
||||
/*
|
||||
return dx * dx + dy * dy +
|
||||
5 * std::sin(dx * dy / 10) +
|
||||
25 * std::sin (std::sqrt(A.x * B.x) * (A.y - B.y) / 100 * (scaleX * scaleY));
|
||||
*/
|
||||
|
||||
return A.dist2dSQ(B);
|
||||
|
||||
}
|
||||
@ -830,9 +814,6 @@ void CZonePlacer::assignZones(CRandomGenerator * rand)
|
||||
auto width = map.getMapGenOptions().getWidth();
|
||||
auto height = map.getMapGenOptions().getHeight();
|
||||
|
||||
//scale to Medium map to ensure smooth results
|
||||
scaleX = 72.f / width;
|
||||
scaleY = 72.f / height;
|
||||
|
||||
auto zones = map.getZones();
|
||||
vstd::erase_if(zones, [](const std::pair<TRmgTemplateZoneId, std::shared_ptr<Zone>> & pr)
|
||||
@ -903,7 +884,6 @@ void CZonePlacer::assignZones(CRandomGenerator * rand)
|
||||
if(zone.second->area().empty())
|
||||
throw rmgException("Empty zone is generated, probably RMG template is inappropriate for map size");
|
||||
|
||||
// FIXME: Is 2. correct and doesn't break balance?
|
||||
moveZoneToCenterOfMass(zone.second);
|
||||
}
|
||||
|
||||
@ -912,7 +892,7 @@ void CZonePlacer::assignZones(CRandomGenerator * rand)
|
||||
|
||||
// Assign zones to closest Penrose vertex
|
||||
PenroseTiling penrose;
|
||||
auto vertices = penrose.generatePenroseTiling(zones.size(), rand);
|
||||
auto vertices = penrose.generatePenroseTiling(zones.size() / map.levels(), rand);
|
||||
|
||||
std::map<std::shared_ptr<Zone>, std::set<int3>> vertexMapping;
|
||||
|
||||
@ -928,15 +908,6 @@ void CZonePlacer::assignZones(CRandomGenerator * rand)
|
||||
vertexMapping[closestZone].insert(int3(vertex.x() * width, vertex.y() * height, closestZone->getPos().z)); //Closest vertex belongs to zone
|
||||
}
|
||||
|
||||
for (const auto & p : vertexMapping)
|
||||
{
|
||||
for (const auto vertex : p.second)
|
||||
{
|
||||
logGlobal->info("Zone %2d is assigned to vertex %s", p.first->getId(), vertex.toString());
|
||||
}
|
||||
logGlobal->info("Zone %2d has total of %d vertices", p.first->getId(), p.second.size());
|
||||
}
|
||||
|
||||
//Assign actual tiles to each zone using nonlinear norm for fine edges
|
||||
for (pos.z = 0; pos.z < levels; pos.z++)
|
||||
{
|
||||
|
@ -54,9 +54,7 @@ private:
|
||||
private:
|
||||
int width;
|
||||
int height;
|
||||
//metric coeficients
|
||||
float scaleX;
|
||||
float scaleY;
|
||||
//metric coeficient
|
||||
float mapSize;
|
||||
|
||||
float gravityConstant;
|
||||
|
@ -124,7 +124,7 @@ void PenroseTiling::split(Triangle& p, std::vector<Point2D>& points,
|
||||
|
||||
std::set<Point2D> PenroseTiling::generatePenroseTiling(size_t numZones, CRandomGenerator * rand)
|
||||
{
|
||||
float scale = 100.f / (numZones + 20);
|
||||
float scale = 100.f / (numZones * 1.5f + 20);
|
||||
float polyAngle = (2 * PI_CONSTANT) / POLY;
|
||||
|
||||
float randomAngle = rand->nextDouble(0, 2 * PI_CONSTANT);
|
||||
@ -143,14 +143,6 @@ std::set<Point2D> PenroseTiling::generatePenroseTiling(size_t numZones, CRandomG
|
||||
p.x(p.x() * scale * BASE_SIZE);
|
||||
}
|
||||
|
||||
// Scale square to window size
|
||||
/*
|
||||
for (auto& p : points)
|
||||
{
|
||||
p.x = (p.x / window_w) * window_h;
|
||||
}
|
||||
*/
|
||||
|
||||
std::set<Point2D> finalPoints;
|
||||
|
||||
for (uint32_t i = 0; i < POLY; i++)
|
||||
@ -162,21 +154,11 @@ std::set<Point2D> PenroseTiling::generatePenroseTiling(size_t numZones, CRandomG
|
||||
split(t, points, indices, DEPTH);
|
||||
}
|
||||
|
||||
/*
|
||||
//No difference for the number of points
|
||||
for (auto& p : points)
|
||||
{
|
||||
p = p + Point2D(0.5f, 0.5f); // Center in a square (0,1)
|
||||
}
|
||||
*/
|
||||
|
||||
vstd::copy_if(points, vstd::set_inserter(finalPoints), [](const Point2D point)
|
||||
{
|
||||
return vstd::isbetween(point.x(), 0.f, 1.0f) && vstd::isbetween(point.y(), 0.f, 1.0f);
|
||||
});
|
||||
|
||||
logGlobal->info("Number of points within unit square: %d", finalPoints.size());
|
||||
|
||||
return finalPoints;
|
||||
}
|
||||
|
||||
|
@ -14,7 +14,6 @@
|
||||
#include "../CRandomGenerator.h"
|
||||
#include <boost/geometry.hpp>
|
||||
#include <boost/geometry/geometries/point_xy.hpp>
|
||||
#include <boost/geometry/strategies/transform/matrix_transformers.hpp>
|
||||
|
||||
VCMI_LIB_NAMESPACE_BEGIN
|
||||
|
||||
@ -55,10 +54,9 @@ class PenroseTiling
|
||||
|
||||
public:
|
||||
const float PHI = 1.0 / ((1.0 + std::sqrt(5.0)) / 2);
|
||||
// TODO: Is that the number of symmetries?
|
||||
const uint32_t POLY = 10;
|
||||
const uint32_t POLY = 10; // Number of symmetries?
|
||||
|
||||
const float BASE_SIZE = 1.f;
|
||||
const float BASE_SIZE = 1.25f;
|
||||
const uint32_t DEPTH = 7; //Recursion depth
|
||||
|
||||
const bool P2 = false; // Tiling type
|
||||
|
Loading…
x
Reference in New Issue
Block a user