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

View File

@ -3,10 +3,7 @@ ENT.Type = "anim"
ENT.Base = "base_entity" ENT.Base = "base_entity"
function ENT:Initialize() 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:DrawShadow(false)
self:SetCollisionBounds(Vector(-0.1, -0.1, -0.1), Vector(0.1, 0.1, 0.1)) self:SetCollisionBounds(Vector(-0.1, -0.1, -0.1), Vector(0.1, 0.1, 0.1))
self:SetSolid(SOLID_VPHYSICS) self:SetSolid(SOLID_VPHYSICS)
@ -63,11 +60,17 @@ function ENT:Initialize()
self.ScaleYZ self.ScaleYZ
} }
self.scale = 0 self.width = GetConVar("ragdollmover_width"):GetInt() or 0.5
self.width = 0 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 end
function ENT:TestCollision(pl, scale) function ENT:TestCollision(pl)
-- PrintTable(self:GetTable()) -- PrintTable(self:GetTable())
local rotate = RAGDOLLMOVER[pl].Rotate or false local rotate = RAGDOLLMOVER[pl].Rotate or false
local modescale = RAGDOLLMOVER[pl].Scale or false local modescale = RAGDOLLMOVER[pl].Scale or false
@ -80,9 +83,17 @@ function ENT:TestCollision(pl, scale)
for i = start, last do for i = start, last do
local e = self.Axises[i] local e = self.Axises[i]
-- print(e) -- print(e)
local intersect = e:TestCollision(pl, scale) local intersect = e:TestCollision(pl)
if intersect then return intersect end if intersect then return intersect end
end end
self.scale = scale
return false return false
end 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 end
--To be overwritten --To be overwritten
function basepart:TestCollision(pl, scale) function basepart:TestCollision(pl)
end
function basepart:CalculateGizmo(scale)
end end
if SERVER then if SERVER then
@ -150,7 +153,7 @@ do
return intersect return intersect
end end
function posarrow:TestCollision(pl, scale) function posarrow:TestCollision(pl)
local plTable = RAGDOLLMOVER[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 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 eyepos, eyeang = rgm.EyePosAng(pl, plviewent)
@ -158,15 +161,8 @@ do
local localized = self:WorldToLocal(intersect) local localized = self:WorldToLocal(intersect)
local distmin, distmax local distmin, distmax
if self.Parent.scale ~= scale or not self.collpositions then distmin = self.collpositions[1]
distmin = Vector(0.1 * scale, -0.075 * scale, -0.075 * scale) distmax = self.collpositions[2]
distmax = Vector(1 * scale, 0.075 * scale, 0.075 * scale)
self.collpositions = {distmin, distmax}
else
distmin = self.collpositions[1]
distmax = self.collpositions[2]
end
if localized.x >= distmin.x and localized.x <= distmax.x if localized.x >= distmin.x and localized.x <= distmax.x
and localized.y >= distmin.y and localized.y <= distmax.y and localized.y >= distmin.y and localized.y <= distmax.y
@ -176,6 +172,15 @@ do
return false return false
end 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 if SERVER then
function posarrow:ProcessMovement(offpos, _, eyepos, eyeang, ent, bone, ppos, _, movetype, _, _, nphyspos) function posarrow:ProcessMovement(offpos, _, eyepos, eyeang, ent, bone, ppos, _, movetype, _, _, nphyspos)
@ -302,7 +307,7 @@ local posside = table.Copy(basepart)
do do
function posside:TestCollision(pl, scale) function posside:TestCollision(pl)
local plTable = RAGDOLLMOVER[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 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 eyepos, eyeang = rgm.EyePosAng(pl, plviewent)
@ -310,19 +315,10 @@ do
local localized = self:WorldToLocal(intersect) local localized = self:WorldToLocal(intersect)
local distmin1, distmax1, distmin2, distmax2 local distmin1, distmax1, distmin2, distmax2
if self.Parent.scale ~= scale or not self.collpositions then distmin1 = self.collpositions[1]
distmin1 = Vector(-0.15 * scale, scale * 0.2, 0) distmax1 = self.collpositions[2]
distmax1 = Vector(0.15 * scale, scale * 0.3, scale * 0.3) distmin2 = self.collpositions[3]
distmin2 = Vector(-0.15 * scale, 0, scale * 0.2) distmax2 = self.collpositions[4]
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
if (localized.x >= distmin1.x and localized.x <= distmax1.x if (localized.x >= distmin1.x and localized.x <= distmax1.x
and localized.y >= distmin1.y and localized.y <= distmax1.y and localized.y >= distmin1.y and localized.y <= distmax1.y
@ -335,6 +331,17 @@ do
return false return false
end 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 if SERVER then
function posside:ProcessMovement(offpos, _, eyepos, eyeang, ent, bone, ppos, pnorm, movetype, _, _, nphyspos) function posside:ProcessMovement(offpos, _, eyepos, eyeang, ent, bone, ppos, pnorm, movetype, _, _, nphyspos)
@ -480,7 +487,7 @@ local omnipos = table.Copy(posside)
do do
function omnipos:TestCollision(pl, scale) function omnipos:TestCollision(pl)
local plTable = RAGDOLLMOVER[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 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 eyepos, eyeang = rgm.EyePosAng(pl, plviewent)
@ -488,15 +495,8 @@ do
local localized = self:WorldToLocal(intersect) local localized = self:WorldToLocal(intersect)
local distmin1, distmax1 local distmin1, distmax1
if self.Parent.scale ~= scale or not self.collpositions then distmin1 = self.collpositions[1]
distmin1 = Vector(-0.075 * scale, scale * (-0.08), scale * (-0.08)) distmax1 = self.collpositions[2]
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
if (localized.x >= distmin1.x and localized.x <= distmax1.x if (localized.x >= distmin1.x and localized.x <= distmax1.x
and localized.y >= distmin1.y and localized.y <= distmax1.y and localized.y >= distmin1.y and localized.y <= distmax1.y
@ -506,6 +506,15 @@ do
return false return false
end 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 if SERVER then
function omnipos:ProcessMovement(offpos, _, eyepos, eyeang, ent, bone, ppos, pnorm, movetype, _, _, nphyspos, _, _, tracepos) function omnipos:ProcessMovement(offpos, _, eyepos, eyeang, ent, bone, ppos, pnorm, movetype, _, _, nphyspos, _, _, tracepos)
@ -628,13 +637,13 @@ do
disc.IsDisc = true disc.IsDisc = true
function disc:TestCollision(pl, scale) function disc:TestCollision(pl)
local plTable = RAGDOLLMOVER[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 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 eyepos, eyeang = rgm.EyePosAng(pl, plviewent)
local intersect = self:GetGrabPos(eyepos, eyeang) local intersect = self:GetGrabPos(eyepos, eyeang)
local distmin = 0.9 * scale local distmin = self.collpositions[1]
local distmax = 1.1 * scale local distmax = self.collpositions[2]
local dist = intersect:Distance(self:GetPos()) local dist = intersect:Distance(self:GetPos())
if dist >= distmin and dist <= distmax then if dist >= distmin and dist <= distmax then
return {axis = self, hitpos = intersect} return {axis = self, hitpos = intersect}
@ -642,6 +651,10 @@ do
return false return false
end end
function disc:CalculateGizmo(scale)
self.collpositions = { 0.9 * scale, 1.1 * scale }
end
if SERVER then if SERVER then
local function ConvertVector(vec, axistype) local function ConvertVector(vec, axistype)
@ -964,13 +977,13 @@ local disclarge = table.Copy(disc)
do do
function disclarge:TestCollision(pl, scale) function disclarge:TestCollision(pl)
local plTable = RAGDOLLMOVER[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 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 eyepos, eyeang = rgm.EyePosAng(pl, plviewent)
local intersect = self:GetGrabPos(eyepos, eyeang) local intersect = self:GetGrabPos(eyepos, eyeang)
local distmin = 1.15 * scale local distmin = self.collpositions[1]
local distmax = 1.35 * scale local distmax = self.collpositions[2]
local dist = intersect:Distance(self:GetPos()) local dist = intersect:Distance(self:GetPos())
if dist >= distmin and dist <= distmax then if dist >= distmin and dist <= distmax then
return {axis = self, hitpos = intersect} return {axis = self, hitpos = intersect}
@ -978,6 +991,10 @@ do
return false return false
end end
function disclarge:CalculateGizmo(scale)
self.collpositions = { 1.15 * scale, 1.35 * scale }
end
if CLIENT then if CLIENT then
function disclarge:DrawLines(yellow, scale, width) function disclarge:DrawLines(yellow, scale, width)
@ -1023,7 +1040,7 @@ do
return intersect return intersect
end end
function scalearrow:TestCollision(pl, scale) function scalearrow:TestCollision(pl)
local plTable = RAGDOLLMOVER[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 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 eyepos, eyeang = rgm.EyePosAng(pl, plviewent)
@ -1031,15 +1048,8 @@ do
local localized = self:WorldToLocal(intersect) local localized = self:WorldToLocal(intersect)
local distmin, distmax local distmin, distmax
if self.Parent.scale ~= scale or not self.collpositions then distmin = self.collpositions[1]
distmin = Vector(0, -0.075 * scale, -0.075 * scale) distmax = self.collpositions[2]
distmax = Vector(1 * scale, 0.075 * scale, 0.075 * scale)
self.collpositions = {distmin, distmax}
else
distmin = self.collpositions[1]
distmax = self.collpositions[2]
end
if localized.x >= distmin.x and localized.x <= distmax.x if localized.x >= distmin.x and localized.x <= distmax.x
and localized.y >= distmin.y and localized.y <= distmax.y and localized.y >= distmin.y and localized.y <= distmax.y
@ -1049,6 +1059,15 @@ do
return false return false
end 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 if SERVER then
function scalearrow:ProcessMovement(offpos, offang, eyepos, eyeang, ent, bone, ppos, pnorm, movetype, _, startgrab, _, _, nphysscale) function scalearrow:ProcessMovement(offpos, offang, eyepos, eyeang, ent, bone, ppos, pnorm, movetype, _, startgrab, _, _, nphysscale)

View File

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

View File

@ -3,7 +3,7 @@ TOOL.Category = "Poser"
TOOL.Command = nil TOOL.Command = nil
TOOL.ConfigName = "" 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 APPLIED = 2
local APPLY_FAILED = 3 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 для получения информации об изменениях