Added different shapes in advanced selection mode that allow to discern bone types, as just having them be different colors may not be easily noticeable if they are darkened

This commit is contained in:
penolakushari 2025-02-15 20:26:23 +03:00
parent 2c9c5a9417
commit 4722de62f9

View File

@ -1050,16 +1050,40 @@ function DrawEntName(ent)
draw.SimpleTextOutlined(name, "RagdollMoverFont", textpos.x, textpos.y, COLOR_RGMGREEN, TEXT_ALIGN_LEFT, TEXT_ALIGN_BOTTOM, OUTLINE_WIDTH, COLOR_RGMBLACK) draw.SimpleTextOutlined(name, "RagdollMoverFont", textpos.x, textpos.y, COLOR_RGMGREEN, TEXT_ALIGN_LEFT, TEXT_ALIGN_BOTTOM, OUTLINE_WIDTH, COLOR_RGMBLACK)
end end
local RGM_CIRCLE = { local RGM_SHAPES = {
{ x = -3, y = -3 }, { -- Square, phys
{ x = -5, y = -5 },
{ x = 0, y = -4 }, { x = 5, y = -5 },
{ x = 3, y = -3 }, { x = 5, y = 5 },
{ x = 4, y = 0 }, { x = -5, y = 5 }
{ x = 3, y = 3 }, },
{ x = 0, y = 4 },
{ x = -3, y = 3 }, { -- Circle, nonphys
{ x = -4, y = 0 } { x = -3, y = -3 },
{ x = 0, y = -4 },
{ x = 3, y = -3 },
{ x = 4, y = 0 },
{ x = 3, y = 3 },
{ x = 0, y = 4 },
{ x = -3, y = 3 },
{ x = -4, y = 0 }
},
{ -- Triangle, procedural
{ x = 0, y = -5 },
{ x = 5, y = 5 },
{ x = -5, y = 5 }
},
{ -- 180 rotated triangle, parented
{ x = -5, y = -5 },
{ x = 5, y = -5 },
{ x = 0, y = 5 }
}
} }
local LockGo = Material("icon16/lock_go.png", "alphatest") local LockGo = Material("icon16/lock_go.png", "alphatest")
@ -1165,25 +1189,27 @@ function AdvBoneSelectRender(ent, bonenodes, prevbones, calc, eyePos, eyeVector,
prevbones[i] = math.Clamp(math.ceil(fraction * NUM_GRADIENT_POINTS), 1, NUM_GRADIENT_POINTS ) prevbones[i] = math.Clamp(math.ceil(fraction * NUM_GRADIENT_POINTS), 1, NUM_GRADIENT_POINTS )
end end
local bonetype = bonenodes[ent][i] and bonenodes[ent][i].Type or 1
if dist < 576 then -- 24 pixels if dist < 576 then -- 24 pixels
surface.SetDrawColor(COLOR_BRIGHT_YELLOW:Unpack()) surface.SetDrawColor(COLOR_BRIGHT_YELLOW:Unpack())
table.insert(selectedBones, {name, i}) table.insert(selectedBones, {name, i})
else else
if nodesExist and bonenodes[ent][i] and bonenodes[ent][i].Type and prevbones[i] then if nodesExist and bonetype and prevbones[i] then
surface.SetDrawColor(BONETYPE_COLORS[bonenodes[ent][i].Type][prevbones[i]]:Unpack()) surface.SetDrawColor(BONETYPE_COLORS[bonetype][prevbones[i]]:Unpack())
else else
surface.SetDrawColor(COLOR_RGMGREEN:Unpack()) surface.SetDrawColor(COLOR_RGMGREEN:Unpack())
end end
end end
local circ = table.Copy(RGM_CIRCLE) local shape = table.Copy(RGM_SHAPES[bonetype])
for k, v in ipairs(circ) do for k, v in ipairs(shape) do
v.x = v.x + x v.x = v.x + x
v.y = v.y + y v.y = v.y + y
end end
draw.NoTexture() draw.NoTexture()
surface.DrawPoly(circ) surface.DrawPoly(shape)
if bonenodes[ent][i].bonelock then if bonenodes[ent][i].bonelock then
surface.SetMaterial(LockGo) surface.SetMaterial(LockGo)
@ -1315,8 +1341,12 @@ function AdvBoneSelectRadialRender(ent, bones, bonenodes, isresetmode)
local thisrad = thisang / 180 * math.pi local thisrad = thisang / 180 * math.pi
local uix, uiy = (math.sin(thisrad) * 250 * modifier), (math.cos(thisrad) * -250 * modifier) local uix, uiy = (math.sin(thisrad) * 250 * modifier), (math.cos(thisrad) * -250 * modifier)
local color = COLOR_WHITE local color = COLOR_WHITE
if bonenodes and bonenodes[ent] and bonenodes[ent][bone] and bonenodes[ent][bone].Type then
color = BONETYPE_COLORS[bonenodes[ent][bone].Type][1] local nodecheck = (bonenodes and bonenodes[ent] and bonenodes[ent][bone] and bonenodes[ent][bone].Type) and true or false
local bonetype = bonenodes[ent][bone] and bonenodes[ent][bone].Type or 1
if nodecheck then
color = BONETYPE_COLORS[bonetype][1]
end end
uix, uiy = uix + midw, uiy + midh uix, uiy = uix + midw, uiy + midh
@ -1328,8 +1358,8 @@ function AdvBoneSelectRadialRender(ent, bones, bonenodes, isresetmode)
local pos = ent:GetBonePosition(bone) local pos = ent:GetBonePosition(bone)
pos = pos:ToScreen() pos = pos:ToScreen()
local circ = table.Copy(RGM_CIRCLE) local shape = table.Copy(RGM_SHAPES[bonetype])
for k, v in ipairs(circ) do for k, v in ipairs(shape) do
v.x = v.x + pos.x v.x = v.x + pos.x
v.y = v.y + pos.y v.y = v.y + pos.y
end end
@ -1339,15 +1369,11 @@ function AdvBoneSelectRadialRender(ent, bones, bonenodes, isresetmode)
color = COLOR_BRIGHT_YELLOW color = COLOR_BRIGHT_YELLOW
SelectedBone = bone SelectedBone = bone
else else
if bonenodes and bonenodes[ent] and bonenodes[ent][bone] and bonenodes[ent][bone].Type then surface.SetDrawColor(BONETYPE_COLORS[bonetype][1]:Unpack())
surface.SetDrawColor(BONETYPE_COLORS[bonenodes[ent][bone].Type][1]:Unpack())
else
surface.SetDrawColor(COLOR_RGMGREEN:Unpack())
end
end end
draw.NoTexture() draw.NoTexture()
surface.DrawPoly(circ) surface.DrawPoly(shape)
local ytextoffset = -14 local ytextoffset = -14
if uiy > (midh + 30) then ytextoffset = RGMFontSize + 14 end if uiy > (midh + 30) then ytextoffset = RGMFontSize + 14 end
@ -1375,8 +1401,8 @@ function AdvBoneSelectRadialRender(ent, bones, bonenodes, isresetmode)
local pos = ent:GetBonePosition(bone) local pos = ent:GetBonePosition(bone)
pos = pos:ToScreen() pos = pos:ToScreen()
local circ = table.Copy(RGM_CIRCLE) local shape = table.Copy(RGM_SHAPES[btype])
for k, v in ipairs(circ) do for k, v in ipairs(shape) do
v.x = v.x + pos.x v.x = v.x + pos.x
v.y = v.y + pos.y v.y = v.y + pos.y
end end
@ -1384,7 +1410,7 @@ function AdvBoneSelectRadialRender(ent, bones, bonenodes, isresetmode)
surface.SetDrawColor(COLOR_WHITE:Unpack()) surface.SetDrawColor(COLOR_WHITE:Unpack())
draw.NoTexture() draw.NoTexture()
surface.DrawPoly(circ) surface.DrawPoly(shape)
local boneoptions = btype == 1 and FeaturesPhys or FeaturesNPhys local boneoptions = btype == 1 and FeaturesPhys or FeaturesNPhys
local count = #boneoptions local count = #boneoptions