Tune CGA tier/bay budget and lean LOD2 hulls under 16 MiB
This commit is contained in:
parent
394e44369d
commit
53e88ac2d7
1 changed files with 26 additions and 21 deletions
|
|
@ -764,18 +764,18 @@ def _build_wall_bay_geometry(
|
||||||
return col_parts, col_parts, False
|
return col_parts, col_parts, False
|
||||||
|
|
||||||
# Compute window openings within [0..bay_len] x [0..h]
|
# Compute window openings within [0..bay_len] x [0..h]
|
||||||
# Keep 1-2 crisp windows per bay to hold <= 16 MiB RCGA city budget
|
# Keep 1 window on normal bays (2 on wide >=8.5m facades) to hold <= 16 MiB RCGA city budget
|
||||||
if micro_zone == MICRO_FORTRESS:
|
if micro_zone == MICRO_FORTRESS:
|
||||||
n_win = 1 if bay_len < 6.0 else 2
|
n_win = 1 if bay_len < 8.5 else 2
|
||||||
win_w = min(0.68, (bay_len - 1.0) / n_win * 0.42)
|
win_w = min(0.75, (bay_len - 1.0) / n_win * 0.36)
|
||||||
win_h = min(1.75, h * 0.56)
|
win_h = min(1.75, h * 0.56)
|
||||||
elif micro_zone == MICRO_RONQUOZ:
|
elif micro_zone == MICRO_RONQUOZ:
|
||||||
n_win = 1 if bay_len < 7.5 else 2
|
n_win = 1 if bay_len < 10.5 else 2
|
||||||
win_w = min(2.40, (bay_len - 1.2) / n_win * 0.62)
|
win_w = min(2.40, (bay_len - 1.2) / n_win * 0.55)
|
||||||
win_h = min(1.25, h * 0.40)
|
win_h = min(1.25, h * 0.40)
|
||||||
else:
|
else:
|
||||||
n_win = 1 if bay_len < 5.2 else 2
|
n_win = 1 if bay_len < 8.5 else 2
|
||||||
win_w = min(1.12, (bay_len - 0.9) / n_win * 0.46)
|
win_w = min(1.25, (bay_len - 0.9) / n_win * 0.42)
|
||||||
win_h = min(1.42, h * 0.52)
|
win_h = min(1.42, h * 0.52)
|
||||||
|
|
||||||
if win_w < 0.50 or win_h < 0.70:
|
if win_w < 0.50 or win_h < 0.70:
|
||||||
|
|
@ -1008,7 +1008,7 @@ def build_cga_building(
|
||||||
micro_zone, arch_style = classify_sion_micro_zone(objektart, name, pts_enz, r_rtd, raw_min_y, raw_max_y)
|
micro_zone, arch_style = classify_sion_micro_zone(objektart, name, pts_enz, r_rtd, raw_min_y, raw_max_y)
|
||||||
pal = _choose_building_palette(b_hash, micro_zone, objektart)
|
pal = _choose_building_palette(b_hash, micro_zone, objektart)
|
||||||
|
|
||||||
simplify_tol = 0.25 if micro_zone in (MICRO_FORTRESS, MICRO_OLD_TOWN) else 0.55
|
simplify_tol = 0.32 if micro_zone in (MICRO_FORTRESS, MICRO_OLD_TOWN) else 0.70
|
||||||
footprints = _extract_footprint_polygons(fl_rtd, w_rtd, r_rtd, s_rtd, simplify_tol=simplify_tol)
|
footprints = _extract_footprint_polygons(fl_rtd, w_rtd, r_rtd, s_rtd, simplify_tol=simplify_tol)
|
||||||
if not footprints:
|
if not footprints:
|
||||||
xmin, zmin = float(all_pts[:, 0].min()), float(all_pts[:, 2].min())
|
xmin, zmin = float(all_pts[:, 0].min()), float(all_pts[:, 2].min())
|
||||||
|
|
@ -1101,7 +1101,9 @@ def build_cga_building(
|
||||||
return Polygon(ext, holes)
|
return Polygon(ext, holes)
|
||||||
|
|
||||||
# 1. Zone 0: Plinth / Foundation (IsGroundAnchored = true)
|
# 1. Zone 0: Plinth / Foundation (IsGroundAnchored = true)
|
||||||
plinth_uv = fp_to_uv(primary_fp)
|
plinth_fp = primary_fp.simplify(0.85, preserve_topology=True)
|
||||||
|
plinth_fp = _clean_polygon_2d(plinth_fp if isinstance(plinth_fp, Polygon) else primary_fp, min_area=0.8) or primary_fp
|
||||||
|
plinth_uv = fp_to_uv(plinth_fp)
|
||||||
plinth_parts = extrude_2d_poly_prism(
|
plinth_parts = extrude_2d_poly_prism(
|
||||||
np.array([0.0, plinth_bot_y, 0.0]), u_xz, v_xz, n_up, plinth_uv,
|
np.array([0.0, plinth_bot_y, 0.0]), u_xz, v_xz, n_up, plinth_uv,
|
||||||
0.0, plinth_top_y - plinth_bot_y,
|
0.0, plinth_top_y - plinth_bot_y,
|
||||||
|
|
@ -1119,9 +1121,12 @@ def build_cga_building(
|
||||||
is_canopy_only = (len(w_rtd) == 0 and wall_h > 1.2) or objektart in ("Flugdach",)
|
is_canopy_only = (len(w_rtd) == 0 and wall_h > 1.2) or objektart in ("Flugdach",)
|
||||||
is_mauer = (objektart == "Mauer gross")
|
is_mauer = (objektart == "Mauer gross")
|
||||||
|
|
||||||
# Build lean watertight LOD2 silhouette (single simplified prism + roof cap) for 620..2200m GLB
|
# Build lean watertight LOD2 silhouette (single simplified prism) for 620..2200m GLB
|
||||||
lod2_fp = primary_fp.simplify(0.85, preserve_topology=True)
|
lod2_tol = 1.1 if primary_fp.area > 35.0 else 1.8
|
||||||
|
lod2_fp = primary_fp.simplify(lod2_tol, preserve_topology=True)
|
||||||
lod2_fp = _clean_polygon_2d(lod2_fp if isinstance(lod2_fp, Polygon) else primary_fp, min_area=0.5) or primary_fp
|
lod2_fp = _clean_polygon_2d(lod2_fp if isinstance(lod2_fp, Polygon) else primary_fp, min_area=0.5) or primary_fp
|
||||||
|
if len(lod2_fp.exterior.coords) > 9:
|
||||||
|
lod2_fp = box(*lod2_fp.bounds)
|
||||||
lod2_uv = Polygon([(x, -z) for x, z in lod2_fp.exterior.coords])
|
lod2_uv = Polygon([(x, -z) for x, z in lod2_fp.exterior.coords])
|
||||||
lod2_h = max(1.2, max(eave_y, raw_max_y) - plinth_bot_y)
|
lod2_h = max(1.2, max(eave_y, raw_max_y) - plinth_bot_y)
|
||||||
lod2_t, lod2_m, _, _ = extrude_2d_poly_prism(
|
lod2_t, lod2_m, _, _ = extrude_2d_poly_prism(
|
||||||
|
|
@ -1180,20 +1185,20 @@ def build_cga_building(
|
||||||
}[micro_zone]
|
}[micro_zone]
|
||||||
|
|
||||||
n_stories = max(1, int(round(wall_h / story_h_target)))
|
n_stories = max(1, int(round(wall_h / story_h_target)))
|
||||||
min_edge = 2.0 if micro_zone in (MICRO_OLD_TOWN, MICRO_FORTRESS) else 3.0
|
min_edge = 2.6 if micro_zone in (MICRO_OLD_TOWN, MICRO_FORTRESS) else 3.8
|
||||||
ext_pts = _merge_short_ring_edges(list(primary_fp.exterior.coords), min_edge_len=min_edge)
|
ext_pts = _merge_short_ring_edges(list(primary_fp.exterior.coords), min_edge_len=min_edge)
|
||||||
raw_bays_len = max(3, len(ext_pts))
|
raw_bays_len = max(3, len(ext_pts))
|
||||||
|
|
||||||
# Cap structural tiers cleanly so total city RCGA + LOD2 fits well <= 16 MiB
|
# Cap structural tiers cleanly so total city RCGA + LOD2 fits well <= 16 MiB
|
||||||
avail_for_stories = MAX_ZONES_PER_BUILDING - (2 + n_roofs)
|
avail_for_stories = MAX_ZONES_PER_BUILDING - (2 + n_roofs)
|
||||||
max_tiers = 5 if n_stories >= 8 else (4 if micro_zone in (MICRO_OLD_TOWN, MICRO_FORTRESS) else 3)
|
max_tiers = 4 if n_stories >= 7 else (3 if micro_zone in (MICRO_OLD_TOWN, MICRO_FORTRESS) else 2)
|
||||||
n_tiers = min(n_stories, max_tiers, max(1, avail_for_stories // max(4, min(raw_bays_len + 1, 10))))
|
n_tiers = min(n_stories, max_tiers, max(1, avail_for_stories // max(4, min(raw_bays_len + 1, 8))))
|
||||||
n_tiers = max(1, n_tiers)
|
n_tiers = max(1, n_tiers)
|
||||||
|
|
||||||
max_bays_per_tier = max(3, min(10, (avail_for_stories // n_tiers) - 1))
|
max_bays_per_tier = max(3, min(8, (avail_for_stories // n_tiers) - 1))
|
||||||
|
|
||||||
perim = float(primary_fp.exterior.length)
|
perim = float(primary_fp.exterior.length)
|
||||||
base_bay_len = 9.0 if micro_zone in (MICRO_OLD_TOWN, MICRO_FORTRESS) else (14.0 if (is_mauer or micro_zone == MICRO_RONQUOZ or perim > 70.0) else 11.5)
|
base_bay_len = 11.0 if micro_zone in (MICRO_OLD_TOWN, MICRO_FORTRESS) else (16.0 if (is_mauer or micro_zone == MICRO_RONQUOZ or perim > 70.0) else 14.0)
|
||||||
bays_2d: list[tuple[np.ndarray, np.ndarray, float]] = []
|
bays_2d: list[tuple[np.ndarray, np.ndarray, float]] = []
|
||||||
for mult in (1.0, 1.4, 2.0, 3.0, 5.0, 10.0):
|
for mult in (1.0, 1.4, 2.0, 3.0, 5.0, 10.0):
|
||||||
cand = _split_ring_into_wall_bays(ext_pts, base_bay_len * mult)
|
cand = _split_ring_into_wall_bays(ext_pts, base_bay_len * mult)
|
||||||
|
|
@ -1201,9 +1206,9 @@ def build_cga_building(
|
||||||
bays_2d = cand
|
bays_2d = cand
|
||||||
break
|
break
|
||||||
if not bays_2d:
|
if not bays_2d:
|
||||||
simple_fp = primary_fp.simplify(max(0.6, perim * 0.03), preserve_topology=True)
|
simple_fp = primary_fp.simplify(max(0.8, perim * 0.04), preserve_topology=True)
|
||||||
if isinstance(simple_fp, Polygon) and not simple_fp.is_empty:
|
if isinstance(simple_fp, Polygon) and not simple_fp.is_empty:
|
||||||
ext_pts = _merge_short_ring_edges(list(simple_fp.exterior.coords), min_edge_len=2.6)
|
ext_pts = _merge_short_ring_edges(list(simple_fp.exterior.coords), min_edge_len=3.2)
|
||||||
cand = _split_ring_into_wall_bays(ext_pts, max(base_bay_len, perim / max(3, max_bays_per_tier)))
|
cand = _split_ring_into_wall_bays(ext_pts, max(base_bay_len, perim / max(3, max_bays_per_tier)))
|
||||||
if len(cand) <= max_bays_per_tier:
|
if len(cand) <= max_bays_per_tier:
|
||||||
bays_2d = cand
|
bays_2d = cand
|
||||||
|
|
@ -1231,7 +1236,7 @@ def build_cga_building(
|
||||||
slab_fp = primary_fp.buffer(-slab_inset, join_style="mitre")
|
slab_fp = primary_fp.buffer(-slab_inset, join_style="mitre")
|
||||||
if not isinstance(slab_fp, Polygon) or slab_fp.is_empty or slab_fp.area < 0.8:
|
if not isinstance(slab_fp, Polygon) or slab_fp.is_empty or slab_fp.area < 0.8:
|
||||||
slab_fp = primary_fp
|
slab_fp = primary_fp
|
||||||
slab_fp_s = slab_fp.simplify(0.60, preserve_topology=True)
|
slab_fp_s = slab_fp.simplify(0.95, preserve_topology=True)
|
||||||
if isinstance(slab_fp_s, Polygon) and not slab_fp_s.is_empty and slab_fp_s.area >= 0.8:
|
if isinstance(slab_fp_s, Polygon) and not slab_fp_s.is_empty and slab_fp_s.area >= 0.8:
|
||||||
slab_fp = slab_fp_s
|
slab_fp = slab_fp_s
|
||||||
slab_uv = fp_to_uv(slab_fp)
|
slab_uv = fp_to_uv(slab_fp)
|
||||||
|
|
@ -1242,7 +1247,7 @@ def build_cga_building(
|
||||||
prev_bay_mids: list[np.ndarray] = []
|
prev_bay_mids: list[np.ndarray] = []
|
||||||
all_tier_supports_mask = plinth_bit | core_bit
|
all_tier_supports_mask = plinth_bit | core_bit
|
||||||
|
|
||||||
hero_zone = micro_zone in (MICRO_OLD_TOWN, MICRO_FORTRESS, MICRO_CIVIC, MICRO_VISSIGEN)
|
hero_zone = micro_zone in (MICRO_OLD_TOWN, MICRO_FORTRESS, MICRO_CIVIC)
|
||||||
|
|
||||||
for t_idx in range(n_tiers):
|
for t_idx in range(n_tiers):
|
||||||
y0 = plinth_top_y + t_idx * tier_h
|
y0 = plinth_top_y + t_idx * tier_h
|
||||||
|
|
@ -1257,7 +1262,7 @@ def build_cga_building(
|
||||||
if len(zones) >= MAX_ZONES_PER_BUILDING - n_roofs - 1:
|
if len(zones) >= MAX_ZONES_PER_BUILDING - n_roofs - 1:
|
||||||
break
|
break
|
||||||
want_win = (not is_mauer) and (
|
want_win = (not is_mauer) and (
|
||||||
(hero_zone and blen >= 2.8) or (blen >= 3.6 and (b_i % 2 == 0))
|
(hero_zone and blen >= 3.0) or (blen >= 4.0 and (b_i % 2 == 0) and t_idx == 0)
|
||||||
)
|
)
|
||||||
r_parts, c_parts, has_win = _build_wall_bay_geometry(
|
r_parts, c_parts, has_win = _build_wall_bay_geometry(
|
||||||
sa, sb, blen, y0, bay_y_top, wall_thick, pal, micro_zone,
|
sa, sb, blen, y0, bay_y_top, wall_thick, pal, micro_zone,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue