本文整理汇总了C++中TimeSamplingPtr::getCeilIndex方法的典型用法代码示例。如果您正苦于以下问题:C++ TimeSamplingPtr::getCeilIndex方法的具体用法?C++ TimeSamplingPtr::getCeilIndex怎么用?C++ TimeSamplingPtr::getCeilIndex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TimeSamplingPtr
的用法示例。
在下文中一共展示了TimeSamplingPtr::getCeilIndex方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetRelevantSampleTimes
//-*****************************************************************************
void GetRelevantSampleTimes( ProcArgs &args, TimeSamplingPtr timeSampling,
size_t numSamples, SampleTimeSet &output )
{
if ( numSamples < 2 )
{
output.insert( 0.0 );
return;
}
chrono_t frameTime = args.frame / args.fps;
chrono_t shutterOpenTime = ( args.frame + args.shutterOpen ) / args.fps;
chrono_t shutterCloseTime = ( args.frame + args.shutterClose ) / args.fps;
std::pair<index_t, chrono_t> shutterOpenFloor =
timeSampling->getFloorIndex( shutterOpenTime, numSamples );
std::pair<index_t, chrono_t> shutterCloseCeil =
timeSampling->getCeilIndex( shutterCloseTime, numSamples );
//TODO, what's a reasonable episilon?
static const chrono_t epsilon = 1.0 / 10000.0;
//check to see if our second sample is really the
//floor that we want due to floating point slop
//first make sure that we have at least two samples to work with
if ( shutterOpenFloor.first < shutterCloseCeil.first )
{
//if our open sample is less than open time,
//look at the next index time
if ( shutterOpenFloor.second < shutterOpenTime )
{
chrono_t nextSampleTime =
timeSampling->getSampleTime( shutterOpenFloor.first + 1 );
if ( fabs( nextSampleTime - shutterOpenTime ) < epsilon )
{
shutterOpenFloor.first += 1;
shutterOpenFloor.second = nextSampleTime;
}
}
}
for ( index_t i = shutterOpenFloor.first; i < shutterCloseCeil.first; ++i )
{
output.insert( timeSampling->getSampleTime( i ) );
}
//no samples above? put frame time in there and get out
if ( output.size() == 0 )
{
output.insert( frameTime );
return;
}
chrono_t lastSample = *(output.rbegin() );
//determine whether we need the extra sample at the end
if ( ( fabs( lastSample - shutterCloseTime ) > epsilon )
&& lastSample < shutterCloseTime )
{
output.insert( shutterCloseCeil.second );
}
}