Вопрос Помощь с анимфиксом

Пользователь
Статус
Оффлайн
Регистрация
5 Фев 2018
Сообщения
134
Реакции[?]
33
Поинты[?]
0
Собственно говоря я сделал десинки, и так как моделька перса без анимфикса = десинк, я решил сделать анимфикс, но проблема в том что у меня оружие(от 3 лица на локале) как бы привязано к десинку и соответственно разворазчивается плавно от 0 до 58 градусов. Собственно вопрос к знатокам, как пофиксить ?
ps анимфикс с пандоры

Код:
void LagComp::UpdateLocalAnimations(int iStage)
{
    if (iStage != FRAME_RENDER_START)
        return;

    auto pLocal = Interfaces::User();
    if (!pLocal || !pLocal->m_bIsAlive())
        return;

    auto AnimState = pLocal->m_pAnimState();
    if (!AnimState)
        return;

    auto pNet = Interfaces::Engine->GetNetChannel();
    if (!pNet)
        return;

    // allow re-animating in the same frame.
    if (AnimState->m_iLastClientSideAnimationUpdateFramecount == Interfaces::GlobalVars->framecount)
        AnimState->m_iLastClientSideAnimationUpdateFramecount -= 1;

    // update anim update delta as server build.
    AnimState->m_flAnimUpdateDelta = max(0.0f, Interfaces::GlobalVars->curtime - AnimState->m_flLastClientSideAnimationUpdateTime); // negative values possible when clocks on client and server go out of sync..

    if (Globals::NewTick)
    {
        // get layers.
        pLocal->GetAnimLayers(Globals::RealLayers);

        // allow the game to update animations this tick.
        pLocal->m_bClientSideAnimation() = Globals::UpdateAnimations = true;

        // update animations.
        AnimState->Update(Globals::RealAngle);
        pLocal->UpdateClientSideAnimations();

        // disallow the game from updating animations this tick.
        pLocal->m_bClientSideAnimation() = Globals::UpdateAnimations = true;

        // save data when our choke cycle resets.
        if (!pNet->m_iChokedPackets)
            Globals::Rotation = AnimState->m_flGoalFeetYaw;
        
        // remove model sway.
        Globals::RealLayers[12].m_flWeight = 0.f;

        // make sure to only animate once per tick.
        Globals::NewTick = false;
    }

    // update our layers and poses with the saved ones.
    pLocal->SetAnimLayers(Globals::RealLayers);

    // update our real rotation.
    pLocal->SetAbsAngles(Vec3D(0.f, Globals::Rotation, 0.f));

    // build bones.
    pLocal->SetupBones(Globals::RealMatrix, 128, BONE_USED_BY_ANYTHING, pLocal->m_flSimulationTime());
}

