Skip to content

Commit

Permalink
Merge branch 'ccrouzet/gh-388-opengl-duplicate-shapes' into 'main'
Browse files Browse the repository at this point in the history
Fix Incorrect OpenGL Rendering of Duplicate Cylinder/Mesh Shapes

See merge request omniverse/warp!971
  • Loading branch information
christophercrouzet committed Jan 15, 2025
2 parents cca9134 + 41ef6ca commit e0331ac
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@
- Negative constants evaluate to compile-time constants (fixes [GH-403](https://github.com/NVIDIA/warp/issues/403))
- Fix `AttributeError` crash in the OpenGL renderer when moving the camera ([GH-426](https://github.com/NVIDIA/warp/issues/426)).
- Fix `tile_register_t` `extract()` and `valid()` methods.
- Fix the OpenGL renderer now correctly displaying duplicate cylinder shapes ([GH-388](https://github.com/NVIDIA/warp/issues/388)).
- Fix the OpenGL renderer now correctly displaying duplicate capsule, cone, and cylinder shapes ([GH-388](https://github.com/NVIDIA/warp/issues/388)).
- Fix the OpenGL renderer now correctly displaying duplicate cylinder and mesh shapes ([GH-388](https://github.com/NVIDIA/warp/issues/388)).

## [1.5.1] - 2025-01-02

Expand Down
14 changes: 10 additions & 4 deletions warp/render/render_opengl.py
Original file line number Diff line number Diff line change
Expand Up @@ -2840,7 +2840,7 @@ def render_capsule(
up_axis: The axis of the capsule that points up (0: x, 1: y, 2: z)
color: The color of the capsule
"""
geo_hash = hash(("capsule", radius, half_height))
geo_hash = hash(("capsule", radius, half_height, up_axis))
if geo_hash in self._shape_geo_hash:
shape = self._shape_geo_hash[geo_hash]
if self.update_shape_instance(name, pos, rot):
Expand Down Expand Up @@ -2875,7 +2875,7 @@ def render_cylinder(
up_axis: The axis of the cylinder that points up (0: x, 1: y, 2: z)
color: The color of the capsule
"""
geo_hash = hash(("cylinder", radius, half_height))
geo_hash = hash(("cylinder", radius, half_height, up_axis))
if geo_hash in self._shape_geo_hash:
shape = self._shape_geo_hash[geo_hash]
if self.update_shape_instance(name, pos, rot):
Expand Down Expand Up @@ -2910,7 +2910,7 @@ def render_cone(
up_axis: The axis of the cone that points up (0: x, 1: y, 2: z)
color: The color of the cone
"""
geo_hash = hash(("cone", radius, half_height))
geo_hash = hash(("cone", radius, half_height, up_axis))
if geo_hash in self._shape_geo_hash:
shape = self._shape_geo_hash[geo_hash]
if self.update_shape_instance(name, pos, rot):
Expand Down Expand Up @@ -2989,7 +2989,7 @@ def render_mesh(
indices = np.array(indices, dtype=np.int32).reshape((-1, 3))
idx_count = len(indices)

geo_hash = hash((indices.tobytes(),))
geo_hash = hash((points.tobytes(), indices.tobytes()))

if name in self._instances:
# We've already registered this mesh instance and its associated shape.
Expand All @@ -3011,6 +3011,12 @@ def render_mesh(
if shape is not None:
# Update the shape's point positions.
self.update_shape_vertices(shape, points, scale)

if not is_template and name not in self._instances:
# Create a new instance.
body = self._resolve_body_id(parent_body)
self.add_shape_instance(name, shape, body, pos, rot, color1=colors)

return shape

# No existing shape for the given mesh was found, or its topology may have changed,
Expand Down

0 comments on commit e0331ac

Please sign in to comment.