diff --git a/lua/pac3/core/client/parts/bone.lua b/lua/pac3/core/client/parts/bone.lua index e3414b447..29526e574 100644 --- a/lua/pac3/core/client/parts/bone.lua +++ b/lua/pac3/core/client/parts/bone.lua @@ -290,12 +290,12 @@ function PART:GetBonePosition() if not self.bone_index then return ent:GetPos(), ent:GetAngles() end local m = ent:GetBoneMatrix(self.bone_index) - if not m then return ent:GetPos(), ent:GetAngles() end - local pos = m:GetTranslation() - local ang = m:GetAngles() - - return pos, ang + if m then + return m:GetTranslation(), m:GetAngles() + else + return ent:GetPos(), ent:GetAngles() + end end function PART:GetBoneMatrix() @@ -306,12 +306,15 @@ BUILDER:Register() pac.AddHook("OnEntityCreated", "hide_mesh_no_crash", function(ent) local ply = ent:GetRagdollOwner() + if ply:IsPlayer() and ply.pac_inf_scale then for i = 0, ply:GetBoneCount() - 1 do local scale = ply:GetManipulateBoneScale(i) + if scale == inf_scale then - scale = Vector(0,0,0) + scale = vector_origin end + ply:ManipulateBoneScale(i, scale) end end diff --git a/lua/pac3/core/client/parts/clip.lua b/lua/pac3/core/client/parts/clip.lua index 7b40e4f0a..7dda463a2 100644 --- a/lua/pac3/core/client/parts/clip.lua +++ b/lua/pac3/core/client/parts/clip.lua @@ -40,6 +40,16 @@ do function PART:PreOnDraw() bclip = render_EnableClipping(true) + -- this fixes clip planes lagging behind when parented to a bone on a model part + local owner = self:GetParentOwner() + if owner:IsValid() and not owner.pac_clip_bonessetup and owner.PACPart then + -- in case there are multiple clips on one model part, only the first one needs to call SetupBones + self.pac_clip_owner = owner + owner.pac_clip_bonessetup = true + + pac.SetupBones(owner) + end + local pos, ang = LocalToWorld(self.Position + self.PositionOffset, self:CalcAngles(self.Angles + self.AngleOffset), self:GetBonePosition()) local normal = ang:Forward() @@ -49,6 +59,11 @@ do local render_PopCustomClipPlane = render.PopCustomClipPlane function PART:PostOnDraw() + if self.pac_clip_owner then + self.pac_clip_owner.pac_clip_bonessetup = nil + self.pac_clip_owner = nil + end + render_PopCustomClipPlane() render_EnableClipping(bclip)