Open nashmit opened 2 years ago
Possible quick fix ( I would recommend redesign for this functionality by decoupling the "callback" function from "on_draw" )
in: pyglet\app\base.py:
dt = self.clock.update_time()
redraw_all = self.clock.call_scheduled_functions(dt)
# Redraw all windows
for window in app.windows:
if redraw_all or (window._legacy_invalid and window.invalid):
window.switch_to()
if redraw_all: ## this line was added
window.redraw_all = True ## this line was added
else: ## this line was added
window.redraw_all = False ## this line was added
window.dispatch_event('on_draw')
window.flip()
window._legacy_invalid = False
# Update timout
return self.clock.get_sleep_time(True)
in trimesh\viewer\windowed.py:
def _update_meshes(self):
# call the callback if specified
if self.callback is not None:
if hasattr(self,"redraw_all") and self.redraw_all: ## this line was added
self.callback(self.scene) ## this line was added
self._update_vertex_list()
self._update_perspective(self.width, self.height)
When you define your "callback" function the desired behavior is to get it triggered once every "callback_period" times. What happens instead is that it also gets triggered by any control applied in the window ( e.g. mouse pressed, key pressed, etc ) hence, the "callback" function gets activated more times than it should be.