garrysmod-issues
garrysmod-issues copied to clipboard
Model rendering issues when using NPC models
When using NPC models as player models and overriding some animation code to translate activities properly, they will sometimes cause various issues when the model is rendered.
The most reliable way that I've found to make it happen is to use a map that has some PVS optimization (my test map is https://steamcommunity.com/sharedfiles/filedetails/?id=1532126505) and have two players be a fair distance apart and in different visleaves. After waiting a couple of minutes, bring the players back together and there's about a 1 in 3 chance that they will have some sort of bone issue. It's more likely to happen for yourself if you are tabbed out of the game.
Forcing a full update for your client will resolve this issue temporarily, and many players have resorted to having to use record 1; stop in console to do so.
There are a couple different kinds of bugs that will happen, including incorrect bone rotation: https://i.imgur.com/dRiHaXs.jpg
Models not rendering at all: https://streamable.com/c2y7z
And models twitching left and right rapidly, which I couldn't get a video of at the moment.
I've isolated this issue with a test gamemode that includes a stripped down version of the animation code that we use. No other addons/lua files have been ran except for the gamemode code and base GMod stuff. You can check out the gamemode here https://gist.github.com/impulsh/b6de45e03ecf5b2c5d722a1bea07ee0e
The issues that are happening seems to be similar to #3010. Using the fix from https://github.com/ValveSoftware/source-sdk-2013/issues/404#issuecomment-405042224 might solve the problem
Bone positions become completely invalid which is the point at which the player becomes completely invisible.
] lua_run_cl print(LocalPlayer():GetEyeTraceNoCursor().Entity:GetBonePosition(1))
-nan(ind) -nan(ind) -nan(ind) nan nan 0.000
@willox @robotboy655
This also seems to happen for regular player models, although not nearly as frequent as NPC models it seems
Merged the potential fix from https://github.com/ValveSoftware/source-sdk-2013/issues/404#issuecomment-405042224 Let me know if that fixes it.
When would this be pushed to the dev branch?
All changes are pushed to Dev branch within minutes of them being committed automatically.
The patch has fixed it partially, players no longer go invisible at all and the spine twisting/twitching seems much less frequent.
Not sure if this was reverted in the latest patch but it seems to have started occurring frequently since.
It wasn't.
I'm seeing this a lot now on citizen based NPC models, the spine is turned roughly 90 degrees to the right if I'm not mistaken. Happening frequently to those with higher FPS.
Been starting to see this more and more often now that I'm entering gamemodes with higher FPS, honestly a weird occurrence and I've seen this occur on both Citizen and Combine based models
I could only speculate that it's becoming more of an issue with the x64 branch if that's where you're testing it.
And yes, the higher the FPS the higher the chance of it happening (max_fps 120 on the client should prevent it from happening as a workaround), but really, it wasn't a problem anymore with the Lerp_Hermite specialisation, so I'm at a loss as to where else it could come from, someone would need to do some deep digging if it still has to do with the pose params going out of bounds.
The only workaround I've found is starting to record a demo with 'record demo' in console, then following it up with 'stop'.
Yeah, that forces a full client update which would usually be done with cl_fullupdate but that command requires cheats.
@robotboy655 Could this get reopened? This issue seems to still be persisting even through the lerp fix
We've found a pretty reproducible test case for triggering the issue. It isn't as extreme as we've seen in the wild, but it's as good as it's going to get in terms of reliably reproducing the issue.
We simply switched between the male_01 and police models a couple times and it would happen almost every time as captured in this video: https://streamable.com/mebf8. It shows the model being switched 6 times and with the final switch back to the male_01 model, you can see the spine being distorted. Shortly after, cl_fullupdate was used to reset the entity and fix the issue.
The issue also shows up in demos, so I've uploaded one at https://www.dropbox.com/s/mw4a27ucacgcieo/animtest.dem if it's at all useful.
The test code that was used is below. The gamemode used is the one linked in the OP (https://gist.github.com/impulsh/b6de45e03ecf5b2c5d722a1bea07ee0e).
concommand.Add("animmodel", function(client)
for i = 1, 3 do
timer.Simple(i * 0.1, function()
local newModel = client:GetModel() == "models/humans/group01/male_01.mdl" and "models/police.mdl" or "models/humans/group01/male_01.mdl"
client:SetModel(newModel)
end)
end
end)
It appears as if changing the model results in the pose parameters being copied over, but the models have different pose parameters (or pose parameters are stored in a different order.)
I can't say for sure it is related to your first post, but I can try to fix it. I would assume this only causes any issues when the players' model is changed.
I pushed a fix for that to the dev branch. I'm still not sure if it'll fix the actual issue.
It appears as if changing the model results in the pose parameters being copied over, but the models have different pose parameters (or pose parameters are stored in a different order.)
I can't say for sure it is related to your first post, but I can try to fix it. I would assume this only causes any issues when the players' model is changed.
I'll give it a test. This happens on it's own over time (5-10 minutes) without any model changes but changing the model a couple times is the most reproducable trigger of the issue.
I pushed a fix for that to the dev branch. I'm still not sure if it'll fix the actual issue.
It's happening less frequently now, however, it is still noticeable in a couple of players over time 10minutes & People still continue to go invisible which in combat screws over the person they're fighting against.

I can confirm that it is still reproduced when I change the player model to the NPCs model and back. Some pose parameters goes up to 300k or even inf/nan by engine.
ClearPoseParameters right after the model change does not help.
but I can just set player:SetPoseParameter("body_yaw", 0) for example in UpdateAnimation and forget.
Or maybe the calculation code of "body_yaw" is completely broken.
I have made some changes that may or may not help with this.
I could never reproduce this the way described above, but I did cause similar issues by manually setting cycle to infinity in the engine.
I am considering this solved for now, unless someone can disprove it.