From 6d8ee9ce245213966201ddf6b1b5be277dbf8565 Mon Sep 17 00:00:00 2001 From: BabbleBones Date: Wed, 27 Sep 2023 01:36:38 -0400 Subject: [PATCH] Factor in hands for fade --- main.lua | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/main.lua b/main.lua index 0642611..fd4949a 100644 --- a/main.lua +++ b/main.lua @@ -308,8 +308,23 @@ function modeConfigure(pass) end function modeDraw(pass) - local x, y, z = lovr.headset.getPosition("head") - local closestDist = getClosestDistanceToPerimeter(x, y, z, settings.points) + local hx, hy, hz = lovr.headset.getPosition("head") + + -- Calculate the distance from the head to the perimeter + local perimeterDistHead = getClosestDistanceToPerimeter(hx, hy, hz, settings.points) + + -- Check distance from each hand to the perimeter + local handDistances = {perimeterDistHead} + for _, hand in ipairs(hands) do + if isTracked(hand) then + local handX, handY, handZ = lovr.headset.getPosition(hand) + local dist = getClosestDistanceToPerimeter(handX, handY, handZ, settings.points) + table.insert(handDistances, dist) + end + end + + -- Take the minimum of the distances for the fade logic + local closestDist = math.min(unpack(handDistances)) -- Update the fade logic based on the closest distance closestDist = (closestDist - settings.fade_stop) / (settings.fade_start - settings.fade_stop) @@ -324,8 +339,8 @@ function modeDraw(pass) } end - local cornerColor = interpolateColor(settings.color_far_corners, settings.color_close_corners) - local gridColor = interpolateColor(settings.color_far_grid, settings.color_close_grid) + local cornerColor = interpolateColor(settings.color_far_corners, settings.color_close_corners) + local gridColor = interpolateColor(settings.color_far_grid, settings.color_close_grid) drawPointGrid(pass, settings.points, cornerColor, gridColor) end