void LagComp::UpdateFakeAnimations(int iStage)
{
    if (iStage != FRAME_RENDER_START)
        return;

    auto pLocal = Interfaces::User();
    if (!pLocal || !pLocal->m_bIsAlive())
        return;

    auto pNet = Interfaces::Engine->GetNetChannel();
    if (!pNet)
        return;

    bool allocate = (Globals::FakeState == nullptr);
    bool change = (!allocate) && (pLocal->GetRefEHandle() != Globals::EntHandle);
    bool reset = (!allocate && !change) && (pLocal->m_flSpawnTime() != Globals::SpawnTime);

    // player changed, free old animation state.
    if (change && Globals::FakeStateAllocated)
        Interfaces::MemAlloc->Free(Globals::FakeStateAllocated);

    if (reset)
    {
        Globals::FakeState->Reset();
        Globals::SpawnTime = pLocal->m_flSpawnTime();
    }

    // need to allocate or create new due to player change.
    if (allocate || change) {
        // only works with games heap alloc.
        Globals::FakeStateAllocated = (CPlayerAnimstate*)Interfaces::MemAlloc->Alloc(sizeof(CPlayerAnimstate));

        if (Globals::FakeStateAllocated != nullptr)
            Globals::FakeStateAllocated->Create(pLocal);

        // used to detect if we need to recreate / reset.
        Globals::EntHandle = pLocal->GetRefEHandle();
        Globals::SpawnTime = pLocal->m_flSpawnTime();

        // note anim state for future use.
        Globals::FakeState = Globals::FakeStateAllocated;
    }
    else
    {
        // make sure our state isn't null.
        if (!Globals::FakeState)
            return;

        // allow re-animating in the same frame.
        Globals::FakeState->m_iLastClientSideAnimationUpdateFramecount = 0.f;

        // update fake animations per tick.
        Globals::FakeState->m_flAnimUpdateDelta = fmaxf(Interfaces::GlobalVars->curtime - Globals::FakeState->m_flLastClientSideAnimationUpdateTime, 0.0);

        // update fake animations per tick.
        if (Globals::NewTickF)
        {
            // update fake animations when we send commands.
            if (!pNet->m_iChokedPackets) {

                // update fake animation state.
                Globals::FakeState->Update(Globals::RealAngle);

                pLocal->GetAnimLayers(Globals::FakeLayers);
            }

            // remove model sway.
            Globals::FakeLayers[12].m_flWeight = 0.f;

            // make sure to only animate once per tick.
            Globals::NewTickF = false;
        }

        // replace current animation layers and poses with the fake ones.
        pLocal->SetAnimLayers(Globals::FakeLayers);

        // replace the model rotation and build a matrix with our fake data.
        pLocal->SetAbsAngles(Vec3D(0.f, Globals::FakeState->m_flGoalFeetYaw, 0.f));

        // generate a fake matrix.
        pLocal->SetupBones(Globals::FakeMatrix, 128, BONE_USED_BY_ANYTHING, pLocal->m_flSimulationTime());

        // fix interpolated model.
        for (auto& i : Globals::FakeMatrix) {
            i[0][3] -= pLocal->GetRenderOrigin().x;
            i[1][3] -= pLocal->GetRenderOrigin().y;
            i[2][3] -= pLocal->GetRenderOrigin().z;
        }

        // revert our layers and poses back.
        pLocal->SetAnimLayers(Globals::RealLayers);

        // replace the model rotation with the proper rotation.
        pLocal->SetAbsAngles(Vec3D(0.f, Globals::Rotation, 0.f));
    }
}
 
Забаненный
Статус
Оффлайн
Регистрация
6 Дек 2020
Сообщения
63
Реакции[?]
19
Поинты[?]
0
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
Собственно говоря я сделал десинки, и так как моделька перса без анимфикса = десинк, я решил сделать анимфикс, но проблема в том что у меня оружие(от 3 лица на локале) как бы привязано к десинку и соответственно разворазчивается плавно от 0 до 58 градусов. Собственно вопрос к знатокам, как пофиксить ?
ps анимфикс с пандоры

Код:
void LagComp::UpdateLocalAnimations(int iStage)
{
    if (iStage != FRAME_RENDER_START)
        return;

    auto pLocal = Interfaces::User();
    if (!pLocal || !pLocal->m_bIsAlive())
        return;

    auto AnimState = pLocal->m_pAnimState();
    if (!AnimState)
        return;

    auto pNet = Interfaces::Engine->GetNetChannel();
    if (!pNet)
        return;

    // allow re-animating in the same frame.
    if (AnimState->m_iLastClientSideAnimationUpdateFramecount == Interfaces::GlobalVars->framecount)
        AnimState->m_iLastClientSideAnimationUpdateFramecount -= 1;

    // update anim update delta as server build.
    AnimState->m_flAnimUpdateDelta = max(0.0f, Interfaces::GlobalVars->curtime - AnimState->m_flLastClientSideAnimationUpdateTime); // negative values possible when clocks on client and server go out of sync..

    if (Globals::NewTick)
    {
        // get layers.
        pLocal->GetAnimLayers(Globals::RealLayers);

        // allow the game to update animations this tick.
        pLocal->m_bClientSideAnimation() = Globals::UpdateAnimations = true;

        // update animations.
        AnimState->Update(Globals::RealAngle);
        pLocal->UpdateClientSideAnimations();

        // disallow the game from updating animations this tick.
        pLocal->m_bClientSideAnimation() = Globals::UpdateAnimations = true;

        // save data when our choke cycle resets.
        if (!pNet->m_iChokedPackets)
            Globals::Rotation = AnimState->m_flGoalFeetYaw;
       
        // remove model sway.
        Globals::RealLayers[12].m_flWeight = 0.f;

        // make sure to only animate once per tick.
        Globals::NewTick = false;
    }

    // update our layers and poses with the saved ones.
    pLocal->SetAnimLayers(Globals::RealLayers);

    // update our real rotation.
    pLocal->SetAbsAngles(Vec3D(0.f, Globals::Rotation, 0.f));

    // build bones.
    pLocal->SetupBones(Globals::RealMatrix, 128, BONE_USED_BY_ANYTHING, pLocal->m_flSimulationTime());
}

