Fixed clip planes lagging behind when parented to a bone on a model part

Resolves last reported problem on issue #1341
This commit is contained in:
TW1STaL1CKY 2025-02-15 16:55:09 +00:00
parent 760ee74017
commit 4e8eb09f16
2 changed files with 15 additions and 6 deletions

View File

@ -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

View File

@ -40,6 +40,12 @@ 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 owner.PACPart then
pac.SetupBones(owner)
end
local pos, ang = LocalToWorld(self.Position + self.PositionOffset, self:CalcAngles(self.Angles + self.AngleOffset), self:GetBonePosition())
local normal = ang:Forward()