Skip to content

Remove ShapeMaterials, ShapeGeometry structs#492

Merged
eric-heiden merged 13 commits into
newton-physics:mainfrom
eric-heiden:remove-materials-geo
Jul 31, 2025
Merged

Remove ShapeMaterials, ShapeGeometry structs#492
eric-heiden merged 13 commits into
newton-physics:mainfrom
eric-heiden:remove-materials-geo

Conversation

@eric-heiden

@eric-heiden eric-heiden commented Jul 31, 2025

Copy link
Copy Markdown
Member

Description

Newton Migration Guide

Please ensure the migration guide for warp.sim users is up-to-date with the changes made in this MR.

  • The migration guide in docs/migration.rst is up-to date

Before your PR is "Ready for review"

  • All commits are signed-off to indicate that your contribution adheres to the Developer Certificate of Origin requirements
  • Necessary tests have been added and new examples are tested (see newton/tests/test_examples.py)
  • Documentation is up-to-date
  • Code passes formatting and linting checks with pre-commit run -a

Summary by CodeRabbit

  • Refactor

    • Unified and simplified naming for shape geometry and material attributes across simulation, rendering, and solver components.
    • Removed composite shape material and geometry structures, replacing them with explicit arrays for each property.
    • Updated kernel and solver interfaces to use separate material property arrays instead of structured types.
    • Updated documentation and comments to reflect new attribute names.
  • Bug Fixes

    • Corrected attribute references in examples, solvers, utilities, and tests to align with the new naming conventions.
  • Documentation

    • Updated API documentation to match the revised attribute structure and naming.
  • Tests

    • Adjusted test cases to use the new attribute names for shape geometry and materials.

@coderabbitai

coderabbitai Bot commented Jul 31, 2025

Copy link
Copy Markdown
Contributor

Caution

Review failed

The head commit changed during the review from 71a2074 to f179357.

📝 Walkthrough

Walkthrough

This change removes the ShapeMaterials and ShapeGeometry structured types throughout the codebase, refactoring all shape material and geometry properties to use individual arrays instead. All references, imports, and serialization logic for these types are eliminated. Attribute names are updated for clarity and consistency, and all affected modules, solvers, tests, utilities, and documentation are revised to use the new flat attribute structure.

Changes

Cohort / File(s) Change Summary
Docs and API
docs/api/newton_sim.rst
Removed ShapeGeometry and ShapeMaterials from documentation autosummary.
Module Exports
newton/__init__.py, newton/sim/__init__.py
Removed ShapeMaterials and ShapeGeometry from __all__ export lists.
Type Definitions
newton/sim/types.py
Deleted the file defining ShapeMaterials and ShapeGeometry.
Model and Builder Refactor
newton/sim/model.py, newton/sim/builder.py
Replaced structured shape material/geometry attributes with flat arrays; renamed all related attributes and updated all usages.
Collision and Simulation Kernels
newton/sim/collide.py, newton/solvers/euler/kernels.py, newton/solvers/xpbd/kernels.py, newton/solvers/featherstone/solver_featherstone.py, newton/solvers/mujoco/solver_mujoco.py, newton/solvers/style3d/kernels.py, newton/solvers/style3d/solver_style3d.py, newton/solvers/vbd/solver_vbd.py, newton/solvers/xpbd/solver_xpbd.py
Updated all kernel signatures, launches, and internal logic to use individual arrays for shape material and geometry properties instead of structured types.
Examples
newton/examples/example_anymal_c_walk_on_sand.py, newton/examples/example_mujoco.py, newton/examples/example_selection_materials.py
Updated attribute accesses and assignments to use new flat array names for shape geometry and material properties.
Test Suite
newton/tests/test_import_mjcf.py, newton/tests/test_import_urdf.py, newton/tests/test_import_usd.py, newton/tests/test_model.py, newton/tests/test_mujoco_solver.py
Updated all test code to use new attribute names for shape geometry and materials; removed references to structured types.
Utilities and Serialization
newton/utils/import_mjcf.py, newton/utils/import_urdf.py, newton/utils/recorder.py, newton/utils/render.py, newton/utils/selection.py
Updated attribute accesses, serialization, deserialization, and rendering logic to use new flat arrays and attribute names; removed all handling of structured types.
Flags and Documentation
newton/sim/flags.py
Clarified docstring for shape property notification flag to reflect new structure.
Geometry Kernels
newton/geometry/kernels.py
Renamed parameter and references of shape source array from shape_source to shape_source_ptr for consistency.
Geometry Types
newton/geometry/types.py
Added a docstring to the SDF.finalize method.
Other Examples
newton/examples/example_g1.py
Set explicit up_axis parameter to "Y" in ModelBuilder initialization; always enable MuJoCo viewer unconditionally.