void LagComp::UpdateFakeAnimations(int iStage)
{
    if (iStage != FRAME_RENDER_START)
        return;

    auto pLocal = Interfaces::User();
    if (!pLocal || !pLocal->m_bIsAlive())
        return;

    auto pNet = Interfaces::Engine->GetNetChannel();
    if (!pNet)
        return;

    bool allocate = (Globals::FakeState == nullptr);
    bool change = (!allocate) && (pLocal->GetRefEHandle() != Globals::EntHandle);
    bool reset = (!allocate && !change) && (pLocal->m_flSpawnTime() != Globals::SpawnTime);

    // player changed, free old animation state.
    if (change && Globals::FakeStateAllocated)
        Interfaces::MemAlloc->Free(Globals::FakeStateAllocated);

    if (reset)
    {
        Globals::FakeState->Reset();
        Globals::SpawnTime = pLocal->m_flSpawnTime();
    }

    // need to allocate or create new due to player change.
    if (allocate || change) {
        // only works with games heap alloc.
        Globals::FakeStateAllocated = (CPlayerAnimstate*)Interfaces::MemAlloc->Alloc(sizeof(CPlayerAnimstate));

        if (Globals::FakeStateAllocated != nullptr)
            Globals::FakeStateAllocated->Create(pLocal);

        // used to detect if we need to recreate / reset.
        Globals::EntHandle = pLocal->GetRefEHandle();
        Globals::SpawnTime = pLocal->m_flSpawnTime();

        // note anim state for future use.
        Globals::FakeState = Globals::FakeStateAllocated;
    }
    else
    {
        // make sure our state isn't null.
        if (!Globals::FakeState)
            return;

        // allow re-animating in the same frame.
        Globals::FakeState->m_iLastClientSideAnimationUpdateFramecount = 0.f;

        // update fake animations per tick.
        Globals::FakeState->m_flAnimUpdateDelta = fmaxf(Interfaces::GlobalVars->curtime - Globals::FakeState->m_flLastClientSideAnimationUpdateTime, 0.0);

        // update fake animations per tick.
        if (Globals::NewTickF)
        {
            // update fake animations when we send commands.
            if (!pNet->m_iChokedPackets) {

                // update fake animation state.
                Globals::FakeState->Update(Globals::RealAngle);

                pLocal->GetAnimLayers(Globals::FakeLayers);
            }

            // remove model sway.
            Globals::FakeLayers[12].m_flWeight = 0.f;

            // make sure to only animate once per tick.
            Globals::NewTickF = false;
        }

        // replace current animation layers and poses with the fake ones.
        pLocal->SetAnimLayers(Globals::FakeLayers);

        // replace the model rotation and build a matrix with our fake data.
        pLocal->SetAbsAngles(Vec3D(0.f, Globals::FakeState->m_flGoalFeetYaw, 0.f));

        // generate a fake matrix.
        pLocal->SetupBones(Globals::FakeMatrix, 128, BONE_USED_BY_ANYTHING, pLocal->m_flSimulationTime());

        // fix interpolated model.
        for (auto& i : Globals::FakeMatrix) {
            i[0][3] -= pLocal->GetRenderOrigin().x;
            i[1][3] -= pLocal->GetRenderOrigin().y;
            i[2][3] -= pLocal->GetRenderOrigin().z;
        }

        // revert our layers and poses back.
        pLocal->SetAnimLayers(Globals::RealLayers);

        // replace the model rotation with the proper rotation.
        pLocal->SetAbsAngles(Vec3D(0.f, Globals::Rotation, 0.f));
    }
}
Не совсем понял твоей проблемки, можно видео чтоли..
А по поводу кода : как минимум "FRAME_RENDER_START" , это уже не правильно для нормального не гетто анимфикса.
Анимации на локал плеера должны обновляться каждый тик, а значит это дело надо делать в критмуве :flushed:
 
Сверху Снизу