[Warp Raytrace] Renamed geom to shape#1246
Conversation
📝 WalkthroughWalkthroughRenames geometry-centric identifiers to shape-centric ones across warp_raytrace and tiled camera sensor modules, and consolidates separate clear parameters into a single ClearData structure used throughout the rendering pipeline. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes
Possibly related PRs
Suggested reviewers
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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. Comment |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (5)
newton/_src/sensors/warp_raytrace/ray.py (2)
42-56: Alignmap_ray_to_localdocstring with actual parametersThe docstring still talks about
posandmat, but the function now takes a singletransform. Consider updating the args section for clarity:- Args: - pos: position of shape frame - mat: orientation of shape frame - ray_origin_world: starting point of ray in world coordinates - ray_direction_world: direction of ray in world coordinates + Args: + transform: transform of the shape frame in world space + ray_origin_world: starting point of the ray in world coordinates + ray_direction_world: direction of the ray in world coordinatesThis keeps the “shape frame” wording but matches the actual signature.
581-607:ray_mesh_with_bvhrename tomesh_shape_idkeeps semantics but check call sitesThe function now takes and returns
mesh_shape_id, but still uses that value as the index intomesh_bvh_ids. Behavior is preserved relative to the previousmesh_geom_idnaming; the only change is the identifier that gets surfaced to callers (last tuple element). Please double‑check that all call sites now pass the ID they want to write into the shape‑index output (vs. a raw mesh index), since that distinction is now encoded in the name.newton/_src/sensors/tiled_camera_sensor.py (1)
654-662: New shape‑index image output API looks good; consider doc/migration implications
create_shape_index_image_output()wraps the corresponding RenderContext helper and exposes a clear, shape‑centric replacement for any previous geom‑id image output.Since this is a public API rename, it’s worth checking:
- Example and user‑facing docs that might still reference the old geom‑id terminology.
- Whether
docs/migration.rstactually needs an entry: prior guidance was that this document is specifically for warp.sim → Newton migrations, and Newton‑only features generally don’t require migration notes. Based on learnings, you may only need to touch it if warp.sim had an analogous geom‑id sensor API.newton/_src/sensors/warp_raytrace/ray_cast.py (2)
172-174: Consider renaming internal variables for clarity.The variables
gi_globalandgi_bvh_localstill use thegi(geometry index) prefix even though this function handles particles. Consider renaming tobounds_index_global/bounds_index_localorpi_global/pi_bvh_localfor consistency with the shape-focused refactoring.while wp.bvh_query_next(query, bounds_nr, closest_hit.distance): - gi_global = bounds_nr - gi_bvh_local = gi_global - (world_index * bvh_particles_size) - si = gi_bvh_local + particle_index = bounds_nr - (world_index * bvh_particles_size)
397-399: Same variable naming inconsistency as inclosest_hit_particles.The
gi_global/gi_bvh_localvariables use geometry-centric naming in a particle-handling function. Consider the same refactor suggested forclosest_hit_particles.
📜 Review details
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (11)
asv/benchmarks/simulation/bench_tiled_camera_sensor.py(2 hunks)newton/_src/sensors/tiled_camera_sensor.py(15 hunks)newton/_src/sensors/warp_raytrace/__init__.py(1 hunks)newton/_src/sensors/warp_raytrace/bvh.py(2 hunks)newton/_src/sensors/warp_raytrace/lighting.py(3 hunks)newton/_src/sensors/warp_raytrace/ray.py(3 hunks)newton/_src/sensors/warp_raytrace/ray_cast.py(15 hunks)newton/_src/sensors/warp_raytrace/render.py(13 hunks)newton/_src/sensors/warp_raytrace/render_context.py(9 hunks)newton/_src/sensors/warp_raytrace/textures.py(3 hunks)newton/examples/sensors/example_sensor_tiled_camera.py(5 hunks)
🧰 Additional context used
🧠 Learnings (8)
📓 Common learnings
Learnt from: shi-eric
Repo: newton-physics/newton PR: 521
File: newton/examples/example_cloth_hanging.py:36-36
Timestamp: 2025-08-12T05:17:34.423Z
Learning: The Newton migration guide (docs/migration.rst) is specifically for documenting how to migrate existing warp.sim functionality to Newton equivalents. New Newton-only features that didn't exist in warp.sim do not need migration documentation.
Learnt from: nvlukasz
Repo: newton-physics/newton PR: 519
File: newton/geometry.py:16-22
Timestamp: 2025-08-12T17:51:37.474Z
Learning: In the Newton public API refactor, common geometry symbols like ParticleFlags and ShapeFlags are now exposed at the top level in newton/__init__.py rather than through newton.geometry. The newton/geometry.py module is intentionally focused only on broad-phase collision detection classes (BroadPhaseAllPairs, BroadPhaseExplicit, BroadPhaseSAP).
📚 Learning: 2025-09-09T10:29:35.521Z
Learnt from: gdaviet
Repo: newton-physics/newton PR: 750
File: newton/_src/solvers/implicit_mpm/rasterized_collisions.py:86-90
Timestamp: 2025-09-09T10:29:35.521Z
Learning: In Warp's mesh query system, wp.mesh_eval_face_normal returns face normals that point outward from the collider surface by definition. The query.sign from wp.mesh_query_point_sign_normal indicates inside/outside but should not be used to flip the face normal direction, as this would make outward-pointing normals point inward incorrectly.
Applied to files:
newton/_src/sensors/warp_raytrace/ray.py
📚 Learning: 2025-08-12T17:51:37.474Z
Learnt from: nvlukasz
Repo: newton-physics/newton PR: 519
File: newton/geometry.py:16-22
Timestamp: 2025-08-12T17:51:37.474Z
Learning: In the Newton public API refactor, common geometry symbols like ParticleFlags and ShapeFlags are now exposed at the top level in newton/__init__.py rather than through newton.geometry. The newton/geometry.py module is intentionally focused only on broad-phase collision detection classes (BroadPhaseAllPairs, BroadPhaseExplicit, BroadPhaseSAP).
Applied to files:
newton/_src/sensors/warp_raytrace/textures.pynewton/_src/sensors/warp_raytrace/bvh.pynewton/_src/sensors/warp_raytrace/lighting.pynewton/_src/sensors/tiled_camera_sensor.pynewton/_src/sensors/warp_raytrace/ray_cast.pynewton/_src/sensors/warp_raytrace/render.pynewton/_src/sensors/warp_raytrace/render_context.py
📚 Learning: 2025-09-26T05:58:21.013Z
Learnt from: WenchaoHuang
Repo: newton-physics/newton PR: 835
File: newton/_src/solvers/style3d/collision/collision.py:49-53
Timestamp: 2025-09-26T05:58:21.013Z
Learning: In newton/_src/solvers/style3d/collision/collision.py, the broad_phase buffers (broad_phase_ee, broad_phase_ef, broad_phase_vf) created with wp.array() don't need zero-initialization because they follow a write-first-read-later pattern: BVH query kernels in frame_begin() populate these buffers completely (write-only operations), and collision kernels only read from them afterward in accumulate_contact_force(), ensuring no undefined reads occur.
Applied to files:
newton/_src/sensors/warp_raytrace/bvh.pynewton/_src/sensors/warp_raytrace/render_context.py
📚 Learning: 2025-09-26T05:58:21.013Z
Learnt from: WenchaoHuang
Repo: newton-physics/newton PR: 835
File: newton/_src/solvers/style3d/collision/collision.py:49-53
Timestamp: 2025-09-26T05:58:21.013Z
Learning: In newton/_src/solvers/style3d/collision/collision.py, the broad_phase buffers (broad_phase_ee, broad_phase_ef, broad_phase_vf) created with wp.array() don't need zero-initialization because the BVH query kernels that use them always write the count to query_results[0, tid] = 0 first before populating any data, ensuring no undefined reads occur.
Applied to files:
newton/_src/sensors/warp_raytrace/bvh.pynewton/_src/sensors/warp_raytrace/render_context.py
📚 Learning: 2025-11-12T23:53:29.478Z
Learnt from: daniela-hase
Repo: newton-physics/newton PR: 1044
File: newton/_src/sensors/tiled_camera_sensor.py:451-466
Timestamp: 2025-11-12T23:53:29.478Z
Learning: In newton/_src/sensors/tiled_camera_sensor.py, the convert_camera_to_warp_arrays method extracts [:3, :3] from camera.get_view_matrix().reshape(4, 4) without transposing. This is correct because Pyglet's Mat4.look_at returns a column-major view matrix, and reshaping it as row-major in NumPy creates an implicit transpose, converting the world→camera rotation into the camera→world rotation that the renderer expects.
Applied to files:
newton/examples/sensors/example_sensor_tiled_camera.pynewton/_src/sensors/tiled_camera_sensor.pynewton/_src/sensors/warp_raytrace/render.py
📚 Learning: 2025-09-15T13:13:37.976Z
Learnt from: gdaviet
Repo: newton-physics/newton PR: 750
File: newton/_src/solvers/implicit_mpm/solve_rheology.py:772-783
Timestamp: 2025-09-15T13:13:37.976Z
Learning: In Warp's tiled launch API, using a 2D launch dimension dim=(num_blocks, tile_size) is correct for tiled kernels. The wp.tid() function can either return a 2D tuple (block_index, lane) or just discard the last dimension to return only the block_index when lane information is not needed, making `block_index = wp.tid()` a valid shortcut in tiled kernels.
Applied to files:
newton/_src/sensors/warp_raytrace/render.py
📚 Learning: 2025-09-25T16:14:22.033Z
Learnt from: dylanturpin
Repo: newton-physics/newton PR: 806
File: newton/_src/sim/ik/ik_objectives.py:0-0
Timestamp: 2025-09-25T16:14:22.033Z
Learning: In NVIDIA Warp's Newton physics library, wp.transform supports direct numerical indexing (e.g., body_tf[0], body_tf[1], body_tf[2] for position and body_tf[3], body_tf[4], body_tf[5], body_tf[6] for quaternion components) to access its elements. This is the standard API used throughout the codebase.
Applied to files:
newton/_src/sensors/warp_raytrace/render.py
🧬 Code graph analysis (8)
newton/_src/sensors/warp_raytrace/__init__.py (1)
newton/_src/sensors/warp_raytrace/render_context.py (2)
ClearData(27-31)RenderContext(37-330)
newton/_src/sensors/warp_raytrace/textures.py (1)
newton/_src/sensors/warp_raytrace/types.py (1)
GeomType(21-32)
newton/_src/sensors/warp_raytrace/bvh.py (2)
newton/_src/sensors/warp_raytrace/types.py (1)
GeomType(21-32)newton/_src/sensors/tiled_camera_sensor.py (1)
compute_mesh_bounds(52-65)
newton/examples/sensors/example_sensor_tiled_camera.py (2)
newton/_src/sensors/tiled_camera_sensor.py (2)
create_shape_index_image_output(654-661)flatten_color_image_to_rgba(442-479)newton/_src/sensors/warp_raytrace/render_context.py (1)
create_shape_index_image_output(144-145)
newton/_src/sensors/warp_raytrace/lighting.py (1)
newton/_src/sensors/warp_raytrace/render_context.py (4)
particles_position(303-304)particles_position(307-310)particles_radius(313-314)particles_radius(317-320)
newton/_src/sensors/warp_raytrace/ray_cast.py (2)
newton/_src/sensors/warp_raytrace/types.py (1)
GeomType(21-32)newton/_src/sensors/warp_raytrace/ray.py (1)
ray_mesh_with_bvh(582-608)
newton/_src/sensors/warp_raytrace/render.py (4)
newton/_src/sensors/warp_raytrace/render_context.py (6)
ClearData(27-31)RenderContext(37-330)particles_position(303-304)particles_position(307-310)particles_radius(313-314)particles_radius(317-320)newton/_src/sensors/warp_raytrace/ray_cast.py (1)
closest_hit(216-281)newton/_src/sensors/warp_raytrace/textures.py (1)
sample_texture(88-147)newton/_src/sensors/warp_raytrace/lighting.py (1)
compute_lighting(22-119)
newton/_src/sensors/warp_raytrace/render_context.py (3)
newton/_src/sensors/warp_raytrace/bvh.py (2)
compute_bvh_group_roots(237-239)compute_shape_bvh_bounds(145-201)newton/_src/sensors/tiled_camera_sensor.py (1)
render(336-378)newton/_src/sensors/warp_raytrace/render.py (1)
render_megakernel(312-410)
⏰ 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 Tests / Run GPU Unit Tests on AWS EC2
- GitHub Check: Run GPU Benchmarks / Run GPU Benchmarks on AWS EC2
🔇 Additional comments (27)
asv/benchmarks/simulation/bench_tiled_camera_sensor.py (1)
89-103: Benchmark render calls correctly opt into the newclear_dataAPIPassing
clear_data=Nonevia keyword while still specifyingrefit_bvh=Falsekeeps the call compatible with the updatedTiledCameraSensor.rendersignature and cleanly disables per‑frame clears for these tight timing loops. Looks good.Also applies to: 106-120
newton/_src/sensors/warp_raytrace/__init__.py (1)
16-24: ExportingClearDatafrom the package is appropriateRe‑exporting
ClearDataalongsideRenderContextand the enums makes the new clear API discoverable to callers without having to know aboutrender_context.pyinternals. No issues here.newton/examples/sensors/example_sensor_tiled_camera.py (1)
77-100: Shape‑index visualization pipeline looks coherent end‑to‑endThe rename from geom‑id to shape‑index is threaded consistently:
- Kernels now accept
shape_indicesand either map to semantic colors viasemantic_colorsor to per‑shape random colors, both writing packed RGBA into the same buffer.tiled_camera_sensor_shape_index_imageis allocated via the newcreate_shape_index_image_output()and passed intoTiledCameraSensor.renderusing the updated keyword.update_texture()uses the shape‑index image both as input and output for the mapping kernels, then feeds it toflatten_color_image_to_rgba, which matches the packed‑RGBA representation.- The GUI toggle label “Show Shape Index Output” correctly reflects the new naming.
No correctness issues stand out here.
Also applies to: 211-212, 240-249, 295-335, 371-374
newton/_src/sensors/warp_raytrace/textures.py (1)
36-53: Texture sampling refactor to shape‑centric parameters preserves logicThe plane/mesh branches now consume per‑shape inputs (
shape_geom_type,shape_transform, indices) instead of indirect geom IDs, but the core sampling logic and early‑exit checks remain the same. The updatedsample_texture_planecall sequence and the PLANE / MESH dispatch look consistent with the new API.Also applies to: 88-147
newton/_src/sensors/warp_raytrace/lighting.py (1)
22-49: Shape‑based BVH inputs incompute_lightinglook consistent; verifyfirst_hitsignatureThe lighting function now cleanly separates config (
enable_shadows,enable_particles) from data (shape_*,mesh_ids, particles) and passes a coherent set of shape‑centric BVH arguments toray_cast.first_hit. The shadow origin/max‑t handling and visibility reduction are unchanged.Since this is a fairly wide signature change, please confirm that
ray_cast.first_hithas been updated to accept the same parameter order to avoid subtle mismatches.Also applies to: 79-119
newton/_src/sensors/warp_raytrace/bvh.py (2)
144-202:compute_shape_bvh_boundscorrectly switches to shape‑indexed dataThe kernel now:
- Treats
shape_enabledas a compact list of enabled shapes (shape_index = shape_enabled[bvh_index_local]).- Uses
shape_world_index,shape_geom_types,shape_sizes,shape_transforms, andshape_mesh_indicesto compute bounds, with the same per‑type logic (sphere, capsule, cylinder, cone, plane, mesh, ellipsoid, box) as before.- Writes lowers/uppers and
world_indexback into the BVH buffers using the local BVH index.This is a clean terminology and data‑flow update; behavior should remain the same as the previous geom‑based version.
205-234: Particle BVH bounds rename is mechanical
compute_particle_bvh_boundsonly renames intermediates (bvh_index_local,shape_index) without changing how world indices or sphere bounds are computed. No functional differences introduced here.newton/_src/sensors/tiled_camera_sensor.py (7)
24-29: ClearData integration and default clear color are wired sensiblyImporting
ClearDataand defining a module‑levelDEFAULT_CLEAR_DATA = ClearData(0xFF666666)gives a clear, reusable default for callers while still allowing them to passNoneto skip clears. Using this constant as the default forrender(clear_data=...)is straightforward and keeps behavior explicit.
68-88: Shape enablement helpers match the new shape‑centric RenderContext fields
is_supported_shape_geom_typeandcompute_enabled_shapesnow operate onshape_geom_type/shape_flagsand fill:
out_shape_enabledas a packed list of visible, supported shapes, andout_mesh_indicesas a simple per‑shape index map,with
num_shapesderived fromout_shape_enabled_count. This aligns with howcompute_shape_bvh_boundsconsumesshape_enabled/num_shapesand should be a drop‑in replacement for the previous geom‑based paths.Also applies to: 90-110
248-308: RenderContext initialization is consistent with shape‑based data and BVH setupThe constructor now:
- Initializes
shape_mesh_indices,mesh_bounds, and allshape_*arrays onrender_context.- Uses
compute_enabled_shapesto populateshape_enabled/num_shapesandcompute_mesh_boundsto fillmesh_bounds.- For particle/triangle data, keeps the existing pattern of wiring
model.particle_*andtri_indicesinto the context.This matches the expectations of the updated BVH and render code and keeps the public
TiledCameraSensorAPI unchanged apart from the new shape‑index output.
316-335: State update path correctly switches to shape‑centric transformsGating the kernel launch on
self.render_context.has_shapesand writing intoshape_transforms/shape_sizesmirrors the previous geom‑based update logic and respects the new RenderContext fields. Triangle and particle updates are untouched and still guard on their respectivehas_*properties.
336-378:rendersignature and ClearData propagation are coherentThe
rendermethod now:
- Accepts an optional
shape_index_imagealongside color/depth/normal outputs.- Forwards
clear_data(defaulting toDEFAULT_CLEAR_DATA) down intorender_context.render.- Continues to call
update_from_statewhen astateis provided.Existing call sites using only color/depth still work, and new call sites can opt into shape‑index and customized clear behavior without breaking the API.
563-588: Random color assignment correctly targetsshape_colorsBoth
assign_random_colors_per_worldandassign_random_colors_per_shapenow populaterender_context.shape_colorswith per‑shapevec4fcolors. The per‑world variant reuses colors based onshape_world, which matches the intended semantics of “colors_per_world”.
605-635: Checkerboard material setup uses the new shape‑material fields correctlyThe checkerboard helper enables textures, sets up single‑texture metadata, and then assigns all shapes to material 0 via
shape_materials. This is consistent with the shape‑centric material system and should behave identically to the previous geom‑based version.newton/_src/sensors/warp_raytrace/ray_cast.py (4)
21-24: Constants renamed consistently.The sentinel constants are properly renamed from
*_GEOM_IDto*_SHAPE_ID. The values remain unchanged which ensures backward compatibility for any persisted data.
27-35: Struct field renaming is consistent.The
ClosestHitstruct appropriately renames fields fromgeom_*toshape_*, and changes the suffix fromidtoindexwhich better reflects that these are array indices rather than unique identifiers.
48-146: Function rename and parameter updates are consistent.The
closest_hit_shapefunction (renamed fromclosest_hit_geom) correctly propagates the shape-based naming throughout its parameters and internal logic. The geometry type dispatch logic remains correct.
215-281: Main closest_hit function wiring is correct.The
closest_hitfunction correctly initializes theClosestHitstruct with the new field names and properly passes all renamed shape parameters to the helper functions.newton/_src/sensors/warp_raytrace/render_context.py (5)
26-34: ClearData dataclass is well-designed.The consolidation of clear parameters into a single
ClearDatadataclass improves the API ergonomics. The use offield(default_factory=...)correctly handles mutable defaults.
83-90: Shape-related field naming is consistent.The field naming
shape_geom_typesappropriately indicates that each shape has an associated geometry type. This preserves clarity about what the data represents while aligning with the shape-centric naming convention.
118-126: Private method renamed appropriately.The
__init_shape_outputsmethod correctly initializes shape-related BVH output buffers with consistent naming.
187-210: Render method signature and implementation updated correctly.The
render()method now acceptsshape_index_imageandclear_data: ClearDataparameters, replacing the previous geometry-centric naming and individual clear parameters. The check forhas_shapesis correctly used.
212-230: BVH bounds computation correctly rewired to shape-based naming.The
__compute_bvh_shape_boundsmethod properly invokes the renamedcompute_shape_bvh_boundskernel with all shape-prefixed inputs and outputs.newton/_src/sensors/warp_raytrace/render.py (4)
37-49: Coordinate function return values appropriately renamed.The
tid_to_tile_coordfunction now returnsworld_index, camera_indexinstead ofworld_id, camera_id, which better reflects that these are array indices.
98-109: Kernel parameters renamed consistently with section comments.The
_render_megakernelsignature correctly renames all geometry-related parameters to shape-based equivalents. The section comments (# Shapes BVH,# Shapes) are appropriately updated.
163-168: Camera transform access uses consistent indexing.The camera transforms and rays are correctly accessed using
[camera_index, world_index]which aligns with the renamed index variables.
359-370: Kernel launch inputs correctly wired to RenderContext shape fields.The
render_megakernelwrapper correctly passes all renamedrc.shape_*andrc.bvh_shapes*fields to the kernel.
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
newton/_src/sensors/warp_raytrace/bvh.py (1)
144-201: Inconsistent local variable name:geom_typeshould beshape_type.Line 175 still uses
geom_typeas the local variable name while all other parameters and references have been renamed to useshape_*terminology.- geom_type = shape_types[shape_index] + shape_type = shape_types[shape_index] lower = wp.vec3f() upper = wp.vec3f() - if geom_type == RenderShapeType.SPHERE: + if shape_type == RenderShapeType.SPHERE: lower, upper = compute_sphere_bounds(wp.transform_get_translation(transform), size[0]) - elif geom_type == RenderShapeType.CAPSULE: + elif shape_type == RenderShapeType.CAPSULE: lower, upper = compute_capsule_bounds(transform, size) - elif geom_type == RenderShapeType.CYLINDER: + elif shape_type == RenderShapeType.CYLINDER: lower, upper = compute_cylinder_bounds(transform, size) - elif geom_type == RenderShapeType.CONE: + elif shape_type == RenderShapeType.CONE: lower, upper = compute_cone_bounds(transform, size) - elif geom_type == RenderShapeType.PLANE: + elif shape_type == RenderShapeType.PLANE: lower, upper = compute_plane_bounds(transform, size) - elif geom_type == RenderShapeType.MESH: + elif shape_type == RenderShapeType.MESH: min_bounds = mesh_bounds[shape_mesh_indices[shape_index], 0] max_bounds = mesh_bounds[shape_mesh_indices[shape_index], 1] lower, upper = compute_mesh_bounds(transform, size, min_bounds, max_bounds) - elif geom_type == RenderShapeType.ELLIPSOID: + elif shape_type == RenderShapeType.ELLIPSOID: lower, upper = compute_ellipsoid_bounds(transform, size) - elif geom_type == RenderShapeType.BOX: + elif shape_type == RenderShapeType.BOX: lower, upper = compute_box_bounds(transform, size)
📜 Review details
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (12)
asv/benchmarks/simulation/bench_tiled_camera_sensor.py(2 hunks)newton/_src/sensors/tiled_camera_sensor.py(17 hunks)newton/_src/sensors/warp_raytrace/__init__.py(1 hunks)newton/_src/sensors/warp_raytrace/bvh.py(3 hunks)newton/_src/sensors/warp_raytrace/lighting.py(3 hunks)newton/_src/sensors/warp_raytrace/ray.py(3 hunks)newton/_src/sensors/warp_raytrace/ray_cast.py(15 hunks)newton/_src/sensors/warp_raytrace/render.py(13 hunks)newton/_src/sensors/warp_raytrace/render_context.py(9 hunks)newton/_src/sensors/warp_raytrace/textures.py(4 hunks)newton/_src/sensors/warp_raytrace/types.py(2 hunks)newton/examples/sensors/example_sensor_tiled_camera.py(5 hunks)
🧰 Additional context used
🧠 Learnings (10)
📓 Common learnings
Learnt from: shi-eric
Repo: newton-physics/newton PR: 521
File: newton/examples/example_cloth_hanging.py:36-36
Timestamp: 2025-08-12T05:17:34.423Z
Learning: The Newton migration guide (docs/migration.rst) is specifically for documenting how to migrate existing warp.sim functionality to Newton equivalents. New Newton-only features that didn't exist in warp.sim do not need migration documentation.
Learnt from: nvlukasz
Repo: newton-physics/newton PR: 519
File: newton/geometry.py:16-22
Timestamp: 2025-08-12T17:51:37.474Z
Learning: In the Newton public API refactor, common geometry symbols like ParticleFlags and ShapeFlags are now exposed at the top level in newton/__init__.py rather than through newton.geometry. The newton/geometry.py module is intentionally focused only on broad-phase collision detection classes (BroadPhaseAllPairs, BroadPhaseExplicit, BroadPhaseSAP).
📚 Learning: 2025-08-12T17:51:37.474Z
Learnt from: nvlukasz
Repo: newton-physics/newton PR: 519
File: newton/geometry.py:16-22
Timestamp: 2025-08-12T17:51:37.474Z
Learning: In the Newton public API refactor, common geometry symbols like ParticleFlags and ShapeFlags are now exposed at the top level in newton/__init__.py rather than through newton.geometry. The newton/geometry.py module is intentionally focused only on broad-phase collision detection classes (BroadPhaseAllPairs, BroadPhaseExplicit, BroadPhaseSAP).
Applied to files:
newton/_src/sensors/warp_raytrace/__init__.pynewton/_src/sensors/warp_raytrace/textures.pynewton/_src/sensors/warp_raytrace/bvh.pynewton/_src/sensors/warp_raytrace/types.pynewton/_src/sensors/warp_raytrace/lighting.pynewton/_src/sensors/warp_raytrace/ray_cast.pynewton/_src/sensors/warp_raytrace/render.pynewton/_src/sensors/warp_raytrace/render_context.py
📚 Learning: 2025-08-25T20:10:51.009Z
Learnt from: dylanturpin
Repo: newton-physics/newton PR: 634
File: newton/examples/ik/example_ik_h1.py:0-0
Timestamp: 2025-08-25T20:10:51.009Z
Learning: In Warp, creating a new wp.array() with an existing array and different shape (e.g., wp.array(existing_array, shape=new_shape)) creates a view into the same underlying memory buffer, not a copy. This means modifications through either view are automatically reflected in both arrays.
Applied to files:
newton/_src/sensors/warp_raytrace/textures.pynewton/_src/sensors/warp_raytrace/bvh.py
📚 Learning: 2025-09-26T05:58:21.013Z
Learnt from: WenchaoHuang
Repo: newton-physics/newton PR: 835
File: newton/_src/solvers/style3d/collision/collision.py:49-53
Timestamp: 2025-09-26T05:58:21.013Z
Learning: In newton/_src/solvers/style3d/collision/collision.py, the broad_phase buffers (broad_phase_ee, broad_phase_ef, broad_phase_vf) created with wp.array() don't need zero-initialization because the BVH query kernels that use them always write the count to query_results[0, tid] = 0 first before populating any data, ensuring no undefined reads occur.
Applied to files:
newton/_src/sensors/warp_raytrace/bvh.pynewton/_src/sensors/warp_raytrace/render_context.py
📚 Learning: 2025-09-26T05:58:21.013Z
Learnt from: WenchaoHuang
Repo: newton-physics/newton PR: 835
File: newton/_src/solvers/style3d/collision/collision.py:49-53
Timestamp: 2025-09-26T05:58:21.013Z
Learning: In newton/_src/solvers/style3d/collision/collision.py, the broad_phase buffers (broad_phase_ee, broad_phase_ef, broad_phase_vf) created with wp.array() don't need zero-initialization because they follow a write-first-read-later pattern: BVH query kernels in frame_begin() populate these buffers completely (write-only operations), and collision kernels only read from them afterward in accumulate_contact_force(), ensuring no undefined reads occur.
Applied to files:
newton/_src/sensors/warp_raytrace/bvh.pynewton/_src/sensors/warp_raytrace/render_context.py
📚 Learning: 2025-11-12T23:53:29.478Z
Learnt from: daniela-hase
Repo: newton-physics/newton PR: 1044
File: newton/_src/sensors/tiled_camera_sensor.py:451-466
Timestamp: 2025-11-12T23:53:29.478Z
Learning: In newton/_src/sensors/tiled_camera_sensor.py, the convert_camera_to_warp_arrays method extracts [:3, :3] from camera.get_view_matrix().reshape(4, 4) without transposing. This is correct because Pyglet's Mat4.look_at returns a column-major view matrix, and reshaping it as row-major in NumPy creates an implicit transpose, converting the world→camera rotation into the camera→world rotation that the renderer expects.
Applied to files:
newton/examples/sensors/example_sensor_tiled_camera.pynewton/_src/sensors/warp_raytrace/render.pynewton/_src/sensors/tiled_camera_sensor.py
📚 Learning: 2025-11-07T01:42:36.906Z
Learnt from: daniela-hase
Repo: newton-physics/newton PR: 1044
File: newton/_src/sensors/tiled_camera_sensor.py:224-256
Timestamp: 2025-11-07T01:42:36.906Z
Learning: In newton/_src/sensors/tiled_camera_sensor.py, the `# noqa: PLC0415` directives on the local PIL imports (lines 224 and 256 in save_color_image and save_depth_image methods) should be kept because they are required by the pre-commit configuration. The local imports are intentional for optional dependency handling.
Applied to files:
newton/_src/sensors/warp_raytrace/render.pynewton/_src/sensors/tiled_camera_sensor.py
📚 Learning: 2025-09-15T13:13:37.976Z
Learnt from: gdaviet
Repo: newton-physics/newton PR: 750
File: newton/_src/solvers/implicit_mpm/solve_rheology.py:772-783
Timestamp: 2025-09-15T13:13:37.976Z
Learning: In Warp's tiled launch API, using a 2D launch dimension dim=(num_blocks, tile_size) is correct for tiled kernels. The wp.tid() function can either return a 2D tuple (block_index, lane) or just discard the last dimension to return only the block_index when lane information is not needed, making `block_index = wp.tid()` a valid shortcut in tiled kernels.
Applied to files:
newton/_src/sensors/warp_raytrace/render.pynewton/_src/sensors/tiled_camera_sensor.py
📚 Learning: 2025-09-25T16:14:22.033Z
Learnt from: dylanturpin
Repo: newton-physics/newton PR: 806
File: newton/_src/sim/ik/ik_objectives.py:0-0
Timestamp: 2025-09-25T16:14:22.033Z
Learning: In NVIDIA Warp's Newton physics library, wp.transform supports direct numerical indexing (e.g., body_tf[0], body_tf[1], body_tf[2] for position and body_tf[3], body_tf[4], body_tf[5], body_tf[6] for quaternion components) to access its elements. This is the standard API used throughout the codebase.
Applied to files:
newton/_src/sensors/warp_raytrace/render.py
📚 Learning: 2025-09-09T10:29:35.521Z
Learnt from: gdaviet
Repo: newton-physics/newton PR: 750
File: newton/_src/solvers/implicit_mpm/rasterized_collisions.py:86-90
Timestamp: 2025-09-09T10:29:35.521Z
Learning: In Warp's mesh query system, wp.mesh_eval_face_normal returns face normals that point outward from the collider surface by definition. The query.sign from wp.mesh_query_point_sign_normal indicates inside/outside but should not be used to flip the face normal direction, as this would make outward-pointing normals point inward incorrectly.
Applied to files:
newton/_src/sensors/warp_raytrace/ray.py
🧬 Code graph analysis (3)
newton/_src/sensors/warp_raytrace/__init__.py (2)
newton/_src/sensors/warp_raytrace/render_context.py (2)
ClearData(27-31)RenderContext(37-330)newton/_src/sensors/warp_raytrace/types.py (2)
RenderLightType(35-42)RenderShapeType(21-32)
newton/_src/sensors/warp_raytrace/textures.py (1)
newton/_src/sensors/warp_raytrace/types.py (1)
RenderShapeType(21-32)
newton/_src/sensors/warp_raytrace/ray_cast.py (2)
newton/_src/sensors/warp_raytrace/types.py (1)
RenderShapeType(21-32)newton/_src/sensors/warp_raytrace/ray.py (1)
ray_mesh_with_bvh(582-608)
⏰ 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). (1)
- GitHub Check: Run GPU Benchmarks / Run GPU Benchmarks on AWS EC2
🔇 Additional comments (51)
newton/_src/sensors/warp_raytrace/types.py (2)
21-32: LGTM - Clean enum rename fromGeomTypetoRenderShapeType.The rename aligns with the broader shape-centric naming convention. Note that this is a breaking API change. Per the PR description, ensure
docs/migration.rstis updated for warp.sim users who may reference the oldGeomTypename.
35-42: LGTM - Clean enum rename fromLightTypetoRenderLightType.Consistent with the
RenderShapeTypenaming pattern.newton/_src/sensors/warp_raytrace/textures.py (3)
18-18: LGTM - Import updated to useRenderShapeType.
36-52: LGTM -sample_texture_planeparameter renamed fromgeom_transformtoshape_transform.The inverse transform computation on line 45 correctly uses the renamed parameter.
87-124: LGTM -sample_texturesignature and logic updated for shape-centric API.The parameter renames (
shape_type,shape_transform,material_index,texture_index) are consistent, and the type comparisons correctly useRenderShapeType.PLANEandRenderShapeType.MESH.newton/_src/sensors/warp_raytrace/bvh.py (2)
18-18: LGTM - Import updated to useRenderShapeType.
204-233: LGTM -compute_particle_bvh_boundsupdated with consistent naming.The variable renames (
bvh_index_local,world_index,shape_index) are consistent with the shape-centric convention.asv/benchmarks/simulation/bench_tiled_camera_sensor.py (2)
101-102: LGTM - Updated to use newclear_dataAPI.The change from separate
clear_color/clear_depthparameters to the unifiedclear_data=Nonealigns with the consolidatedClearDatastructure introduced in this PR.
118-119: LGTM - Consistentclear_datausage in tiled rendering benchmark.newton/_src/sensors/warp_raytrace/__init__.py (1)
16-24: LGTM - Public API exports updated for shape-centric naming.The module now correctly exports
ClearData,RenderContext,RenderLightType, andRenderShapeType. This is a breaking change that removesGeomTypeandLightTypefrom the public API.newton/_src/sensors/warp_raytrace/ray.py (2)
43-56: LGTM - Docstring updated to reflect shape-centric terminology.The documentation now correctly references "local shape frame" instead of "local geom frame".
581-608: LGTM -ray_mesh_with_bvhparameter renamed frommesh_geom_idtomesh_shape_id.The parameter rename is consistent throughout the function body and return statement.
newton/_src/sensors/warp_raytrace/render_context.py (7)
26-34: LGTM - Well-designedClearDatadataclass consolidating clear parameters.The dataclass cleanly encapsulates all clearing options with sensible defaults:
clear_color: 0 (black)clear_depth: 0.0clear_shape_index: 0xFFFFFFFF (sentinel for "no shape")clear_normal: (0, 0, 0)Using
field(default_factory=...)correctly avoids mutable default argument issues with Warp types.
64-90: LGTM - Instance variables renamed fromgeom_*toshape_*.All geometry-related fields consistently renamed to shape-centric terminology.
109-126: LGTM - BVH arrays and initialization method renamed to shape-centric naming.The rename from
bvh_geom_*tobvh_shapes_*and__init_geom_outputsto__init_shape_outputsis consistent.
144-145: LGTM - Output creation method renamed fromcreate_geom_id_image_outputtocreate_shape_index_image_output.Breaking API change - consumers calling the old method name will need to update.
187-210: LGTM -render()method signature updated withshape_index_imageandclear_dataparameters.The consolidated
clear_data: ClearData | Noneparameter replaces the previous individual clear parameters, improving API ergonomics.
212-230: LGTM - BVH bounds computation method and kernel call updated for shape-centric naming.The
__compute_bvh_shape_boundsmethod correctly passes allshape_*arrays to the renamedcompute_shape_bvh_boundskernel.
254-272: LGTM - Properties renamed for shape-centric API.
num_shapes_totalandhas_shapescorrectly replace the previousnum_geoms_totalandhas_geometries.newton/_src/sensors/warp_raytrace/lighting.py (2)
21-49: LGTM! Function signature updated consistently with shape-centric naming.The parameter renaming from
geom_*toshape_*andworld_idtoworld_indexis consistent with the broader refactor. The reordering of parameters (e.g.,normalmoved aftertriangle_mesh_id) aligns with the updatedray_cast.first_hitsignature.
82-114: Shadow ray casting correctly updated to use shape-based parameters.The
ray_cast.first_hitcall now passes the renamed shape-centric parameters in the correct order, matching the updated function signature inray_cast.py.newton/examples/sensors/example_sensor_tiled_camera.py (4)
77-99: Kernel renaming fromgeom_idtoshape_indexis consistent and correct.The kernels
shape_index_to_semantic_rgbandshape_index_to_random_rgbcorrectly useshape_indexfor variable naming internally. The logic remains unchanged.
211-211: Output image creation updated correctly.The
create_shape_index_image_output()call aligns with the renamed API inTiledCameraSensor.
315-334: Kernel launch calls updated consistently with renamed kernels and image outputs.All references to
shape_index_to_semantic_rgb,shape_index_to_random_rgb, andtiled_camera_sensor_shape_index_imageare correctly propagated.
373-374: UI label updated appropriately."Show Shape Index Output" correctly reflects the renamed output type.
newton/_src/sensors/warp_raytrace/ray_cast.py (9)
19-24: Constants and import updated consistently.The import of
RenderShapeTypeand renamed constants (NO_HIT_SHAPE_ID,MAX_SHAPE_ID,TRIANGLE_MESH_SHAPE_ID,PARTICLES_SHAPE_ID) align with the shape-centric naming convention.
27-36: ClosestHit struct fields renamed appropriately.The fields
shape_indexandshape_mesh_indexreplace the formergeom_idandgeom_mesh_id, maintaining semantic clarity.
47-146:closest_hit_shapefunction correctly refactored fromclosest_hit_geom.All parameter names, internal variable names, and
RenderShapeTypecomparisons are consistently updated. The BVH traversal logic and hit detection remain unchanged.
149-189:closest_hit_particlesupdated withworld_indexnaming.The particle hit detection correctly uses
PARTICLES_SHAPE_IDfor the shape index assignment on hit.
192-212:closest_hit_triangle_meshupdated to use shape-centric field names.Correctly assigns
TRIANGLE_MESH_SHAPE_IDand-1forshape_mesh_index.
215-281: Mainclosest_hitfunction updated with shape-centric API.Initialization uses
NO_HIT_SHAPE_ID, and all calls to helper functions use the renamed parameters correctly.
284-371:first_hit_shapefunction correctly refactored.The early-out optimization for shadow rays uses shape-centric parameters and
RenderShapeTypecomparisons consistently.
374-411:first_hit_particlesupdated withworld_indexnaming.Particle intersection for shadow rays correctly uses the renamed parameters.
429-489: Mainfirst_hitfunction updated consistently.All calls to
first_hit_shapeandfirst_hit_particlesuse the renamed shape-centric parameters.newton/_src/sensors/warp_raytrace/render.py (6)
37-49: Coordinate extraction functions updated withworld_index/camera_indexnaming.The return values are consistently renamed throughout tile and pixel coordinate calculations.
79-149: Kernel parameters comprehensively renamed to shape-centric naming.BVH parameters (
bvh_shapes_*), shape data (shape_enabled,shape_types, etc.), and output (out_shape_index) are all consistently updated.
163-192: Ray casting and camera transform indexing updated correctly.The
camera_transformsandcamera_raysindexing usescamera_index, world_indexorder, andclosest_hitcall passes shape-centric parameters.
195-309: Shading, texturing, and lighting paths updated to useshape_indexand shape-centric data.The
closest_hit.shape_indexis used for color lookup, material access, texture sampling, and final pixel output. All shape array accesses are consistent.
326-336: Clear logic now uses explicitis not Nonechecks.This correctly addresses the previous review comment about the inconsistent truthiness check for
clear_color(which defaults to0, a falsy value). All clear fields now useis not Nonefor consistency.
312-409: Publicrender_megakernelfunction updated withClearDataandshape_index_image.The API change from individual clear parameters to a single
ClearDataobject is clean, and all kernel inputs are correctly mapped to the renamedRenderContextattributes.newton/_src/sensors/tiled_camera_sensor.py (11)
26-28: Imports and default clear data updated appropriately.The import of
ClearData,RenderLightType, andRenderShapeTypealigns with the module-level type renames.DEFAULT_CLEAR_DATAprovides a sensible default gray background.
68-87:is_supported_shape_typeupdated to useRenderShapeTypeconstants.All shape type comparisons now reference the renamed enum values consistently.
90-109:compute_enabled_shapeskernel updated with shape-centric output names.The output arrays
out_shape_enabledandout_shape_enabled_countare consistently renamed.
236-238: Class-level type aliases updated.Exposing
RenderLightTypeandRenderShapeTypeas class attributes maintains API discoverability.
248-291:__init__method updated with shape-centric render_context attributes.All attribute assignments (
shape_enabled,shape_types,shape_sizes,shape_transforms,shape_materials,shape_colors,shape_world_index,num_shapes) are consistently renamed.
309-327:update_from_stateupdated to write to shape-centric attributes.The kernel outputs now correctly target
shape_transformsandshape_sizes.
336-378:render()method API updated withshape_index_imageandclear_data.The parameter rename from
geom_id_imagetoshape_index_imageand consolidation of clear parameters intoClearDataprovides a cleaner API. The docstring is updated accordingly.
563-587: Color assignment methods updated to useshape_colors.Both
assign_random_colors_per_worldandassign_random_colors_per_shapecorrectly write torender_context.shape_colors.
596-603: Default light creation usesRenderLightType.DIRECTIONAL.The enum reference is updated to match the renamed type.
654-661:create_shape_index_image_output()replacescreate_geom_id_image_output().The method name and docstring are updated to reflect the shape-centric terminology.
605-634: Checkerboard material assignment updated to useshape_materials.The docstring and implementation correctly reference shapes instead of geometries.
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (3)
newton/_src/sensors/tiled_camera_sensor.py (1)
86-86: Minor: Log message still references "geom".For consistency with the renaming effort, consider updating the message to remove "geom".
- wp.printf("Unsupported shape geom type: %d\n", shape_type) + wp.printf("Unsupported shape type: %d\n", shape_type)newton/_src/sensors/warp_raytrace/bvh.py (2)
175-175: Minor: Local variable still namedgeom_type.For full consistency with the renaming effort, consider renaming this local variable to
shape_type.- geom_type = shape_types[shape_index] + shape_type = shape_types[shape_index]This would require updating the subsequent comparisons (lines 180-196) to use
shape_typeinstead ofgeom_type.
204-233: Naming inconsistency:shape_indexused for particle index.In
compute_particle_bvh_bounds, the variableshape_index(line 220) is used to index particles, not shapes. This is semantically misleading since particles are distinct from shapes.Consider using
particle_indexfor clarity:- shape_index = bvh_index_local + particle_index = bvh_index_local - world_index = particle_world_index[shape_index] + world_index = particle_world_index[particle_index] ... - lower, upper = compute_sphere_bounds(particle_position[shape_index], particle_radius[shape_index]) + lower, upper = compute_sphere_bounds(particle_position[particle_index], particle_radius[particle_index])
📜 Review details
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (9)
newton/_src/sensors/tiled_camera_sensor.py(17 hunks)newton/_src/sensors/warp_raytrace/__init__.py(1 hunks)newton/_src/sensors/warp_raytrace/bvh.py(3 hunks)newton/_src/sensors/warp_raytrace/lighting.py(3 hunks)newton/_src/sensors/warp_raytrace/ray_cast.py(15 hunks)newton/_src/sensors/warp_raytrace/render.py(13 hunks)newton/_src/sensors/warp_raytrace/render_context.py(9 hunks)newton/_src/sensors/warp_raytrace/textures.py(4 hunks)newton/_src/sensors/warp_raytrace/types.py(2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- newton/_src/sensors/warp_raytrace/init.py
🧰 Additional context used
🧠 Learnings (9)
📓 Common learnings
Learnt from: shi-eric
Repo: newton-physics/newton PR: 521
File: newton/examples/example_cloth_hanging.py:36-36
Timestamp: 2025-08-12T05:17:34.423Z
Learning: The Newton migration guide (docs/migration.rst) is specifically for documenting how to migrate existing warp.sim functionality to Newton equivalents. New Newton-only features that didn't exist in warp.sim do not need migration documentation.
Learnt from: nvlukasz
Repo: newton-physics/newton PR: 519
File: newton/geometry.py:16-22
Timestamp: 2025-08-12T17:51:37.474Z
Learning: In the Newton public API refactor, common geometry symbols like ParticleFlags and ShapeFlags are now exposed at the top level in newton/__init__.py rather than through newton.geometry. The newton/geometry.py module is intentionally focused only on broad-phase collision detection classes (BroadPhaseAllPairs, BroadPhaseExplicit, BroadPhaseSAP).
📚 Learning: 2025-08-12T17:51:37.474Z
Learnt from: nvlukasz
Repo: newton-physics/newton PR: 519
File: newton/geometry.py:16-22
Timestamp: 2025-08-12T17:51:37.474Z
Learning: In the Newton public API refactor, common geometry symbols like ParticleFlags and ShapeFlags are now exposed at the top level in newton/__init__.py rather than through newton.geometry. The newton/geometry.py module is intentionally focused only on broad-phase collision detection classes (BroadPhaseAllPairs, BroadPhaseExplicit, BroadPhaseSAP).
Applied to files:
newton/_src/sensors/warp_raytrace/types.pynewton/_src/sensors/warp_raytrace/render_context.pynewton/_src/sensors/warp_raytrace/ray_cast.pynewton/_src/sensors/warp_raytrace/render.pynewton/_src/sensors/warp_raytrace/textures.pynewton/_src/sensors/tiled_camera_sensor.pynewton/_src/sensors/warp_raytrace/bvh.pynewton/_src/sensors/warp_raytrace/lighting.py
📚 Learning: 2025-09-26T05:58:21.013Z
Learnt from: WenchaoHuang
Repo: newton-physics/newton PR: 835
File: newton/_src/solvers/style3d/collision/collision.py:49-53
Timestamp: 2025-09-26T05:58:21.013Z
Learning: In newton/_src/solvers/style3d/collision/collision.py, the broad_phase buffers (broad_phase_ee, broad_phase_ef, broad_phase_vf) created with wp.array() don't need zero-initialization because they follow a write-first-read-later pattern: BVH query kernels in frame_begin() populate these buffers completely (write-only operations), and collision kernels only read from them afterward in accumulate_contact_force(), ensuring no undefined reads occur.
Applied to files:
newton/_src/sensors/warp_raytrace/render_context.pynewton/_src/sensors/warp_raytrace/bvh.py
📚 Learning: 2025-09-26T05:58:21.013Z
Learnt from: WenchaoHuang
Repo: newton-physics/newton PR: 835
File: newton/_src/solvers/style3d/collision/collision.py:49-53
Timestamp: 2025-09-26T05:58:21.013Z
Learning: In newton/_src/solvers/style3d/collision/collision.py, the broad_phase buffers (broad_phase_ee, broad_phase_ef, broad_phase_vf) created with wp.array() don't need zero-initialization because the BVH query kernels that use them always write the count to query_results[0, tid] = 0 first before populating any data, ensuring no undefined reads occur.
Applied to files:
newton/_src/sensors/warp_raytrace/render_context.pynewton/_src/sensors/warp_raytrace/bvh.py
📚 Learning: 2025-11-12T23:53:29.478Z
Learnt from: daniela-hase
Repo: newton-physics/newton PR: 1044
File: newton/_src/sensors/tiled_camera_sensor.py:451-466
Timestamp: 2025-11-12T23:53:29.478Z
Learning: In newton/_src/sensors/tiled_camera_sensor.py, the convert_camera_to_warp_arrays method extracts [:3, :3] from camera.get_view_matrix().reshape(4, 4) without transposing. This is correct because Pyglet's Mat4.look_at returns a column-major view matrix, and reshaping it as row-major in NumPy creates an implicit transpose, converting the world→camera rotation into the camera→world rotation that the renderer expects.
Applied to files:
newton/_src/sensors/warp_raytrace/render.pynewton/_src/sensors/tiled_camera_sensor.py
📚 Learning: 2025-11-07T01:42:36.906Z
Learnt from: daniela-hase
Repo: newton-physics/newton PR: 1044
File: newton/_src/sensors/tiled_camera_sensor.py:224-256
Timestamp: 2025-11-07T01:42:36.906Z
Learning: In newton/_src/sensors/tiled_camera_sensor.py, the `# noqa: PLC0415` directives on the local PIL imports (lines 224 and 256 in save_color_image and save_depth_image methods) should be kept because they are required by the pre-commit configuration. The local imports are intentional for optional dependency handling.
Applied to files:
newton/_src/sensors/warp_raytrace/render.py
📚 Learning: 2025-09-15T13:13:37.976Z
Learnt from: gdaviet
Repo: newton-physics/newton PR: 750
File: newton/_src/solvers/implicit_mpm/solve_rheology.py:772-783
Timestamp: 2025-09-15T13:13:37.976Z
Learning: In Warp's tiled launch API, using a 2D launch dimension dim=(num_blocks, tile_size) is correct for tiled kernels. The wp.tid() function can either return a 2D tuple (block_index, lane) or just discard the last dimension to return only the block_index when lane information is not needed, making `block_index = wp.tid()` a valid shortcut in tiled kernels.
Applied to files:
newton/_src/sensors/warp_raytrace/render.pynewton/_src/sensors/tiled_camera_sensor.py
📚 Learning: 2025-09-25T16:14:22.033Z
Learnt from: dylanturpin
Repo: newton-physics/newton PR: 806
File: newton/_src/sim/ik/ik_objectives.py:0-0
Timestamp: 2025-09-25T16:14:22.033Z
Learning: In NVIDIA Warp's Newton physics library, wp.transform supports direct numerical indexing (e.g., body_tf[0], body_tf[1], body_tf[2] for position and body_tf[3], body_tf[4], body_tf[5], body_tf[6] for quaternion components) to access its elements. This is the standard API used throughout the codebase.
Applied to files:
newton/_src/sensors/warp_raytrace/render.py
📚 Learning: 2025-08-25T20:10:51.009Z
Learnt from: dylanturpin
Repo: newton-physics/newton PR: 634
File: newton/examples/ik/example_ik_h1.py:0-0
Timestamp: 2025-08-25T20:10:51.009Z
Learning: In Warp, creating a new wp.array() with an existing array and different shape (e.g., wp.array(existing_array, shape=new_shape)) creates a view into the same underlying memory buffer, not a copy. This means modifications through either view are automatically reflected in both arrays.
Applied to files:
newton/_src/sensors/warp_raytrace/textures.pynewton/_src/sensors/warp_raytrace/bvh.py
🧬 Code graph analysis (6)
newton/_src/sensors/warp_raytrace/render_context.py (3)
newton/_src/sensors/warp_raytrace/bvh.py (1)
compute_bvh_group_roots(237-239)newton/_src/sensors/tiled_camera_sensor.py (1)
render(336-378)newton/_src/sensors/warp_raytrace/render.py (1)
render_megakernel(312-410)
newton/_src/sensors/warp_raytrace/render.py (3)
newton/_src/sensors/warp_raytrace/render_context.py (6)
ClearData(27-31)RenderContext(37-330)particles_position(303-304)particles_position(307-310)particles_radius(313-314)particles_radius(317-320)newton/_src/sensors/warp_raytrace/ray_cast.py (1)
closest_hit(216-281)newton/_src/sensors/warp_raytrace/textures.py (1)
sample_texture(88-147)
newton/_src/sensors/warp_raytrace/textures.py (1)
newton/_src/sensors/warp_raytrace/types.py (1)
RenderShapeType(21-32)
newton/_src/sensors/tiled_camera_sensor.py (3)
newton/_src/sensors/warp_raytrace/render_context.py (3)
ClearData(27-31)RenderContext(37-330)create_shape_index_image_output(144-145)newton/_src/sensors/warp_raytrace/types.py (2)
RenderLightType(35-42)RenderShapeType(21-32)newton/_src/sim/builder.py (1)
shape_count(932-936)
newton/_src/sensors/warp_raytrace/bvh.py (2)
newton/_src/sensors/warp_raytrace/types.py (1)
RenderShapeType(21-32)newton/_src/sensors/tiled_camera_sensor.py (1)
compute_mesh_bounds(52-65)
newton/_src/sensors/warp_raytrace/lighting.py (1)
newton/_src/sensors/warp_raytrace/render_context.py (4)
particles_position(303-304)particles_position(307-310)particles_radius(313-314)particles_radius(317-320)
🔇 Additional comments (30)
newton/_src/sensors/tiled_camera_sensor.py (7)
26-28: LGTM: Clean consolidation of clear parameters and type imports.The import of
ClearData,RenderLightType, andRenderShapeTypealigns with the shape-centric terminology refactor. TheDEFAULT_CLEAR_DATAinitialization is straightforward.
90-109: LGTM: Kernel parameter renaming is consistent.The
compute_enabled_shapeskernel correctly renames output parameters fromgeom_*toshape_*while preserving the original logic.
236-291: LGTM: Class attributes and initialization properly renamed.All
geom_*references in theTiledCameraSensor.__init__method have been consistently renamed toshape_*, including buffer allocations and kernel launch inputs.
309-334: LGTM: State update method uses consistent shape terminology.The
update_from_statemethod correctly useshas_shapesguard andshape_transforms/shape_sizesoutputs.
654-661: LGTM: Output creation method renamed consistently.The
create_shape_index_image_outputmethod properly delegates torender_context.create_shape_index_image_output()with updated docstring.
605-634: LGTM: Checkerboard material assignment uses correct shape terminology.Docstring and implementation consistently use "shapes" terminology.
336-378: Verify all call sites are updated for breaking API changes.The
render()method signature has changed significantly:
geom_id_image→shape_index_image- Individual
clear_color,clear_depth,clear_geom_id, andclear_normalparameters → consolidatedclear_data: ClearDataEnsure all call sites throughout the codebase have been updated to use the new parameter names and consolidated structure.
newton/_src/sensors/warp_raytrace/types.py (2)
21-32: LGTM: Enum renamed to RenderShapeType with preserved values.The enum correctly maps to
GeoTypevalues and the "Render" prefix clearly indicates this is for the raytracer subsystem.
35-42: LGTM: RenderLightType with inline docstrings.The enum rename and added per-member docstrings improve API documentation.
newton/_src/sensors/warp_raytrace/textures.py (3)
35-52: LGTM: Parameter renamed to shape_transform.The
sample_texture_planefunction correctly renamesgeom_transformtoshape_transformwith preserved logic.
87-111: LGTM: Simplified sample_texture signature with shape-centric parameters.The function now takes direct values (
shape_type,shape_transform,material_index,texture_index) instead of arrays with index lookups, which is cleaner and aligns with the shape terminology.
113-145: LGTM: Type checks updated to use RenderShapeType.Both
RenderShapeType.PLANEandRenderShapeType.MESHcomparisons are correct and consistent with the new enum.newton/_src/sensors/warp_raytrace/lighting.py (2)
21-49: LGTM: compute_lighting signature updated with shape-centric parameters.The function signature is comprehensively updated:
world_id→world_indexfor consistencybvh_geom_*→bvh_shapes_*geom_*→shape_*- Added
mesh_idsparameter for shape-to-mesh mappingParameter reordering groups related inputs logically.
82-114: LGTM: Shadow ray casting uses updated shape-centric parameters.The
ray_cast.first_hitcall correctly passes the renamedbvh_shapes_*andshape_*parameters with proper ordering.newton/_src/sensors/warp_raytrace/bvh.py (2)
144-201: LGTM: Kernel renamed with shape-centric parameters.The
compute_shape_bvh_boundskernel correctly renames all parameters and usesRenderShapeTypefor type comparisons. The logic is preserved.
18-18: LGTM: Import updated to RenderShapeType.Correctly imports the renamed enum from the types module.
newton/_src/sensors/warp_raytrace/ray_cast.py (5)
19-35: LGTM! Consistent renaming of types and constants.The import and constant renames from
geom*toshape*terminology are consistent and maintain the same values. TheClosestHitstruct field renames (geom_id→shape_index,geom_mesh_id→shape_mesh_index) align well with the broader refactoring.
39-146: LGTM! Thorough renaming in ray-shape intersection logic.The function renaming (
closest_hit_geom→closest_hit_shape) and parameter updates are consistent throughout. All internal variables and array accesses have been properly updated to useshape_*terminology, and the intersection logic remains intact.
150-212: LGTM! Particle and triangle mesh hit functions updated consistently.The special shape IDs (
PARTICLES_SHAPE_ID,TRIANGLE_MESH_SHAPE_ID) are correctly assigned toclosest_hit.shape_index, and theworld_indexparameter is properly used throughout. The variable renaming fromgi_bvh_localtosiimproves clarity.
215-282: LGTM! Main closest_hit function properly orchestrates shape-based ray casting.The wrapper function correctly initializes
closest_hit.shape_indextoNO_HIT_SHAPE_IDand passes all shape-related parameters to the helper functions. The parameter renaming is complete and consistent.
284-489: LGTM! First-hit detection functions consistently updated.The
first_hit_shape,first_hit_particles, andfirst_hitfunctions have been updated with the same consistentshape_*terminology. All parameter renames and function calls are properly aligned with theclosest_hitfunctions.newton/_src/sensors/warp_raytrace/render.py (5)
24-66: LGTM! Coordinate functions updated with index terminology.The import of
ClearDataand the renaming of return values fromworld_id/camera_idtoworld_index/camera_indexin the coordinate conversion functions are consistent with the broader terminology shift.
79-196: LGTM! Kernel signature and ray casting setup properly updated.The
_render_megakernelfunction signature has been thoroughly updated withshape_*parameters andrender_shape_index/out_shape_index. Ray computation and intersection testing correctly useworld_index/camera_indexand shape-based parameters throughout.
198-252: LGTM! Output writes and texture sampling use shape indices correctly.All output array writes properly index with
world_indexandcamera_index. The color, material, and texture lookups correctly useclosest_hit.shape_indexandclosest_hit.shape_mesh_indexto access shape-related arrays.
254-309: LGTM! Lighting calculations updated with shape terminology.The lighting loop correctly passes shape-based BVH and array parameters to
compute_lighting, and the final output write properly usesworld_indexandcamera_index.
312-410: LGTM! Wrapper function properly integrated with ClearData and shape terminology.The
render_megakernelwrapper correctly:
- Uses
shape_index_imageparameter (renamed fromgeom_id_image)- Implements
ClearDatawith explicitis not Nonechecks for all fields, properly addressing the previous concern about falsy values likewp.int32(0)- Passes all shape-based BVH and array parameters to the kernel
newton/_src/sensors/warp_raytrace/render_context.py (4)
18-34: LGTM! ClearData consolidates clear parameters effectively.The
ClearDatadataclass properly consolidates separate clear parameters into a single structure with sensible defaults:
clear_color: 0 (black)clear_depth: 0.0 (near plane)clear_shape_index: 0xFFFFFFFF (no hit)clear_normal: (0,0,0) (zero vector)The use of
field(default_factory=...)correctly handles mutable defaults, andDEFAULT_CLEAR_DATAprovides a convenient default instance.
22-126: LGTM! RenderContext fields and initialization consistently renamed.All geometry-related fields have been systematically renamed to shape-based equivalents:
bvh_geom→bvh_shapesnum_geoms→num_shapesgeom_*→shape_*for all arraysbvh_geom_*→bvh_shapes_*for BVH buffers__init_geom_outputs→__init_shape_outputsThe import change to
compute_shape_bvh_boundsaligns with updates in the bvh module.
144-210: LGTM! Render methods properly integrated with shape terminology and ClearData.The output creation, BVH refit, and render methods have been correctly updated:
create_shape_index_image_outputreplacescreate_geom_id_image_output- BVH refit uses
num_shapes_total,bvh_shapes, and shape-related buffersrendermethod signature matches the updates inrender_megakernel, acceptingshape_index_imageandclear_datawithDEFAULT_CLEAR_DATAas a convenient default
212-272: LGTM! BVH computation and properties consistently updated.The BVH bounds computation method (
__compute_bvh_shape_bounds) and properties (num_shapes_total,has_shapes) have been properly renamed and updated to use shape-based terminology throughout.
Renamed all
geom*variables toshape*in the warp rendering code to make it uniform with the rest of Newton.Newton Migration Guide
Please ensure the migration guide for warp.sim users is up-to-date with the changes made in this PR.
docs/migration.rstis up-to dateBefore your PR is "Ready for review"
newton/tests/test_examples.py)pre-commit run -aSummary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.