{"action":"created","comment":{"url":"https://api.github.com/repos/cedricpinson/osgjs/pulls/comments/32615131","id":32615131,"diff_hunk":"@@ -38,41 +38,19 @@ define( [\n             // Not working if culling disabled ??\n             return !node.isCullingActive() || this.intersects( node.getBound() );\n         },\n-        // Intersection Segment/Sphere \n+        // Optimized Intersection Segment/Sphere \n+        // From Real-Time Rendering, by Tomas Akenine-Möller, Eric Haines, and Naty Hoffman. Pages 738-741\n         intersects: ( function () {\n-            var sm = Vec3.create();\n-            var se = Vec3.create();\n+            var l = Vec3.create();\n             return function ( bsphere ) {\n-                // test for _start inside the bounding sphere\n                 if ( !bsphere.valid() ) return false;\n-                Vec3.sub( this._iStart, bsphere.center(), sm );\n-                var c = Vec3.length2( sm ) - bsphere.radius2();\n-                if ( c < 0.0 ) {\n-                    return true;\n-                }\n-                // solve quadratic equation\n-                Vec3.sub( this._iEnd, this._iStart, se );\n-                var a = Vec3.length2( se );\n-                var b = Vec3.dot( sm, se ) * 2.0;\n-                var d = b * b - 4.0 * a * c;\n-                // no intersections if d<0\n-                if ( d < 0.0 ) {\n-                    return false;\n-                }\n-                // compute two solutions of quadratic equation\n-                d = Math.sqrt( d );\n-                var div = 0.5 / a;\n-                var r1 = ( -b - d ) * div;\n-                var r2 = ( -b + d ) * div;\n-\n-                // return false if both intersections are before the ray start\n-                if ( r1 <= 0.0 && r2 <= 0.0 ) {\n-                    return false;\n-                }\n-\n-                if ( r1 >= 1.0 && r2 >= 1.0 ) {\n-                    return false;\n-                }\n+                Vec3.sub( bsphere.center(), this._iStart, l );\n+                var l2 = Vec3.length2( l );\n+                if ( l2 <= bsphere.radius2() ) return true;\n+                var s = Vec3.dot( l, this._iEnd );\n+                if ( s < 0 ) return false;","path":"sources/osgUtil/LineSegmentIntersector.js","position":46,"original_position":46,"commit_id":"53be60f281bc77927bec106cb018edeb909ea86c","original_commit_id":"53be60f281bc77927bec106cb018edeb909ea86c","user":{"login":"cedricpinson","id":351686,"avatar_url":"https://avatars.githubusercontent.com/u/351686?v=3","gravatar_id":"","url":"https://api.github.com/users/cedricpinson","html_url":"https://github.com/cedricpinson","followers_url":"https://api.github.com/users/cedricpinson/followers","following_url":"https://api.github.com/users/cedricpinson/following{/other_user}","gists_url":"https://api.github.com/users/cedricpinson/gists{/gist_id}","starred_url":"https://api.github.com/users/cedricpinson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cedricpinson/subscriptions","organizations_url":"https://api.github.com/users/cedricpinson/orgs","repos_url":"https://api.github.com/users/cedricpinson/repos","events_url":"https://api.github.com/users/cedricpinson/events{/privacy}","received_events_url":"https://api.github.com/users/cedricpinson/received_events","type":"User","site_admin":false},"body":"it's better to use float when you test float, like 0.0 instead of just 0. It helps the jit, like not converting type on the fly","created_at":"2015-06-17T10:58:28Z","updated_at":"2015-06-17T10:58:28Z","html_url":"https://github.com/cedricpinson/osgjs/pull/338#discussion_r32615131","pull_request_url":"https://api.github.com/repos/cedricpinson/osgjs/pulls/338","_links":{"self":{"href":"https://api.github.com/repos/cedricpinson/osgjs/pulls/comments/32615131"},"html":{"href":"https://github.com/cedricpinson/osgjs/pull/338#discussion_r32615131"},"pull_request":{"href":"https://api.github.com/repos/cedricpinson/osgjs/pulls/338"}}},"pull_request":{"url":"https://api.github.com/repos/cedricpinson/osgjs/pulls/338","id":37556038,"html_url":"https://github.com/cedricpinson/osgjs/pull/338","diff_url":"https://github.com/cedricpinson/osgjs/pull/338.diff","patch_url":"https://github.com/cedricpinson/osgjs/pull/338.patch","issue_url":"https://api.github.com/repos/cedricpinson/osgjs/issues/338","number":338,"state":"open","locked":false,"title":"Replaced intersection ray/sphere method by a faster one","user":{"login":"jtorresfabra","id":1784900,"avatar_url":"https://avatars.githubusercontent.com/u/1784900?v=3","gravatar_id":"","url":"https://api.github.com/users/jtorresfabra","html_url":"https://github.com/jtorresfabra","followers_url":"https://api.github.com/users/jtorresfabra/followers","following_url":"https://api.github.com/users/jtorresfabra/following{/other_user}","gists_url":"https://api.github.com/users/jtorresfabra/gists{/gist_id}","starred_url":"https://api.github.com/users/jtorresfabra/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jtorresfabra/subscriptions","organizations_url":"https://api.github.com/users/jtorresfabra/orgs","repos_url":"https://api.github.com/users/jtorresfabra/repos","events_url":"https://api.github.com/users/jtorresfabra/events{/privacy}","received_events_url":"https://api.github.com/users/jtorresfabra/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-06-12T12:05:03Z","updated_at":"2015-06-17T10:58:28Z","closed_at":null,"merged_at":null,"merge_commit_sha":"814e938144576dcb264581e5f900605fd2c14590","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/cedricpinson/osgjs/pulls/338/commits","review_comments_url":"https://api.github.com/repos/cedricpinson/osgjs/pulls/338/comments","review_comment_url":"https://api.github.com/repos/cedricpinson/osgjs/pulls/comments{/number}","comments_url":"https://api.github.com/repos/cedricpinson/osgjs/issues/338/comments","statuses_url":"https://api.github.com/repos/cedricpinson/osgjs/statuses/53be60f281bc77927bec106cb018edeb909ea86c","head":{"label":"jtorresfabra:fasterIntersectRaySphere","ref":"fasterIntersectRaySphere","sha":"53be60f281bc77927bec106cb018edeb909ea86c","user":{"login":"jtorresfabra","id":1784900,"avatar_url":"https://avatars.githubusercontent.com/u/1784900?v=3","gravatar_id":"","url":"https://api.github.com/users/jtorresfabra","html_url":"https://github.com/jtorresfabra","followers_url":"https://api.github.com/users/jtorresfabra/followers","following_url":"https://api.github.com/users/jtorresfabra/following{/other_user}","gists_url":"https://api.github.com/users/jtorresfabra/gists{/gist_id}","starred_url":"https://api.github.com/users/jtorresfabra/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jtorresfabra/subscriptions","organizations_url":"https://api.github.com/users/jtorresfabra/orgs","repos_url":"https://api.github.com/users/jtorresfabra/repos","events_url":"https://api.github.com/users/jtorresfabra/events{/privacy}","received_events_url":"https://api.github.com/users/jtorresfabra/received_events","type":"User","site_admin":false},"repo":{"id":16796956,"name":"osgjs","full_name":"jtorresfabra/osgjs","owner":{"login":"jtorresfabra","id":1784900,"avatar_url":"https://avatars.githubusercontent.com/u/1784900?v=3","gravatar_id":"","url":"https://api.github.com/users/jtorresfabra","html_url":"https://github.com/jtorresfabra","followers_url":"https://api.github.com/users/jtorresfabra/followers","following_url":"https://api.github.com/users/jtorresfabra/following{/other_user}","gists_url":"https://api.github.com/users/jtorresfabra/gists{/gist_id}","starred_url":"https://api.github.com/users/jtorresfabra/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jtorresfabra/subscriptions","organizations_url":"https://api.github.com/users/jtorresfabra/orgs","repos_url":"https://api.github.com/users/jtorresfabra/repos","events_url":"https://api.github.com/users/jtorresfabra/events{/privacy}","received_events_url":"https://api.github.com/users/jtorresfabra/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jtorresfabra/osgjs","description":"Javascript Implementation of OpenSceneGraph","fork":true,"url":"https://api.github.com/repos/jtorresfabra/osgjs","forks_url":"https://api.github.com/repos/jtorresfabra/osgjs/forks","keys_url":"https://api.github.com/repos/jtorresfabra/osgjs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jtorresfabra/osgjs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jtorresfabra/osgjs/teams","hooks_url":"https://api.github.com/repos/jtorresfabra/osgjs/hooks","issue_events_url":"https://api.github.com/repos/jtorresfabra/osgjs/issues/events{/number}","events_url":"https://api.github.com/repos/jtorresfabra/osgjs/events","assignees_url":"https://api.github.com/repos/jtorresfabra/osgjs/assignees{/user}","branches_url":"https://api.github.com/repos/jtorresfabra/osgjs/branches{/branch}","tags_url":"https://api.github.com/repos/jtorresfabra/osgjs/tags","blobs_url":"https://api.github.com/repos/jtorresfabra/osgjs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jtorresfabra/osgjs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jtorresfabra/osgjs/git/refs{/sha}","trees_url":"https://api.github.com/repos/jtorresfabra/osgjs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jtorresfabra/osgjs/statuses/{sha}","languages_url":"https://api.github.com/repos/jtorresfabra/osgjs/languages","stargazers_url":"https://api.github.com/repos/jtorresfabra/osgjs/stargazers","contributors_url":"https://api.github.com/repos/jtorresfabra/osgjs/contributors","subscribers_url":"https://api.github.com/repos/jtorresfabra/osgjs/subscribers","subscription_url":"https://api.github.com/repos/jtorresfabra/osgjs/subscription","commits_url":"https://api.github.com/repos/jtorresfabra/osgjs/commits{/sha}","git_commits_url":"https://api.github.com/repos/jtorresfabra/osgjs/git/commits{/sha}","comments_url":"https://api.github.com/repos/jtorresfabra/osgjs/comments{/number}","issue_comment_url":"https://api.github.com/repos/jtorresfabra/osgjs/issues/comments{/number}","contents_url":"https://api.github.com/repos/jtorresfabra/osgjs/contents/{+path}","compare_url":"https://api.github.com/repos/jtorresfabra/osgjs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jtorresfabra/osgjs/merges","archive_url":"https://api.github.com/repos/jtorresfabra/osgjs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jtorresfabra/osgjs/downloads","issues_url":"https://api.github.com/repos/jtorresfabra/osgjs/issues{/number}","pulls_url":"https://api.github.com/repos/jtorresfabra/osgjs/pulls{/number}","milestones_url":"https://api.github.com/repos/jtorresfabra/osgjs/milestones{/number}","notifications_url":"https://api.github.com/repos/jtorresfabra/osgjs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jtorresfabra/osgjs/labels{/name}","releases_url":"https://api.github.com/repos/jtorresfabra/osgjs/releases{/id}","created_at":"2014-02-13T08:48:03Z","updated_at":"2015-05-07T13:01:22Z","pushed_at":"2015-06-12T18:55:28Z","git_url":"git://github.com/jtorresfabra/osgjs.git","ssh_url":"git@github.com:jtorresfabra/osgjs.git","clone_url":"https://github.com/jtorresfabra/osgjs.git","svn_url":"https://github.com/jtorresfabra/osgjs","homepage":"http://osgjs.org","size":148899,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"develop"}},"base":{"label":"cedricpinson:develop","ref":"develop","sha":"08e095f7032d6c30865e6dfb6594091bed26d251","user":{"login":"cedricpinson","id":351686,"avatar_url":"https://avatars.githubusercontent.com/u/351686?v=3","gravatar_id":"","url":"https://api.github.com/users/cedricpinson","html_url":"https://github.com/cedricpinson","followers_url":"https://api.github.com/users/cedricpinson/followers","following_url":"https://api.github.com/users/cedricpinson/following{/other_user}","gists_url":"https://api.github.com/users/cedricpinson/gists{/gist_id}","starred_url":"https://api.github.com/users/cedricpinson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cedricpinson/subscriptions","organizations_url":"https://api.github.com/users/cedricpinson/orgs","repos_url":"https://api.github.com/users/cedricpinson/repos","events_url":"https://api.github.com/users/cedricpinson/events{/privacy}","received_events_url":"https://api.github.com/users/cedricpinson/received_events","type":"User","site_admin":false},"repo":{"id":1675632,"name":"osgjs","full_name":"cedricpinson/osgjs","owner":{"login":"cedricpinson","id":351686,"avatar_url":"https://avatars.githubusercontent.com/u/351686?v=3","gravatar_id":"","url":"https://api.github.com/users/cedricpinson","html_url":"https://github.com/cedricpinson","followers_url":"https://api.github.com/users/cedricpinson/followers","following_url":"https://api.github.com/users/cedricpinson/following{/other_user}","gists_url":"https://api.github.com/users/cedricpinson/gists{/gist_id}","starred_url":"https://api.github.com/users/cedricpinson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cedricpinson/subscriptions","organizations_url":"https://api.github.com/users/cedricpinson/orgs","repos_url":"https://api.github.com/users/cedricpinson/repos","events_url":"https://api.github.com/users/cedricpinson/events{/privacy}","received_events_url":"https://api.github.com/users/cedricpinson/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/cedricpinson/osgjs","description":"Javascript Implementation of OpenSceneGraph","fork":false,"url":"https://api.github.com/repos/cedricpinson/osgjs","forks_url":"https://api.github.com/repos/cedricpinson/osgjs/forks","keys_url":"https://api.github.com/repos/cedricpinson/osgjs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cedricpinson/osgjs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cedricpinson/osgjs/teams","hooks_url":"https://api.github.com/repos/cedricpinson/osgjs/hooks","issue_events_url":"https://api.github.com/repos/cedricpinson/osgjs/issues/events{/number}","events_url":"https://api.github.com/repos/cedricpinson/osgjs/events","assignees_url":"https://api.github.com/repos/cedricpinson/osgjs/assignees{/user}","branches_url":"https://api.github.com/repos/cedricpinson/osgjs/branches{/branch}","tags_url":"https://api.github.com/repos/cedricpinson/osgjs/tags","blobs_url":"https://api.github.com/repos/cedricpinson/osgjs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cedricpinson/osgjs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cedricpinson/osgjs/git/refs{/sha}","trees_url":"https://api.github.com/repos/cedricpinson/osgjs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cedricpinson/osgjs/statuses/{sha}","languages_url":"https://api.github.com/repos/cedricpinson/osgjs/languages","stargazers_url":"https://api.github.com/repos/cedricpinson/osgjs/stargazers","contributors_url":"https://api.github.com/repos/cedricpinson/osgjs/contributors","subscribers_url":"https://api.github.com/repos/cedricpinson/osgjs/subscribers","subscription_url":"https://api.github.com/repos/cedricpinson/osgjs/subscription","commits_url":"https://api.github.com/repos/cedricpinson/osgjs/commits{/sha}","git_commits_url":"https://api.github.com/repos/cedricpinson/osgjs/git/commits{/sha}","comments_url":"https://api.github.com/repos/cedricpinson/osgjs/comments{/number}","issue_comment_url":"https://api.github.com/repos/cedricpinson/osgjs/issues/comments{/number}","contents_url":"https://api.github.com/repos/cedricpinson/osgjs/contents/{+path}","compare_url":"https://api.github.com/repos/cedricpinson/osgjs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cedricpinson/osgjs/merges","archive_url":"https://api.github.com/repos/cedricpinson/osgjs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cedricpinson/osgjs/downloads","issues_url":"https://api.github.com/repos/cedricpinson/osgjs/issues{/number}","pulls_url":"https://api.github.com/repos/cedricpinson/osgjs/pulls{/number}","milestones_url":"https://api.github.com/repos/cedricpinson/osgjs/milestones{/number}","notifications_url":"https://api.github.com/repos/cedricpinson/osgjs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cedricpinson/osgjs/labels{/name}","releases_url":"https://api.github.com/repos/cedricpinson/osgjs/releases{/id}","created_at":"2011-04-28T12:36:33Z","updated_at":"2015-06-12T15:13:16Z","pushed_at":"2015-06-17T10:40:47Z","git_url":"git://github.com/cedricpinson/osgjs.git","ssh_url":"git@github.com:cedricpinson/osgjs.git","clone_url":"https://github.com/cedricpinson/osgjs.git","svn_url":"https://github.com/cedricpinson/osgjs","homepage":"http://osgjs.org","size":213255,"stargazers_count":198,"watchers_count":198,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":46,"mirror_url":null,"open_issues_count":23,"forks":46,"open_issues":23,"watchers":198,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/cedricpinson/osgjs/pulls/338"},"html":{"href":"https://github.com/cedricpinson/osgjs/pull/338"},"issue":{"href":"https://api.github.com/repos/cedricpinson/osgjs/issues/338"},"comments":{"href":"https://api.github.com/repos/cedricpinson/osgjs/issues/338/comments"},"review_comments":{"href":"https://api.github.com/repos/cedricpinson/osgjs/pulls/338/comments"},"review_comment":{"href":"https://api.github.com/repos/cedricpinson/osgjs/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/cedricpinson/osgjs/pulls/338/commits"},"statuses":{"href":"https://api.github.com/repos/cedricpinson/osgjs/statuses/53be60f281bc77927bec106cb018edeb909ea86c"}}}}