本文整理汇总了C++中keyframeset::iterator::getInterpolation方法的典型用法代码示例。如果您正苦于以下问题:C++ iterator::getInterpolation方法的具体用法?C++ iterator::getInterpolation怎么用?C++ iterator::getInterpolation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类keyframeset::iterator
的用法示例。
在下文中一共展示了iterator::getInterpolation方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setKeyFrameInterpolation
KeyFrame Curve::setKeyFrameInterpolation(Natron::KeyframeType interp,int index,int* newIndex)
{
bool evaluateAnimation = false;
KeyFrame ret;
{
QWriteLocker l(&_imp->_lock);
KeyFrameSet::iterator it = atIndex(index);
assert(it != _imp->keyFrames.end());
///if the curve is a string_curve or bool_curve the interpolation is bound to be constant.
if ((_imp->type == CurvePrivate::STRING_CURVE || _imp->type == CurvePrivate::BOOL_CURVE ||
_imp->type == CurvePrivate::INT_CURVE_CONSTANT_INTERP) && interp != Natron::KEYFRAME_CONSTANT) {
return *it;
}
if (interp != it->getInterpolation()) {
it = setKeyframeInterpolation_internal(it, interp);
}
if (newIndex) {
*newIndex = std::distance(_imp->keyFrames.begin(),it);
}
ret = *it;
}
if (evaluateAnimation && _imp->owner) {
_imp->owner->evaluateAnimationChange();
}
return ret;
}
示例2: setCurveInterpolation
void Curve::setCurveInterpolation(Natron::KeyframeType interp)
{
bool evaluateAnimation = false;
{
QWriteLocker l(&_imp->_lock);
///if the curve is a string_curve or bool_curve the interpolation is bound to be constant.
if ((_imp->type == CurvePrivate::STRING_CURVE || _imp->type == CurvePrivate::BOOL_CURVE ||
_imp->type == CurvePrivate::INT_CURVE_CONSTANT_INTERP) && interp != Natron::KEYFRAME_CONSTANT) {
return;
}
for (int i = 0; i < (int)_imp->keyFrames.size(); ++i)
{
KeyFrameSet::iterator it = _imp->keyFrames.begin();
std::advance(it, i);
if (interp != it->getInterpolation()) {
it = setKeyframeInterpolation_internal(it, interp);
evaluateAnimation = true;
}
}
}
if (evaluateAnimation && _imp->owner) {
_imp->owner->evaluateAnimationChange();
}
}
示例3: evaluateCurveChanged
KeyFrameSet::iterator Curve::evaluateCurveChanged(CurveChangedReason reason, KeyFrameSet::iterator key)
{
// PRIVATE - should not lock
assert(key!=_imp->keyFrames.end());
if (key->getInterpolation()!= Natron::KEYFRAME_BROKEN && key->getInterpolation() != Natron::KEYFRAME_FREE
&& reason != DERIVATIVES_CHANGED ) {
key = refreshDerivatives(DERIVATIVES_CHANGED,key);
}
KeyFrameSet::iterator prev = key;
if (key != _imp->keyFrames.begin()) {
--prev;
if(prev->getInterpolation()!= Natron::KEYFRAME_BROKEN &&
prev->getInterpolation()!= Natron::KEYFRAME_FREE &&
prev->getInterpolation()!= Natron::KEYFRAME_NONE){
prev = refreshDerivatives(DERIVATIVES_CHANGED,prev);
}
}
KeyFrameSet::iterator next = key;
++next;
if (next != _imp->keyFrames.end()) {
if(next->getInterpolation()!= Natron::KEYFRAME_BROKEN &&
next->getInterpolation()!= Natron::KEYFRAME_FREE &&
next->getInterpolation()!= Natron::KEYFRAME_NONE){
next = refreshDerivatives(DERIVATIVES_CHANGED,next);
}
}
return key;
}
示例4: refreshDerivatives
KeyFrameSet::iterator Curve::refreshDerivatives(Curve::CurveChangedReason reason, KeyFrameSet::iterator key)
{
// PRIVATE - should not lock
double tcur = key->getTime();
double vcur = key->getValue();
double tprev, vprev, tnext, vnext, vprevDerivRight, vnextDerivLeft;
Natron::KeyframeType prevType, nextType;
if (key == _imp->keyFrames.begin()) {
tprev = tcur;
vprev = vcur;
vprevDerivRight = 0.;
prevType = Natron::KEYFRAME_NONE;
} else {
KeyFrameSet::const_iterator prev = key;
--prev;
tprev = prev->getTime();
vprev = prev->getValue();
vprevDerivRight = prev->getRightDerivative();
prevType = prev->getInterpolation();
//if prev is the first keyframe, and not edited by the user then interpolate linearly
if (prev == _imp->keyFrames.begin() && prevType != Natron::KEYFRAME_FREE &&
prevType != Natron::KEYFRAME_BROKEN) {
prevType = Natron::KEYFRAME_LINEAR;
}
}
KeyFrameSet::const_iterator next = key;
++next;
if (next == _imp->keyFrames.end()) {
tnext = tcur;
vnext = vcur;
vnextDerivLeft = 0.;
nextType = Natron::KEYFRAME_NONE;
} else {
tnext = next->getTime();
vnext = next->getValue();
vnextDerivLeft = next->getLeftDerivative();
nextType = next->getInterpolation();
KeyFrameSet::const_iterator nextnext = next;
++nextnext;
//if next is thelast keyframe, and not edited by the user then interpolate linearly
if (nextnext == _imp->keyFrames.end() && nextType != Natron::KEYFRAME_FREE &&
nextType != Natron::KEYFRAME_BROKEN) {
nextType = Natron::KEYFRAME_LINEAR;
}
}
double vcurDerivLeft,vcurDerivRight;
assert(key->getInterpolation() != Natron::KEYFRAME_NONE &&
key->getInterpolation() != Natron::KEYFRAME_BROKEN &&
key->getInterpolation() != Natron::KEYFRAME_FREE);
Natron::autoComputeDerivatives(prevType,
key->getInterpolation(),
nextType,
tprev, vprev,
tcur, vcur,
tnext, vnext,
vprevDerivRight,
vnextDerivLeft,
&vcurDerivLeft, &vcurDerivRight);
KeyFrame newKey(*key);
newKey.setLeftDerivative(vcurDerivLeft);
newKey.setRightDerivative(vcurDerivRight);
std::pair<KeyFrameSet::iterator,bool> newKeyIt = _imp->keyFrames.insert(newKey);
// keyframe at this time exists, erase and insert again
if (!newKeyIt.second) {
_imp->keyFrames.erase(newKeyIt.first);
newKeyIt = _imp->keyFrames.insert(newKey);
assert(newKeyIt.second);
}
key = newKeyIt.first;
if (reason != DERIVATIVES_CHANGED) {
key = evaluateCurveChanged(DERIVATIVES_CHANGED,key);
}
return key;
}