TAnimationCurve<T> TAnimationCurve<T>::split(float start, float end)
	{
		Vector<TKeyframe<T>> keyFrames;

		start = Math::clamp(start, mStart, mEnd);
		end = Math::clamp(end, mStart, mEnd);

		if (Math::approxEquals(end - start, 0.0f))
			return TAnimationCurve<T>();

		UINT32 startKeyIdx = findKey(start);
		UINT32 endKeyIdx = findKey(end);

		keyFrames.reserve(endKeyIdx - startKeyIdx + 2);

		const KeyFrame& startKey = mKeyframes[startKeyIdx];
		const KeyFrame& endKey = mKeyframes[endKeyIdx];

		if (!Math::approxEquals(startKey.time, start))
		{
			keyFrames.push_back(evaluateKey(startKey, mKeyframes[startKeyIdx + 1], start));

			if (start > startKey.time)
				startKeyIdx++;
		}
		else
		{
			keyFrames.push_back(startKey);
			startKeyIdx++;
		}

		if(!Math::approxEquals(endKey.time, end))
		{
			keyFrames.push_back(evaluateKey(endKey, mKeyframes[endKeyIdx + 1], end));

			if (end < endKey.time)
				endKeyIdx--;
		}

		keyFrames.insert(keyFrames.begin() + 1, mKeyframes.begin() + startKeyIdx, mKeyframes.begin() + endKeyIdx + 1);

		for (auto& entry : keyFrames)
			entry.time -= start;

		return TAnimationCurve<T>(keyFrames);
	}
Пример #2
0
	TKeyframe<T> TAnimationCurve<T>::evaluateKey(float time, bool loop) const
	{
		if (mKeyframes.size() == 0)
			return TKeyframe<T>();

		AnimationUtility::wrapTime(time, mStart, mEnd, loop);

		UINT32 leftKeyIdx;
		UINT32 rightKeyIdx;

		findKeys(time, leftKeyIdx, rightKeyIdx);

		const KeyFrame& leftKey = mKeyframes[leftKeyIdx];
		const KeyFrame& rightKey = mKeyframes[rightKeyIdx];

		return evaluateKey(leftKey, rightKey, time);
	}
Пример #3
0
static CondResult evalMultipleConditions (Key * key, const Key * meta, const Key * suffixList, Key * parentKey, KeySet * returned)
{
	int countSucceeded = 0;
	int countFailed = 0;
	int countNoexpr = 0;
	KeySet * condKS = elektraMetaArrayToKS (key, keyName (meta));
	Key * c;
	CondResult result = FALSE;
	while ((c = ksNext (condKS)) != NULL)
	{
		if (!keyCmp (c, meta)) continue;
		result = evaluateKey (c, suffixList, parentKey, key, returned, CONDITION);
		if (result == TRUE)
			++countSucceeded;
		else if (result == ERROR)
			++countFailed;
		else if (result == NOEXPR)
			++countNoexpr;
	}
	ksDel (condKS);
	if (!strcmp (keyBaseName (meta), "all"))
	{
		// all conditions must evaluate to TRUE
		if (countFailed || countNoexpr)
			return ERROR;
		else
			return TRUE;
	}
	else if (!strcmp (keyBaseName (meta), "any"))
	{
		// at least one conditional must evaluate to TRUE
		if (countSucceeded)
			return TRUE;
		else
			return ERROR;
	}
	else
	{
		// no condition must evaluate to FALSE
		if (countFailed)
			return ERROR;
		else
			return TRUE;
	}
}