# HG changeset patch # User drewp@bigasterisk.com # Date 2024-05-28 22:41:53 # Node ID ffa69645e9dcd0e8ff25cd45e2742478a44b4a16 # Parent b8a408caf1157fc400b24afabe7a0dc96eeaaf7e refactor diff --git a/src/light9/blender/time_sync/time_from_graph.py b/src/light9/blender/time_sync/time_from_graph.py --- a/src/light9/blender/time_sync/time_from_graph.py +++ b/src/light9/blender/time_sync/time_from_graph.py @@ -17,10 +17,6 @@ def clamp(lo, hi, x): return max(lo, min(hi, x)) -def floatValue(graph: SyncedGraph, s: URIRef, p: URIRef) -> float | None: - return typedValue(float | None, graph, s, p) - - UPDATE_PERIOD = 1 / 20 @@ -29,19 +25,18 @@ class Sync: duration: float = 1 wallStartTime: float | None = None pausedSongTime: float | None = None - playing=False + playing = False latestTime: float def __init__(self): # main thread self.lastSetFrame = -1 self.lastGraphFrame = -1 - self.frameSetBy = 'init' startLoopInThread(self.task()) bpy.app.timers.register(self.update) bpy.app.handlers.frame_change_post.append(self.on_frame_change_post) - ## read from graph + ## updates from graph -> self async def task(self): # bg thread with asyncio loop @@ -52,9 +47,9 @@ class Sync: # bg thread with self.lock: asco = L9['ascoltami'] - self.wallStartTime = floatValue(self.graph, asco, L9['wallStartTime']) - self.pausedSongTime = floatValue(self.graph, asco, L9['pausedSongTime']) - self.duration = floatValue(self.graph, asco, L9['duration']) or 1.0 + self.wallStartTime = typedValue(float | None, self.graph, asco, L9['wallStartTime']) + self.pausedSongTime = typedValue(float | None, self.graph, asco, L9['pausedSongTime']) + self.duration = typedValue(float | None, self.graph, asco, L9['duration']) or 1.0 self.playing = typedValue(bool, self.graph, asco, L9['playing']) def currentTime(self) -> float | None: @@ -97,4 +92,4 @@ class Sync: self.setInGraph(t) def setInGraph(self, t: float): - log.warning(f'todo: set graph to {t}') \ No newline at end of file + log.warning(f'todo: set graph to {t}')