Facepunch / garrysmod-issues

Garry's Mod issue tracker
147 stars 56 forks source link

weapon_physcannon prediction was broken for ages (and probably can be fixed) #3100

Open Klizmotron opened 7 years ago

Klizmotron commented 7 years ago

Details

Maybe now it's time?..

As I can understand, a gravity gun has a special prediction mechanism that in theory should make entities predicted when you grab them (to avoid jiggling and backtracking), it's easy to notice if you enable vcollide_wireframe and try to grab some entity with the gravity gun. vcollide_wireframe shows serverside physics in blue color and clientside (predicted) physics objects in red color. If you move an object a bit while holding it you will notice that even though it's predicted (red) physics object is correctly predicted and moves without lag or glitching, the actual visual mesh of the entity behaves weirdly. Probably the client still draws the entity relatevely to a non-predicted physics object, even though it shouldn't, or even glitches in-between (because it not only backtracks, it also flickers in a strange way). So I want to know what this bug is caused by, first of all, to find a way around it in my projects, and it would be just wonderful if this aged issue would be finally fixed in Garry's mod.

Wouldn't it be cool to no longer see glitching 3D2D screens on money printers on DarkRP when holding them with a gravity gun? This bug is exactly what this glitching is caused by!

Steps to reproduce

  1. sv_cheats 1
  2. vcollide_wireframe 1
  3. Spawn a prop and grab it with gravity gun
  4. Move it around and see how it's predicted physics object and the actual model are desynchronized

EDIT: By the way, the only way I found to fix this issue for my entities at the moment is the following:

function ENT:Draw()

    local Phys = self:GetPhysicsObject()

    if Phys and Phys:IsValid() then

        self:InvalidateBoneCache()
    end

    self:DrawModel()
end

But I don't like it at all, anyways, at least it works

EDIT 2: This seems to work like a universal function for recursive hierarchy fix (so that parent entities don't backtrack when their parent is held by a gravity gun)

function ApplyGGunFix( Ent )

    if not ( Ent and Ent:IsValid() ) then return end

    local Phys = Ent:GetPhysicsObject()
    local Parent = Ent:GetParent()

    if ( Phys and Phys:IsValid() ) or ( Parent and Parent.ApplyGGunFix ) then 
        Ent.ApplyGGunFix = true 
    else
        Ent.ApplyGGunFix = nil
    end

    if Ent.ApplyGGunFix then Ent:InvalidateBoneCache() end
end

You should apply it like this:

function ENT:Draw()

    ApplyGGunFix( self )
    self:DrawModel()
end

Though it will only work for those entities in hierarchy for which you call this function. If there is a simple prop parented to your entity or whatever it will still backtrack

Klizmotron commented 7 years ago

Ignored. Nice.

Kefta commented 7 years ago

Look at all of the issues on this GitHub: there are a lot that can't all be handled immediately by two part-time devs.

neico commented 7 years ago

They could "hire" more, or even add some mods that only handle the trackers if it's that much of a problem though, pretty sure there's plenty who are willing to help...

But that's going out of scope, so here's that:

prediction on the physcannon is only a minor issue, there's more important things to take care of, but yeah it can be fixed at some point for sure.