Refactor building assembly module

This commit is contained in:
2026-08-03 12:52:10 +08:00
parent bd392becb4
commit 032922ae99
12 changed files with 330 additions and 70 deletions

View File

@@ -24,7 +24,8 @@
osmassets/mesh.py MeshBatch、prism、polyline
osmassets/materials.py 材质构建
osmassets/tree.py 树实例化
osmassets/water.py grass.py scrub.py 要素装配
osmassets/water.py grass.py scrub.py
osmassets/building.py fountain.py 要素装配
generate_scene.py export_cesium.py 两个入口脚本
tools/scene_digest.py 结构摘要工具
```
@@ -51,6 +52,7 @@
| `materials.py` | bpy | 把 `catalog` 的规格变成真实材质:`from_spec()`、贴图、程序化噪声、tint、alpha-clip |
| `tree.py` | bpy | 两个 vendored 模型 → 一套可实例化的运行时形状 |
| `water.py` / `grass.py` / `scrub.py` | bpy | 单一 OSM 面要素的装配 |
| `building.py` | bpy | 单一 OSM 面要素 `building=*` 的装配 |
| `fountain.py` | bpy | 单一 OSM 点要素 `amenity=fountain` 的装配 |
### `geom.py` 的两条隐含约定
@@ -95,6 +97,20 @@ def assemble(name, x, y, collection, materials):
创建三张 fountain 材质,并维护 `counts["fountain_count"]`。模块只负责在已投影
坐标上创建 basin / water / pedestal / spray objects保持对象名和自定义属性不变。
`building.py` 是面要素模块,但不裁剪 ring入口在调用前已经过滤
`len(ring) >= 3`,并且建筑要保持原始 OSM footprint 参与相机取景:
```python
def assemble(ring, way_id, tag, office_overrides, collection, materials):
...
return added, industrial_added, ring_pts
```
`generate_scene.py` 仍负责解析 `--office-overrides`、创建六张 building 材质、
分发 `building=*` way、累加 `counts["building_count"]` /
`counts["industrial_count"]`,以及写 `scene["office_override_way_ids"]`
模块只负责 prism / roof / windows / bevel / building custom properties。
### 加一种新 OSM 要素
目标形态:**新增一个模块 + 注册一行,不改 `build()`**。
@@ -110,7 +126,7 @@ def assemble(name, x, y, collection, materials):
## 两个入口脚本
| | `generate_scene.py` (999行) | `export_cesium.py` (624行) |
| | `generate_scene.py` (899行) | `export_cesium.py` (647行) |
|---|---|---|
| 调用 | `--background --factory-startup --python` | `--background --python` |
| 输入 | `--osm` + `--geojson` | `--blend` |