Ejemplo n.º 1
0
void CActionScope::Pause()
{
    if (!m_scopeContext.charInst)
    {
        return;
    }

    ISkeletonAnim *pSkeletonAnim = m_scopeContext.charInst->GetISkeletonAnim();
    if (!pSkeletonAnim)
    {
        return;
    }

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

        const int animationLayer = m_layer + i;

        const int animationsInLayer = pSkeletonAnim->GetNumAnimsInFIFO(animationLayer);
        if (animationsInLayer == 0)
        {
            sequencer.savedAnimNormalisedTime = -1;
        }
        else
        {
            const int lastAnimationIndex = animationsInLayer - 1;
            const CAnimation &animation = pSkeletonAnim->GetAnimFromFIFO(animationLayer, lastAnimationIndex);
            sequencer.savedAnimNormalisedTime = pSkeletonAnim->GetAnimationNormalizedTime(&animation);
        }
    }
}
//------------------------------------------------------------------------
void CVehicleSeatActionPassengerIK::Update(float frameTime)
{
	if (!m_passengerId)
		return;

	IActor* pActor = CCryAction::GetCryAction()->GetIActorSystem()->GetActor(m_passengerId);
	if (!pActor)
	{
		CRY_ASSERT(!"Invalid entity id for the actor id, Actor System didn't know it");
		return;
	}

	if (ICharacterInstance* pCharInstance = pActor->GetEntity()->GetCharacter(0))
	{
		ISkeletonAnim* pSkeletonAnim = pCharInstance->GetISkeletonAnim();
		CRY_ASSERT(pSkeletonAnim);

		if (pSkeletonAnim->GetNumAnimsInFIFO(0) >= 1)
		{
			const CAnimation& anim = pSkeletonAnim->GetAnimFromFIFO(0, 0);
			const uint16 loopCount = anim.GetLoop();
			const f32 animationTime = pSkeletonAnim->GetAnimationNormalizedTime( &anim );
			if (!m_waitShortlyBeforeStarting || (loopCount > 0 || animationTime > 0.9f))
			{
				for (TIKLimbVector::iterator ite = m_ikLimbs.begin(); ite != m_ikLimbs.end(); ++ite)
				{
					const SIKLimb& limb = *ite;

					Vec3 helperPos = limb.pHelper->GetWorldSpaceTranslation();
					pActor->SetIKPos(limb.limbName.c_str(), helperPos, 1);
				}
			}
		}
	}

}