feat: procedural terrain generators with example script and bilingual tutorial docs - #53
Conversation
6755191 to
d0228f0
Compare
There was a problem hiding this comment.
🟡 Changes recommended
The new terrain generator implementations include several correctness issues (division-by-zero/NaN cases and a duplicated __all__ export) that should be addressed before merging.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
This PR adds a new bilingual (zh_CN/en) framework tutorial on build-time procedural height-field terrain generation, along with rendered screenshots, and introduces/extends the underlying terrain generator configs in motrix_env_core.config.scene (plus tests and a preview script) to support the documented workflows.
Changes:
- Added a new
motrix_env_core.config.scene.terrainmodule implementing multiple procedural terrain generators plus composition utilities (CompositeTerrainGeneratorCfg,TerrainRegionCfg,grid_terrain, etc.). - Extended
NoiseTerrainGeneratorCfgwith optional coarse sampling + bilinear interpolation (downsampled_scale) and added an end-to-end generator showcase script (examples/terrain_generate.py). - Added comprehensive generator contract/behavior tests and the bilingual tutorial pages + LFS-backed tutorial screenshots.
File summaries
| File | Description |
|---|---|
| motrix_envs/tests/test_scene_cfg.py | Adds unit tests for generator contracts, validation, determinism, and composition behavior. |
| motrix_env_core/src/motrix_env_core/config/scene/terrain.py | Introduces new build-time procedural terrain generator configs and composition helpers. |
| motrix_env_core/src/motrix_env_core/config/scene/asset.py | Extends NoiseTerrainGeneratorCfg with downsampled_scale and bilinear resizing helper. |
| motrix_env_core/src/motrix_env_core/config/scene/init.py | Re-exports the new terrain generator symbols from motrix_env_core.config.scene. |
| examples/terrain_generate.py | Adds a runnable preview + optional MotrixSim render path for generator outputs. |
| docs/source/zh_CN/user_guide/tutorial/building_envs/terrain.md | New zh_CN tutorial page describing the generator contract and built-in generators with screenshots. |
| docs/source/zh_CN/user_guide/tutorial/building_envs/index.md | Adds the new terrain tutorial page to the zh_CN tutorial navigation/toctree. |
| docs/source/en/user_guide/tutorial/building_envs/terrain.md | New English tutorial page mirroring zh_CN content with screenshots. |
| docs/source/en/user_guide/tutorial/building_envs/index.md | Adds the new terrain tutorial page to the English tutorial navigation/toctree. |
| docs/source/_static/images/tutorial/terrain/stairs_pyramid.jpg | Adds LFS-backed tutorial screenshot asset. |
| docs/source/_static/images/tutorial/terrain/stairs_inverted_pyramid.jpg | Adds LFS-backed tutorial screenshot asset. |
| docs/source/_static/images/tutorial/terrain/stairs_ascending.jpg | Adds LFS-backed tutorial screenshot asset. |
| docs/source/_static/images/tutorial/terrain/slope_compare.jpg | Adds LFS-backed tutorial screenshot asset. |
| docs/source/_static/images/tutorial/terrain/obstacles_choice.jpg | Adds LFS-backed tutorial screenshot asset. |
| docs/source/_static/images/tutorial/terrain/noise_terraced.jpg | Adds LFS-backed tutorial screenshot asset. |
| docs/source/_static/images/tutorial/terrain/noise_smooth.jpg | Adds LFS-backed tutorial screenshot asset. |
| docs/source/_static/images/tutorial/terrain/noise_rough.jpg | Adds LFS-backed tutorial screenshot asset. |
| docs/source/_static/images/tutorial/terrain/grid.jpg | Adds LFS-backed tutorial screenshot asset. |
| docs/source/_static/images/tutorial/terrain/composite.jpg | Adds LFS-backed tutorial screenshot asset. |
Review details
Suppressed comments (1)
motrix_env_core/src/motrix_env_core/config/scene/terrain.py:186
- _apply_platform() uses min(size) to convert platform_width (meters) into a fractional mask even in linear axis modes. For rectangular terrains this makes the platform band width incorrect; use the same axis-aligned extent as in generate() for linear modes.
platform_half_frac = (self.platform_width / 2.0) / min(size)
if self.axis == "radial":
- Files reviewed: 19/19 changed files
- Comments generated: 5
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
…, and composition
d0228f0 to
1b83034
Compare
|
Copilot review 反馈已在 1b83034 修复:
124 个测试通过, |

Summary
motrix_env_core/config/scene/terrain.py):Stairs(线性/径向,四种 profile、固定踏面、中心平台、base_level)、DiscreteObstacles(fixed/choice)、PyramidSlope(含反转)、Quantized 台地化,以及组合地形CompositeTerrainGeneratorCfg/TerrainRegionCfg/grid_terrain;物理高度在组合时守恒,validate()拒绝超出height_scale的配置examples/terrain_generate.py:展示每种生成器与组合布局,打印高度统计、保存灰度高度图,--render打开查看器docs/source/{zh_CN,en}/user_guide/tutorial/building_envs/terrain.md),加入两侧 toctree 与阅读路径;覆盖生成器契约、各生成器字段、组合地形、环境中替换 scene 的模式、sample_terrain_height运行时采样、自定义生成器docs/source/_static/images/tutorial/terrain/,JPEG 共约 640 KB)Validation
python -m pytest:地形相关 31 个用例通过prek run --all-files全部 hook 通过sphinx-build -W --keep-going严格构建通过;构建产物中 10 张插图与图注逐一确认