MCPcopy Create free account
hub / github.com/carbonengine/trinity / Update

Method Update

trinity/Controllers/Tr2TimelineController.cpp:171–237  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

169}
170
171void Tr2TimelineController::Update( float normalizedUpdateFrequency )
172{
173 if( !m_isActive )
174 {
175 return;
176 }
177
178 if( EveThrottleable::ShouldSkipUpdate( normalizedUpdateFrequency ) )
179 {
180 return;
181 }
182
183 {
184 CCP_STATS_INC( controllerUpdateCount );
185 CCP_STATS_SCOPED_TIME( controllerUpdateTime );
186
187 auto simTime = BeOS->GetCurrentFrameTime();
188 auto dt = TimeAsFloat( simTime - m_lastUpdateTime ) * m_timeScale;
189 m_lastUpdateTime = simTime;
190 if( !m_isPaused )
191 {
192 CcpAutoMutex lock( g_controllerMutex );
193
194 auto oldTime = m_time;
195 m_time += dt;
196
197 for( size_t i = 0; i < m_actions.size(); ++i )
198 {
199 if( !IsActionEnabled( i ) )
200 {
201 continue;
202 }
203 auto action = m_actions[i];
204 auto& entry = m_entries[i];
205 auto wasActive = InRange( oldTime, entry );
206 auto nowActive = InRange( m_time, entry );
207 if( wasActive && !nowActive )
208 {
209 action->Stop( *this );
210 }
211 else if( !wasActive && nowActive )
212 {
213 action->Start( *this );
214 }
215 else if( InRange( entry.startTime, { oldTime, m_time } ) && InRange( entry.endTime, { oldTime, m_time } ) )
216 {
217 action->Start( *this );
218 action->Stop( *this );
219 }
220 }
221 }
222
223 if( !m_updateables.empty() )
224 {
225 CCP_STATS_SCOPED_TIME( controllerUpdateablesTime );
226
227 auto realTime = BeOS->GetActualTime();
228

Callers

nothing calls this directly

Calls 5

InRangeFunction · 0.85
sizeMethod · 0.80
emptyMethod · 0.80
StopMethod · 0.45
StartMethod · 0.45

Tested by

no test coverage detected