@@ -39,7 +39,7 @@ enum MODE {NORMAL, LOOP}
3939var _mode : int = MODE .NORMAL
4040
4141## Stores all fixtures that are currently being animated
42- ## str(fixture.uuid + method_name ):{
42+ ## str(fixture.uuid + zone + parameter ):{
4343## "current_value": Variant,
4444## "animator": Animator
4545## }
@@ -81,6 +81,7 @@ func _component_ready() -> void:
8181 _intensity = 1
8282 TC .frames_changed .connect (_find_keyframes )
8383
84+
8485## Adds a pre-existing cue to this CueList
8586## Returns false if the cue already exists in this list, or if the index is already in use
8687func add_cue (cue : Cue , number : float = 0 , rename : bool = false ) -> bool :
@@ -154,7 +155,6 @@ func _on_cue_timecode_trigger_changed(timecode_trigger: int, cue: Cue) -> void:
154155 _add_cue_keyframe (cue )
155156
156157
157-
158158func _add_cue_keyframe (cue : Cue ) -> void :
159159 if not cue .timecode_trigger in _keyframes .keys ():
160160 _keyframes [cue .timecode_trigger ] = []
@@ -167,8 +167,6 @@ func _add_cue_keyframe(cue: Cue) -> void:
167167 cue .local_data [uuid + "old_timecode_trigger" ] = cue .timecode_trigger
168168
169169
170-
171-
172170func _on_cue_timecode_enabled_stage_changed (timecode_enabled : bool , cue : Cue ) -> void :
173171 if timecode_enabled :
174172 _add_cue_keyframe (cue )
@@ -186,7 +184,6 @@ func _on_cue_timecode_enabled_stage_changed(timecode_enabled: bool, cue: Cue) ->
186184 print (_keyframes )
187185
188186
189-
190187func _find_keyframes (frame : int ) -> void :
191188 # Use binary search to find the closest frame <= frame
192189
@@ -311,24 +308,38 @@ func _seek_to_next_cue_after(seconds: float) -> void:
311308func _reset_animated_fixtures (animator : Animator , accumulated_animated_data : Dictionary ) -> void :
312309 for animation_id in _current_animated_fixtures .keys ():
313310 var animating_fixture = _current_animated_fixtures [animation_id ]
314- var from_value : Variant = animating_fixture .fixture .get_value_from_layer_id ( uuid , animating_fixture .method_name )
315- var to_value : Variant = animating_fixture .fixture .get_zero_from_channel_key (animating_fixture .method_name )
311+ var from_value : float = animating_fixture .fixture .get_current_value ( animating_fixture . zone , animating_fixture . parameter , uuid , animating_fixture .function )
312+ var to_value : float = animating_fixture .fixture .get_default (animating_fixture .zone , animating_fixture . parameter , animating_fixture . function )
316313
317314 if is_instance_valid (animating_fixture .animator ):
318315 animating_fixture .animator .remove_track_from_id (animation_id , false )
319316
320317 accumulated_animated_data [animation_id ] = {
321318 "method" : func (new_value : Variant ) -> void :
322319 _current_animated_fixtures [animation_id ].current_value = new_value
323- animating_fixture .fixture .get (animating_fixture .method_name ).call (new_value , uuid ),
320+ animating_fixture .fixture .set_parameter (
321+ animating_fixture .parameter ,
322+ animating_fixture .function ,
323+ new_value * _intensity ,
324+ uuid ,
325+ animating_fixture .zone
326+ ),
324327 "from" : from_value ,
325328 "to" : to_value ,
326- "current" : from_value
329+ "current" : from_value ,
330+ "can_fade" : animating_fixture .can_fade ,
331+ "start" : animating_fixture .start ,
332+ "stop" : animating_fixture .stop ,
327333 }
328334
329335 _current_animated_fixtures [animation_id ] = {
330- "method_name" : animating_fixture .method_name ,
336+ "zone" : animating_fixture .zone ,
337+ "parameter" : animating_fixture .parameter ,
338+ "function" : animating_fixture .function ,
331339 "fixture" : animating_fixture .fixture ,
340+ "can_fade" : animating_fixture .can_fade ,
341+ "start" : animating_fixture .start ,
342+ "stop" : animating_fixture .stop ,
332343 "animator" : animator ,
333344 # "current_value": to_value
334345 }
@@ -339,39 +350,62 @@ func _remove_all_animators() -> void:
339350 _remove_animator (old_cue_number )
340351
341352
353+ ## Builds animation data from the cue and updates current animations.
342354func _accumulate_state (cue : Cue , accumulated_animated_data : Dictionary , animator : Animator ) -> void :
343- for fixture : Fixture in cue .get_fixture_data ().keys ():
344- for method_name : String in cue .get_fixture_data ()[fixture ]:
345- var stored_value : Dictionary = cue .get_fixture_data ()[fixture ][method_name ]
346- var from_value : Variant = fixture .get_value_from_layer_id (uuid , method_name )
347- var to_value : Variant = stored_value .value
348- print (stored_value )
349- var animation_id : String = fixture .uuid + method_name
350- accumulated_animated_data [animation_id ] = {
351- "method" : func (new_value : Variant ) -> void :
352- _current_animated_fixtures [animation_id ].current_value = new_value
353- fixture .get (method_name ).call (new_value * _intensity , uuid )
354- ,
355- "from" : from_value * (2 - _intensity ),
356- "to" : to_value ,
357- "current" : from_value * (2 - _intensity ),
358- }
359-
360- if animation_id in _current_animated_fixtures :
361- if _current_animated_fixtures [animation_id ].has ("current_value" ):
362- accumulated_animated_data [animation_id ].from = _current_animated_fixtures [animation_id ].current_value
363-
364- var _animator = _current_animated_fixtures [animation_id ].animator
365- if is_instance_valid (_animator ) and _animator != animator :
366- _animator .remove_track_from_id (animation_id , false )
367-
368-
369- _current_animated_fixtures [animation_id ] = {
370- "method_name" : method_name ,
371- "fixture" : fixture ,
372- "animator" : animator ,
373- "current_value" : from_value
374- }
355+ var fixture_data : Dictionary = cue .get_fixture_data ()
356+
357+ for fixture : Fixture in fixture_data :
358+ for zone : String in fixture_data [fixture ]:
359+ for parameter : String in fixture_data [fixture ][zone ]:
360+ var value_config : Dictionary = fixture_data [fixture ][zone ][parameter ]
361+ var from_value : float = fixture .get_current_value (zone , parameter , uuid , value_config .function )
362+ var to_value : Variant = value_config .value
363+ if parameter == "Zoom" :
364+ print (from_value )
365+ print (to_value )
366+ print ()
367+
368+ var animation_id : String = fixture .uuid + zone + parameter
369+ accumulated_animated_data [animation_id ] = {
370+ "method" : func (new_value : Variant ) -> void :
371+ _current_animated_fixtures [animation_id ].current_value = new_value
372+ if parameter == "Zoom" :
373+ print (new_value * _intensity )
374+ fixture .set_parameter (
375+ parameter ,
376+ value_config .function ,
377+ new_value * _intensity ,
378+ uuid ,
379+ zone
380+ ),
381+ "from" : from_value * (2 - _intensity ),
382+ "to" : to_value ,
383+ "current" : from_value * (2 - _intensity ),
384+ "can_fade" : value_config .can_fade ,
385+ "start" : value_config .start ,
386+ "stop" : value_config .stop ,
387+ }
388+
389+ if animation_id in _current_animated_fixtures :
390+ if _current_animated_fixtures [animation_id ].has ("current_value" ):
391+ accumulated_animated_data [animation_id ].from = _current_animated_fixtures [animation_id ].current_value
392+
393+ var _animator = _current_animated_fixtures [animation_id ].animator
394+ if is_instance_valid (_animator ) and _animator != animator :
395+ _animator .remove_track_from_id (animation_id , false )
396+
397+
398+ _current_animated_fixtures [animation_id ] = {
399+ "zone" : zone ,
400+ "parameter" : parameter ,
401+ "function" : value_config .function ,
402+ "can_fade" : value_config .can_fade ,
403+ "start" : value_config .start ,
404+ "stop" : value_config .stop ,
405+ "fixture" : fixture ,
406+ "animator" : animator ,
407+ "current_value" : from_value
408+ }
375409
376410
377411func _handle_animator_finished (animator : Animator , cue_number : float , fade_time : float ) -> void :
@@ -518,7 +552,16 @@ func set_intensity(p_intensity: float) -> void:
518552 if _index != - 1 :
519553 for animated_fixture : Dictionary in _current_animated_fixtures .values ():
520554 if not is_instance_valid (animated_fixture .animator ) and animated_fixture .has ("current_value" ):
521- animated_fixture .fixture .get (animated_fixture .method_name ).call (animated_fixture .current_value * _intensity , uuid )
555+ var fixture : Fixture = animated_fixture .fixture
556+
557+ if fixture .function_can_fade (animated_fixture .zone , animated_fixture .parameter , animated_fixture .function ):
558+ fixture .set_parameter (
559+ animated_fixture .parameter ,
560+ animated_fixture .function ,
561+ animated_fixture .current_value * _intensity ,
562+ uuid ,
563+ animated_fixture .zone
564+ )
522565
523566
524567## Sets the fade time for all cues
0 commit comments