MCPcopy Create free account
hub / github.com/ImageEngine/cortex / tickInterval

Method tickInterval

src/IECore/OversamplesCalculator.cpp:103–132  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

101}
102
103float OversamplesCalculator::tickInterval( float frame, int &tickLow, int &tickHigh ) const
104{
105 float step = ( float )m_ticksPerSecond / ( m_frameRate * m_samplesPerFrame );
106
107 float tickF = frame * m_ticksPerSecond / m_frameRate ;
108 int tick = ( int )( tickF );
109
110 float tickLowF = ( float )tick - fmod(( float )tick,step );
111 float tickHighF = tickLowF + step;
112
113 /// Due to rounding errors we might find that our low/high bound does not actually bracket the tick. Correct
114 /// for that here.
115 if ( tick > ( int )tickHighF )
116 {
117 tickLowF += step;
118 tickHighF += step;
119 }
120 if ( tick < ( int )tickLowF )
121 {
122 tickLowF -= step;
123 tickHighF -= step;
124 }
125 tickLow = int( tickLowF );
126 tickHigh = int( tickHighF );
127 assert( tick >= tickLow );
128 assert( tick <= tickHigh );
129
130 float x = ( float )( tickF - tickLowF ) / ( float )( tickHigh - tickLowF );
131 return x;
132}

Callers 1

tickIntervalFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected