@@ -2,7 +2,6 @@ use super::pin;
22use crate :: {
33 core:: {
44 animation_node:: AnimationNode ,
5- context:: { CacheReadFilter , CacheWriteFilter } ,
65 duration_data:: DurationData ,
76 edge_data:: AnimationEvent ,
87 errors:: { GraphError , GraphValidationError } ,
@@ -669,15 +668,10 @@ impl AnimationGraph {
669668 } ;
670669
671670 let source_value = match source_pin {
672- SourcePin :: NodeData ( node_id, _) => {
673- if ctx
674- . caches ( )
675- . get (
676- |c| c. is_updated ( node_id) . then_some ( ( ) ) ,
677- CacheReadFilter :: for_temp ( ctx. temp_cache ) ,
678- )
679- . is_none ( )
680- {
671+ SourcePin :: NodeData ( node_id, node_pin) => {
672+ let key = ctx. state_key ;
673+
674+ if !ctx. node_caches ( ) . is_updated ( node_id. to_owned ( ) , key) {
681675 let node = & self . nodes [ node_id] ;
682676 let should_debug = node. should_debug ;
683677
@@ -687,22 +681,11 @@ impl AnimationGraph {
687681 node. update ( ctx. with_node ( node_id, self ) . with_debugging ( should_debug) ) ?;
688682 }
689683
690- let is_temp = ctx. temp_cache ;
691-
692- ctx. caches_mut ( ) . set (
693- |c| c. set_updated ( node_id. clone ( ) ) ,
694- CacheWriteFilter :: for_temp ( is_temp) ,
695- ) ;
684+ ctx. node_caches_mut ( ) . mark_updated ( node_id. to_owned ( ) , key) ;
696685 }
697686
698- let Some ( value) = ctx. caches ( ) . get (
699- |c| c. get_data ( source_pin) . cloned ( ) ,
700- CacheReadFilter :: for_temp ( ctx. temp_cache ) ,
701- ) else {
702- return Err ( GraphError :: OutputMissing ( source_pin. clone ( ) ) ) ;
703- } ;
704-
705- value
687+ ctx. node_caches ( )
688+ . get_output_data ( node_id. clone ( ) , key, node_pin. clone ( ) ) ?
706689 }
707690 SourcePin :: InputData ( pin_id) => ctx
708691 . parent_data_back ( pin_id)
@@ -740,23 +723,15 @@ impl AnimationGraph {
740723 panic ! ( "Incompatible pins connected: {source_pin:?} --> {target_pin:?}" )
741724 }
742725 SourcePin :: NodeTime ( node_id) => {
743- if let Some ( dur) = ctx. caches ( ) . get (
744- |c| c. get_duration ( source_pin) ,
745- CacheReadFilter :: for_temp ( ctx. temp_cache ) ,
746- ) {
726+ let key = ctx. state_key ;
727+
728+ if let Ok ( dur) = ctx. node_caches ( ) . get_duration ( node_id. clone ( ) , key) {
747729 dur
748730 } else {
749731 let node = & self . nodes [ node_id] ;
750732 let should_debug = node. should_debug ;
751733 node. duration ( ctx. with_node ( node_id, self ) . with_debugging ( should_debug) ) ?;
752- let Some ( dur) = ctx. caches ( ) . get (
753- |c| c. get_duration ( source_pin) ,
754- CacheReadFilter :: for_temp ( ctx. temp_cache ) ,
755- ) else {
756- // TODO: Make a graph error for duration missing
757- return Err ( GraphError :: OutputMissing ( source_pin. clone ( ) ) ) ;
758- } ;
759- dur
734+ ctx. node_caches ( ) . get_duration ( node_id. clone ( ) , key) ?
760735 }
761736 }
762737 SourcePin :: InputTime ( pin_id) => {
@@ -780,37 +755,22 @@ impl AnimationGraph {
780755 return Err ( GraphError :: MissingEdgeToSource ( source_pin) ) ;
781756 } ;
782757
758+ let key = ctx. state_key ;
759+
783760 match target_pin {
784761 TargetPin :: NodeData ( _, _) => {
785762 panic ! ( "Incompatible pins connected: {source_pin:?} --> {target_pin:?}" )
786763 }
787764 TargetPin :: OutputData ( _) => {
788765 panic ! ( "Incompatible pins connected: {source_pin:?} --> {target_pin:?}" )
789766 }
790- TargetPin :: NodeTime ( _, _) => {
791- let Some ( time_update) = ctx. caches ( ) . get (
792- |c| c. get_time_update_back ( target_pin) . cloned ( ) ,
793- CacheReadFilter :: for_temp ( ctx. temp_cache ) ,
794- ) else {
795- return Err ( GraphError :: TimeUpdateMissing ( target_pin. clone ( ) ) ) ;
796- } ;
797-
798- Ok ( time_update)
799- }
800- TargetPin :: OutputTime => {
801- let Some ( time_update) = ctx
802- . caches ( )
803- . get (
804- |c| c. get_time_update_back ( target_pin) . cloned ( ) ,
805- CacheReadFilter :: for_temp ( ctx. temp_cache ) ,
806- )
807- . or_else ( || ctx. parent_time_update_fwd ( ) . ok ( ) )
808- else {
809- return Err ( GraphError :: TimeUpdateMissing ( target_pin. clone ( ) ) ) ;
810- } ;
811-
812- Ok ( time_update)
813- }
767+ TargetPin :: NodeTime ( target_node, target_pin) => ctx
768+ . node_caches ( )
769+ . get_input_time_update ( target_node. clone ( ) , key, target_pin. clone ( ) ) ,
770+ TargetPin :: OutputTime => match ctx. context ( ) . query_output_time . clone ( ) {
771+ Some ( update) => Ok ( update) ,
772+ None => ctx. parent_time_update_fwd ( ) ,
773+ } ,
814774 }
815775 }
816776
@@ -855,10 +815,7 @@ impl AnimationGraph {
855815 entity_map,
856816 deferred_gizmos,
857817 ) ;
858- ctx. caches_mut ( ) . set (
859- |c| c. set_time_update_back ( TargetPin :: OutputTime , time_update) ,
860- CacheWriteFilter :: Primary ,
861- ) ;
818+ ctx. context_mut ( ) . query_output_time = Some ( time_update) ;
862819 let mut outputs = HashMap :: new ( ) ;
863820 for k in self . output_parameters . keys ( ) {
864821 let out = self . get_data ( TargetPin :: OutputData ( k. clone ( ) ) , ctx. clone ( ) ) ?;
0 commit comments