CapsAdmin / pac3

advanced avatar customization for garrysmod
GNU General Public License v3.0
205 stars 94 forks source link

PAC doesnt follow lag compensation in TTT #1341

Closed Earu closed 5 months ago

Earu commented 8 months ago

To reproduce this issue, have a player wear an outfit with model parts parented to any bone of a player. Hit the player while they are moving, notice how the part are desync'd.

homonovus commented 8 months ago

related source links https://github.com/ValveSoftware/source-sdk-2013/blob/0d8dceea4310fde5706b3ce1c70609d72a38efdf/sp/src/game/server/player_lagcompensation.cpp#L410 https://github.com/ValveSoftware/source-sdk-2013/blob/0d8dceea4310fde5706b3ce1c70609d72a38efdf/sp/src/game/server/player_lagcompensation.cpp#L611

CapsAdmin commented 8 months ago

related garrysmod issue https://github.com/Facepunch/garrysmod-issues/issues/884

wrefgtzweve commented 7 months ago

If i understand the issue correctly whats shown in the video is what you mean right? Did a test with this, seems like only GetBonePosition is affected while GetBoneMatrix + GetTranslation doesnt

https://github.com/CapsAdmin/pac3/assets/69946827/ace5e1d2-533a-4810-8638-2d61124c217f

The test code:

hook.Add( "HUDPaint", "BoneExample", function()
    for _, ply in ipairs( player.GetAll() ) do
        if not ply:Alive() then continue end
        if ply == LocalPlayer() then continue end

        local bone = ply:LookupBone( "ValveBiped.Bip01_Head1" )
        if not bone then continue end

        local matrix = ply:GetBoneMatrix( bone )
        if not matrix then continue end

        local pos = matrix:GetTranslation()
        local toScreen = pos:ToScreen()

        draw.SimpleText( "GetBoneMatrix", "DermaDefault", toScreen.x, toScreen.y, color_white, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER )

        local pos = ply:GetBonePosition( bone )
        local toScreen = pos:ToScreen()

        draw.SimpleText( "GetBonePosition", "DermaDefault", toScreen.x, toScreen.y, color_white, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER )
    end
end )
TW1STaL1CKY commented 7 months ago

Yeah, that is the problem. It looks like PAC does mainly use Entity:GetBoneMatrix, though there are a couple of spots still using Entity:GetBonePosition it seems. Those few instances are likely the cause

CapsAdmin commented 7 months ago

Last time I looked into this, I couldn't figure out how to use GetBoneMatrix without breaking the part placement of old outfits.

Earu commented 5 months ago

Last time I looked into this, I couldn't figure out how to use GetBoneMatrix without breaking the part placement of old outfits.

How about today? Maybe you have more ideas than back then? 😁

TW1STaL1CKY commented 5 months ago

Using GetBoneMatrix seems to work fine for me, I'm not sure how old an "old outfit" would be though, the outfits that I've tried have been fine

Before - pac.GetBonePosAng using GetBonePosition: https://github.com/CapsAdmin/pac3/assets/1499739/d508cf27-92c8-41fb-9c71-8d5a5d119c94

After - pac.GetBonePosAng using GetBoneMatrix: (the nametags I have use GetBonePosition so you can kind of compare the difference using it) https://github.com/CapsAdmin/pac3/assets/1499739/babe7b9e-f0d8-4b49-b01d-d4f59f3579b4

I can push/PR this to the develop branch or a new branch for further testing?

TW1STaL1CKY commented 5 months ago

I was told to just push it so I've pushed it to develop😁