Refactor road assembly module

This commit is contained in:
2026-08-03 13:39:05 +08:00
parent 64517993e9
commit 0f3c1ee635
12 changed files with 315 additions and 39 deletions

View File

@@ -38,7 +38,7 @@
│ osmassets/materials.py 材质构建(消费 catalog 的声明) │
│ osmassets/tree.py 树实例化 │
│ osmassets/water.py grass.py scrub.py │
│ osmassets/building.py fountain.py 要素装配
│ osmassets/building.py fountain.py roads.py 要素装配 │
│ │
│ generate_scene.py export_cesium.py 两个入口 │
│ tools/scene_digest.py 结构摘要工具 │
@@ -121,7 +121,7 @@
| 文件 | 行数 | 层 |
|---|---|---|
| `generate_scene.py` | 899 | bpy · 入口 |
| `generate_scene.py` | 869 | bpy · 入口 |
| `export_cesium.py` | 647 | bpy · 入口 |
| `osmassets/tree.py` | 318 | bpy |
| `osmassets/geom.py` | 241 | 纯 |
@@ -129,7 +129,7 @@
| `osmassets/catalog.py` | 197 | 纯 |
| `osmassets/mesh.py` | 126 | bpy |
| `osmassets/osm.py` | 89 | 纯 |
| `osmassets/building.py` / `fountain.py` | 56 / 49 | bpy |
| `osmassets/building.py` / `fountain.py` / `roads.py` | 56 / 49 / 40 | bpy |
| `osmassets/water.py` / `grass.py` / `scrub.py` | 15 / 22 / 13 | bpy |
| `tools/scene_digest.py` | 171 | bpy · 工具 |
| `tests/test_pure.py` | 372 | 纯 · 测试 |

View File

@@ -25,7 +25,7 @@
osmassets/materials.py 材质构建
osmassets/tree.py 树实例化
osmassets/water.py grass.py scrub.py
osmassets/building.py fountain.py 要素装配
osmassets/building.py fountain.py roads.py 要素装配
generate_scene.py export_cesium.py 两个入口脚本
tools/scene_digest.py 结构摘要工具
```
@@ -54,6 +54,7 @@
| `water.py` / `grass.py` / `scrub.py` | bpy | 单一 OSM 面要素的装配 |
| `building.py` | bpy | 单一 OSM 面要素 `building=*` 的装配 |
| `fountain.py` | bpy | 单一 OSM 点要素 `amenity=fountain` 的装配 |
| `roads.py` | bpy | osm2streets GeoJSON road layer 装配与 OSM highway 折线回退 |
### `geom.py` 的两条隐含约定
@@ -111,6 +112,18 @@ def assemble(ring, way_id, tag, office_overrides, collection, materials):
`counts["industrial_count"]`,以及写 `scene["office_override_way_ids"]`
模块只负责 prism / roof / windows / bevel / building custom properties。
`roads.py` 是 road layer 装配模块,不拥有图层表或计数:
```python
def assemble_geojson_layer(path, layer_id, projector, collection, material, z): ...
def assemble_osm_fallback(ways, projector, collection, material): ...
```
`generate_scene.py` 仍负责创建 `road_mats`、调用 `catalog.check_layers()` 并打印
`Layer catalog warning:`、遍历 `catalog.ROAD_LAYERS`、维护 `road_counts`,以及写
`scene["road_feature_counts"]` / `SCENE_DONE["road_features"]`。模块只负责把已选定的
GeoJSON layer 或 OSM fallback ways 变成 `Road_<layer_id>` / `OSM_Road_<way_id>` 对象。
### 加一种新 OSM 要素
目标形态:**新增一个模块 + 注册一行,不改 `build()`**。

View File

@@ -163,7 +163,7 @@ capturedAt / durationMs / label
|---|---|---|
| P0 | 抽纯函数到 `osmassets/{osm,geom}.py` | ✅ 已完成 |
| P1 | `catalog.py` 单一定义源 + `check_layers` | ✅ 已完成 |
| P2 | 要素注册表 | ⚠️ **部分**——`water/grass/scrub/tree/fountain/building.py` 已拆出,但**没有 `features/` 注册表**`roads` 仍在 `generate_scene.py` |
| P2 | 要素注册表 | ⚠️ **部分**——`water/grass/scrub/tree/fountain/building/roads.py` 已拆出,但**没有 `features/` 注册表** |
| P3 | 材质契约化(自定义属性传递 spec | ✅ 已完成——`catalog.MATERIALS[*]["cesium"]``materials.from_spec()` 写入 `material["cesium_export"]``export_cesium.py` 优先读该属性;四张材质名表仅作旧 `.blend` 回退 |
### 已知缺陷(记录在案,本轮不修)