mirror of
https://github.com/Winded/RagdollMover.git
synced 2025-03-04 03:13:36 -05:00
Optimizations to AdvBoneSelectRender
- Bone positions are only rendered when it is visible on the screen. This results in about 23% increase in performance on average from looking away at a model with 139 bones + Added comments about mindist and maxdist
This commit is contained in:
parent
6ca12972fc
commit
b8a367d2b0
@ -1140,6 +1140,8 @@ function AdvBoneSelectRender(ent, bonenodes, prevbones, calc)
|
||||
end
|
||||
bonedistances[i] = dist
|
||||
end
|
||||
-- maxdist or mindist may be nil if we weren't looking at all the bones.
|
||||
-- We set them to some numbers to avoid issues with indicing with these
|
||||
maxdist = maxdist or 1
|
||||
mindist = mindist or 0
|
||||
maxdist = maxdist - mindist
|
||||
@ -1156,12 +1158,6 @@ function AdvBoneSelectRender(ent, bonenodes, prevbones, calc)
|
||||
|
||||
local dist = math.abs((mx - x)^2 + (my - y)^2)
|
||||
|
||||
local circ = table.Copy(RGM_CIRCLE)
|
||||
for k, v in ipairs(circ) do
|
||||
v.x = v.x + x
|
||||
v.y = v.y + y
|
||||
end
|
||||
|
||||
if calc then
|
||||
local fraction = ( bonedistances[i] - mindist ) / maxdist
|
||||
prevbones[i] = math.Clamp(math.ceil(fraction * NUM_GRADIENT_POINTS), 1, NUM_GRADIENT_POINTS )
|
||||
@ -1178,17 +1174,25 @@ function AdvBoneSelectRender(ent, bonenodes, prevbones, calc)
|
||||
end
|
||||
end
|
||||
|
||||
draw.NoTexture()
|
||||
surface.DrawPoly(circ)
|
||||
|
||||
if bonenodes[ent][i].bonelock then
|
||||
surface.SetMaterial(LockGo)
|
||||
surface.SetDrawColor(COLOR_WHITE:Unpack())
|
||||
surface.DrawTexturedRect(x - 12, y - 12, 24, 24)
|
||||
elseif bonenodes[ent][i].poslock or bonenodes[ent][i].anglock then
|
||||
surface.SetMaterial(Lock)
|
||||
surface.SetDrawColor(COLOR_WHITE:Unpack())
|
||||
surface.DrawTexturedRect(x - 12, y - 12, 24, 24)
|
||||
if pos.visible then
|
||||
local circ = table.Copy(RGM_CIRCLE)
|
||||
for k, v in ipairs(circ) do
|
||||
v.x = v.x + x
|
||||
v.y = v.y + y
|
||||
end
|
||||
|
||||
draw.NoTexture()
|
||||
surface.DrawPoly(circ)
|
||||
|
||||
if bonenodes[ent][i].bonelock then
|
||||
surface.SetMaterial(LockGo)
|
||||
surface.SetDrawColor(COLOR_WHITE:Unpack())
|
||||
surface.DrawTexturedRect(x - 12, y - 12, 24, 24)
|
||||
elseif bonenodes[ent][i].poslock or bonenodes[ent][i].anglock then
|
||||
surface.SetMaterial(Lock)
|
||||
surface.SetDrawColor(COLOR_WHITE:Unpack())
|
||||
surface.DrawTexturedRect(x - 12, y - 12, 24, 24)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user