ArranzCNL / ImprovedCameraSE-NG

First Person Mod for The Elder Scrolls V: Skyrim - Special Edition
Mozilla Public License 2.0
31 stars 6 forks source link

Fix for the sliding legs bug. #26

Open DeclineDawn opened 1 month ago

DeclineDawn commented 1 month ago

Hi. After two years I found a way to fix a very old bug in Improved Camera SE with legs sliding in the air for the body in 1st person, in standard mode, with a small change to the animation for 3rd person. Here is a video of the standard vanilla animation, without my fix - https://disk.yandex.ru/i/L297jLsMWQ_QXQ Here is a video with the fix - https://disk.yandex.ru/i/zIcAtH8p_8bMPQ Everything works, but there is a problem.... For my fixed animation for 3rd person to work, it is necessary that the body from 3rd person in 1st person mode is attached not to the NPC Head bone [Head], but to the NPCEyeBone bone. I have a friend who can make a dll file patch that changes the binding of the NPC Head [Head] bone to NPCEyeBone, BUT after looking through all the Source files of the Improved Camera mod published on github, we could not find information on where and how to connect the 1st and 3rd person skeletons to the NPC Head [Head] bone to change it to NPCEyeBone. Please tell me where to look for information about the skeleton connection bones in the Source files, so that we can make a dll patch for your Improved Camera mod.

ArranzCNL commented 1 month ago

No need v2 already fixes this, you have to be careful with the eye bone as VL calls it NPC Eyebrow (work around in v2).

The whole issue with this is due to the fact IC was supporting two modes, headbob (attached camera) and non-headbob (detacted camera). It is always headbob, attached camera now!

v2 has many changes coming, it'll be available on discord very soon I want to sort out the building process on github before updating it over here. Should be able to work around the source files much easier in v2 if the problem still persists.

The beta should be available within a week from now at the latest. Main issue is currently working out which settings need removing/updating before iterating on the betas getting events implemented.

DeclineDawn commented 1 month ago

Thanks for the answer. I tested the latest available version ImprovedCameraSE-NG-v1.1.1. In v1.1.1, the headbob mode did not work, only non-headbob.

Unfortunately, the headbob mode has a bug with long-range weapons. The projectiles do not work correctly. I understand the reason for this problem with shooting and projectiles in the headbob.

And I understand that it is impossible to fix this bug for the headbob mode.

It will be great if the non-headbob mode is saved in the new version. And it will be great if the ability to change the bone of connection with the body of the NPC Head [Head] is added in the ini file.

Tell me, please, can you add the ability to change the bone of the NPC Head [Head] binding for the non-headbob mode? If you don't add this, could you please tell me in which specific Source files the NPC Head bone binding functions are performed? My friend and I will try to create an additional dll file ourselves, a patch to fix sliding legs in non-headbob mode.

ArranzCNL commented 1 month ago

Non-headbob won't be coming back to the core as there is no need to bring it back. Only thing I can advise for a moment is to wait until I release the sources of the beta on github as the project is a lot more organized.

If you guys still feel unhappy about the handling in v2+, I do need to do an API which would mean could work with you guys to open up an API to which parts you need access too. As I'm seriously not going to create an API just to say whether it is in first person or not as that just seems wasteful!

Bare in mind due to it being beta it will still be iterated over as the initial beta release is just to test camera handling etc most events are currently deactivated/not coded due to initial testing feedback. More beta's will following fixing bugs/implementing events until v2.0.1 is ready for public release over on Nexus.

Also thanks for your feedback!

DeclineDawn commented 3 weeks ago

Ok. It will be interesting to look at the fixed v2. Tell me, do you know why in vanilla, when moving to the sides, there is a hardware shift in the coordinates of the projectile launch position? For example, as in this video - https://disk.yandex.ru/i/QKJOCxwJx74MJA The faster the player moves, the more the shift in the position of the launch of the projectiles occurs. The shift occurs in all directions of movement. At the same time, the position of the bones from which the projectiles are launched does not change. Is it possible to somehow turn off this shift of projectiles while moving?

ArranzCNL commented 3 weeks ago

I think it is using the crosshair data. My current fix for both when in true first person:

void GCamera::FixWeaponPosition(RE::Actor* a_actor, RE::NiNode* a_cameraRoot) const
{
    // Fix first person
    auto firstperson3D = a_actor->Get3D(1);
    if (firstperson3D)
    {
        auto fpWeapon3D = firstperson3D->GetObjectByName("WEAPON");
        auto fpLeftMagic3D = firstperson3D->GetObjectByName("NPC L MagicNode [LMag]");
        auto fpRightMagic3D = firstperson3D->GetObjectByName("NPC R MagicNode [RMag]");

        if (fpWeapon3D) fpWeapon3D->world.translate += a_cameraRoot->local.translate - m_rootLocalTranslatePrevious;
        if (fpLeftMagic3D) fpLeftMagic3D->world.translate += a_cameraRoot->local.translate - m_rootLocalTranslatePrevious;
        if (fpRightMagic3D) fpRightMagic3D->world.translate += a_cameraRoot->local.translate - m_rootLocalTranslatePrevious;
    }
    // Fix third person
    auto thirdperson3D = a_actor->Get3D(0);
    if (thirdperson3D)
    {
        auto tpWeapon3D = thirdperson3D->GetObjectByName("WEAPON");
        auto tpLeftMagic3D = thirdperson3D->GetObjectByName("NPC L MagicNode [LMag]");
        auto tpRightMagic3D = thirdperson3D->GetObjectByName("NPC R MagicNode [RMag]");

        // This isn't perfect but its better than nothing
        RE::NiPoint3 vel{};
        a_actor->GetLinearVelocity(vel);
        // 70.0f is roughly 1 meter
        vel /= (70.0f * 0.25f);

        if (tpWeapon3D) tpWeapon3D->world.translate += vel;
        if (tpLeftMagic3D) tpLeftMagic3D->world.translate += vel;
        if (tpRightMagic3D) tpRightMagic3D->world.translate += vel;
    }
}

m_rootLocalTranslatePrevious is a snapshot of cameraRoot->local.translate before I update the camera.

The thirdperson3D is for using the 3rd person arms, although the velocity does help as I mentioned it is not perfect due to needing to know ideally the max velocity as above is a ramp up.

DeclineDawn commented 2 weeks ago

After much research into this projectile displacement issue, my friend and I recently discovered that to disable projectile displacement when the player moves, all you need to do is change these settings in Skyrim.ini [Camera] f1stHorzDampeningSpringConstant=0.000 f1stHorzDampeningVelocityDampening=0.0 f1stVertDampeningSpringConstant=0.0000 f1stVertDampeningVelocityDampening=0.0