Skip to content

Commit

Permalink
viewer reset clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
fbxiang committed Nov 3, 2023
1 parent 2869a49 commit 50f8a2c
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 9 deletions.
7 changes: 6 additions & 1 deletion python/py_package/utils/viewer/entity_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,9 @@ def enable_collision_visual(self, entity=None):
vs = sapien.render.RenderShapePlane([1, 1e4, 1e4], blue_mat)

elif isinstance(s, sapien.physx.PhysxCollisionShapeCylinder):
vs = sapien.render.RenderShapeCylinder(s.radius, s.half_length, green_mat)
vs = sapien.render.RenderShapeCylinder(
s.radius, s.half_length, green_mat
)

else:
raise Exception(
Expand Down Expand Up @@ -805,3 +807,6 @@ def get_ui_windows(self):
if self.ui_window:
return [self.ui_window]
return []

def notify_scene_change(self):
self.reset()
5 changes: 5 additions & 0 deletions python/py_package/utils/viewer/render_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ def set_shader(self, index):

def reset(self):
self.ui_window = None
self.shader_dir = None
self.shader_index = None
self.shader_list = None
self.shader_type = None
self.shader_types = None

@property
def is_rt(self):
Expand Down
14 changes: 10 additions & 4 deletions python/py_package/utils/viewer/transform_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,21 @@ def reset(self):
self.gizmo = None
self._gizmo_pose = sapien.Pose()
self.ghost_objects = []

self.ik_articulation = None
self.follow = False
self.ik_enabled = True
self.display_ghosts = False

self.enabled = False
self.ik_errpr = None
self.ik_result = None
self.ik_success = False

# self.ui_move_group = None
self.follow = False
self.display_ghosts = False
self.enabled = False
self.ui_move_group = None
self.move_group_joints = []
self.move_group_selection = []
self.pinocchio_model = None

def close(self):
self.reset()
Expand Down
12 changes: 8 additions & 4 deletions python/py_package/utils/viewer/viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ def __init__(
if renderer is None:
renderer = SapienRenderer()

self.renderer = renderer

self.renderer_context = renderer._internal_context

if not shader_dir:
Expand Down Expand Up @@ -125,7 +123,15 @@ def closed(self):
return self.window is None

def close(self):
for plugin in self.plugins:
plugin.close()

self.selected_entity = None
self.scene = None
self.system = None
self.window = None
self.plugins = None
self.renderer_context = None

def set_camera_pose(self, pose):
self.window.set_camera_pose(pose)
Expand All @@ -140,8 +146,6 @@ def reset_notifications(self):

def render(self):
if self.window.should_close:
for plugin in self.plugins:
plugin.close()
self.close()

if self.closed:
Expand Down

0 comments on commit 50f8a2c

Please sign in to comment.