Sequence Diagram(s)

sequenceDiagram
    participant Builder
    participant Model
    participant Solver

    Builder->>Model: finalize() (provides shape_type, shape_scale, shape_src, ... as arrays)
    Solver->>Model: Accesses shape_material_mu, shape_material_ke, ... directly
    Model->>Solver: Provides flat arrays for all shape geometry/material properties
    Solver->>Solver: Passes arrays to kernels instead of structured types
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~50 minutes

Suggested reviewers

  • adenzler-nvidia
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@eric-heiden eric-heiden requested a review from nvlukasz July 31, 2025 16:12

@nvlukasz nvlukasz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good!

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (2)
newton/solvers/mujoco/solver_mujoco.py (1)

1651-1652: Consider variable naming consistency.

The attribute model.shape_scale is being assigned to a variable named shape_size. While the logic is correct, consider using consistent naming either shape_scale for both or shape_size for both to improve code clarity.

newton/utils/render.py (1)

338-365: Doc-string still speaks of geometry, not shape

Now that the API was flattened, each parameter represents a shape property, not a geometry property. The doc-string paragraphs (shape_type, shape_scale, shape_thickness, shape_is_solid) still contain phrases like “each shape's geometry”. This is minor, but it can trip up users scanning the documentation for the new API.

-    shape_type (numpy.ndarray): Type of each shape's geometry.
-    shape_scale (numpy.ndarray): Scale of each shape's geometry.
-    shape_thickness (numpy.ndarray): Thickness of each shape's geometry.
-    shape_is_solid (numpy.ndarray): Solid flag for each shape's geometry.
+    shape_type (numpy.ndarray): Type of each shape.
+    shape_scale (numpy.ndarray): Per–shape scaling factors.
+    shape_thickness (numpy.ndarray): Per–shape shell thickness.
+    shape_is_solid (numpy.ndarray): Whether a shape is rendered as a closed solid.
📜 Review details

Configuration used: .coderabbit.yml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3ec30d8 and 47109b9.

