Пример #1
0
bool CActionScope::InstallAnimation(const SAnimationEntry &animEntry, int layer, const SAnimBlend &animBlend)
{
	if ((BIT(layer) & m_mutedAnimLayerMask) == BIT(layer))
	{
		return false;
	}

	if (animEntry.animRef.IsEmpty())
	{
		StopAnimationOnLayer(layer, animBlend.duration);
		return true;
	}
	else
	{
		int animID = m_scopeContext.pCharInst->GetIAnimationSet()->GetAnimIDByCRC(animEntry.animRef.crc);

		if (animID >= 0)
		{
			//--- Cleared for install, install across scopes
			CryCharAnimationParams animParams;
			InitAnimationParams(animEntry, layer, animBlend, animParams);
			return InstallAnimation(animID, animParams);
		}
		else
		{
			CryWarning(VALIDATOR_MODULE_GAME, VALIDATOR_WARNING, "Invalid anim ref '%s' on scope '%s' in database '%s'. Skeleton '%s'", animEntry.animRef.c_str(), m_name.c_str(), m_scopeContext.pDatabase->GetFilename(), m_scopeContext.pCharInst->GetIDefaultSkeleton().GetModelFilePath());

			StopAnimationOnLayer(layer, animBlend.duration);
			return false;
		}
	}
}
Пример #2
0
bool CActionScope::InstallAnimation(const SAnimationEntry &animEntry, int layer, const SAnimBlend &animBlend)
{
    if (animEntry.animRef.IsEmpty())
    {
        StopAnimationOnLayer(layer, animBlend.duration);
        return true;
    }
    else
    {
        int animID = m_scopeContext.charInst->GetIAnimationSet()->GetAnimIDByCRC(animEntry.animRef.crc);

        if (animID >= 0)
        {
            //--- Cleared for install, install across scopes
            CryCharAnimationParams animParams;
            InitAnimationParams(animEntry, layer, animBlend, animParams);
            return InstallAnimation(animID, animParams);
        }
        else
        {
            CryWarning(VALIDATOR_MODULE_GAME, VALIDATOR_WARNING, "Invalid anim ref %s on scope %s in database %s", animEntry.animRef.GetString(), m_name.c_str(), m_scopeContext.database->GetFilename());

            StopAnimationOnLayer(layer, animBlend.duration);
            return false;
        }
    }
}
Пример #3
0
void CActionScope::Resume(float forcedBlendTime, uint32 resumeFlags)
{
	if (!m_scopeContext.pCharInst)
	{
		return;
	}

	IAnimationSet* pAnimSet = m_scopeContext.pCharInst->GetIAnimationSet();
	if (!pAnimSet)
	{
		return;
	}

	ISkeletonAnim &skeletonAnimation = *m_scopeContext.pCharInst->GetISkeletonAnim();

	const bool useDefaultBlendTime = (forcedBlendTime < 0);

	for (int i = 0; i < m_numLayers; ++i)
	{
		SSequencer &sequencer = m_layerSequencers[i];

		const int   animationLayer = m_layer + i;
		const float blendTime      = useDefaultBlendTime ? sequencer.blend.duration : forcedBlendTime;

		if (sequencer.savedAnimNormalisedTime < 0)
		{
			skeletonAnimation.StopAnimationInLayer(animationLayer, blendTime);
		}
		else
		{
			const uint32 pos = sequencer.pos - 1;
			if (pos < sequencer.sequence.size())
			{
				SAnimClip &clip   = sequencer.sequence[pos];
				const int  animID = pAnimSet->GetAnimIDByCRC(clip.animation.animRef.crc);
				if (0 <= animID)
				{
					CryCharAnimationParams params;
					InitAnimationParams(clip.animation, i, clip.blend, params);
					const bool installAnimationSuccess = InstallAnimation(animID, params);
					if (installAnimationSuccess)
					{
						const int animationsInLayer = skeletonAnimation.GetNumAnimsInFIFO(animationLayer);
						CRY_ASSERT(1 <= animationsInLayer);

						const bool   loopingAnimation                = ((clip.animation.flags & CA_LOOP_ANIMATION) != 0);
						const uint32 restoreAnimationTimeFlagToCheck = loopingAnimation ? IActionController::ERF_RestoreLoopingAnimationTime : IActionController::ERF_RestoreNonLoopingAnimationTime;
						const bool   restoreAnimationTime            = ((restoreAnimationTimeFlagToCheck & resumeFlags) != 0);
						if (restoreAnimationTime)
						{
							const int   lastAnimationIndex = animationsInLayer - 1;
							CAnimation &animation          = skeletonAnimation.GetAnimFromFIFO(animationLayer, lastAnimationIndex);
							skeletonAnimation.SetAnimationNormalizedTime(&animation, sequencer.savedAnimNormalisedTime);
						}
					}
				}
			}
		}
	}
}