{"action":"created","comment":{"url":"https://api.github.com/repos/leapmotion/UnityModules/pulls/comments/110236966","pull_request_review_id":31392683,"id":110236966,"diff_hunk":"@@ -556,8 +593,130 @@ public enum GraspedMovementType {\n \n     private InteractionHand _closestHoveringHand = null;\n \n-    public float GetDistance(Vector3 worldPosition) {\n-      return Vector3.Distance(this.transform.position, worldPosition);\n+    public virtual float GetComparativeHoverDistance(Vector3 worldPosition) {\n+      float closestComparativeColliderDistance = float.PositiveInfinity;\n+      bool hasColliders = false;\n+      Collider collider;\n+      Transform colliderTransform;\n+      foreach (var colliderTransformPair in _colliderTransformPairs) {\n+        if (!hasColliders) hasColliders = true;\n+\n+        collider = colliderTransformPair.collider;\n+        colliderTransform = colliderTransformPair.transform;\n+\n+        float testDistance;\n+        if (collider is SphereCollider) {\n+          testDistance = GetComparativeCenterSqrDistance((SphereCollider)collider, colliderTransform, worldPosition);\n+        }\n+        else if (collider is CapsuleCollider) {\n+          testDistance = GetComparativeCenterSqrDistance((CapsuleCollider)collider, colliderTransform, worldPosition);\n+        }\n+        else if (collider is BoxCollider) {\n+          testDistance = GetComparativeCenterSqrDistance((BoxCollider)collider, colliderTransform, worldPosition);\n+        }\n+        else if (collider is MeshCollider) {\n+          testDistance = GetComparativeCenterSqrDistance((MeshCollider)collider, colliderTransform, worldPosition);\n+        }\n+        else {\n+          testDistance = (this.transform.position - worldPosition).sqrMagnitude;\n+        }\n+\n+        if (testDistance < closestComparativeColliderDistance) {\n+          closestComparativeColliderDistance = testDistance;\n+        }\n+      }\n+\n+      if (!hasColliders) {\n+        return (this.transform.position - worldPosition).sqrMagnitude;\n+      }\n+      else {\n+        return closestComparativeColliderDistance;\n+      }\n+    }\n+\n+    /// <summary>\n+    /// Returns the squared distance to the center of the argument SphereCollider.\n+    /// </summary>\n+    protected static float GetComparativeCenterSqrDistance(SphereCollider sphere, Transform sphereTransform, Vector3 worldPosition) {\n+      return (sphereTransform.TransformPoint(sphere.center) - worldPosition).sqrMagnitude;\n+    }\n+\n+    /// <summary>\n+    /// Returns the squared distance to the line segment at the center of the CapsuleCollider.\n+    /// </summary>\n+    protected static float GetComparativeCenterSqrDistance(CapsuleCollider capsule, Transform capsuleTransform, Vector3 worldPosition) {\n+      // https://docs.unity3d.com/ScriptReference/CapsuleCollider-direction.html\n+      Vector3 dir = capsule.direction == 0 ? Vector3.right : capsule.direction == 1 ? Vector3.up : Vector3.forward;\n+\n+      Vector3 a = capsule.center + dir * (capsule.height / 2F - capsule.radius);\n+      Vector3 b = capsule.center - dir * (capsule.height / 2F - capsule.radius);\n+      return (worldPosition.ConstrainToSegment(capsuleTransform.TransformPoint(a), capsuleTransform.TransformPoint(b)) - worldPosition)","path":"Assets/LeapMotionModules/Interaction/InteractionBehaviour.cs","position":131,"original_position":131,"commit_id":"930911c0f455c72b79caca9d34154f513da92a8e","original_commit_id":"930911c0f455c72b79caca9d34154f513da92a8e","user":{"login":"jselstad","id":18404478,"avatar_url":"https://avatars3.githubusercontent.com/u/18404478?v=3","gravatar_id":"","url":"https://api.github.com/users/jselstad","html_url":"https://github.com/jselstad","followers_url":"https://api.github.com/users/jselstad/followers","following_url":"https://api.github.com/users/jselstad/following{/other_user}","gists_url":"https://api.github.com/users/jselstad/gists{/gist_id}","starred_url":"https://api.github.com/users/jselstad/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jselstad/subscriptions","organizations_url":"https://api.github.com/users/jselstad/orgs","repos_url":"https://api.github.com/users/jselstad/repos","events_url":"https://api.github.com/users/jselstad/events{/privacy}","received_events_url":"https://api.github.com/users/jselstad/received_events","type":"User","site_admin":false},"body":"You should only need one transform point, since you can just negate the offset from the center to one end to get the offset to the other end (in world space).","created_at":"2017-04-06T18:40:12Z","updated_at":"2017-04-06T18:53:32Z","html_url":"https://github.com/leapmotion/UnityModules/pull/649#discussion_r110236966","pull_request_url":"https://api.github.com/repos/leapmotion/UnityModules/pulls/649","_links":{"self":{"href":"https://api.github.com/repos/leapmotion/UnityModules/pulls/comments/110236966"},"html":{"href":"https://github.com/leapmotion/UnityModules/pull/649#discussion_r110236966"},"pull_request":{"href":"https://api.github.com/repos/leapmotion/UnityModules/pulls/649"}}},"pull_request":{"url":"https://api.github.com/repos/leapmotion/UnityModules/pulls/649","id":114510870,"html_url":"https://github.com/leapmotion/UnityModules/pull/649","diff_url":"https://github.com/leapmotion/UnityModules/pull/649.diff","patch_url":"https://github.com/leapmotion/UnityModules/pull/649.patch","issue_url":"https://api.github.com/repos/leapmotion/UnityModules/issues/649","number":649,"state":"open","locked":false,"title":"better hover distance, plus some fixes","user":{"login":"omonomo","id":4485426,"avatar_url":"https://avatars0.githubusercontent.com/u/4485426?v=3","gravatar_id":"","url":"https://api.github.com/users/omonomo","html_url":"https://github.com/omonomo","followers_url":"https://api.github.com/users/omonomo/followers","following_url":"https://api.github.com/users/omonomo/following{/other_user}","gists_url":"https://api.github.com/users/omonomo/gists{/gist_id}","starred_url":"https://api.github.com/users/omonomo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/omonomo/subscriptions","organizations_url":"https://api.github.com/users/omonomo/orgs","repos_url":"https://api.github.com/users/omonomo/repos","events_url":"https://api.github.com/users/omonomo/events{/privacy}","received_events_url":"https://api.github.com/users/omonomo/received_events","type":"User","site_admin":false},"body":"CHECK this GOODNESS out\r\n\r\n- Hover distance is now calculated based on an object's colliders using a method that checks for distance to the \"center\" of that object, which is a point if the object is a SphereCollider or MeshCollider, but is a line segment if the object is an oblong shape like a CapsuleCollider or a long BoxCollider. This fixes an edge case where the old primary hover would fail as demonstrated in the Example scene. (We may want to just bite the bullet and do distance to surface calculations at some point.)\r\n- Exposes the finger that is causing an object to be primary-hovered; observe how I use it and Physics.ClosestPoint in the example scene to draw a blue line -- oooooo pretty.\r\n- Minor fixes and some docstrings added","created_at":"2017-04-06T02:31:54Z","updated_at":"2017-04-06T18:53:32Z","closed_at":null,"merged_at":null,"merge_commit_sha":"106856d7d37039cfa25be882aeba5e3eb77f868e","assignee":{"login":"omonomo","id":4485426,"avatar_url":"https://avatars0.githubusercontent.com/u/4485426?v=3","gravatar_id":"","url":"https://api.github.com/users/omonomo","html_url":"https://github.com/omonomo","followers_url":"https://api.github.com/users/omonomo/followers","following_url":"https://api.github.com/users/omonomo/following{/other_user}","gists_url":"https://api.github.com/users/omonomo/gists{/gist_id}","starred_url":"https://api.github.com/users/omonomo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/omonomo/subscriptions","organizations_url":"https://api.github.com/users/omonomo/orgs","repos_url":"https://api.github.com/users/omonomo/repos","events_url":"https://api.github.com/users/omonomo/events{/privacy}","received_events_url":"https://api.github.com/users/omonomo/received_events","type":"User","site_admin":false},"assignees":[{"login":"omonomo","id":4485426,"avatar_url":"https://avatars0.githubusercontent.com/u/4485426?v=3","gravatar_id":"","url":"https://api.github.com/users/omonomo","html_url":"https://github.com/omonomo","followers_url":"https://api.github.com/users/omonomo/followers","following_url":"https://api.github.com/users/omonomo/following{/other_user}","gists_url":"https://api.github.com/users/omonomo/gists{/gist_id}","starred_url":"https://api.github.com/users/omonomo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/omonomo/subscriptions","organizations_url":"https://api.github.com/users/omonomo/orgs","repos_url":"https://api.github.com/users/omonomo/repos","events_url":"https://api.github.com/users/omonomo/events{/privacy}","received_events_url":"https://api.github.com/users/omonomo/received_events","type":"User","site_admin":false}],"milestone":{"url":"https://api.github.com/repos/leapmotion/UnityModules/milestones/14","html_url":"https://github.com/leapmotion/UnityModules/milestone/14","labels_url":"https://api.github.com/repos/leapmotion/UnityModules/milestones/14/labels","id":2293458,"number":14,"title":"Leap Unified Interaction","description":"The Interaction Engine encompasses a lot of useful and reasonably mature interaction logic. UIs qua the Leap GUI system will also heavily rely on interactions; we'd like to take advantage of IE's maturity to support a unified interaction model that can support physically-intuitive (a la IE) as well as more abstract interaction paradigms. Currently this work is happening in feature-gui-interaction.","creator":{"login":"omonomo","id":4485426,"avatar_url":"https://avatars0.githubusercontent.com/u/4485426?v=3","gravatar_id":"","url":"https://api.github.com/users/omonomo","html_url":"https://github.com/omonomo","followers_url":"https://api.github.com/users/omonomo/followers","following_url":"https://api.github.com/users/omonomo/following{/other_user}","gists_url":"https://api.github.com/users/omonomo/gists{/gist_id}","starred_url":"https://api.github.com/users/omonomo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/omonomo/subscriptions","organizations_url":"https://api.github.com/users/omonomo/orgs","repos_url":"https://api.github.com/users/omonomo/repos","events_url":"https://api.github.com/users/omonomo/events{/privacy}","received_events_url":"https://api.github.com/users/omonomo/received_events","type":"User","site_admin":false},"open_issues":4,"closed_issues":18,"state":"open","created_at":"2017-02-01T20:22:26Z","updated_at":"2017-04-06T02:31:54Z","due_on":"2017-04-08T07:00:00Z","closed_at":null},"commits_url":"https://api.github.com/repos/leapmotion/UnityModules/pulls/649/commits","review_comments_url":"https://api.github.com/repos/leapmotion/UnityModules/pulls/649/comments","review_comment_url":"https://api.github.com/repos/leapmotion/UnityModules/pulls/comments{/number}","comments_url":"https://api.github.com/repos/leapmotion/UnityModules/issues/649/comments","statuses_url":"https://api.github.com/repos/leapmotion/UnityModules/statuses/930911c0f455c72b79caca9d34154f513da92a8e","head":{"label":"leapmotion:feature-primary-hover-info","ref":"feature-primary-hover-info","sha":"930911c0f455c72b79caca9d34154f513da92a8e","user":{"login":"leapmotion","id":2242710,"avatar_url":"https://avatars2.githubusercontent.com/u/2242710?v=3","gravatar_id":"","url":"https://api.github.com/users/leapmotion","html_url":"https://github.com/leapmotion","followers_url":"https://api.github.com/users/leapmotion/followers","following_url":"https://api.github.com/users/leapmotion/following{/other_user}","gists_url":"https://api.github.com/users/leapmotion/gists{/gist_id}","starred_url":"https://api.github.com/users/leapmotion/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/leapmotion/subscriptions","organizations_url":"https://api.github.com/users/leapmotion/orgs","repos_url":"https://api.github.com/users/leapmotion/repos","events_url":"https://api.github.com/users/leapmotion/events{/privacy}","received_events_url":"https://api.github.com/users/leapmotion/received_events","type":"Organization","site_admin":false},"repo":{"id":52047290,"name":"UnityModules","full_name":"leapmotion/UnityModules","owner":{"login":"leapmotion","id":2242710,"avatar_url":"https://avatars2.githubusercontent.com/u/2242710?v=3","gravatar_id":"","url":"https://api.github.com/users/leapmotion","html_url":"https://github.com/leapmotion","followers_url":"https://api.github.com/users/leapmotion/followers","following_url":"https://api.github.com/users/leapmotion/following{/other_user}","gists_url":"https://api.github.com/users/leapmotion/gists{/gist_id}","starred_url":"https://api.github.com/users/leapmotion/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/leapmotion/subscriptions","organizations_url":"https://api.github.com/users/leapmotion/orgs","repos_url":"https://api.github.com/users/leapmotion/repos","events_url":"https://api.github.com/users/leapmotion/events{/privacy}","received_events_url":"https://api.github.com/users/leapmotion/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/leapmotion/UnityModules","description":"Repository containing all Leap Motion asset packages","fork":false,"url":"https://api.github.com/repos/leapmotion/UnityModules","forks_url":"https://api.github.com/repos/leapmotion/UnityModules/forks","keys_url":"https://api.github.com/repos/leapmotion/UnityModules/keys{/key_id}","collaborators_url":"https://api.github.com/repos/leapmotion/UnityModules/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/leapmotion/UnityModules/teams","hooks_url":"https://api.github.com/repos/leapmotion/UnityModules/hooks","issue_events_url":"https://api.github.com/repos/leapmotion/UnityModules/issues/events{/number}","events_url":"https://api.github.com/repos/leapmotion/UnityModules/events","assignees_url":"https://api.github.com/repos/leapmotion/UnityModules/assignees{/user}","branches_url":"https://api.github.com/repos/leapmotion/UnityModules/branches{/branch}","tags_url":"https://api.github.com/repos/leapmotion/UnityModules/tags","blobs_url":"https://api.github.com/repos/leapmotion/UnityModules/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/leapmotion/UnityModules/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/leapmotion/UnityModules/git/refs{/sha}","trees_url":"https://api.github.com/repos/leapmotion/UnityModules/git/trees{/sha}","statuses_url":"https://api.github.com/repos/leapmotion/UnityModules/statuses/{sha}","languages_url":"https://api.github.com/repos/leapmotion/UnityModules/languages","stargazers_url":"https://api.github.com/repos/leapmotion/UnityModules/stargazers","contributors_url":"https://api.github.com/repos/leapmotion/UnityModules/contributors","subscribers_url":"https://api.github.com/repos/leapmotion/UnityModules/subscribers","subscription_url":"https://api.github.com/repos/leapmotion/UnityModules/subscription","commits_url":"https://api.github.com/repos/leapmotion/UnityModules/commits{/sha}","git_commits_url":"https://api.github.com/repos/leapmotion/UnityModules/git/commits{/sha}","comments_url":"https://api.github.com/repos/leapmotion/UnityModules/comments{/number}","issue_comment_url":"https://api.github.com/repos/leapmotion/UnityModules/issues/comments{/number}","contents_url":"https://api.github.com/repos/leapmotion/UnityModules/contents/{+path}","compare_url":"https://api.github.com/repos/leapmotion/UnityModules/compare/{base}...{head}","merges_url":"https://api.github.com/repos/leapmotion/UnityModules/merges","archive_url":"https://api.github.com/repos/leapmotion/UnityModules/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/leapmotion/UnityModules/downloads","issues_url":"https://api.github.com/repos/leapmotion/UnityModules/issues{/number}","pulls_url":"https://api.github.com/repos/leapmotion/UnityModules/pulls{/number}","milestones_url":"https://api.github.com/repos/leapmotion/UnityModules/milestones{/number}","notifications_url":"https://api.github.com/repos/leapmotion/UnityModules/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/leapmotion/UnityModules/labels{/name}","releases_url":"https://api.github.com/repos/leapmotion/UnityModules/releases{/id}","deployments_url":"https://api.github.com/repos/leapmotion/UnityModules/deployments","created_at":"2016-02-18T23:42:29Z","updated_at":"2017-04-06T16:47:41Z","pushed_at":"2017-04-06T18:22:41Z","git_url":"git://github.com/leapmotion/UnityModules.git","ssh_url":"git@github.com:leapmotion/UnityModules.git","clone_url":"https://github.com/leapmotion/UnityModules.git","svn_url":"https://github.com/leapmotion/UnityModules","homepage":null,"size":240513,"stargazers_count":54,"watchers_count":54,"language":"C#","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":26,"mirror_url":null,"open_issues_count":60,"forks":26,"open_issues":60,"watchers":54,"default_branch":"master"}},"base":{"label":"leapmotion:feature-leap-gui","ref":"feature-leap-gui","sha":"fbc6bbad3a47a15289b857e2363bb7bbfe5929b8","user":{"login":"leapmotion","id":2242710,"avatar_url":"https://avatars2.githubusercontent.com/u/2242710?v=3","gravatar_id":"","url":"https://api.github.com/users/leapmotion","html_url":"https://github.com/leapmotion","followers_url":"https://api.github.com/users/leapmotion/followers","following_url":"https://api.github.com/users/leapmotion/following{/other_user}","gists_url":"https://api.github.com/users/leapmotion/gists{/gist_id}","starred_url":"https://api.github.com/users/leapmotion/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/leapmotion/subscriptions","organizations_url":"https://api.github.com/users/leapmotion/orgs","repos_url":"https://api.github.com/users/leapmotion/repos","events_url":"https://api.github.com/users/leapmotion/events{/privacy}","received_events_url":"https://api.github.com/users/leapmotion/received_events","type":"Organization","site_admin":false},"repo":{"id":52047290,"name":"UnityModules","full_name":"leapmotion/UnityModules","owner":{"login":"leapmotion","id":2242710,"avatar_url":"https://avatars2.githubusercontent.com/u/2242710?v=3","gravatar_id":"","url":"https://api.github.com/users/leapmotion","html_url":"https://github.com/leapmotion","followers_url":"https://api.github.com/users/leapmotion/followers","following_url":"https://api.github.com/users/leapmotion/following{/other_user}","gists_url":"https://api.github.com/users/leapmotion/gists{/gist_id}","starred_url":"https://api.github.com/users/leapmotion/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/leapmotion/subscriptions","organizations_url":"https://api.github.com/users/leapmotion/orgs","repos_url":"https://api.github.com/users/leapmotion/repos","events_url":"https://api.github.com/users/leapmotion/events{/privacy}","received_events_url":"https://api.github.com/users/leapmotion/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/leapmotion/UnityModules","description":"Repository containing all Leap Motion asset packages","fork":false,"url":"https://api.github.com/repos/leapmotion/UnityModules","forks_url":"https://api.github.com/repos/leapmotion/UnityModules/forks","keys_url":"https://api.github.com/repos/leapmotion/UnityModules/keys{/key_id}","collaborators_url":"https://api.github.com/repos/leapmotion/UnityModules/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/leapmotion/UnityModules/teams","hooks_url":"https://api.github.com/repos/leapmotion/UnityModules/hooks","issue_events_url":"https://api.github.com/repos/leapmotion/UnityModules/issues/events{/number}","events_url":"https://api.github.com/repos/leapmotion/UnityModules/events","assignees_url":"https://api.github.com/repos/leapmotion/UnityModules/assignees{/user}","branches_url":"https://api.github.com/repos/leapmotion/UnityModules/branches{/branch}","tags_url":"https://api.github.com/repos/leapmotion/UnityModules/tags","blobs_url":"https://api.github.com/repos/leapmotion/UnityModules/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/leapmotion/UnityModules/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/leapmotion/UnityModules/git/refs{/sha}","trees_url":"https://api.github.com/repos/leapmotion/UnityModules/git/trees{/sha}","statuses_url":"https://api.github.com/repos/leapmotion/UnityModules/statuses/{sha}","languages_url":"https://api.github.com/repos/leapmotion/UnityModules/languages","stargazers_url":"https://api.github.com/repos/leapmotion/UnityModules/stargazers","contributors_url":"https://api.github.com/repos/leapmotion/UnityModules/contributors","subscribers_url":"https://api.github.com/repos/leapmotion/UnityModules/subscribers","subscription_url":"https://api.github.com/repos/leapmotion/UnityModules/subscription","commits_url":"https://api.github.com/repos/leapmotion/UnityModules/commits{/sha}","git_commits_url":"https://api.github.com/repos/leapmotion/UnityModules/git/commits{/sha}","comments_url":"https://api.github.com/repos/leapmotion/UnityModules/comments{/number}","issue_comment_url":"https://api.github.com/repos/leapmotion/UnityModules/issues/comments{/number}","contents_url":"https://api.github.com/repos/leapmotion/UnityModules/contents/{+path}","compare_url":"https://api.github.com/repos/leapmotion/UnityModules/compare/{base}...{head}","merges_url":"https://api.github.com/repos/leapmotion/UnityModules/merges","archive_url":"https://api.github.com/repos/leapmotion/UnityModules/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/leapmotion/UnityModules/downloads","issues_url":"https://api.github.com/repos/leapmotion/UnityModules/issues{/number}","pulls_url":"https://api.github.com/repos/leapmotion/UnityModules/pulls{/number}","milestones_url":"https://api.github.com/repos/leapmotion/UnityModules/milestones{/number}","notifications_url":"https://api.github.com/repos/leapmotion/UnityModules/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/leapmotion/UnityModules/labels{/name}","releases_url":"https://api.github.com/repos/leapmotion/UnityModules/releases{/id}","deployments_url":"https://api.github.com/repos/leapmotion/UnityModules/deployments","created_at":"2016-02-18T23:42:29Z","updated_at":"2017-04-06T16:47:41Z","pushed_at":"2017-04-06T18:22:41Z","git_url":"git://github.com/leapmotion/UnityModules.git","ssh_url":"git@github.com:leapmotion/UnityModules.git","clone_url":"https://github.com/leapmotion/UnityModules.git","svn_url":"https://github.com/leapmotion/UnityModules","homepage":null,"size":240513,"stargazers_count":54,"watchers_count":54,"language":"C#","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":26,"mirror_url":null,"open_issues_count":60,"forks":26,"open_issues":60,"watchers":54,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/leapmotion/UnityModules/pulls/649"},"html":{"href":"https://github.com/leapmotion/UnityModules/pull/649"},"issue":{"href":"https://api.github.com/repos/leapmotion/UnityModules/issues/649"},"comments":{"href":"https://api.github.com/repos/leapmotion/UnityModules/issues/649/comments"},"review_comments":{"href":"https://api.github.com/repos/leapmotion/UnityModules/pulls/649/comments"},"review_comment":{"href":"https://api.github.com/repos/leapmotion/UnityModules/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/leapmotion/UnityModules/pulls/649/commits"},"statuses":{"href":"https://api.github.com/repos/leapmotion/UnityModules/statuses/930911c0f455c72b79caca9d34154f513da92a8e"}}}}
{"actor":{"display_login":"jselstad"}}