Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 29 additions & 2 deletions src/Classes/PassiveTreeView.lua
Original file line number Diff line number Diff line change
Expand Up @@ -168,11 +168,11 @@ function PassiveTreeViewClass:Draw(build, viewPort, inputEvents)
local offsetY = self.zoomY + viewPort.y + viewPort.height/2
local function treeToScreen(x, y)
return x * scale + offsetX,
y * scale + offsetY
y * scale + offsetY
end
local function screenToTree(x, y)
return (x - offsetX) / scale,
(y - offsetY) / scale
(y - offsetY) / scale
end

if IsKeyDown("SHIFT") then
Expand Down Expand Up @@ -854,6 +854,23 @@ function PassiveTreeViewClass:Draw(build, viewPort, inputEvents)
SetDrawColor(1, 1, 1)
end
end
if IsKeyDown("ALT") and hoverNode and node ~= hoverNode then
local dx = node.x - hoverNode.x
local dy = node.y - hoverNode.y
local distSq = dx*dx + dy*dy
for _, radData in ipairs(build.data.jewelRadius) do
if radData.inner == 0 then
local r = radData.outer * build.data.gameConstants["PassiveTreeJewelDistanceMultiplier"]
if distSq <= r * r then
SetDrawLayer(nil, 30)
SetDrawColor(radData.col)
local size = 140 * scale / self.zoom ^ 0.2
DrawImage(self.highlightRing, scrX - size, scrY - size, size * 2, size * 2)
break
end
end
end
end
Comment on lines +857 to +873
Copy link

Copilot AI Dec 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code executes distance calculations for every node in the passive tree (potentially thousands of nodes) on every frame while ALT is held and a node is hovered. Consider optimizing by:

  1. Pre-calculating which nodes fall within jewel radii when the hover node changes (similar to how nodesInRadius is used for jewel sockets at line 810)
  2. Caching results when the hovered node hasn't changed
  3. Or limiting the check to nodes within a maximum possible jewel radius distance first

Copilot uses AI. Check for mistakes.
if self.searchStrResults[nodeId] then
-- Node matches the search string, show the highlight circle
SetDrawLayer(nil, 30)
Expand Down Expand Up @@ -895,6 +912,16 @@ function PassiveTreeViewClass:Draw(build, viewPort, inputEvents)

-- Draw ring overlays for jewel sockets
SetDrawLayer(nil, 25)
if IsKeyDown("ALT") and hoverNode then
local scrX, scrY = treeToScreen(hoverNode.x, hoverNode.y)
for _, radData in ipairs(build.data.jewelRadius) do
if radData.inner == 0 then
local outerSize = radData.outer * build.data.gameConstants["PassiveTreeJewelDistanceMultiplier"] * scale
SetDrawColor(radData.col)
DrawImage(self.ring, scrX - outerSize, scrY - outerSize, outerSize * 2, outerSize * 2)
end
end
end
for nodeId in pairs(tree.sockets) do
local node = spec.nodes[nodeId]
if node and node.name ~= "Charm Socket" and node.containJewelSocket ~= true and (not node.expansionJewel or node.expansionJewel.size == 2) then
Expand Down
Loading