{"action":"created","comment":{"url":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/pulls/comments/77741570","id":77741570,"diff_hunk":"@@ -984,51 +988,60 @@ define([\n                 } else {\n                     // Tile does not meet SSE.\n \n+                    // Get visibility for all children. Check if any visible children are not loaded.\n+                    var allVisibleChildrenLoaded = true;\n+                    var someVisibleChildrenLoaded = false;\n+                    for (k = 0; k < childrenLength; ++k) {\n+                        child = children[k];\n+                        child.parentPlaneMask = planeMask;\n+                        child.planeMask = child.visibility(frameState.cullingVolume);\n+                        // If the child is visible...\n+                        if (child.planeMask !== CullingVolume.MASK_OUTSIDE) {\n+                            if (child.contentReady) {\n+                                someVisibleChildrenLoaded = true;\n+                            } else {\n+                                allVisibleChildrenLoaded = false;\n+                            }\n+                        }\n+                    }\n+\n                     // Only sort children by distance if we are going to refine to them\n                     // or slots are available to request them.  If we are just rendering the\n                     // tile (and can't make child requests because no slots are available)\n                     // then the children do not need to be sorted.\n \n-                    var allChildrenLoaded = t.numberOfChildrenWithoutContent === 0;\n-                    if (allChildrenLoaded || t.canRequestContent()) {\n+                    if (someVisibleChildrenLoaded || t.canRequestContent()) {\n                         // Distance is used for sorting now and for computing SSE when the tile comes off the stack.\n                         computeDistanceToCamera(children, frameState);\n \n                         // Sort children by distance for (1) request ordering, and (2) early-z\n                         children.sort(sortChildrenByDistanceToCamera);\n-// TODO: same TODO as above.\n                     }\n \n-                    if (!allChildrenLoaded) {\n-                        // Tile does not meet SSE.  Add its commands since it is the best we have and request its children.\n+                    if (!allVisibleChildrenLoaded) {","path":"Source/Scene/Cesium3DTileset.js","position":129,"original_position":129,"commit_id":"dd35d3566e83c35903a2b488e229fe7c3969caa9","original_commit_id":"dd35d3566e83c35903a2b488e229fe7c3969caa9","user":{"login":"pjcozzi","id":782098,"avatar_url":"https://avatars.githubusercontent.com/u/782098?v=3","gravatar_id":"","url":"https://api.github.com/users/pjcozzi","html_url":"https://github.com/pjcozzi","followers_url":"https://api.github.com/users/pjcozzi/followers","following_url":"https://api.github.com/users/pjcozzi/following{/other_user}","gists_url":"https://api.github.com/users/pjcozzi/gists{/gist_id}","starred_url":"https://api.github.com/users/pjcozzi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pjcozzi/subscriptions","organizations_url":"https://api.github.com/users/pjcozzi/orgs","repos_url":"https://api.github.com/users/pjcozzi/repos","events_url":"https://api.github.com/users/pjcozzi/events{/privacy}","received_events_url":"https://api.github.com/users/pjcozzi/received_events","type":"User","site_admin":false},"body":"Is there a comment here for the case empty parent case that we discussed offline today?","created_at":"2016-09-07T00:11:19Z","updated_at":"2016-09-07T00:11:19Z","html_url":"https://github.com/AnalyticalGraphicsInc/cesium/pull/4287#discussion_r77741570","pull_request_url":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/pulls/4287","_links":{"self":{"href":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/pulls/comments/77741570"},"html":{"href":"https://github.com/AnalyticalGraphicsInc/cesium/pull/4287#discussion_r77741570"},"pull_request":{"href":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/pulls/4287"}}},"pull_request":{"url":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/pulls/4287","id":84197474,"html_url":"https://github.com/AnalyticalGraphicsInc/cesium/pull/4287","diff_url":"https://github.com/AnalyticalGraphicsInc/cesium/pull/4287.diff","patch_url":"https://github.com/AnalyticalGraphicsInc/cesium/pull/4287.patch","issue_url":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/issues/4287","number":4287,"state":"open","locked":false,"title":"3D Tiles - refine to visible children in replacement refinement","user":{"login":"lilleyse","id":915398,"avatar_url":"https://avatars.githubusercontent.com/u/915398?v=3","gravatar_id":"","url":"https://api.github.com/users/lilleyse","html_url":"https://github.com/lilleyse","followers_url":"https://api.github.com/users/lilleyse/followers","following_url":"https://api.github.com/users/lilleyse/following{/other_user}","gists_url":"https://api.github.com/users/lilleyse/gists{/gist_id}","starred_url":"https://api.github.com/users/lilleyse/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lilleyse/subscriptions","organizations_url":"https://api.github.com/users/lilleyse/orgs","repos_url":"https://api.github.com/users/lilleyse/repos","events_url":"https://api.github.com/users/lilleyse/events{/privacy}","received_events_url":"https://api.github.com/users/lilleyse/received_events","type":"User","site_admin":false},"body":"For #3241 \r\n\r\n>Performance: optimize replacement refinement - instead of requesting all children when a tile needs to refine, request only the visible ones, and then allow refining a tile if all the required visible tiles are loaded (instead of all - including invisible - tiles). When the camera moves, and children that are not yet loaded are needed, either render the parent or render the available children and the parent with clipping.\r\n\r\nWhen not all visible children are loaded, I go with a third approach - render the parent and available children together, which is slightly noticeable in some cases but doesn't hurt visual quality since the other visible children usually load in soon after.\r\n\r\nSince the visibility check must now happen in the replacement refinement path, I save the result and don't recheck the visibility once the tile is popped from the stack. I modified the additive refinement path to do the same, store the `planeMask` now and use later.\r\n\r\nI also ended up reverting https://github.com/AnalyticalGraphicsInc/cesium/pull/4280 because otherwise the bounding volume check will happen twice, first in the `selectTiles` loop, and again in `selectTile`. This only applies to tiles without content bounding volumes, which is many replacement tilesets. As long as `contentsVisibility` is called after `visibility` is already checked, this should be ok.\r\n\r\nSome numbers:\r\n\r\nNow that we don't need to request all children, and instead just the visible ones, there are some memory improvements. In real world tilesets I've noticed between 50% to 86% savings in the number of loaded tiles. These numbers below are for a generic replacement refinement tileset:\r\n\r\n**Before**\r\n\r\n|View|Loaded|Rendered|Total|\r\n|-----|--------|-----------|-----|\r\n|**Horizon**|233|152|341|\r\n|**Straight Down**|135|53|341|\r\n\r\n**After**\r\n\r\n|View|Loaded|Rendered|Total\r\n|-----|----|-----------|--------|\r\n|**Horizon**|210|152|341|\r\n|**Straight Down**|86|53|341|\r\n\r\n","created_at":"2016-09-06T21:12:57Z","updated_at":"2016-09-07T00:11:19Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8c434ef31b6d743de9600114fc9837324e81daf6","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/pulls/4287/commits","review_comments_url":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/pulls/4287/comments","review_comment_url":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/pulls/comments{/number}","comments_url":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/issues/4287/comments","statuses_url":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/statuses/dd35d3566e83c35903a2b488e229fe7c3969caa9","head":{"label":"AnalyticalGraphicsInc:3d-tiles-refine-visible","ref":"3d-tiles-refine-visible","sha":"dd35d3566e83c35903a2b488e229fe7c3969caa9","user":{"login":"AnalyticalGraphicsInc","id":1490220,"avatar_url":"https://avatars.githubusercontent.com/u/1490220?v=3","gravatar_id":"","url":"https://api.github.com/users/AnalyticalGraphicsInc","html_url":"https://github.com/AnalyticalGraphicsInc","followers_url":"https://api.github.com/users/AnalyticalGraphicsInc/followers","following_url":"https://api.github.com/users/AnalyticalGraphicsInc/following{/other_user}","gists_url":"https://api.github.com/users/AnalyticalGraphicsInc/gists{/gist_id}","starred_url":"https://api.github.com/users/AnalyticalGraphicsInc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AnalyticalGraphicsInc/subscriptions","organizations_url":"https://api.github.com/users/AnalyticalGraphicsInc/orgs","repos_url":"https://api.github.com/users/AnalyticalGraphicsInc/repos","events_url":"https://api.github.com/users/AnalyticalGraphicsInc/events{/privacy}","received_events_url":"https://api.github.com/users/AnalyticalGraphicsInc/received_events","type":"Organization","site_admin":false},"repo":{"id":3606738,"name":"cesium","full_name":"AnalyticalGraphicsInc/cesium","owner":{"login":"AnalyticalGraphicsInc","id":1490220,"avatar_url":"https://avatars.githubusercontent.com/u/1490220?v=3","gravatar_id":"","url":"https://api.github.com/users/AnalyticalGraphicsInc","html_url":"https://github.com/AnalyticalGraphicsInc","followers_url":"https://api.github.com/users/AnalyticalGraphicsInc/followers","following_url":"https://api.github.com/users/AnalyticalGraphicsInc/following{/other_user}","gists_url":"https://api.github.com/users/AnalyticalGraphicsInc/gists{/gist_id}","starred_url":"https://api.github.com/users/AnalyticalGraphicsInc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AnalyticalGraphicsInc/subscriptions","organizations_url":"https://api.github.com/users/AnalyticalGraphicsInc/orgs","repos_url":"https://api.github.com/users/AnalyticalGraphicsInc/repos","events_url":"https://api.github.com/users/AnalyticalGraphicsInc/events{/privacy}","received_events_url":"https://api.github.com/users/AnalyticalGraphicsInc/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/AnalyticalGraphicsInc/cesium","description":"An open-source JavaScript library for world-class 3D globes and maps :earth_americas:","fork":false,"url":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium","forks_url":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/forks","keys_url":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/keys{/key_id}","collaborators_url":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/teams","hooks_url":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/hooks","issue_events_url":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/issues/events{/number}","events_url":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/events","assignees_url":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/assignees{/user}","branches_url":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/branches{/branch}","tags_url":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/tags","blobs_url":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/git/refs{/sha}","trees_url":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/git/trees{/sha}","statuses_url":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/statuses/{sha}","languages_url":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/languages","stargazers_url":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/stargazers","contributors_url":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/contributors","subscribers_url":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/subscribers","subscription_url":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/subscription","commits_url":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/commits{/sha}","git_commits_url":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/git/commits{/sha}","comments_url":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/comments{/number}","issue_comment_url":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/issues/comments{/number}","contents_url":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/contents/{+path}","compare_url":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/compare/{base}...{head}","merges_url":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/merges","archive_url":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/downloads","issues_url":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/issues{/number}","pulls_url":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/pulls{/number}","milestones_url":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/milestones{/number}","notifications_url":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/labels{/name}","releases_url":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/releases{/id}","deployments_url":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/deployments","created_at":"2012-03-02T22:27:14Z","updated_at":"2016-09-06T21:43:55Z","pushed_at":"2016-09-06T21:12:57Z","git_url":"git://github.com/AnalyticalGraphicsInc/cesium.git","ssh_url":"git@github.com:AnalyticalGraphicsInc/cesium.git","clone_url":"https://github.com/AnalyticalGraphicsInc/cesium.git","svn_url":"https://github.com/AnalyticalGraphicsInc/cesium","homepage":"http://cesiumjs.org/","size":403720,"stargazers_count":1655,"watchers_count":1655,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":815,"mirror_url":null,"open_issues_count":455,"forks":815,"open_issues":455,"watchers":1655,"default_branch":"master"}},"base":{"label":"AnalyticalGraphicsInc:3d-tiles","ref":"3d-tiles","sha":"12347d00a00afef1c244d62bd588145f27d3efe9","user":{"login":"AnalyticalGraphicsInc","id":1490220,"avatar_url":"https://avatars.githubusercontent.com/u/1490220?v=3","gravatar_id":"","url":"https://api.github.com/users/AnalyticalGraphicsInc","html_url":"https://github.com/AnalyticalGraphicsInc","followers_url":"https://api.github.com/users/AnalyticalGraphicsInc/followers","following_url":"https://api.github.com/users/AnalyticalGraphicsInc/following{/other_user}","gists_url":"https://api.github.com/users/AnalyticalGraphicsInc/gists{/gist_id}","starred_url":"https://api.github.com/users/AnalyticalGraphicsInc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AnalyticalGraphicsInc/subscriptions","organizations_url":"https://api.github.com/users/AnalyticalGraphicsInc/orgs","repos_url":"https://api.github.com/users/AnalyticalGraphicsInc/repos","events_url":"https://api.github.com/users/AnalyticalGraphicsInc/events{/privacy}","received_events_url":"https://api.github.com/users/AnalyticalGraphicsInc/received_events","type":"Organization","site_admin":false},"repo":{"id":3606738,"name":"cesium","full_name":"AnalyticalGraphicsInc/cesium","owner":{"login":"AnalyticalGraphicsInc","id":1490220,"avatar_url":"https://avatars.githubusercontent.com/u/1490220?v=3","gravatar_id":"","url":"https://api.github.com/users/AnalyticalGraphicsInc","html_url":"https://github.com/AnalyticalGraphicsInc","followers_url":"https://api.github.com/users/AnalyticalGraphicsInc/followers","following_url":"https://api.github.com/users/AnalyticalGraphicsInc/following{/other_user}","gists_url":"https://api.github.com/users/AnalyticalGraphicsInc/gists{/gist_id}","starred_url":"https://api.github.com/users/AnalyticalGraphicsInc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AnalyticalGraphicsInc/subscriptions","organizations_url":"https://api.github.com/users/AnalyticalGraphicsInc/orgs","repos_url":"https://api.github.com/users/AnalyticalGraphicsInc/repos","events_url":"https://api.github.com/users/AnalyticalGraphicsInc/events{/privacy}","received_events_url":"https://api.github.com/users/AnalyticalGraphicsInc/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/AnalyticalGraphicsInc/cesium","description":"An open-source JavaScript library for world-class 3D globes and maps :earth_americas:","fork":false,"url":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium","forks_url":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/forks","keys_url":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/keys{/key_id}","collaborators_url":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/teams","hooks_url":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/hooks","issue_events_url":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/issues/events{/number}","events_url":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/events","assignees_url":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/assignees{/user}","branches_url":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/branches{/branch}","tags_url":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/tags","blobs_url":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/git/refs{/sha}","trees_url":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/git/trees{/sha}","statuses_url":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/statuses/{sha}","languages_url":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/languages","stargazers_url":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/stargazers","contributors_url":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/contributors","subscribers_url":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/subscribers","subscription_url":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/subscription","commits_url":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/commits{/sha}","git_commits_url":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/git/commits{/sha}","comments_url":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/comments{/number}","issue_comment_url":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/issues/comments{/number}","contents_url":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/contents/{+path}","compare_url":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/compare/{base}...{head}","merges_url":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/merges","archive_url":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/downloads","issues_url":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/issues{/number}","pulls_url":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/pulls{/number}","milestones_url":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/milestones{/number}","notifications_url":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/labels{/name}","releases_url":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/releases{/id}","deployments_url":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/deployments","created_at":"2012-03-02T22:27:14Z","updated_at":"2016-09-06T21:43:55Z","pushed_at":"2016-09-06T21:12:57Z","git_url":"git://github.com/AnalyticalGraphicsInc/cesium.git","ssh_url":"git@github.com:AnalyticalGraphicsInc/cesium.git","clone_url":"https://github.com/AnalyticalGraphicsInc/cesium.git","svn_url":"https://github.com/AnalyticalGraphicsInc/cesium","homepage":"http://cesiumjs.org/","size":403720,"stargazers_count":1655,"watchers_count":1655,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":815,"mirror_url":null,"open_issues_count":455,"forks":815,"open_issues":455,"watchers":1655,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/pulls/4287"},"html":{"href":"https://github.com/AnalyticalGraphicsInc/cesium/pull/4287"},"issue":{"href":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/issues/4287"},"comments":{"href":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/issues/4287/comments"},"review_comments":{"href":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/pulls/4287/comments"},"review_comment":{"href":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/pulls/4287/commits"},"statuses":{"href":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/statuses/dd35d3566e83c35903a2b488e229fe7c3969caa9"}}}}
{"actor":{"display_login":"pjcozzi"}}