Localize k-d-tree traversal function

master
Lars Mueller 2020-06-02 23:05:42 +02:00
parent 4e425823b0
commit dfba3c44df
1 changed files with 2 additions and 2 deletions

View File

@ -31,7 +31,7 @@ function kd_closest_color_finder(colors)
return function(color)
local min_distance=math.huge
local closest_color
f=function(tree)
local function f(tree)
local axis=tree.axis
if #tree > 0 then -- Subtree is leaf
local distance = distance(tree, color)
@ -43,7 +43,7 @@ function kd_closest_color_finder(colors)
else
local new_tree, other_tree = tree.right, tree.left
if color[axis] < tree.pivot[axis] then
new_tree, other_tree = tree.left, tree.right
new_tree, other_tree = other_tree, new_tree
end
f(other_tree)
if tree.pivot then