Merge pull request #56 from penolakushari/scalefix

Gizmo scale fix
This commit is contained in:
penolakushari 2024-09-29 08:41:16 +03:00 committed by GitHub
commit d661452cd5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 296 additions and 118 deletions

View File

@ -12,11 +12,12 @@ local Fulldisc = GetConVar("ragdollmover_fulldisc")
local pl
function ENT:DrawLines(scale, width)
function ENT:DrawLines(width)
if not pl then pl = LocalPlayer() end
local rotate = RAGDOLLMOVER[pl].Rotate or false
local modescale = RAGDOLLMOVER[pl].Scale or false
local scale = self.scale
local start, last = 1, 7
if rotate then start, last = 8, 11 end
if modescale then start, last = 12, 17 end
@ -26,7 +27,7 @@ function ENT:DrawLines(scale, width)
for i = start, last do
local moveaxis = self.Axises[i]
local yellow = false
if moveaxis:TestCollision(pl, scale) and not gotselected then
if moveaxis:TestCollision(pl) and not gotselected then
yellow = true
gotselected = true
end
@ -36,9 +37,9 @@ function ENT:DrawLines(scale, width)
self.width = width
end
function ENT:DrawDirectionLine(norm, scale, ghost)
function ENT:DrawDirectionLine(norm, ghost)
local pos1 = self:GetPos():ToScreen()
local pos2 = (self:GetPos() + (norm * scale)):ToScreen()
local pos2 = (self:GetPos() + (norm * self.scale)):ToScreen()
local grn = 255
if ghost then grn = 150 end
surface.SetDrawColor(0, grn, 0, 255)

View File

@ -3,10 +3,7 @@ ENT.Type = "anim"
ENT.Base = "base_entity"
function ENT:Initialize()
if CLIENT then
self:SetNoDraw(true)
self.fulldisc = GetConVar("ragdollmover_fulldisc"):GetInt() ~= 0 -- last time i used GetBool, it was breaking for 64 bit branch
end
self:DrawShadow(false)
self:SetCollisionBounds(Vector(-0.1, -0.1, -0.1), Vector(0.1, 0.1, 0.1))
self:SetSolid(SOLID_VPHYSICS)
@ -63,11 +60,17 @@ function ENT:Initialize()
self.ScaleYZ
}
self.scale = 0
self.width = 0
self.width = GetConVar("ragdollmover_width"):GetInt() or 0.5
self.scale = GetConVar("ragdollmover_scale"):GetInt() or 10
self:CalculateGizmo()
if CLIENT then
self:SetNoDraw(true)
self.fulldisc = GetConVar("ragdollmover_fulldisc"):GetInt() ~= 0 -- last time i used GetBool, it was breaking for 64 bit branch
end
end
function ENT:TestCollision(pl, scale)
function ENT:TestCollision(pl)
-- PrintTable(self:GetTable())
local rotate = RAGDOLLMOVER[pl].Rotate or false
local modescale = RAGDOLLMOVER[pl].Scale or false
@ -80,9 +83,17 @@ function ENT:TestCollision(pl, scale)
for i = start, last do
local e = self.Axises[i]
-- print(e)
local intersect = e:TestCollision(pl, scale)
local intersect = e:TestCollision(pl)
if intersect then return intersect end
end
self.scale = scale
return false
end
function ENT:CalculateGizmo()
local scale = self.scale
for i, axis in ipairs(self.Axises) do
axis:CalculateGizmo(scale)
end
end

View File

