From 6a30285576c386095302ea484d9845611b30fc85 Mon Sep 17 00:00:00 2001 From: Mikael Dallaire Cote Date: Sat, 1 Apr 2023 11:51:21 -0400 Subject: [PATCH 1/3] Fix viewer.py framebuffer size mismatch. --- examples/viewer.py | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/examples/viewer.py b/examples/viewer.py index c479482554..4f4d3840db 100644 --- a/examples/viewer.py +++ b/examples/viewer.py @@ -53,10 +53,22 @@ def __init__(self, sim_settings: Dict[str, Any]) -> None: ) # Compute environment camera resolution based on the number of environments to render in the window. - surface_size: tuple(int, int) = ( + window_size: tuple(int, int) = ( self.sim_settings["window_width"], self.sim_settings["window_height"], ) + + configuration = self.Configuration() + configuration.title = "Habitat Sim Interactive Viewer" + configuration.size = window_size + Application.__init__(self, configuration) + self.fps: float = 60.0 + + # Compute environment camera resolution based on the number of environments to render in the window. + surface_size: tuple(int, int) = ( + mn.gl.default_framebuffer.viewport.size()[0], + mn.gl.default_framebuffer.viewport.size()[1], + ) grid_size: tuple(int, int) = ReplayRenderer.environment_grid_size(self.num_env) camera_resolution: tuple(int, int) = ( surface_size[0] / grid_size[0], @@ -65,12 +77,6 @@ def __init__(self, sim_settings: Dict[str, Any]) -> None: self.sim_settings["width"] = camera_resolution[0] self.sim_settings["height"] = camera_resolution[1] - configuration = self.Configuration() - configuration.title = "Habitat Sim Interactive Viewer" - configuration.size = surface_size - Application.__init__(self, configuration) - self.fps: float = 60.0 - # draw Bullet debug line visualizations (e.g. collision meshes) self.debug_bullet_draw = False # draw active contact point debug line visualizations From e6b643767c3a375c5c155b3c0e362d0be01887c1 Mon Sep 17 00:00:00 2001 From: Mikael Dallaire Cote <110583667+0mdc@users.noreply.github.com> Date: Mon, 3 Apr 2023 09:29:40 -0400 Subject: [PATCH 2/3] Change int tuples to mn.Vector2. --- examples/viewer.py | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/examples/viewer.py b/examples/viewer.py index 4f4d3840db..8428bd32d8 100644 --- a/examples/viewer.py +++ b/examples/viewer.py @@ -53,7 +53,7 @@ def __init__(self, sim_settings: Dict[str, Any]) -> None: ) # Compute environment camera resolution based on the number of environments to render in the window. - window_size: tuple(int, int) = ( + window_size: mn.Vector2 = ( self.sim_settings["window_width"], self.sim_settings["window_height"], ) @@ -65,14 +65,10 @@ def __init__(self, sim_settings: Dict[str, Any]) -> None: self.fps: float = 60.0 # Compute environment camera resolution based on the number of environments to render in the window. - surface_size: tuple(int, int) = ( - mn.gl.default_framebuffer.viewport.size()[0], - mn.gl.default_framebuffer.viewport.size()[1], - ) grid_size: tuple(int, int) = ReplayRenderer.environment_grid_size(self.num_env) - camera_resolution: tuple(int, int) = ( - surface_size[0] / grid_size[0], - surface_size[1] / grid_size[1], + camera_resolution: mn.Vector2 = ( + self.framebuffer_size[0] / grid_size[0], + self.framebuffer_size[1] / grid_size[1], ) self.sim_settings["width"] = camera_resolution[0] self.sim_settings["height"] = camera_resolution[1] @@ -144,11 +140,13 @@ def __init__(self, sim_settings: Dict[str, Any]) -> None: # text object transform in window space is Projection matrix times Translation Matrix # put text in top left of window self.window_text_transform = mn.Matrix3.projection( - mn.Vector2(surface_size) + self.framebuffer_size ) @ mn.Matrix3.translation( mn.Vector2( - surface_size[0] * -HabitatSimInteractiveViewer.TEXT_DELTA_FROM_CENTER, - surface_size[1] * HabitatSimInteractiveViewer.TEXT_DELTA_FROM_CENTER, + self.framebuffer_size[0] + * -HabitatSimInteractiveViewer.TEXT_DELTA_FROM_CENTER, + self.framebuffer_size[1] + * HabitatSimInteractiveViewer.TEXT_DELTA_FROM_CENTER, ) ) self.shader = shaders.VectorGL2D() From 61a9443d589baaca663a4e289358a7650f3a5627 Mon Sep 17 00:00:00 2001 From: Mikael Dallaire Cote <110583667+0mdc@users.noreply.github.com> Date: Mon, 3 Apr 2023 10:59:53 -0400 Subject: [PATCH 3/3] Minor simplifications. --- examples/viewer.py | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/examples/viewer.py b/examples/viewer.py index 8428bd32d8..21241ace67 100644 --- a/examples/viewer.py +++ b/examples/viewer.py @@ -65,10 +65,9 @@ def __init__(self, sim_settings: Dict[str, Any]) -> None: self.fps: float = 60.0 # Compute environment camera resolution based on the number of environments to render in the window. - grid_size: tuple(int, int) = ReplayRenderer.environment_grid_size(self.num_env) - camera_resolution: mn.Vector2 = ( - self.framebuffer_size[0] / grid_size[0], - self.framebuffer_size[1] / grid_size[1], + grid_size: mn.Vector2i = ReplayRenderer.environment_grid_size(self.num_env) + camera_resolution: mn.Vector2 = mn.Vector2(self.framebuffer_size) / mn.Vector2( + grid_size ) self.sim_settings["width"] = camera_resolution[0] self.sim_settings["height"] = camera_resolution[1] @@ -142,11 +141,10 @@ def __init__(self, sim_settings: Dict[str, Any]) -> None: self.window_text_transform = mn.Matrix3.projection( self.framebuffer_size ) @ mn.Matrix3.translation( - mn.Vector2( - self.framebuffer_size[0] - * -HabitatSimInteractiveViewer.TEXT_DELTA_FROM_CENTER, - self.framebuffer_size[1] - * HabitatSimInteractiveViewer.TEXT_DELTA_FROM_CENTER, + mn.Vector2(self.framebuffer_size) + * mn.Vector2( + -HabitatSimInteractiveViewer.TEXT_DELTA_FROM_CENTER, + HabitatSimInteractiveViewer.TEXT_DELTA_FROM_CENTER, ) ) self.shader = shaders.VectorGL2D()