本文整理汇总了C++中KeyFrameSet::rbegin方法的典型用法代码示例。如果您正苦于以下问题:C++ KeyFrameSet::rbegin方法的具体用法?C++ KeyFrameSet::rbegin怎么用?C++ KeyFrameSet::rbegin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KeyFrameSet
的用法示例。
在下文中一共展示了KeyFrameSet::rbegin方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: assert
/// compute interpolation parameters from keyframes and an iterator
/// to the next keyframe (the first with time > t)
static void
interParams(const KeyFrameSet &keyFrames,
double t,
const KeyFrameSet::const_iterator &itup,
double *tcur,
double *vcur,
double *vcurDerivRight,
Natron::KeyframeType *interp,
double *tnext,
double *vnext,
double *vnextDerivLeft,
Natron::KeyframeType *interpNext)
{
assert(itup == keyFrames.end() || t < itup->getTime());
if (itup == keyFrames.begin()) {
//if all keys have a greater time
// get the first keyframe
*tnext = itup->getTime();
*vnext = itup->getValue();
*vnextDerivLeft = itup->getLeftDerivative();
*interpNext = itup->getInterpolation();
*tcur = *tnext - 1.;
*vcur = *vnext;
*vcurDerivRight = 0.;
*interp = Natron::KEYFRAME_NONE;
} else if (itup == keyFrames.end()) {
//if we found no key that has a greater time
// get the last keyframe
KeyFrameSet::const_reverse_iterator itlast = keyFrames.rbegin();
*tcur = itlast->getTime();
*vcur = itlast->getValue();
*vcurDerivRight = itlast->getRightDerivative();
*interp = itlast->getInterpolation();
*tnext = *tcur + 1.;
*vnext = *vcur;
*vnextDerivLeft = 0.;
*interpNext = Natron::KEYFRAME_NONE;
} else {
// between two keyframes
// get the last keyframe with time <= t
KeyFrameSet::const_iterator itcur = itup;
--itcur;
assert(itcur->getTime() <= t);
*tcur = itcur->getTime();
*vcur = itcur->getValue();
*vcurDerivRight = itcur->getRightDerivative();
*interp = itcur->getInterpolation();
*tnext = itup->getTime();
*vnext = itup->getValue();
*vnextDerivLeft = itup->getLeftDerivative();
*interpNext = itup->getInterpolation();
}
}
示例2: DimIdx
static void
deleteKnobAnimation(const std::set<double>& userKeyframes,
const KnobIPtr& knob,
DeleteKnobAnimationEnum type,
double currentTime)
{
for (int i = 0; i < knob->getNDimensions(); ++i) {
CurvePtr curve = knob->getAnimationCurve(ViewIdx(0), DimIdx(i));
assert(curve);
KeyFrameSet keys = curve->getKeyFrames_mt_safe();
std::list<double> toRemove;
switch (type) {
case eDeleteKnobAnimationAll: {
for (KeyFrameSet::iterator it = keys.begin(); it != keys.end(); ++it) {
std::set<double>::iterator found = userKeyframes.find( it->getTime() );
if ( found == userKeyframes.end() ) {
toRemove.push_back( it->getTime() );
}
}
break;
}
case eDeleteKnobAnimationBeforeTime: {
for (KeyFrameSet::iterator it = keys.begin(); it != keys.end(); ++it) {
if (it->getTime() >= currentTime) {
break;
}
std::set<double>::iterator found = userKeyframes.find( it->getTime() );
if ( found == userKeyframes.end() ) {
toRemove.push_back( it->getTime() );
}
}
break;
}
case eDeleteKnobAnimationAfterTime: {
for (KeyFrameSet::reverse_iterator it = keys.rbegin(); it != keys.rend(); ++it) {
if (it->getTime() <= currentTime) {
break;
}
std::set<double>::iterator found = userKeyframes.find( it->getTime() );
if ( found == userKeyframes.end() ) {
toRemove.push_back( it->getTime() );
}
}
break;
}
}
knob->deleteValuesAtTime(toRemove, ViewSetSpec::all(), DimIdx(i), eValueChangedReasonUserEdited);
}
}
示例3: assert
void
CurveGui::nextPointForSegment(const double x, // < in curve coordinates
const KeyFrameSet & keys,
const bool isPeriodic,
const double parametricXMin,
const double parametricXMax,
KeyFrameSet::const_iterator* lastUpperIt,
double* x2WidgetCoords,
KeyFrame* x1Key,
bool* isx1Key)
{
// always running in the main thread
assert( qApp && qApp->thread() == QThread::currentThread() );
assert( !keys.empty() );
*isx1Key = false;
// If non periodic and out of curve range, draw straight lines from widget border to
// the keyframe on the side
if (!isPeriodic && x < keys.begin()->getTime()) {
*x2WidgetCoords = keys.begin()->getTime();
double y;
_imp->curveWidget->toWidgetCoordinates(x2WidgetCoords, &y);
*x1Key = *keys.begin();
*isx1Key = true;
return;
} else if (!isPeriodic && x >= keys.rbegin()->getTime()) {
*x2WidgetCoords = _imp->curveWidget->width() - 1;
return;
}
// We're between 2 keyframes or the curve is periodic, get the upper and lower keyframes widget coordinates
// Points to the first keyframe with a greater time (in widget coords) than x1
KeyFrameSet::const_iterator upperIt = keys.end();
// If periodic, bring back x in the period range (in widget coordinates)
double xClamped = x;
double period = parametricXMax - parametricXMin;
{
//KeyFrameSet::const_iterator start = keys.begin();
const double xMin = parametricXMin;// + start->getTime();
const double xMax = parametricXMax;// + start->getTime();
if ((x < xMin || x > xMax) && isPeriodic) {
xClamped = std::fmod(x - xMin, period) + parametricXMin;
if (xClamped < xMin) {
xClamped += period;
}
assert(xClamped >= xMin && xClamped <= xMax);
}
}
{
KeyFrameSet::const_iterator itKeys = keys.begin();
if ( *lastUpperIt != keys.end() ) {
// If we already have called this function before, start from the previously
// computed iterator to avoid n square complexity
itKeys = *lastUpperIt;
} else {
// Otherwise start from the begining
itKeys = keys.begin();
}
*lastUpperIt = keys.end();
for (; itKeys != keys.end(); ++itKeys) {
if (itKeys->getTime() > xClamped) {
upperIt = itKeys;
*lastUpperIt = upperIt;
break;
}
}
}
double tprev, vprev, vprevDerivRight, tnext, vnext, vnextDerivLeft;
if ( upperIt == keys.end() ) {
// We are in a periodic curve: we are in-between the last keyframe and the parametric xMax
// If the curve is non periodic, it should have been handled in the 2 cases above: we only draw a straightline
// from the widget border to the first/last keyframe
assert(isPeriodic);
KeyFrameSet::const_iterator start = keys.begin();
KeyFrameSet::const_reverse_iterator last = keys.rbegin();
tprev = last->getTime();
vprev = last->getValue();
vprevDerivRight = last->getRightDerivative();
tnext = std::fmod(last->getTime() - start->getTime(), period) + tprev;
//xClamped += period;
vnext = start->getValue();
vnextDerivLeft = start->getLeftDerivative();
} else if ( upperIt == keys.begin() ) {
// We are in a periodic curve: we are in-between the parametric xMin and the first keyframe
// If the curve is non periodic, it should have been handled in the 2 cases above: we only draw a straightline
// from the widget border to the first/last keyframe
assert(isPeriodic);
KeyFrameSet::const_reverse_iterator last = keys.rbegin();
tprev = last->getTime();
//xClamped -= period;
//.........这里部分代码省略.........