Fixed positioning not working correctly for root bones of advanced bonemerged entities

This commit is contained in:
penolakushari 2024-04-13 23:45:06 +03:00
parent e84d5f8241
commit b8c7b7502d
6 changed files with 43 additions and 16 deletions

View File

@ -338,7 +338,12 @@ function ENT:Think()
end
end
else
ang = self.GizmoAng
if pl.rgm.GizmoParentID ~= -1 then
local physobj = ent:GetPhysicsObjectNum(pl.rgm.GizmoParentID)
_, ang = LocalToWorld(vector_origin, self.GizmoAng, physobj:GetPos(), physobj:GetAngles())
else
_, ang = LocalToWorld(vector_origin, self.GizmoAng, ent:GetPos(), ent:GetAngles())
end
local manang = ent:GetManipulateBoneAngles(bone)*1
manang:Normalize()
@ -385,7 +390,12 @@ function ENT:Think()
end
else
if IsValid(ent) then
ang = self.GizmoAng
if pl.rgm.GizmoParentID ~= -1 then
local physobj = ent:GetPhysicsObjectNum(pl.rgm.GizmoParentID)
_, ang = LocalToWorld(vector_origin, self.GizmoAng, physobj:GetPos(), physobj:GetAngles())
else
_, ang = LocalToWorld(vector_origin, self.GizmoAng, ent:GetPos(), ent:GetAngles())
end
end
end
end

View File

@ -65,10 +65,15 @@ function ENT:ProcessMovement(offpos, _, eyepos, eyeang, ent, bone, ppos, _, move
_, boneang = LocalToWorld(vector_origin, diff, vector_origin, axis.GizmoParent)
end
else
if IsValid(ent) then
boneang = ent:GetAngles()
if ent:GetClass() == "ent_advbonemerge" and parent:GetClass() == "prop_ragdoll" then
boneang = angle_zero -- bone has no parent and isn't physical
else
boneang = angle_zero
if pl.rgm.GizmoParentID ~= -1 then
local physobj = ent:GetPhysicsObjectNum(pl.rgm.GizmoParentID)
boneang = physobj:GetAngles()
else
boneang = ent:GetAngles()
end
end
end

View File

@ -29,9 +29,9 @@ function ENT:ProcessMovement(_, offang, eyepos, eyeang, ent, bone, ppos, pnorm,
local pl = axis.Owner
local axistable = {
(self:GetParent():LocalToWorld(VECTOR_SIDE) - self:GetPos()):Angle(), --axis:LocalToWorldAngles(axis.DiscP:GetLocalAngles()),
(self:GetParent():LocalToWorld(vector_up) - self:GetPos()):Angle(), --axis:LocalToWorldAngles(axis.DiscY:GetLocalAngles()),
(self:GetParent():LocalToWorld(VECTOR_FRONT) - self:GetPos()):Angle(), --axis:LocalToWorldAngles(axis.DiscR:GetLocalAngles()),
(self:GetParent():LocalToWorld(VECTOR_SIDE) - self:GetPos()):Angle(),
(self:GetParent():LocalToWorld(vector_up) - self:GetPos()):Angle(),
(self:GetParent():LocalToWorld(VECTOR_FRONT) - self:GetPos()):Angle(),
(self:GetPos() - pl:EyePos()):Angle()
}
axistable[1]:Normalize()

View File

@ -60,10 +60,16 @@ function ENT:ProcessMovement(offpos, _, eyepos, eyeang, ent, bone, ppos, pnorm,
_, boneang = LocalToWorld(vector_origin, diff, vector_origin, axis.GizmoParent)
end
else
if IsValid(ent) then
boneang = ent:GetAngles()
if ent:GetClass() == "ent_advbonemerge" and parent:GetClass() == "prop_ragdoll" then
boneang = angle_zero -- bone has no parent and isn't physical
else
boneang = angle_zero
local pl = self:GetParent().Owner
if pl.rgm.GizmoParentID ~= -1 then
local physobj = ent:GetPhysicsObjectNum(pl.rgm.GizmoParentID)
boneang = physobj:GetAngles()
else
boneang = ent:GetAngles()
end
end
end

View File

@ -64,10 +64,16 @@ function ENT:ProcessMovement(offpos, _, eyepos, eyeang, ent, bone, ppos, pnorm,
_, boneang = LocalToWorld(vector_origin, diff, vector_origin, axis.GizmoParent)
end
else
if IsValid(ent) then
boneang = ent:GetAngles()
if ent:GetClass() == "ent_advbonemerge" and parent:GetClass() == "prop_ragdoll" then
boneang = angle_zero -- bone has no parent and isn't physical
else
boneang = angle_zero
local pl = self:GetParent().Owner
if pl.rgm.GizmoParentID ~= -1 then
local physobj = ent:GetPhysicsObjectNum(pl.rgm.GizmoParentID)
boneang = physobj:GetAngles()
else
boneang = ent:GetAngles()
end
end
end

View File

@ -835,7 +835,7 @@ net.Receive("rgmSendBonePos", function(len, pl)
axis.GizmoPos = newpos
pl.rgm.GizmoPos = newpos - nonpos
if not (axis.EntAdvMerged) then
if not (axis.EntAdvMerged) and ent:GetClass() then
local manang = entog:GetManipulateBoneAngles(boneog)
manang:Normalize()
@ -2380,7 +2380,7 @@ local function rgmSendBonePos(pl, ent, boneid)
gizmoppos = matrix:GetTranslation()
gizmopang = matrix:GetAngles()
else
gizmoppos = ent:GetPos()
gizmoppos = parent:GetPos()
gizmopang = ent:GetAngles()
end
end