Changeset - ffa69645e9dc
[Not reviewed]
default
0 1 0
drewp@bigasterisk.com - 8 months ago 2024-05-28 22:41:53
drewp@bigasterisk.com
refactor
1 file changed with 6 insertions and 11 deletions:
0 comments (0 inline, 0 general)
src/light9/blender/time_sync/time_from_graph.py
Show inline comments
 
@@ -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}')
0 comments (0 inline, 0 general)