Skip to content

Applies world scale to mesh transformation correctly in MeshRayCaster#4700

Open
Mayankm96 wants to merge 1 commit intomainfrom
fix/scale-ray-caster
Open

Applies world scale to mesh transformation correctly in MeshRayCaster#4700
Mayankm96 wants to merge 1 commit intomainfrom
fix/scale-ray-caster

Conversation

@Mayankm96
Copy link
Contributor

@Mayankm96 Mayankm96 commented Feb 23, 2026

Description

Previously, the transforms were applied in the order (scale, transform, rotate). However, in Isaac Sim, the correct transformation order is (transform, rotate, scale). This MR fixes this issue by applying scale later.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Checklist

  • I have read and understood the contribution guidelines
  • I have run the pre-commit checks with ./isaaclab.sh --format
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • I have updated the changelog and the corresponding version in the extension's config/extension.toml file
  • I have added my name to the CONTRIBUTORS.md or my name already exists there

Previously, the transforms were applied in the order (scale, transform, rotate). However, in Isaac Sim, the correct transformation order is (transform, rotate, scale). This MR fixes this issue by applying scale later.

Signed-off-by: Mayank Mittal <12863862+Mayankm96@users.noreply.github.com>
@github-actions github-actions bot added bug Something isn't working isaac-lab Related to Isaac Lab team labels Feb 23, 2026
@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 23, 2026

Greptile Summary

This PR fixes the mesh transformation order in MultiMeshRayCaster._initialize_warp_meshes(). Previously, scale was applied to mesh vertices first via mesh.apply_scale(), then a separate rotation+translation transform was applied. The fix consolidates all three operations (translate, rotate, scale) into a single 4x4 transformation matrix by baking scale into the rotation submatrix (R @ diag(scale)), which is then applied in one step via mesh.apply_transform().

  • Removed the separate mesh.apply_scale(scale) call and renamed the variable from scale to world_scale for clarity
  • Added transform[:3, :3] = transform[:3, :3] @ np.diag(world_scale) to compose scale into the rotation matrix before applying the full transform
  • The fix ensures scale is applied correctly relative to the local coordinate frame, consistent with Isaac Sim's standard (translate, orient, scale) convention defined in standardize_xform_ops()
  • The base RayCaster class already handles this correctly by using get_world_transform_matrix() which includes scale in the full matrix

Confidence Score: 4/5

  • This PR is a targeted bug fix with a single, well-understood change that aligns the transformation order with Isaac Sim conventions.
  • The change is mathematically sound — composing scale into the rotation matrix via R @ diag(scale) is the standard approach for building a combined transformation. The fix is minimal and focused. Score is 4 rather than 5 because: (1) there are no tests specifically validating the non-uniform scale case that was broken, and (2) resolve_prim_scale returns world-frame scale while resolve_prim_pose computes a relative pose, which could produce unexpected results when ancestor prims have non-identity scale — though this is a pre-existing concern not introduced by this PR.
  • No files require special attention beyond verifying the fix with non-uniform scale scenarios in integration testing.

Important Files Changed

Filename Overview
source/isaaclab/isaaclab/sensors/ray_caster/multi_mesh_ray_caster.py Fixes mesh transformation order by combining scale into the 4x4 transform matrix instead of applying it separately before rotation+translation. The change correctly bakes scale into the rotation portion of the transform via R @ diag(scale), matching Isaac Sim's (translate, orient, scale) convention.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["Read mesh_prim vertices\n(local space)"] --> B["resolve_prim_pose(mesh_prim, target_prim)\n→ relative_pos, relative_quat"]
    B --> C["resolve_prim_scale(mesh_prim)\n→ world_scale (sx, sy, sz)"]
    C --> D["Build rotation matrix R\nfrom relative_quat"]
    D --> E["Build 4x4 transform:\ntransform[:3,:3] = R\ntransform[:3,3] = relative_pos"]
    E --> F["Compose scale into rotation:\ntransform[:3,:3] = R @ diag(world_scale)"]
    F --> G["mesh.apply_transform(transform)\n→ vertices in target_prim frame"]
    G --> H["Convert to Warp mesh\nfor raycasting"]

    style F fill:#90EE90,stroke:#333,stroke-width:2px
    style A fill:#f0f0f0,stroke:#333
    style H fill:#f0f0f0,stroke:#333
Loading

Last reviewed commit: 7426231

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

1 file reviewed, no comments

Edit Code Review Agent Settings | Greptile

@ooctipus ooctipus changed the title Apply world scale to mesh transformation correctly in MeshRayCaster Applies world scale to mesh transformation correctly in MeshRayCaster Feb 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working isaac-lab Related to Isaac Lab team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant