public RayHitResult HitWithClick(RayCastInfo clickInfo) { // todo: calculate in screen space? var line = getLine(master); var mouseLine = clickInfo.GlobalRay.ToLine(); Line3.GetClosestPoints(line, mouseLine, out var p1, out var p2); var grad = clickInfo.GetAbsPixelGradientAt((p1 + p2) / 2); var diff = (p2 - p1).Abs(); var pixelDiff = Vector3.Dot(diff, grad); return(pixelDiff <= lineWidth ? new RayHitResult { Successful = true, Node = Node, Distance = (clickInfo.GlobalRay.Point - p1).Length(), GlobalHitPoint = p1, LocalHitPoint = p1, IntTag = intTag, StrTag = strTag } : RayHitResult.Failure()); }