Mercurial > code > home > repos > light9
diff blender/time_sync/time_from_graph.py @ 2458:0e27ba33118c default tip
better blender<->asco playback cooperation. still no play support in blender; only seek
author | drewp@bigasterisk.com |
---|---|
date | Tue, 20 May 2025 16:25:06 -0700 |
parents | d94480bfb179 |
children |
line wrap: on
line diff
--- a/blender/time_sync/time_from_graph.py Tue May 20 13:48:07 2025 -0700 +++ b/blender/time_sync/time_from_graph.py Tue May 20 16:25:06 2025 -0700 @@ -3,7 +3,6 @@ import time from typing import Coroutine -from attr import dataclass from rdfdb.patch import Patch from rdfdb.syncedgraph.syncedgraph import SyncedGraph from rdflib import Literal @@ -35,6 +34,8 @@ def __init__(self): # main thread + + # one mutable instance; modified by bg thread self.ascoPlayState = AscoPlayState(None, None, False, False, 1.0) self.blenderTime = BlenderTime(self.onBlenderEvent, self.ascoPlayState) self.blenderTime.start() @@ -69,25 +70,19 @@ # bg thread with self.lock: asco = L9['ascoltami'] - + self.ascoPlayState.wallStartTime = typedValue(float | None, self.graph, asco, L9['wallStartTime']) self.ascoPlayState.pausedSongTime = typedValue(float | None, self.graph, asco, L9['pausedSongTime']) self.ascoPlayState.duration = typedValue(float | None, self.graph, asco, L9['duration']) or 1.0 - self.blenderTime.durationDirty = True # todo: called too often + self.blenderTime.durationDirty = True # todo: called too often self.ascoPlayState.playing = typedValue(bool | None, self.graph, asco, L9['playing']) or False self.ascoPlayState.endOfSong = typedValue(bool | None, self.graph, asco, L9['endOfSong']) or False log.info(f'🍇 syncFromGraph {self.ascoPlayState=}') self.blenderTime.curFrameDirty = True - async def setGraphPlaying(self, isBlenderPlaying: bool): - return - # bg thread - log.info(f'set graph playing to {isBlenderPlaying}') - self.graph.patchObject(self.ctx, L9['ascoltami'], L9['playing'], Literal(isBlenderPlaying)) - async def setInGraph(self, t: float, isBlenderPlaying: bool): # bg thread - log.info(f'set graph time to {t:.2f} {isBlenderPlaying=}') + log.debug(f'set graph time to {t:.2f} {isBlenderPlaying=}') p = Patch() if isBlenderPlaying: p = p.update(self.graph.getObjectPatch(self.ctx, L9['ascoltami'], L9['playing'], Literal(True))) @@ -100,5 +95,4 @@ if p.isEmpty(): return - log.info(f'setInGraph {p.shortSummary()}') await self.graph.patch(p)