Skip to content

Commit

Permalink
Fixed bug where self._using_temp_camera was used incorrectly (should …
Browse files Browse the repository at this point in the history
…be queried on the viewports). Also made Control modes in the Camera menu only show up when not using a temp camera.
  • Loading branch information
kaufManu committed Aug 15, 2023
1 parent b093e6b commit ccd3de5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
4 changes: 4 additions & 0 deletions aitviewer/renderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ def camera(self, camera: CameraInterface):
self._camera = camera
self._using_temp_camera = not isinstance(camera, ViewerCamera)

@property
def using_temp_camera(self):
return self._using_temp_camera

def contains(self, x: int, y: int):
e = self.extents
return x >= e[0] and x < e[0] + e[2] and y >= e[1] and y < e[1] + e[3]
Expand Down
10 changes: 6 additions & 4 deletions aitviewer/viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,6 @@ def reset(self):

self._pan_camera = False
self._rotate_camera = False
self._using_temp_camera = False
self._past_frametimes = np.zeros([60]) - 1.0
self._last_frame_rendered_at = 0

Expand Down Expand Up @@ -792,18 +791,21 @@ def menu_entry(text, name):
if clicked:
self.center_view_on_selection()

is_ortho = False if self._using_temp_camera else self.scene.camera.is_ortho
# TODO (@Dario): correct to only use self.viewports[0] here?
is_ortho = False if self.viewports[0].using_temp_camera else self.scene.camera.is_ortho
_, is_ortho = imgui.menu_item(
"Orthographic Camera",
self._shortcut_names[self._orthographic_camera_key],
is_ortho,
True,
)
if is_ortho and self._using_temp_camera:
# TODO (@Dario): correct to only use self.viewports[0] here?
if is_ortho and self.viewports[0].using_temp_camera:
self.reset_camera()
self.scene.camera.is_ortho = is_ortho

if imgui.begin_menu("Control modes"):
# TODO (@Dario)
if not self.viewports[0].using_temp_camera and imgui.begin_menu("Control modes"):

def mode(name, mode):
selected = imgui.menu_item(name, None, self.scene.camera.control_mode == mode)[1]
Expand Down

0 comments on commit ccd3de5

Please sign in to comment.