mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Converts the landmap to use MultiPolygon instead of a collection of polygons, since Shapely has explicit support for this. Because we've done that, we can use a single projection from a line instead of brute forcing the extent of the front line. This makes turn processing ~66% faster (3 seconds to 1.8). There are probably other places this should be used.
38 lines
1.3 KiB
Python
38 lines
1.3 KiB
Python
import pickle
|
|
|
|
from dcs.mission import Mission
|
|
from shapely import geometry
|
|
from shapely.geometry import MultiPolygon
|
|
|
|
from game.theater.landmap import Landmap
|
|
|
|
for terrain in ["cau", "nev", "syria", "channel", "normandy", "gulf"]:
|
|
print("Terrain " + terrain)
|
|
m = Mission()
|
|
m.load_file("./{}_terrain.miz".format(terrain))
|
|
|
|
inclusion_zones = []
|
|
exclusion_zones = []
|
|
seas_zones = []
|
|
for plane_group in m.country("USA").plane_group:
|
|
zone = [(x.position.x, x.position.y) for x in plane_group.points]
|
|
|
|
if terrain == "cau" and inclusion_zones:
|
|
# legacy
|
|
exclusion_zones.append(geometry.Polygon(zone))
|
|
else:
|
|
if plane_group.units[0].type == "F-15C":
|
|
exclusion_zones.append(geometry.Polygon(zone))
|
|
else:
|
|
inclusion_zones.append(geometry.Polygon(zone))
|
|
|
|
for ship_group in m.country("USA").ship_group:
|
|
zone = [(x.position.x, x.position.y) for x in ship_group.points]
|
|
seas_zones.append(geometry.Polygon(zone))
|
|
|
|
with open("../{}landmap.p".format(terrain), "wb") as f:
|
|
print(len(inclusion_zones), len(exclusion_zones), len(seas_zones))
|
|
pickle.dump(Landmap(MultiPolygon(inclusion_zones),
|
|
MultiPolygon(exclusion_zones),
|
|
MultiPolygon(seas_zones)), f)
|