Skip to content

Commit

Permalink
Merge pull request #735 from StanfordVL/fix/render_product
Browse files Browse the repository at this point in the history
fix render_product syncing when updating camera width / height
  • Loading branch information
cremebrule authored May 26, 2024
2 parents 36bb9b7 + 9e98760 commit 4c62f2e
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions omnigibson/sensors/vision_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,17 @@ def image_height(self, height):
"""
width, _ = self._viewport.viewport_api.get_texture_resolution()
self._viewport.viewport_api.set_texture_resolution((width, height))

# Also update render product and update all annotators
old_render_product = self._render_product
new_render_product = lazy.omni.replicator.core.create.render_product(self._prim_path, (width, height))
for annotator in self._annotators.values():
annotator.detach([old_render_product.path])
annotator.attach([new_render_product])

old_render_product.destroy()
self._render_product = new_render_product

# Requires 3 updates to propagate changes
for i in range(3):
render()
Expand All @@ -610,6 +621,17 @@ def image_width(self, width):
"""
_, height = self._viewport.viewport_api.get_texture_resolution()
self._viewport.viewport_api.set_texture_resolution((width, height))

# Also update render product and update all annotators
old_render_product = self._render_product
new_render_product = lazy.omni.replicator.core.create.render_product(self._prim_path, (width, height))
for annotator in self._annotators.values():
annotator.detach([old_render_product.path])
annotator.attach([new_render_product])

old_render_product.destroy()
self._render_product = new_render_product

# Requires 3 updates to propagate changes
for i in range(3):
render()
Expand Down

0 comments on commit 4c62f2e

Please sign in to comment.