⛔ Files ignored due to path filters (2)
  • docs/api/_generated/newton.sim.ShapeGeometry.rst is excluded by !**/_generated/**
  • docs/api/_generated/newton.sim.ShapeMaterials.rst is excluded by !**/_generated/**
📒 Files selected for processing (29)
  • docs/api/newton_sim.rst (0 hunks)
  • newton/__init__.py (0 hunks)
  • newton/examples/example_anymal_c_walk_on_sand.py (1 hunks)
  • newton/examples/example_mujoco.py (1 hunks)
  • newton/examples/example_selection_materials.py (1 hunks)
  • newton/sim/__init__.py (0 hunks)
  • newton/sim/builder.py (14 hunks)
  • newton/sim/collide.py (4 hunks)
  • newton/sim/flags.py (1 hunks)
  • newton/sim/model.py (2 hunks)
  • newton/sim/types.py (0 hunks)
  • newton/solvers/euler/kernels.py (6 hunks)
  • newton/solvers/featherstone/solver_featherstone.py (1 hunks)
  • newton/solvers/mujoco/solver_mujoco.py (5 hunks)
  • newton/solvers/style3d/kernels.py (2 hunks)
  • newton/solvers/style3d/solver_style3d.py (1 hunks)
  • newton/solvers/vbd/solver_vbd.py (8 hunks)
  • newton/solvers/xpbd/kernels.py (7 hunks)
  • newton/solvers/xpbd/solver_xpbd.py (3 hunks)
  • newton/tests/test_import_mjcf.py (1 hunks)
  • newton/tests/test_import_urdf.py (2 hunks)
  • newton/tests/test_import_usd.py (1 hunks)
  • newton/tests/test_model.py (1 hunks)
  • newton/tests/test_mujoco_solver.py (4 hunks)
  • newton/utils/import_mjcf.py (2 hunks)
  • newton/utils/import_urdf.py (2 hunks)
  • newton/utils/recorder.py (2 hunks)
  • newton/utils/render.py (5 hunks)
  • newton/utils/selection.py (1 hunks)
💤 Files with no reviewable changes (4)
  • newton/init.py
  • docs/api/newton_sim.rst
  • newton/sim/init.py
  • newton/sim/types.py
🧰 Additional context used
🧠 Learnings (3)
📚 Learning: in warp benchmarks, explicit wp.init() calls are not needed in most circumstances since the first wa...
Learnt from: shi-eric
PR: newton-physics/newton#461
File: asv/benchmarks/envs/example_humanoid.py:40-41
Timestamp: 2025-07-23T14:36:42.182Z
Learning: In Warp benchmarks, explicit wp.init() calls are not needed in most circumstances since the first Warp API call that requires initialization will automatically call wp.init(). Explicit wp.init() in setup() methods is helpful when the ASV benchmark is measuring a Warp API call, as wp.init() has non-trivial overhead that should be excluded from the benchmark timing.

Applied to files:

  • newton/solvers/style3d/kernels.py
📚 Learning: in the newton physics engine codebase, it's acceptable to test private api functions (those prefixed...
Learnt from: dylanturpin
PR: newton-physics/newton#394
File: newton/tests/test_ik.py:119-119
Timestamp: 2025-07-15T21:00:03.709Z
Learning: In the Newton physics engine codebase, it's acceptable to test private API functions (those prefixed with underscore) in unit and component tests, as the maintainers consider this appropriate for testing internal functionality.

Applied to files:

  • newton/tests/test_import_usd.py
📚 Learning: the use_mujoco option in newton/examples/example_mujoco.py is currently unsupported and causes crash...
Learnt from: Kenny-Vilella
PR: newton-physics/newton#398
File: newton/examples/example_mujoco.py:352-352
Timestamp: 2025-07-14T03:57:29.670Z
Learning: The use_mujoco option in newton/examples/example_mujoco.py is currently unsupported and causes crashes. The code automatically disables this option with a warning message when users attempt to enable it. This is intentionally kept as a placeholder for future implementation.

Applied to files:

  • newton/examples/example_mujoco.py
🧬 Code Graph Analysis (4)
newton/tests/test_model.py (2)
newton/tests/unittest_utils.py (1)
  • assert_np_equal (240-246)
newton/tests/test_import_usd.py (1)
  • npsorted (223-224)
newton/examples/example_selection_materials.py (1)
newton/utils/selection.py (2)
  • get_attribute (544-555)
  • set_attribute (557-572)
newton/tests/test_mujoco_solver.py (1)
newton/sim/builder.py (1)
  • shape_count (460-461)
newton/examples/example_mujoco.py (1)
newton/geometry/utils.py (1)
  • remesh_mesh (471-498)
⏰ Context from checks skipped due to timeout of 900000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Run GPU Unit Tests on AWS EC2 (Pull Request)
  • GitHub Check: Run GPU Benchmarks (Pull Request)
🔇 Additional comments (62)
newton/utils/selection.py (1)

450-450: LGTM! Comment correctly updated to reflect new attribute naming.

The comment example has been properly updated from the old structured attribute format ("shape_materials.mu") to the new flat array format ("shape_material_mu"), which aligns with the removal of ShapeMaterials structs throughout the codebase.

newton/utils/import_urdf.py (1)

251-251: LGTM! Attribute names correctly updated for consistency.

The changes from builder.shape_geo_type to builder.shape_type are consistent with the broader refactoring that removed the ShapeGeometry structured types and simplified the attribute naming scheme. The functionality remains unchanged - these are still used to track the range of newly added shapes during URDF parsing.

Also applies to: 320-320

newton/sim/flags.py (1)

38-38: LGTM! Docstring enhanced for better clarity.

The expanded docstring properly clarifies that NOTIFY_FLAG_SHAPE_PROPERTIES covers shape transforms, geometry, and material properties. This improvement better reflects the scope of this flag, especially given the refactoring that replaced structured types with individual property arrays.

newton/solvers/style3d/solver_style3d.py (1)

191-191: LGTM! Consistent with material property refactoring.

The change from self.model.shape_materials to self.model.shape_material_mu aligns with the systematic removal of structured types in favor of individual property arrays. This change is consistent with similar updates across other solver modules and the corresponding kernel update in newton/solvers/style3d/kernels.py.

newton/tests/test_import_mjcf.py (1)

113-113: LGTM! Test updated for new attribute naming scheme.

The change from model.shape_geo_src[i] to model.shape_src[i] correctly updates the test to use the new simplified attribute name. The test logic and coverage remain unchanged - it still validates that meshes have the correct maxhullvert values after MJCF parsing.

newton/utils/import_mjcf.py (1)

768-768: LGTM! Attribute renaming aligns with refactoring.

The changes from builder.shape_geo_type to builder.shape_type are consistent with the broader refactoring to remove the ShapeGeometry structured type and flatten shape geometry attributes. The logic for determining shape count ranges for collision filtering remains correct.

Also applies to: 793-793

newton/examples/example_selection_materials.py (1)

205-205: LGTM! Material attribute access updated correctly.

The changes from "shape_materials.mu" to "shape_material_mu" correctly reflect the refactoring from structured ShapeMaterials type to individual material property arrays. The functionality for accessing and setting friction coefficients remains unchanged.

Also applies to: 210-210, 213-214

newton/tests/test_model.py (1)

252-252: LGTM! Test attribute references updated correctly.

The test assertions have been properly updated to use the new attribute names (shape_src, shape_type, shape_scale) instead of the old shape_geo_* prefixed names. This aligns with the refactoring to remove the ShapeGeometry structured type. The test logic and verification remain unchanged.

Also applies to: 256-258, 262-264

newton/utils/recorder.py (1)

183-183: LGTM! Serialization logic correctly updated.

The removal of special handling for ShapeMaterials and ShapeGeometry types in the serialization/deserialization methods is consistent with these structured types being removed from the codebase. The generic serialization logic for other supported types remains intact.

Also applies to: 227-227

newton/tests/test_import_urdf.py (1)

164-165: LGTM! Test assertions updated for new attribute names.

The test assertions have been correctly updated to use the new simplified attribute names (shape_type, shape_scale, shape_src) instead of the old shape_geo_* prefixed names. This maintains test coverage while aligning with the refactoring to remove the ShapeGeometry structured type. The test logic and verification conditions remain unchanged.

Also applies to: 184-185, 187-188, 194-196

newton/solvers/style3d/kernels.py (1)

151-151: LGTM! Consistent parameter type refactoring.

The replacement of ShapeMaterials structured type with shape_material_mu: wp.array(dtype=float) aligns perfectly with the broader refactoring to remove structured material types in favor of individual arrays. The parameter is correctly passed through to evaluate_body_particle_contact on line 181.

Also applies to: 181-181

newton/tests/test_import_usd.py (1)

252-252: LGTM! Test attributes correctly updated.

All attribute renamings follow the consistent pattern of removing the geo infix from shape geometry attributes:

  • shape_geo_typeshape_type
  • shape_geo_srcshape_src
  • shape_geo_scaleshape_scale

The test logic remains unchanged and correctly validates the refactored model structure.

Also applies to: 255-255, 261-261, 265-267, 271-271

newton/examples/example_mujoco.py (1)

107-107: LGTM! Attribute references correctly updated.

All references to articulation_builder.shape_geo_src have been consistently updated to articulation_builder.shape_src, maintaining the mesh simplification functionality while aligning with the refactored attribute naming convention.

Also applies to: 109-109, 115-115, 120-120

newton/examples/example_anymal_c_walk_on_sand.py (1)

168-168: LGTM! Mesh processing attributes correctly updated.

The attribute references have been consistently updated to follow the new naming convention:

  • shape_geo_srcshape_src for accessing mesh data
  • Shape scale now accessed via shape_scale

The collision shape filtering and mesh merging logic remains intact and functional.

Also applies to: 172-174

newton/solvers/xpbd/solver_xpbd.py (3)

314-314: LGTM! Material property parameter correctly updated.

The replacement of model.shape_materials with model.shape_material_mu correctly provides the friction coefficient array to the particle-shape contact solver, aligning with the refactoring to use individual material property arrays.


519-519: LGTM! Rigid contact material parameter correctly updated.

The replacement of model.shape_materials with model.shape_material_mu correctly provides the friction coefficient to the rigid body contact position solver.


633-633: LGTM! Restitution kernel parameters correctly updated.

The changes properly update the restitution kernel call:

  • model.shape_materialsmodel.shape_material_restitution provides the specific restitution coefficients
  • Contact thickness correctly split into rigid_contact_thickness0 and rigid_contact_thickness1 for more granular control

Both changes align with the broader refactoring to use individual property arrays.

Also applies to: 638-639

newton/solvers/featherstone/solver_featherstone.py (1)

401-405: LGTM! Correct implementation of material property flattening.

The replacement of the single model.shape_materials parameter with individual material property arrays (shape_material_ke, shape_material_kd, shape_material_kf, shape_material_ka, shape_material_mu) correctly implements the PR objective to remove structured types and use flat Warp arrays.

newton/sim/collide.py (4)

48-50: LGTM! Correct shape geometry attribute flattening.

The replacement of nested shape geometry attributes (shape_geo.type, shape_geo.scale, shape_geo.source) with flat attributes (shape_type, shape_scale, shape_source) correctly implements the structural refactoring to remove ShapeGeometry structs.


170-172: LGTM! Consistent shape geometry flattening.

The shape geometry attribute flattening is correctly applied to the create_soft_contacts kernel launch, maintaining consistency with the broader refactoring effort.


202-204: LGTM! Shape geometry flattening applied consistently.

The broadphase collision pairs kernel correctly uses the flattened shape geometry attributes, maintaining consistency across all collision-related kernel launches.


236-239: LGTM! Complete shape geometry attribute flattening.

The handle_contact_pairs kernel launch correctly implements the complete flattening of shape geometry attributes, including the transformation of shape_geo.thickness to shape_thickness. All changes align with the PR objectives.

newton/tests/test_mujoco_solver.py (7)

669-669: LGTM! Test updated for flattened shape type attribute.

The test correctly uses the new shape_type attribute instead of the nested shape_geo.type, maintaining the same test logic while adapting to the API changes.


673-676: LGTM! Material property attributes correctly flattened in tests.

The test code correctly updates from structured material properties (shape_materials.mu, shape_materials.ke, shape_materials.kd) to flattened arrays (shape_material_mu, shape_material_ke, shape_material_kd), preserving the original test validation logic.


851-851: LGTM! Material property assignment updated correctly.

The assignment to shape_material_mu correctly replaces the previous nested structure access, maintaining the test's functionality while using the new flattened API.


856-857: LGTM! Contact parameter assignments updated correctly.

The assignments to shape_material_ke and shape_material_kd correctly use the new flattened material property arrays, maintaining the test's ability to update contact parameters.


866-866: LGTM! Shape scale reading updated correctly.

The test correctly reads from the flattened shape_scale attribute instead of the nested shape_geo.scale, maintaining the same test functionality.


869-869: LGTM! Shape scale assignment updated correctly.

The assignment to the flattened shape_scale attribute correctly replaces the previous nested structure assignment, preserving the test's ability to update shape sizes.


1088-1089: LGTM! Shape source attribute access updated correctly.

The test correctly uses the renamed shape_src attribute (previously shape_geo_src) to access mesh objects and verify their maxhullvert properties, maintaining the test's validation logic.

newton/solvers/mujoco/solver_mujoco.py (5)

1789-1789: LGTM!

The attribute name change from model.shape_geo_src to model.shape_src is consistent with the refactoring to flat arrays.


1832-1833: LGTM!

The attribute name changes from model.shape_materials.mu to model.shape_material_mu are consistent with the refactoring to flat arrays and follow a clear naming convention.


2166-2166: LGTM!

The attribute name change from model.shape_materials.mu to model.shape_material_mu is consistent with the broader refactoring.


2371-2377: LGTM!

All attribute name changes are consistent with the refactoring from structured types to flat arrays:

  • shape_materials.*shape_material_*
  • shape_geo.*shape_*

The parameter updates correctly reflect the new flat array structure.


1651-2377: No remaining references to old structured types in solver_mujoco.py

All searches for shape_geo., shape_materials., and shape_geo_src returned no hits, confirming that the old structured‐type attributes have been fully removed or renamed. No further changes are required.

newton/solvers/vbd/solver_vbd.py (5)

540-540: LGTM! Parameter refactoring is consistent with the broader changes.

The replacement of structured ShapeMaterials with flat shape_material_mu array is correctly implemented. The usage pattern on line 572 properly accesses the friction coefficient via shape_material_mu[shape_index].

Also applies to: 572-572


1664-1664: LGTM! Kernel parameter passing is correctly updated.

The function signature and parameter passing to evaluate_body_particle_contact are consistent with the refactoring to use flat arrays instead of structured types.

Also applies to: 1815-1815


1926-1926: LGTM! Consistent parameter refactoring for no-self-contact kernel.

The function signature and parameter passing follow the same pattern as other kernel functions in the refactor.

Also applies to: 1958-1958


2728-2728: LGTM! Consistent usage across all solver methods.

The method correctly uses the refactored self.model.shape_material_mu attribute, maintaining consistency with other solver methods.


2552-2552: Confirmed: Model.shape_material_mu is defined and populated – approving change.

The Model class in newton/sim/model.py initializes

self.shape_material_mu = None

and the builder in newton/sim/builder.py replaces it with a wp.array, so the solver’s use of self.model.shape_material_mu is valid.

newton/solvers/xpbd/kernels.py (4)

134-134: LGTM: Function signature updated correctly

The parameter change from ShapeMaterials to shape_material_mu: wp.array(dtype=float) properly implements the refactoring to use flat arrays instead of structured types.


184-184: LGTM: Material property access updated correctly

The change from structured field access to direct array indexing (shape_material_mu[shape_index]) is consistent with the refactoring objectives and maintains the correct indexing logic.


2083-2083: LGTM: Material property parameters and access updated consistently

The function parameter and material property access changes correctly implement the flat array approach:

  • Parameter changed to shape_material_mu: wp.array(dtype=float)
  • Array access uses proper indexing for friction coefficient calculation

Also applies to: 2166-2169


2318-2318: LGTM: Restitution and contact thickness changes implemented correctly

The changes properly implement the refactoring:

  • Restitution parameter changed to shape_material_restitution: wp.array(dtype=float)
  • Contact thickness split into contact_thickness0 and contact_thickness1 arrays
  • Thickness computation correctly sums both values: contact_thickness0[tid] + contact_thickness1[tid]
  • Array access patterns for restitution are consistent with the new approach

This improves the handling of per-shape properties in contact pairs.

Also applies to: 2323-2324, 2348-2352, 2396-2396

newton/sim/model.py (3)

95-107: LGTM: Shape material properties properly flattened

The individual shape material property arrays are well-defined with:

  • Consistent naming convention (shape_material_*)
  • Proper type annotations (wp.array(dtype=float))
  • Clear documentation for each property
  • Complete coverage of all material properties (elastic stiffness, damping, friction, adhesion, friction coefficient, restitution)

This correctly implements the refactoring from composite ShapeMaterials to individual arrays.


109-123: LGTM: Shape geometry properties properly flattened and renamed

The individual shape geometry property arrays are well-implemented:

  • Consistent naming convention (shape_* instead of shape_geo_*)
  • Appropriate data types for each property (int32, bool, float, uint64, etc.)
  • Complete coverage of geometry properties (type, solidity, thickness, source, scale, filter)
  • shape_geo_src properly renamed to shape_src for consistency

This correctly implements the flattening of ShapeGeometry into individual arrays.


383-394: LGTM: Attribute frequency mapping updated correctly

The attribute_frequency dictionary updates properly reflect the new individual shape properties:

  • All new shape material properties (shape_material_*) correctly mapped to "shape"
  • All new shape geometry properties (shape_*) correctly mapped to "shape"
  • Complete coverage of all the flattened attributes
  • Maintains consistency with the existing attribute frequency system

This ensures that functionality depending on attribute frequency classification continues to work correctly.

newton/utils/render.py (2)

278-283: Arguments rename propagated correctly

The populate() call site has been updated to pass model.shape_src, model.shape_type, model.shape_scale, model.shape_thickness, and model.shape_is_solid, matching the new flattened arrays introduced in the model. Good catch – this prevents a runtime mismatch between the renderer and the model.


788-791: raycast_kernel signature correctly matches passed arguments

The raycast_kernel in newton/geometry/raycast.py is defined as:

def raycast_kernel(
    body_q: wp.array(dtype=wp.transform),
    shape_body: wp.array(dtype=int),
    shape_transform: wp.array(dtype=wp.transform),
    geom_type: wp.array(dtype=int),      # 4th parameter
    geom_size: wp.array(dtype=wp.vec3),   # 5th parameter
    ray_origin: wp.vec3,
    ray_direction: wp.vec3,
    lock: wp.array(dtype=wp.int32),
    ...
):

In newton/utils/render.py the launch call passes:

  • 4th argument: self.model.shape_type (wp.array(dtype=int)) → matches geom_type
  • 5th argument: self.model.shape_scale (wp.array(dtype=wp.vec3)) → matches geom_size

No changes are needed.

newton/sim/builder.py (8)

326-330: LGTM! Improved attribute naming consistency.

The systematic renaming from shape_geo_* to shape_* improves clarity by removing the redundant "geo" infix. The changes are consistent with the broader refactor to flatten shape geometry representation.


461-461: Correct property update.

The property correctly references the renamed shape_type attribute.


671-675: Consistent attribute list update.

The attribute names in the extension list correctly match the renamed attributes from the constructor.


1362-1362: Correct attribute reference update.

The visualization method correctly uses the renamed shape_type attribute.


2215-2357: Comprehensive attribute renaming in approximate_meshes method.

All shape attribute references have been systematically updated throughout the method:

  • shape_geo_typeshape_type
  • shape_geo_srcshape_src
  • shape_geo_scaleshape_scale
  • shape_geo_thicknessshape_thickness
  • shape_geo_is_solidshape_is_solid

The method logic remains unchanged and all references are consistent.


1776-1780: Correct attribute updates in add_shape method.

The shape creation method correctly uses all the renamed attributes while maintaining the same functionality.


3448-3484: Correct Model finalization with renamed attributes.

The finalize method correctly creates Warp arrays using all the renamed shape attributes:

  • Uses shape_src for geometry sources
  • Creates arrays for shape_type, shape_scale, shape_is_solid, shape_thickness
  • Maintains all material property arrays with correct naming

The functionality is preserved while using the improved naming convention.


3677-3677: Final shape_count assignment updated correctly.

The Model's shape_count property correctly uses the renamed shape_type attribute.

newton/solvers/euler/kernels.py (6)

687-691: LGTM: Clean parameter declaration refactoring.

The individual material property arrays are well-named and properly typed. This flattened approach should improve GPU kernel performance compared to structured access patterns.


744-747: LGTM: Correct material property indexing.

The array indexing with shape_index is consistent across all material properties, and the averaging logic is preserved correctly.


803-807: LGTM: Consistent parameter declarations.

The material property parameter declarations match the pattern established in eval_particle_contacts, maintaining consistency across the codebase.


845-849: LGTM: Correct material property accumulation.

The indexing and accumulation logic is consistent for both shapes. The material properties are properly accessed using shape_a and shape_b indices, and the averaging calculation later divides by mat_nonzero correctly.

Also applies to: 853-857


1623-1627: LGTM: Correct kernel arguments.

The arguments passed match the kernel parameter declarations exactly, with proper ordering and naming convention.


1703-1707: LGTM: Consistent kernel arguments.

The arguments follow the same pattern as eval_body_contact_forces, maintaining consistency across both contact evaluation functions.

Comment thread newton/utils/render.py
@eric-heiden eric-heiden enabled auto-merge (squash) July 31, 2025 16:38
Signed-off-by: Eric Heiden <eheiden@nvidia.com>
Signed-off-by: Eric Heiden <eheiden@nvidia.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: .coderabbit.yml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a3aa016 and 8d4f9bc.

📒 Files selected for processing (4)
  • docs/migration.rst (1 hunks)
  • newton/examples/example_anymal_c_walk_on_sand.py (1 hunks)
  • newton/examples/example_g1.py (3 hunks)
  • newton/examples/example_mujoco.py (1 hunks)
✅ Files skipped from review due to trivial changes (2)
  • newton/examples/example_mujoco.py
  • docs/migration.rst
🚧 Files skipped from review as they are similar to previous changes (1)
  • newton/examples/example_anymal_c_walk_on_sand.py
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: the use_mujoco option in newton/examples/example_mujoco.py is currently unsupported and causes crash...
Learnt from: Kenny-Vilella
PR: newton-physics/newton#398
File: newton/examples/example_mujoco.py:352-352
Timestamp: 2025-07-14T03:57:29.670Z
Learning: The use_mujoco option in newton/examples/example_mujoco.py is currently unsupported and causes crashes. The code automatically disables this option with a warning message when users attempt to enable it. This is intentionally kept as a placeholder for future implementation.

Applied to files:

  • newton/examples/example_g1.py
⏰ Context from checks skipped due to timeout of 900000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Run GPU Unit Tests on AWS EC2 (Pull Request)
  • GitHub Check: Run GPU Benchmarks (Pull Request)
🔇 Additional comments (2)
newton/examples/example_g1.py (2)

39-39: LGTM: Explicit up_axis parameter improves clarity.

Making the up_axis="Y" parameter explicit instead of relying on defaults enhances code readability and ensures consistent behavior across the codebase.


55-55: LGTM: Consistent explicit parameter usage.

Good practice to explicitly specify the up_axis="Y" parameter for consistency with the articulation builder and improved code clarity.

Comment thread newton/examples/example_g1.py Outdated
Signed-off-by: Eric Heiden <eheiden@nvidia.com>
Signed-off-by: Eric Heiden <eheiden@nvidia.com>
@eric-heiden eric-heiden merged commit 036222c into newton-physics:main Jul 31, 2025
11 checks passed
@coderabbitai coderabbitai Bot mentioned this pull request Aug 27, 2025
3 tasks
eric-heiden added a commit to eric-heiden/newton that referenced this pull request Jan 28, 2026
Signed-off-by: Eric Heiden <eheiden@nvidia.com>
@coderabbitai coderabbitai Bot mentioned this pull request Feb 6, 2026
mmacklin pushed a commit to mmacklin/newton that referenced this pull request Apr 7, 2026
Signed-off-by: Eric Heiden <eheiden@nvidia.com>
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