[BUG FIX] Raise on ambiguous morph access for heterogeneous entities#2798
Open
kunni918 wants to merge 1 commit into
Open
[BUG FIX] Raise on ambiguous morph access for heterogeneous entities#2798kunni918 wants to merge 1 commit into
kunni918 wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
💡 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".
598ece8 to
917c0eb
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR makes
.morphfail closed for heterogeneous entities created from multiple morph variants. Heterogeneous entities already expose.morphsfor all variants and.main_morphfor the first variant, so.morphshould not silently return only the first morph in an order-dependent way.The PR also updates internal paths that need non-throwing access:
.main_morphwhen preserving the existing first-variant behavior.tuple(entity.morphs)for heterogeneous entities so variants are not dropped..morphthroughhasattr, sorepr(scene.entities)remains usable.Related Issue
Resolves #2750
Motivation and Context
Accessing
.morphon a heterogeneous entity previously returned only the first morph. That made calls such as.morph.sizeambiguous 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.morphshould raise in this case.This keeps the fail-closed public API while moving known internal renderer, overlay, and repr paths to explicit
.main_morph/.morphsaccess.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
.morphproperty 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.pyThe 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 Changessection 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.