@ -80,7 +80,10 @@ do
end
--To be overwritten
function basepart:TestCollision(pl, scale)
function basepart:TestCollision(pl)
end
function basepart:CalculateGizmo(scale)
end
if SERVER then
@ -150,7 +153,7 @@ do
return intersect
end
function posarrow:TestCollision(pl, scale)
function posarrow:TestCollision(pl)
local plTable = RAGDOLLMOVER[pl]
local plviewent = plTable.always_use_pl_view == 1 and pl or (plTable.PlViewEnt ~= 0 and Entity(plTable.PlViewEnt) or nil)
local eyepos, eyeang = rgm.EyePosAng(pl, plviewent)
@ -158,15 +161,8 @@ do
local localized = self:WorldToLocal(intersect)
local distmin, distmax
if self.Parent.scale ~= scale or not self.collpositions then
distmin = Vector(0.1 * scale, -0.075 * scale, -0.075 * scale)
distmax = Vector(1 * scale, 0.075 * scale, 0.075 * scale)
self.collpositions = {distmin, distmax}
else
distmin = self.collpositions[1]
distmax = self.collpositions[2]
end
distmin = self.collpositions[1]
distmax = self.collpositions[2]
if localized.x >= distmin.x and localized.x <= distmax.x
and localized.y >= distmin.y and localized.y <= distmax.y
@ -176,6 +172,15 @@ do
return false
end
function posarrow:CalculateGizmo(scale)
local distmin, distmax
distmin = Vector(0.1 * scale, -0.075 * scale, -0.075 * scale)
distmax = Vector(1 * scale, 0.075 * scale, 0.075 * scale)
self.collpositions = {distmin, distmax}
end
if SERVER then
function posarrow:ProcessMovement(offpos, _, eyepos, eyeang, ent, bone, ppos, _, movetype, _, _, nphyspos)
@ -302,7 +307,7 @@ local posside = table.Copy(basepart)
do
function posside:TestCollision(pl, scale)
function posside:TestCollision(pl)
local plTable = RAGDOLLMOVER[pl]
local plviewent = plTable.always_use_pl_view == 1 and pl or (plTable.PlViewEnt ~= 0 and Entity(plTable.PlViewEnt) or nil)
local eyepos, eyeang = rgm.EyePosAng(pl, plviewent)
@ -310,19 +315,10 @@ do
local localized = self:WorldToLocal(intersect)
local distmin1, distmax1, distmin2, distmax2
if self.Parent.scale ~= scale or not self.collpositions then
distmin1 = Vector(-0.15 * scale, scale * 0.2, 0)
distmax1 = Vector(0.15 * scale, scale * 0.3, scale * 0.3)
distmin2 = Vector(-0.15 * scale, 0, scale * 0.2)
distmax2 = Vector(0.15 * scale, scale * 0.3, scale * 0.3)
self.collpositions = {distmin1, distmax1, distmin2, distmax2}
else
distmin1 = self.collpositions[1]
distmax1 = self.collpositions[2]
distmin2 = self.collpositions[3]
distmax2 = self.collpositions[4]
end
distmin1 = self.collpositions[1]
distmax1 = self.collpositions[2]
distmin2 = self.collpositions[3]
distmax2 = self.collpositions[4]
if (localized.x >= distmin1.x and localized.x <= distmax1.x
and localized.y >= distmin1.y and localized.y <= distmax1.y
@ -335,6 +331,17 @@ do
return false
end
function posside:CalculateGizmo(scale)
local distmin1, distmax1, distmin2, distmax2
distmin1 = Vector(-0.15 * scale, scale * 0.2, 0)
distmax1 = Vector(0.15 * scale, scale * 0.3, scale * 0.3)
distmin2 = Vector(-0.15 * scale, 0, scale * 0.2)
distmax2 = Vector(0.15 * scale, scale * 0.3, scale * 0.3)
self.collpositions = {distmin1, distmax1, distmin2, distmax2}
end
if SERVER then
function posside:ProcessMovement(offpos, _, eyepos, eyeang, ent, bone, ppos, pnorm, movetype, _, _, nphyspos)
@ -480,7 +487,7 @@ local omnipos = table.Copy(posside)
do
function omnipos:TestCollision(pl, scale)
function omnipos:TestCollision(pl)
local plTable = RAGDOLLMOVER[pl]
local plviewent = plTable.always_use_pl_view == 1 and pl or (plTable.PlViewEnt ~= 0 and Entity(plTable.PlViewEnt) or nil)
local eyepos, eyeang = rgm.EyePosAng(pl, plviewent)
@ -488,15 +495,8 @@ do
local localized = self:WorldToLocal(intersect)
local distmin1, distmax1
if self.Parent.scale ~= scale or not self.collpositions then
distmin1 = Vector(-0.075 * scale, scale * (-0.08), scale * (-0.08))
distmax1 = Vector(0.075 * scale, scale * 0.08, scale * 0.08)
self.collpositions = {distmin1, distmax1}
else
distmin1 = self.collpositions[1]
distmax1 = self.collpositions[2]
end
distmin1 = self.collpositions[1]
distmax1 = self.collpositions[2]
if (localized.x >= distmin1.x and localized.x <= distmax1.x
and localized.y >= distmin1.y and localized.y <= distmax1.y
@ -506,6 +506,15 @@ do
return false
end
function omnipos:CalculateGizmo(scale)
local distmin1, distmax1
distmin1 = Vector(-0.075 * scale, scale * (-0.08), scale * (-0.08))
distmax1 = Vector(0.075 * scale, scale * 0.08, scale * 0.08)
self.collpositions = {distmin1, distmax1}
end
if SERVER then
function omnipos:ProcessMovement(offpos, _, eyepos, eyeang, ent, bone, ppos, pnorm, movetype, _, _, nphyspos, _, _, tracepos)
@ -628,13 +637,13 @@ do
disc.IsDisc = true
function disc:TestCollision(pl, scale)
function disc:TestCollision(pl)
local plTable = RAGDOLLMOVER[pl]
local plviewent = plTable.always_use_pl_view == 1 and pl or (plTable.PlViewEnt ~= 0 and Entity(plTable.PlViewEnt) or nil)
local eyepos, eyeang = rgm.EyePosAng(pl, plviewent)
local intersect = self:GetGrabPos(eyepos, eyeang)
local distmin = 0.9 * scale
local distmax = 1.1 * scale
local distmin = self.collpositions[1]
local distmax = self.collpositions[2]
local dist = intersect:Distance(self:GetPos())
if dist >= distmin and dist <= distmax then
return {axis = self, hitpos = intersect}
@ -642,6 +651,10 @@ do
return false
end
function disc:CalculateGizmo(scale)
self.collpositions = { 0.9 * scale, 1.1 * scale }
end
if SERVER then
local function ConvertVector(vec, axistype)
@ -964,13 +977,13 @@ local disclarge = table.Copy(disc)
do
function disclarge:TestCollision(pl, scale)
function disclarge:TestCollision(pl)
local plTable = RAGDOLLMOVER[pl]
local plviewent = plTable.always_use_pl_view == 1 and pl or (plTable.PlViewEnt ~= 0 and Entity(plTable.PlViewEnt) or nil)
local eyepos, eyeang = rgm.EyePosAng(pl, plviewent)
local intersect = self:GetGrabPos(eyepos, eyeang)
local distmin = 1.15 * scale
local distmax = 1.35 * scale
local distmin = self.collpositions[1]
local distmax = self.collpositions[2]
local dist = intersect:Distance(self:GetPos())
if dist >= distmin and dist <= distmax then
return {axis = self, hitpos = intersect}
@ -978,6 +991,10 @@ do
return false
end
function disclarge:CalculateGizmo(scale)
self.collpositions = { 1.15 * scale, 1.35 * scale }
end
if CLIENT then
function disclarge:DrawLines(yellow, scale, width)
@ -1023,7 +1040,7 @@ do
return intersect
end
function scalearrow:TestCollision(pl, scale)
function scalearrow:TestCollision(pl)
local plTable = RAGDOLLMOVER[pl]
local plviewent = plTable.always_use_pl_view == 1 and pl or (plTable.PlViewEnt ~= 0 and Entity(plTable.PlViewEnt) or nil)
local eyepos, eyeang = rgm.EyePosAng(pl, plviewent)
@ -1031,15 +1048,8 @@ do
local localized = self:WorldToLocal(intersect)
local distmin, distmax
if self.Parent.scale ~= scale or not self.collpositions then
distmin = Vector(0, -0.075 * scale, -0.075 * scale)
distmax = Vector(1 * scale, 0.075 * scale, 0.075 * scale)
self.collpositions = {distmin, distmax}
else
distmin = self.collpositions[1]
distmax = self.collpositions[2]
end
distmin = self.collpositions[1]
distmax = self.collpositions[2]
if localized.x >= distmin.x and localized.x <= distmax.x
and localized.y >= distmin.y and localized.y <= distmax.y
@ -1049,6 +1059,15 @@ do
return false
end
function scalearrow:CalculateGizmo(scale)
local distmin, distmax
distmin = Vector(0, -0.075 * scale, -0.075 * scale)
distmax = Vector(1 * scale, 0.075 * scale, 0.075 * scale)
self.collpositions = {distmin, distmax}
end
if SERVER then
function scalearrow:ProcessMovement(offpos, offang, eyepos, eyeang, ent, bone, ppos, pnorm, movetype, _, startgrab, _, _, nphysscale)

View File

@ -1708,6 +1708,7 @@ local NETFUNC = {
"scalechildren",
"smovechildren",
"scalerelativemove",
"scale",
"updaterate", -- RGM Table related
"unfreeze",
"snapenable",
@ -1718,9 +1719,12 @@ local NETFUNC = {
if var < 8 and IsValid(axis) then
axis[vars[var]] = (tool:GetClientNumber(vars[var], 1) ~= 0)
elseif var == 8 and IsValid(axis) then
axis[vars[var]] = tool:GetClientNumber(vars[var], 10)
axis:CalculateGizmo()
else
plTable[vars[var]] = tool:GetClientNumber(vars[var], 1)
if var == 11 then -- if snapamount, do not accept 0 or negatives
if var == 12 then -- if snapamount, do not accept 0 or negatives
plTable.snapamount = plTable.snapamount < 1 and 1 or plTable.snapamount
end
end
@ -1892,7 +1896,7 @@ function TOOL:LeftClick()
end
local ent = plTable.Entity
local collision = axis:TestCollision(pl, self:GetClientNumber("scale", 10))
local collision = axis:TestCollision(pl)
if collision and IsValid(ent) and rgmCanTool(ent, pl) then
@ -2476,24 +2480,7 @@ hook.Add("InitPostEntity", "rgmSetPlayer", function()
RAGDOLLMOVER[pl].PlViewEnt = 0
end)
hook.Add("KeyPress", "rgmSwitchSelectionMode", function(pl, key)
local tool = pl:GetTool()
if RAGDOLLMOVER[pl] and IsValid(pl:GetActiveWeapon()) and pl:GetActiveWeapon():GetClass() == "gmod_tool" and tool and tool.Mode == "ragdollmover" then
local op = tool:GetOperation()
local opset = 0
if key == IN_WALK then
if op ~= 2 and IsValid(RAGDOLLMOVER[pl].Entity) then opset = 2 end
net.Start("RAGDOLLMOVER")
net.WriteUInt(14, 5)
net.WriteUInt(opset, 2)
net.SendToServer()
if tool:GetStage() == 1 then gui.EnableScreenClicker(false) end
end
end
end)
local GizmoWidth, SkeletonDraw
do
@ -2505,6 +2492,7 @@ do
"ragdollmover_scalechildren",
"ragdollmover_smovechildren",
"ragdollmover_scalerelativemove",
"ragdollmover_scale",
"ragdollmover_updaterate", -- RGM Table
"ragdollmover_unfreeze",
"ragdollmover_snapenable",
@ -2520,7 +2508,11 @@ do
net.WriteUInt(26, 5)
net.WriteUInt(k, 4)
net.SendToServer()
if k == 13 then
if k == 8 then
if not pl or not RAGDOLLMOVER[pl] or not IsValid(RAGDOLLMOVER[pl].Axis) then return end
RAGDOLLMOVER[pl].Axis.scale = new
RAGDOLLMOVER[pl].Axis:CalculateGizmo()
elseif k == 14 then
RAGDOLLMOVER[pl].always_use_pl_view = tonumber(new)
end
end)
@ -2529,12 +2521,6 @@ do
end
local GizmoScale, GizmoWidth, SkeletonDraw
cvars.AddChangeCallback("ragdollmover_scale", function(convar, old, new)
GizmoScale = tonumber(new)
end)
cvars.AddChangeCallback("ragdollmover_width", function(convar, old, new)
GizmoWidth = tonumber(new)
end)
@ -3314,6 +3300,13 @@ local function SetBoneNodes(bonepanel, sortedbones)
LockMode = false
LockTo = { id = nil, ent = nil }
net.Start("RAGDOLLMOVER")
net.WriteUInt(14, 5)
net.WriteUInt(0, 2)
net.SendToServer()
gui.EnableScreenClicker(false)
end
end
@ -3476,8 +3469,16 @@ local function SetBoneNodes(bonepanel, sortedbones)
if not IsValid(ent) then return end
if LockMode == 1 then
nodes[LockTo.ent][LockTo.id]:SetIcon(BoneTypeSort[nodes[LockTo.ent][LockTo.id].Type].Icon)
nodes[LockTo.ent][LockTo.id].Label:SetToolTip(BoneTypeSort[nodes[LockTo.ent][LockTo.id].Type].ToolTip)
if nodes[LockTo.ent][LockTo.id].poslock or nodes[LockTo.ent][LockTo.id].anglock then
nodes[LockTo.ent][LockTo.id]:SetIcon("icon16/lock.png")
nodes[LockTo.ent][LockTo.id].Label:SetToolTip("#tool.ragdollmover.lockedbone")
elseif nodes[LockTo.ent][LockTo.id].scllock then
nodes[LockTo.ent][LockTo.id]:SetIcon("icon16/lightbulb.png")
nodes[LockTo.ent][LockTo.id].Label:SetToolTip("#tool.ragdollmover.lockedscale")
else
nodes[LockTo.ent][LockTo.id]:SetIcon(BoneTypeSort[nodes[LockTo.ent][LockTo.id].Type].Icon)
nodes[LockTo.ent][LockTo.id].Label:SetToolTip(BoneTypeSort[nodes[LockTo.ent][LockTo.id].Type].ToolTip)
end
elseif LockMode == 2 then
conentnodes[LockTo.id]:SetIcon("icon16/brick_link.png")
conentnodes[LockTo.id].Label:SetToolTip(false)
@ -3489,6 +3490,13 @@ local function SetBoneNodes(bonepanel, sortedbones)
surface.PlaySound("buttons/button9.wav")
nodes[ent][v.id]:SetIcon("icon16/brick_add.png")
nodes[ent][v.id].Label:SetToolTip("#tool.ragdollmover.bonetolock")
net.Start("RAGDOLLMOVER")
net.WriteUInt(14, 5)
net.WriteUInt(2, 2)
net.SendToServer()
gui.EnableScreenClicker(false)
end)
option:SetIcon("icon16/lock.png")
@ -3852,8 +3860,16 @@ local function RGMBuildConstrainedEnts(parent, children, entpanel)
else
if LockMode == 1 then
nodes[LockTo.ent][LockTo.id]:SetIcon(BoneTypeSort[nodes[LockTo.ent][LockTo.id].Type].Icon)
nodes[LockTo.ent][LockTo.id].Label:SetToolTip(BoneTypeSort[nodes[LockTo.ent][LockTo.id].Type].ToolTip)
if nodes[LockTo.ent][LockTo.id].poslock or nodes[LockTo.ent][LockTo.id].anglock then
nodes[LockTo.ent][LockTo.id]:SetIcon("icon16/lock.png")
nodes[LockTo.ent][LockTo.id].Label:SetToolTip("#tool.ragdollmover.lockedbone")
elseif nodes[LockTo.ent][LockTo.id].scllock then
nodes[LockTo.ent][LockTo.id]:SetIcon("icon16/lightbulb.png")
nodes[LockTo.ent][LockTo.id].Label:SetToolTip("#tool.ragdollmover.lockedscale")
else
nodes[LockTo.ent][LockTo.id]:SetIcon(BoneTypeSort[nodes[LockTo.ent][LockTo.id].Type].Icon)
nodes[LockTo.ent][LockTo.id].Label:SetToolTip(BoneTypeSort[nodes[LockTo.ent][LockTo.id].Type].ToolTip)
end
elseif LockMode == 2 then
conentnodes[LockTo.id]:SetIcon("icon16/brick_link.png")
conentnodes[LockTo.id].Label:SetToolTip(false)
@ -3865,6 +3881,13 @@ local function RGMBuildConstrainedEnts(parent, children, entpanel)
surface.PlaySound("buttons/button9.wav")
conentnodes[ent]:SetIcon("icon16/brick_edit.png")
conentnodes[ent].Label:SetToolTip("#tool.ragdollmover.entlock")
net.Start("RAGDOLLMOVER")
net.WriteUInt(14, 5)
net.WriteUInt(2, 2)
net.SendToServer()
gui.EnableScreenClicker(false)
end
end
end
@ -3979,6 +4002,8 @@ function TOOL.BuildCPanel(CPanel)
CB:SetToolTip("#tool.ragdollmover.unfreezetip")
local DisFil = CCheckBox(Col3, "#tool.ragdollmover.disablefilter", "ragdollmover_disablefilter")
DisFil:SetToolTip("#tool.ragdollmover.disablefiltertip")
local physmovecheck = CCheckBox(Col3, "#tool.ragdollmover.physmove", "ragdollmover_physmove")
physmovecheck:SetToolTip("#tool.ragdollmover.physmovetip")
CCheckBox(Col3, "#tool.ragdollmover.drawskeleton", "ragdollmover_drawskeleton")
CCheckBox(Col3, "#tool.ragdollmover.snapenable", "ragdollmover_snapenable")
CNumSlider(Col3, "#tool.ragdollmover.snapamount", "ragdollmover_snapamount", 1, 180, 0)
@ -4021,8 +4046,6 @@ function TOOL.BuildCPanel(CPanel)
local Col5 = CCol(Col4, "#tool.ragdollmover.scaleoptions", true)
CCheckBox(Col5, "#tool.ragdollmover.scalechildren", "ragdollmover_scalechildren")
CCheckBox(Col5, "#tool.ragdollmover.smovechildren", "ragdollmover_smovechildren")
local physmovecheck = CCheckBox(Col5, "#tool.ragdollmover.physmove", "ragdollmover_physmove")
physmovecheck:SetToolTip("#tool.ragdollmover.physmovetip")
CCheckBox(Col5, "#tool.ragdollmover.scalerelativemove", "ragdollmover_scalerelativemove")
local ColBones = CCol(Col4, "#tool.ragdollmover.bonelist")
@ -4454,11 +4477,48 @@ function TOOL:Think()
local selbones = rgm.AdvBoneSelectPick(ent, nodes)
if next(selbones) then
if #selbones == 1 then
net.Start("RAGDOLLMOVER")
net.WriteUInt(4, 5)
net.WriteEntity(ent)
net.WriteUInt(selbones[1], 10)
net.SendToServer()
if LockMode == false then
net.Start("RAGDOLLMOVER")
net.WriteUInt(4, 5)
net.WriteEntity(ent)
net.WriteUInt(selbones[1], 10)
net.SendToServer()
else
if LockMode == 1 then
net.Start("RAGDOLLMOVER")
net.WriteUInt(7, 5)
net.WriteEntity(ent)
net.WriteUInt(selbones[1], 10)
net.WriteEntity(LockTo.ent)
net.WriteUInt(LockTo.id, 10)
net.SendToServer()
if nodes[LockTo.ent][LockTo.id].poslock or nodes[LockTo.ent][LockTo.id].anglock then
nodes[LockTo.ent][LockTo.id]:SetIcon("icon16/lock.png")
nodes[LockTo.ent][LockTo.id].Label:SetToolTip("#tool.ragdollmover.lockedbone")
elseif nodes[LockTo.ent][LockTo.id].scllock then
nodes[LockTo.ent][LockTo.id]:SetIcon("icon16/lightbulb.png")
nodes[LockTo.ent][LockTo.id].Label:SetToolTip("#tool.ragdollmover.lockedscale")
else
nodes[LockTo.ent][LockTo.id]:SetIcon(BoneTypeSort[nodes[LockTo.ent][LockTo.id].Type].Icon)
nodes[LockTo.ent][LockTo.id].Label:SetToolTip(BoneTypeSort[nodes[LockTo.ent][LockTo.id].Type].ToolTip)
end
elseif LockMode == 2 then
net.Start("RAGDOLLMOVER")
net.WriteUInt(9, 5)
net.WriteEntity(ent)
net.WriteEntity(LockTo.id)
net.WriteBool(true)
net.WriteUInt(selbones[1], 8)
net.SendToServer()
conentnodes[LockTo.id]:SetIcon("icon16/brick_link.png")
conentnodes[LockTo.id].Label:SetToolTip(false)
end
LockMode = false
LockTo = { id = nil, ent = nil }
end
timer.Simple(0.1, function()
net.Start("RAGDOLLMOVER")
@ -4478,11 +4538,48 @@ function TOOL:Think()
end
end
else
net.Start("RAGDOLLMOVER")
net.WriteUInt(4, 5)
net.WriteEntity(ent)
net.WriteUInt(rgm.AdvBoneSelectRadialPick(), 10)
net.SendToServer()
if LockMode == false then
net.Start("RAGDOLLMOVER")
net.WriteUInt(4, 5)
net.WriteEntity(ent)
net.WriteUInt(rgm.AdvBoneSelectRadialPick(), 10)
net.SendToServer()
else
if LockMode == 1 then
net.Start("RAGDOLLMOVER")
net.WriteUInt(7, 5)
net.WriteEntity(ent)
net.WriteUInt(rgm.AdvBoneSelectRadialPick(), 10)
net.WriteEntity(LockTo.ent)
net.WriteUInt(LockTo.id, 10)
net.SendToServer()
if nodes[LockTo.ent][LockTo.id].poslock or nodes[LockTo.ent][LockTo.id].anglock then
nodes[LockTo.ent][LockTo.id]:SetIcon("icon16/lock.png")
nodes[LockTo.ent][LockTo.id].Label:SetToolTip("#tool.ragdollmover.lockedbone")
elseif nodes[LockTo.ent][LockTo.id].scllock then
nodes[LockTo.ent][LockTo.id]:SetIcon("icon16/lightbulb.png")
nodes[LockTo.ent][LockTo.id].Label:SetToolTip("#tool.ragdollmover.lockedscale")
else
nodes[LockTo.ent][LockTo.id]:SetIcon(BoneTypeSort[nodes[LockTo.ent][LockTo.id].Type].Icon)
nodes[LockTo.ent][LockTo.id].Label:SetToolTip(BoneTypeSort[nodes[LockTo.ent][LockTo.id].Type].ToolTip)
end
elseif LockMode == 2 then
net.Start("RAGDOLLMOVER")
net.WriteUInt(9, 5)
net.WriteEntity(ent)
net.WriteEntity(LockTo.id)
net.WriteBool(true)
net.WriteUInt(rgm.AdvBoneSelectRadialPick(), 8)
net.SendToServer()
conentnodes[LockTo.id]:SetIcon("icon16/brick_link.png")
conentnodes[LockTo.id].Label:SetToolTip(false)
end
LockMode = false
LockTo = { id = nil, ent = nil }
end
timer.Simple(0.1, function()
net.Start("RAGDOLLMOVER")
@ -4500,6 +4597,46 @@ function TOOL:Think()
end
hook.Add("KeyPress", "rgmSwitchSelectionMode", function(pl, key)
local tool = pl:GetTool()
if RAGDOLLMOVER[pl] and IsValid(pl:GetActiveWeapon()) and pl:GetActiveWeapon():GetClass() == "gmod_tool" and tool and tool.Mode == "ragdollmover" then
local op = tool:GetOperation()
local opset = 0
if key == IN_WALK then
if op ~= 2 and IsValid(RAGDOLLMOVER[pl].Entity) then opset = 2 end
net.Start("RAGDOLLMOVER")
net.WriteUInt(14, 5)
net.WriteUInt(opset, 2)
net.SendToServer()
if LockMode ~= false then
if LockMode == 1 then
if nodes[LockTo.ent][LockTo.id].poslock or nodes[LockTo.ent][LockTo.id].anglock then
nodes[LockTo.ent][LockTo.id]:SetIcon("icon16/lock.png")
nodes[LockTo.ent][LockTo.id].Label:SetToolTip("#tool.ragdollmover.lockedbone")
elseif nodes[LockTo.ent][LockTo.id].scllock then
nodes[LockTo.ent][LockTo.id]:SetIcon("icon16/lightbulb.png")
nodes[LockTo.ent][LockTo.id].Label:SetToolTip("#tool.ragdollmover.lockedscale")
else
nodes[LockTo.ent][LockTo.id]:SetIcon(BoneTypeSort[nodes[LockTo.ent][LockTo.id].Type].Icon)
nodes[LockTo.ent][LockTo.id].Label:SetToolTip(BoneTypeSort[nodes[LockTo.ent][LockTo.id].Type].ToolTip)
end
elseif LockMode == 2 then
conentnodes[LockTo.id]:SetIcon("icon16/brick_link.png")
conentnodes[LockTo.id].Label:SetToolTip(false)
end
LockMode = false
LockTo = { id = nil, ent = nil }
end
if tool:GetStage() == 1 then gui.EnableScreenClicker(false) end
end
end
end)
function TOOL:DrawHUD()
if not RAGDOLLMOVER[pl] then RAGDOLLMOVER[pl] = {} end
@ -4517,30 +4654,29 @@ function TOOL:DrawHUD()
local eyepos, eyeang = rgm.EyePosAng(pl, plviewent)
if not (self:GetOperation() == 2) and IsValid(ent) and IsValid(axis) and bone then
local scale = GizmoScale or 10
local width = GizmoWidth or 0.5
local moveaxis = axis[RGMGIZMOS.GizmoTable[plTable.MoveAxis]]
if moving and moveaxis then
cam.Start({type = "3D"})
render.SetMaterial(material)
moveaxis:DrawLines(true, scale, width)
moveaxis:DrawLines(true, axis.scale, width)
cam.End()
if moveaxis.IsDisc then
local intersect = moveaxis:GetGrabPos(eyepos, eyeang)
local fwd = (intersect - axis:GetPos())
fwd:Normalize()
axis:DrawDirectionLine(fwd, scale, false)
axis:DrawDirectionLine(fwd, false)
local dirnorm = plTable.DirNorm or VECTOR_FRONT
axis:DrawDirectionLine(dirnorm, scale, true)
axis:DrawDirectionLine(dirnorm, true)
axis:DrawAngleText(moveaxis, intersect, plTable.StartAngle)
end
else
cam.Start({type = "3D"})
render.SetMaterial(material)
axis:DrawLines(scale, width)
axis:DrawLines(width)
cam.End()
end
end
@ -4561,16 +4697,18 @@ function TOOL:DrawHUD()
else
rgm.AdvBoneSelectRadialRender(ent, plTable.SelectedBones, nodes)
end
elseif IsValid(HoveredEntBone) and EntityFilter(HoveredEntBone, self) and HoveredBone then
rgm.DrawBoneConnections(HoveredEntBone, HoveredBone)
rgm.DrawBoneName(HoveredEntBone, HoveredBone)
elseif IsValid(HoveredEnt) and EntityFilter(HoveredEnt, self) then
rgm.DrawEntName(HoveredEnt)
elseif IsValid(tr.Entity) and EntityFilter(tr.Entity, self) and (not bone or aimedbone ~= bone or tr.Entity ~= ent) and not moving then
rgm.DrawBoneConnections(tr.Entity, aimedbone)
rgm.DrawBoneName(tr.Entity, aimedbone)
end
if IsValid(HoveredEntBone) and EntityFilter(HoveredEntBone, self) and HoveredBone then
rgm.DrawBoneConnections(HoveredEntBone, HoveredBone)
rgm.DrawBoneName(HoveredEntBone, HoveredBone)
elseif IsValid(HoveredEnt) and EntityFilter(HoveredEnt, self) then
rgm.DrawEntName(HoveredEnt)
end
end
end

View File

@ -3,7 +3,7 @@ TOOL.Category = "Poser"
TOOL.Command = nil
TOOL.ConfigName = ""
CVMaxPRBones = CreateConVar("sv_ragdollmover_max_prop_ragdoll_bones", 32, FCVAR_ARCHIVE + FCVAR_NOTIFY, "Maximum amount of bones that can be used in single Prop Ragdoll", 0, 4096)
CVMaxPRBones = CreateConVar("sv_ragdollmover_max_prop_ragdoll_bones", 32, FCVAR_ARCHIVE + FCVAR_NOTIFY + FCVAR_REPLICATED, "Maximum amount of bones that can be used in single Prop Ragdoll", 0, 4096)
local APPLIED = 2
local APPLY_FAILED = 3

View File

@ -0,0 +1,9 @@
ui.ragdollmover.name=Ragdoll Mover
ui.ragdollmover.notice1=Ragdoll Mover был обновлен. Ознакомиться с изменениями можно в Утилиты -> Ragdoll Mover -> Журнал Изменений.
ui.ragdollmover.notice2=Ещё можно ввести "ragdollmover_changelog" в консоль для вывода Журнала Изменений.
ui.ragdollmover.notes=Журнал Изменений
ui.ragdollmover.notes.view=Показать Журнал
ui.ragdollmover.notes.link=Показать весь Журнал Изменений
ui.ragdollmover.notes.error1=Не удалось получить Журнал Изменений
ui.ragdollmover.notes.error2=Не удалось обработать HTML для получения информации об изменениях