Skip to content

[BUG FIX] Raise on ambiguous morph access for heterogeneous entities#2798

Open
kunni918 wants to merge 1 commit into
Genesis-Embodied-AI:mainfrom
kunni918:fix/issue-2750-heterogeneous-morph
Open

[BUG FIX] Raise on ambiguous morph access for heterogeneous entities#2798
kunni918 wants to merge 1 commit into
Genesis-Embodied-AI:mainfrom
kunni918:fix/issue-2750-heterogeneous-morph

Conversation

@kunni918
Copy link
Copy Markdown

@kunni918 kunni918 commented May 17, 2026

Description

This PR makes .morph fail closed for heterogeneous entities created from multiple morph variants. Heterogeneous entities already expose .morphs for all variants and .main_morph for the first variant, so .morph should not silently return only the first morph in an order-dependent way.

The PR also updates internal paths that need non-throwing access:

  • Rasterizer Plane checks now use .main_morph when preserving the existing first-variant behavior.
  • ImGui overlay scene-rebuild capture stores tuple(entity.morphs) for heterogeneous entities so variants are not dropped.
  • Brief repr no longer probes .morph through hasattr, so repr(scene.entities) remains usable.

Related Issue

Resolves #2750

Motivation and Context

Accessing .morph on a heterogeneous entity previously returned only the first morph. That made calls such as .morph.size ambiguous and order-dependent when variants had different morph types or dimensions. A maintainer clarified in the issue that heterogeneous entities should be accessed through .morphs, and that .morph should raise in this case.

This keeps the fail-closed public API while moving known internal renderer, overlay, and repr paths to explicit .main_morph / .morphs access.

Per-variant floor/reflection semantics are intentionally out of scope for this PR; this PR preserves the existing first-morph renderer behavior while avoiding accidental .morph property calls.

How Has This Been / Can This Be Tested?

Tested locally with:

.venv/bin/python -m pytest -q \
  tests/test_rigid_physics.py::test_heterogeneous_morph_property_raises \
  tests/test_imgui_overlay.py::test_imgui_overlay_capture_pending_entities_preserves_heterogeneous_morphs \
  tests/test_render.py::test_rasterizer_context_heterogeneous_main_morph_no_throw

.venv/bin/python -m pytest tests/test_rigid_physics.py -q \
  -k 'heterogeneous and (invalid_material or morph_property or fewer_envs or mass_setters or aabb)'

.venv/bin/pre-commit run --files \
  genesis/engine/entities/rigid_entity/rigid_entity.py \
  genesis/repr_base.py \
  genesis/ext/pyrender/overlay/plugin.py \
  genesis/vis/rasterizer_context.py \
  tests/test_rigid_physics.py \
  tests/test_imgui_overlay.py \
  tests/test_render.py

The heterogeneous regression tests were run outside the sandbox because Quadrants writes compilation cache under ~/.cache/quadrants. I did not run the full test suite locally.

Screenshots (if appropriate):

N/A

Checklist:

  • I read the CONTRIBUTING document.

  • I followed the Submitting Code Changes section of CONTRIBUTING document.

  • I tagged the title correctly (including BUG FIX/FEATURE/MISC/BREAKING)

  • I updated the documentation accordingly or no change is needed.

  • I tested my changes and added instructions on how to test it for reviewers.

  • I have added tests to cover my changes.

  • All new and existing tests passed.

@kunni918 kunni918 marked this pull request as ready for review May 17, 2026 14:07
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 598ece81f3

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread genesis/engine/entities/rigid_entity/rigid_entity.py Outdated
@kunni918 kunni918 force-pushed the fix/issue-2750-heterogeneous-morph branch from 598ece8 to 917c0eb Compare May 18, 2026 14:40
@kunni918 kunni918 changed the title [BUG FIX] Raise when accessing morph on heterogeneous rigid entities [BUG FIX] Raise on ambiguous morph access for heterogeneous entities May 18, 2026
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.

[Bug]: Size of heterogeneous morphs

1 participant