@@ -23,103 +23,91 @@ public void OnCleanUp(CleanUpTask task)
2323 if ( tickNodes . Length <= 1 )
2424 return ;
2525
26+ GltfInteractivityUnitExporterNode firstDeltaTimeNode = null ;
27+ GltfInteractivityUnitExporterNode firstTimeSinceStartNode = null ;
2628
2729 // Ensure the first OnTickNode is from a TimeUnitExports, so we have access to additional helper nodes, like isNaN check
2830 for ( int i = 0 ; i < tickNodes . Length ; i ++ )
2931 {
3032 if ( tickNodes [ i ] is GltfInteractivityUnitExporterNode exporterNode )
3133 {
32- if ( exporterNode . Exporter . exporter is TimeUnitExports )
34+ if ( exporterNode . Exporter . exporter is TimeUnitExports timeUnitExport )
3335 {
34- var tmp = tickNodes [ i ] ;
35- tickNodes [ i ] = tickNodes [ 0 ] ;
36- tickNodes [ 0 ] = tmp ;
37- break ;
36+ if ( timeUnitExport . ValueOption == TimeHelpers . GetTimeValueOption . DeltaTime
37+ && firstDeltaTimeNode == null )
38+ firstDeltaTimeNode = exporterNode ;
39+ if ( timeUnitExport . ValueOption == TimeHelpers . GetTimeValueOption . TimeSinceStartup
40+ && firstTimeSinceStartNode == null )
41+ firstTimeSinceStartNode = exporterNode ;
42+
3843 }
3944 }
40-
4145 }
42- var firstTickNode = tickNodes [ 0 ] ;
43-
44- var firstTickNodeFlowOut = firstTickNode . FlowConnections [ Event_OnTickNode . IdFlowOut ] ;
45-
46- GltfInteractivityNode firstTickNodeSelectNode = null ;
4746
48- if ( firstTickNode is GltfInteractivityUnitExporterNode firstTickNodeExport )
47+ GltfInteractivityExportNode firstDeltaTimeSelectNode = null ;
48+ GltfInteractivityExportNode firstTimeSinceStartSelectNode = null ;
49+ if ( firstDeltaTimeNode != null )
4950 {
50- var selectNode = firstTickNodeExport . Exporter . Nodes . FirstOrDefault ( n => n . Schema is Math_SelectNode ) ;
51- if ( selectNode != null )
52- {
53- firstTickNodeSelectNode = selectNode ;
54- }
51+ firstDeltaTimeSelectNode = firstDeltaTimeNode . Exporter . Nodes . FirstOrDefault ( n => n . Schema is Math_SelectNode ) ;
5552 }
56-
57- for ( int i = 1 ; i < tickNodes . Length ; i ++ )
53+ if ( firstTimeSinceStartNode != null )
54+ {
55+ firstTimeSinceStartSelectNode = firstTimeSinceStartNode . Exporter . Nodes . FirstOrDefault ( n => n . Schema is Math_SelectNode ) ;
56+ }
57+
58+ for ( int i = 0 ; i < tickNodes . Length ; i ++ )
5859 {
60+ if ( tickNodes [ i ] == firstDeltaTimeNode || tickNodes [ i ] == firstTimeSinceStartNode )
61+ continue ; // skip the first tick node, which is used for delta time or time since startup
62+
63+ TimeHelpers . GetTimeValueOption timeValue = TimeHelpers . GetTimeValueOption . DeltaTime ;
64+
5965 var tickNode = tickNodes [ i ] ;
60- bool dontDelete = false ;
61- var flowOut = tickNode . FlowConnections [ Event_OnTickNode . IdFlowOut ] ;
6266 GltfInteractivityNode tickNodeSelectNode = null ;
63-
64- if ( tickNode is GltfInteractivityUnitExporterNode tickNodeExport )
65- {
66- if ( tickNodeExport . Exporter . exporter is not TimeUnitExports )
67- continue ;
68- var selectNode = tickNodeExport . Exporter . Nodes . FirstOrDefault ( n => n . Schema is Math_SelectNode ) ;
69- if ( selectNode != null )
70- {
71- tickNodeSelectNode = selectNode ;
72- }
73- }
74-
75- if ( flowOut . Node != null && flowOut . Node . Value != - 1 )
76- {
77- if ( firstTickNodeFlowOut . Node == null || firstTickNodeFlowOut . Node . Value == - 1 )
78- {
79- firstTickNodeFlowOut . Node = flowOut . Node ;
80- firstTickNodeFlowOut . Socket = flowOut . Socket ;
81- }
82- else
83- {
84- dontDelete = true ;
85- }
86- }
87-
67+
68+ if ( tickNode is not GltfInteractivityUnitExporterNode tickNodeExport )
69+ continue ;
70+
71+ if ( tickNodeExport . Exporter . exporter is not TimeUnitExports timeUnitExport )
72+ continue ;
73+
74+ timeValue = timeUnitExport . ValueOption ;
75+
76+ var selectNode = tickNodeExport . Exporter . Nodes . FirstOrDefault ( n => n . Schema is Math_SelectNode ) ;
77+ if ( selectNode == null )
78+ continue ;
79+
80+ tickNodeSelectNode = selectNode ;
81+
8882 foreach ( var node in nodes )
8983 {
9084 foreach ( var socket in node . ValueInConnection )
9185 {
92- if ( tickNodeSelectNode != null && firstTickNodeSelectNode != null )
86+ if ( timeValue == TimeHelpers . GetTimeValueOption . DeltaTime && firstDeltaTimeNode != null && firstDeltaTimeSelectNode != null )
9387 {
9488 if ( socket . Value . Node != null && socket . Value . Node . Value == tickNodeSelectNode . Index )
9589 {
96- socket . Value . Node = firstTickNodeSelectNode . Index ;
90+ socket . Value . Node = firstDeltaTimeSelectNode . Index ;
9791 }
98-
9992 }
100- else
101- if ( socket . Value . Node != null && socket . Value . Node . Value == tickNode . Index )
93+
94+ if ( timeValue == TimeHelpers . GetTimeValueOption . TimeSinceStartup && firstTimeSinceStartNode != null && firstTimeSinceStartSelectNode != null )
10295 {
103- socket . Value . Node = firstTickNode . Index ;
96+ if ( socket . Value . Node != null && socket . Value . Node . Value == tickNodeSelectNode . Index )
97+ {
98+ socket . Value . Node = firstTimeSinceStartSelectNode . Index ;
99+ }
104100 }
105101 }
106102 }
107103
108- if ( ! dontDelete )
109- {
110- if ( tickNodeSelectNode != null && firstTickNodeSelectNode != null && tickNode is GltfInteractivityUnitExporterNode tickNodeExport2 )
111- {
112- // also remove isNaN check
113- var exporterNode = tickNodeExport2 . Exporter . Nodes ;
114- foreach ( var n in exporterNode )
115- n . ValueInConnection . Clear ( ) ;
104+ // also remove isNaN check
105+ var exporterNode = tickNodeExport . Exporter . Nodes ;
106+ foreach ( var n in exporterNode )
107+ n . ValueInConnection . Clear ( ) ;
116108
117- foreach ( var n in exporterNode )
118- task . RemoveNode ( n ) ;
119- }
120- else
121- task . RemoveNode ( tickNode ) ;
122- }
109+ foreach ( var n in exporterNode )
110+ task . RemoveNode ( n ) ;
123111 }
124112 }
125113 }
0 commit comments