Move on-screen check to prevent any calculations if its not on screen

- Changed on screen check location from before copying the RGM_CIRCLE table to before performing bone distance calculations or setting draw color. This requires a check for prevbones to set distance colors, but this prevents any calculations from doing done at all. This achieves a 3% increase in performance (averaged over 600 frames)
This commit is contained in:
vlazed 2024-12-27 14:40:46 -06:00
parent 3a490f5bb7
commit 6b80c9d2be

View File

@ -1154,6 +1154,7 @@ function AdvBoneSelectRender(ent, bonenodes, prevbones, calc)
if nodesExist and (not bonenodes[ent][i]) or false then continue end
local pos = ent:GetBonePosition(i)
pos = pos:ToScreen()
if not pos.visible then continue end
local x, y = pos.x, pos.y
local dist = math.abs((mx - x)^2 + (my - y)^2)
@ -1167,14 +1168,13 @@ function AdvBoneSelectRender(ent, bonenodes, prevbones, calc)
surface.SetDrawColor(COLOR_BRIGHT_YELLOW:Unpack())
table.insert(selectedBones, {name, i})
else
if nodesExist and bonenodes[ent][i] and bonenodes[ent][i].Type then
if nodesExist and bonenodes[ent][i] and bonenodes[ent][i].Type and prevbones[i] then
surface.SetDrawColor(BONETYPE_COLORS[bonenodes[ent][i].Type][prevbones[i]]:Unpack())
else
surface.SetDrawColor(COLOR_RGMGREEN:Unpack())
end
end
if pos.visible then
local circ = table.Copy(RGM_CIRCLE)
for k, v in ipairs(circ) do
v.x = v.x + x
@ -1194,7 +1194,6 @@ function AdvBoneSelectRender(ent, bonenodes, prevbones, calc)
surface.DrawTexturedRect(x - 12, y - 12, 24, 24)
end
end
end
-- We use the average length of all bone names to ensure some names don't overlap each other
local meanNameLength = 0