Made bones in advanced bone select mode get darker the farther away they are from player's view

This commit is contained in:
penolakushari 2024-12-22 16:49:15 +03:00
parent 5722ce3071
commit 3b908bfdae
2 changed files with 23 additions and 8 deletions

View File

@ -998,7 +998,7 @@ local COLOR_BLUE = RGM_Constants.COLOR_BLUE
local COLOR_BRIGHT_YELLOW = RGM_Constants.COLOR_BRIGHT_YELLOW
local OUTLINE_WIDTH = RGM_Constants.OUTLINE_WIDTH
local BONETYPE_COLORS = {RGM_Constants.COLOR_GREEN, RGM_Constants.COLOR_CYAN, RGM_Constants.COLOR_YELLOW, RGM_Constants.COLOR_RED}
local BONETYPE_COLORS = { { RGM_Constants.COLOR_GREEN, RGM_Constants.COLOR_DARKGREEN }, { RGM_Constants.COLOR_CYAN, RGM_Constants.COLOR_DARKCYAN }, { RGM_Constants.COLOR_YELLOW, RGM_Constants.COLOR_DARKYELLOW }, { RGM_Constants.COLOR_RED, RGM_Constants.COLOR_DARKRED } }
function DrawBoneName(ent, bone, name)
if not name then
@ -1108,6 +1108,17 @@ end)
function AdvBoneSelectRender(ent, bonenodes)
local mx, my = input.GetCursorPos() -- possible bug on mac https://wiki.facepunch.com/gmod/input.GetCursorPos
local nodesExist = bonenodes and bonenodes[ent] and true
local bonedistances = {}
local plpos = LocalPlayer():EyePos()
local mindist, maxdist = nil, nil
for i = 0, ent:GetBoneCount() - 1 do
local dist = plpos:DistToSqr( ent:GetBonePosition(i) )
if not mindist or mindist > dist then mindist = dist end
if not maxdist or maxdist < dist then maxdist = dist end
bonedistances[i] = dist
end
maxdist = maxdist - mindist
local selectedBones = {}
for i = 0, ent:GetBoneCount() - 1 do
@ -1131,7 +1142,7 @@ function AdvBoneSelectRender(ent, bonenodes)
table.insert(selectedBones, {name, i})
else
if nodesExist and bonenodes[ent][i] and bonenodes[ent][i].Type then
surface.SetDrawColor(BONETYPE_COLORS[bonenodes[ent][i].Type]:Unpack())
surface.SetDrawColor(BONETYPE_COLORS[bonenodes[ent][i].Type][1]:Lerp(BONETYPE_COLORS[bonenodes[ent][i].Type][2], (bonedistances[i] - mindist) / (maxdist * 0.75)):Unpack())
else
surface.SetDrawColor(COLOR_RGMGREEN:Unpack())
end
@ -1179,7 +1190,7 @@ function AdvBoneSelectRender(ent, bonenodes)
local color
if nodesExist then
color = BONETYPE_COLORS[bonenodes[ent][selectedBones[i + 1][2]].Type]
color = BONETYPE_COLORS[bonenodes[ent][selectedBones[i + 1][2]].Type][1]
else
color = COLOR_RGMGREEN
end
@ -1269,7 +1280,7 @@ function AdvBoneSelectRadialRender(ent, bones, bonenodes, isresetmode)
local uix, uiy = (math.sin(thisrad) * 250 * modifier), (math.cos(thisrad) * -250 * modifier)
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]
color = BONETYPE_COLORS[bonenodes[ent][bone].Type][1]
end
uix, uiy = uix + midw, uiy + midh
@ -1293,7 +1304,7 @@ function AdvBoneSelectRadialRender(ent, bones, bonenodes, isresetmode)
SelectedBone = bone
else
if bonenodes and bonenodes[ent] and bonenodes[ent][bone] and bonenodes[ent][bone].Type then
surface.SetDrawColor(BONETYPE_COLORS[bonenodes[ent][bone].Type]:Unpack())
surface.SetDrawColor(BONETYPE_COLORS[bonenodes[ent][bone].Type][1]:Unpack())
else
surface.SetDrawColor(COLOR_RGMGREEN:Unpack())
end
@ -1455,7 +1466,7 @@ local function DrawRecursiveBones(ent, bone, bonenodes)
DrawRecursiveBones(ent, boneid, bonenodes)
local color
if nodeexist and nodecache[boneid] then
color = BONETYPE_COLORS[nodecache[boneid].Type]
color = BONETYPE_COLORS[nodecache[boneid].Type][1]
else
color = COLOR_RGMGREEN
end
@ -1483,7 +1494,7 @@ function DrawSkeleton(ent, bonenodes)
pos = pos:ToScreen()
local color
if bonenodes then
color = BONETYPE_COLORS[bonenodes[ent][v].Type]
color = BONETYPE_COLORS[bonenodes[ent][v].Type][1]
else
color = COLOR_RGMGREEN
end
@ -1511,7 +1522,7 @@ function DrawSkeleton(ent, bonenodes)
local color
if bonenodes and bonenodes[ent] and bonenodes[ent][bone] and bonenodes[ent][bone].Type then
color = BONETYPE_COLORS[bonenodes[ent][bone].Type]
color = BONETYPE_COLORS[bonenodes[ent][bone].Type][1]
else
color = COLOR_RGMGREEN
end

View File

@ -1,9 +1,13 @@
RGM_Constants = {
COLOR_RED = Color(200, 0, 0, 255),
COLOR_DARKRED = Color(90, 0, 0, 255),
COLOR_GREEN = Color(0, 200, 0, 255),
COLOR_DARKGREEN = Color(0, 90, 0, 255),
COLOR_BLUE = Color(0, 0, 200, 255),
COLOR_CYAN = Color(0, 200, 200, 255),
COLOR_DARKCYAN = Color(0, 90, 90, 255),
COLOR_YELLOW = Color(200, 200, 0, 255),
COLOR_DARKYELLOW = Color(90, 90, 0, 255),
COLOR_BRIGHT_YELLOW = Color(255, 255, 0, 255),
COLOR_WHITE = Color(255, 255, 255, 255),
COLOR_BLACK = Color(0, 0, 0, 255),