Merge pull request #735 from StanfordVL/fix/render_product

fix render_product syncing when updating camera width / height
This commit is contained in:
Josiah Wong 2024-05-26 02:15:33 -07:00 committed by GitHub
commit 4c62f2e37d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 22 additions and 0 deletions

View File

@ -588,6 +588,17 @@ class VisionSensor(BaseSensor):
"""
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()
@ -610,6 +621,17 @@ class VisionSensor(BaseSensor):
"""
_, 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()