Proper town logic; needs lots of fixing

This commit is contained in:
Segey Lapin
2021-10-25 13:36:58 +03:00
parent aef8a11cc4
commit 6442245253
5 changed files with 92 additions and 28 deletions

View File

@@ -285,8 +285,8 @@ void RoadDiagram::process_diagram(const Dictionary &diagram)
RoadDiagram::RoadDiagram()
{
class_sizes[map_site::SITE_EMPTY] = 10000;
class_sizes[map_site::SITE_TOWN] = 100000;
class_sizes[map_site::SITE_FARM] = 500000;
class_sizes[map_site::SITE_FARM] = 100000;
class_sizes[map_site::SITE_TOWN] = 240000;
class_sizes[map_site::SITE_FOREST] = 1000000;
class_sizes[map_site::SITE_UNASSIGNED] = 2000000;
}
@@ -680,4 +680,40 @@ void RoadGrid::save_json(const String &path)
f->close();
}
}
PoolVector<Vector3> RoadGrid::get_site_border(int site)
{
const struct map_site &msite = map_sites[site];
List<struct vshape *> site_vshapes;
List<struct vshape *>::Element *e;
PoolVector<Vector3> ret;
int i, j;
for (i = 0; i < msite.polygon_ind.size(); i++) {
int p1 = i;
int p2 = (i + 1) % msite.polygon_ind.size();
int p3 = (i + 2) % msite.polygon_ind.size();
for (j = 0; j < vshapes.size(); j++) {
struct vshape &v = vshapes.write()[j];
if (v.site != site)
continue;
struct half_edge *hedge1 = map_hedges[v.e1];
struct half_edge *hedge2 = map_hedges[v.e2];
if (hedge1->a != p1 ||
hedge1->b != p2 || hedge2->b != p3)
continue;
site_vshapes.push_back(&v);
}
}
ret.resize(site_vshapes.size());
int count = 0;
for (e = site_vshapes.front(); e; e = e->next()) {
struct vshape *pv = e->get();
float l = pv->curve3->get_baked_length();
Vector3 bp = pv->curve3->interpolate_baked(l * 0.5f) + pv->p2;
ret.write()[count++] = bp;
}
printf("polygon count %d border count %d\n",
msite.polygon_ind.size(), ret.size());
assert(msite.polygon_ind.size() == ret.size());
return ret;
}