| 38 | } |
| 39 | |
| 40 | void TriEventCurve::UpdateValue( double time ) |
| 41 | { |
| 42 | if( m_length == 0.0f ) |
| 43 | { |
| 44 | return; |
| 45 | } |
| 46 | |
| 47 | double before = m_time; |
| 48 | m_time = time; |
| 49 | if( m_time < before ) |
| 50 | { |
| 51 | // Time has moved backwards - can't rely on our caching |
| 52 | m_currentKeyIt = m_keys.begin(); |
| 53 | // Playing an event curve backwards can be defined IFF we know it's being |
| 54 | // played backwards. However, here we only know that time has moved backwards for |
| 55 | // this one Update call so we cannot assume that. So we just have to give up |
| 56 | // and do nothing. <halldor 2009-03-02> |
| 57 | return; |
| 58 | } |
| 59 | |
| 60 | switch( m_extrapolation ) |
| 61 | { |
| 62 | case TRIEXT_CYCLE: { |
| 63 | float localNow = (float)fmod( m_time, (double)m_length ); |
| 64 | if( localNow < m_localTime ) |
| 65 | { |
| 66 | // We've wrapped around |
| 67 | m_currentKeyIt = m_keys.begin(); |
| 68 | } |
| 69 | m_localTime = localNow; |
| 70 | } |
| 71 | break; |
| 72 | |
| 73 | default: |
| 74 | m_localTime = (float)m_time; |
| 75 | break; |
| 76 | } |
| 77 | |
| 78 | while( ( m_currentKeyIt != m_keys.end() ) && ( m_localTime >= ( *m_currentKeyIt )->m_time ) ) |
| 79 | { |
| 80 | // Found a key that has a time value of less than or equal to now |
| 81 | TriEventKey* currentKey = *m_currentKeyIt; |
| 82 | |
| 83 | m_value = currentKey->m_value; |
| 84 | |
| 85 | // Fire off event |
| 86 | #if BLUE_WITH_PYTHON |
| 87 | if( currentKey->m_callable ) |
| 88 | { |
| 89 | if( PyCallable_Check( currentKey->m_callable ) ) |
| 90 | { |
| 91 | currentKey->Lock(); |
| 92 | gTriDev->AddPostUpdateCallback( EventKeyCallback, reinterpret_cast<void*>( currentKey ) ); |
| 93 | } |
| 94 | else |
| 95 | { |
| 96 | CCP_LOGWARN( "TriEventCurve: Key does not hold a callable object" ); |
| 97 | } |
nothing calls this directly
no test coverage detected