I’m trying to find a good way of doing making the new way of doing SetModelScale behave like the old one.
From what I’ve tested and experienced so far:
The problem with the new method and using Entity.EnableMatrix with RenderMultiply is that if I use it on a model that has more than one bone it will either not scale the model at all or scale the 0 bone only with different axes from the old method. Some models did this in gmod12 but mostly just ragdoll models. This scaling behavior only seems to apply on models with IK on, which is fine I think but now it’s as if IK is enabled on all models by default and the Entity.SetIK function does nothing anymore. Entity.SetIK used to work in previous versions of the gmod beta (but only sometimes for some reason). I can disable IK on players at least by doing this hack ply:SetModelScale(1.00001, 0)
I could work around this by overriding BuildBonePositions on the entities I want to scale. This is kind of annoying and seems to be a lot of work just to scale the model. If you’re scaling an entity you don’t own (as an effect) you’d have to/should make hook code in order to keep the old scale. It’s also in my case a potential big slowdown since I have a lot of entities that need this behavior. Apart from just being annoying and potentially slow, you cannot scale these models between drawing them anymore since the scaling has to be done in another function.
If only the old function was kept and the new one was called SetModelSize instead (since scale usually indicates a vector scale)… This is bugging me a lot atm.
new way: (if you want to make sure it behaves the same as the old way)
if ent:GetBoneCount() > 1 then
local old = ent.BuildBonePositions
ent.BuildBonePositions = function(...) for bone = 0, ent:GetBoneCount() do local mat = ent:GetBoneMatrix(i) if mat then -- ... -- more code that will scale each bone relative to its parent bone ent:SetBoneMatrix(i, mat) end end if old then return old(...) end end
local mat = Matrix()
Which is the only way I can think of atm. I have not successfully made the code that will translate and scale each bone relative to parent bone yet but I think I might need to do a recursive loop instead of a for loop.