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

Method GetLocalTime

trinity/Curves/Tr2CurveScalar.cpp:360–406  ·  view source on GitHub ↗

--------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

358
359// --------------------------------------------------------------------------------
360float Tr2CurveScalar::GetLocalTime( double time ) const
361{
362 if( m_keys.empty() )
363 {
364 return 0;
365 }
366
367 time = time / (double)m_timeScale - (double)m_timeOffset;
368
369 double first = double( m_keys[0].m_time );
370 double last = double( m_keys[m_keys.size() - 1].m_time );
371 double length = last - first;
372 if( time < first )
373 {
374 double intPart;
375 double fracPart = modf( -( time - first ) / length, &intPart );
376
377 if( m_extrapolationBefore == Tr2CurveExtrapolation::CYCLE )
378 {
379 fracPart = 1.0 - fracPart;
380 }
381 else
382 {
383 if( int64_t( intPart ) % 2 != 0 )
384 {
385 fracPart = 1.0 - fracPart;
386 }
387 }
388 return float( fracPart * length + first );
389 }
390 if( time <= last )
391 {
392 return float( time );
393 }
394
395 double intPart;
396 double fracPart = modf( ( time - first ) / length, &intPart );
397
398 if( m_extrapolationAfter == Tr2CurveExtrapolation::MIRROR )
399 {
400 if( int64_t( intPart ) % 2 != 0 )
401 {
402 fracPart = 1.0 - fracPart;
403 }
404 }
405 return float( fracPart * length + first );
406}
407
408// --------------------------------------------------------------------------------
409float Tr2CurveScalar::GetSegmentValue( float time, const Tr2CurveScalarKey& k0, const Tr2CurveScalarKey& k1 )

Callers 1

SampleMorphTracksMethod · 0.45

Calls 2

emptyMethod · 0.80
sizeMethod · 0.80

Tested by

no test coverage detected