Skip to content

feat: procedural terrain generators with example script and bilingual tutorial docs - #53

Merged
wlgys8 merged 1 commit into
mainfrom
feat/procedural-terrain-composition
Sep 17, 2026
Merged

wlgys8 merged 1 commit into
mainfrom
feat/procedural-terrain-composition

Conversation

@wlgys8

@wlgys8 wlgys8 commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

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 运行时采样、自定义生成器
  • 10 张离屏渲染截图(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 张插图与图注逐一确认
  • 文档数值声明(height_scale、校验上限、字段语义)对照实现逐项复核,中英一致

@wlgys8

wlgys8 commented Sep 17, 2026

Copy link
Copy Markdown
Contributor Author

组合地形(CompositeTerrainGeneratorCfg:噪声台地基底 + 径向台阶、反转金字塔坑、离散障碍物、金字塔坡)效果图:

composite terrain

@wlgys8
wlgys8 force-pushed the feat/procedural-terrain-composition branch from 6755191 to d0228f0 Compare September 17, 2026 04:09
@wlgys8
wlgys8 requested a lite review from Copilot September 17, 2026 04:12
@wlgys8 wlgys8 changed the title docs: procedural terrain generation tutorial (zh_CN/en) with rendered screenshots feat: procedural terrain generators with example script and bilingual tutorial docs Sep 17, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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.terrain module implementing multiple procedural terrain generators plus composition utilities (CompositeTerrainGeneratorCfg, TerrainRegionCfg, grid_terrain, etc.).
  • Extended NoiseTerrainGeneratorCfg with 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.

Comment thread motrix_env_core/src/motrix_env_core/config/scene/terrain.py
Comment thread motrix_env_core/src/motrix_env_core/config/scene/terrain.py
Comment thread motrix_env_core/src/motrix_env_core/config/scene/terrain.py
Comment thread motrix_env_core/src/motrix_env_core/config/scene/terrain.py
Comment thread motrix_env_core/src/motrix_env_core/config/scene/__init__.py
@wlgys8
wlgys8 force-pushed the feat/procedural-terrain-composition branch from d0228f0 to 1b83034 Compare September 17, 2026 04:38
@wlgys8

wlgys8 commented Sep 17, 2026

Copy link
Copy Markdown
Contributor Author

Copilot review 反馈已在 1b83034 修复:

  1. 线性台阶在矩形场地上的 tread/platform 宽度:新增 _extent()——axis="x"size[0]axis="y"size[1]radial 保持 min(size)_index_from_distance_apply_platform 均改用轴向 extent。已在 12×4 m 矩形场上验证 step_width=1.0 恰好铺出 12 级、每级 1 m,y 方向恒定。
  2. height_scale=0 除零/NaN(obstacles/slope/composite 三处):在 TerrainGeneratorCfg.validate 统一要求 height_scale > 0,一处修复覆盖全部生成路径,并补充了 height_scale=0.0 的负向测试用例。
  3. __all__ 重复导出 TerrainGeneratorCfg:已去重。

124 个测试通过,prek run --all-files 全部 hook 通过。

@wlgys8
wlgys8 merged commit ae7cae0 into main Sep 17, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants