-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cache pickposition #5169
Merged
+58
−3
Merged
Cache pickposition #5169
Changes from 6 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
c19e304
Scene.pickPosition cache implemented
5a5e386
Scene.pickPosition cache fixed for undefined results
f1eb982
Merge branch 'master' of https://github.com/AnalyticalGraphicsInc/ces…
7dbe7af
code fix belong to review
ca9943e
fixes according to code review and jshint
ateshuseyin 6221b4d
pickPosition cache code fix
ateshuseyin d6baa02
pickPosition cacheKey initiation
0286fa4
Merge branch 'master' of https://github.com/AnalyticalGraphicsInc/ces…
e1f1fd1
merge master
3f7f48d
Remove originaltransformWindowToDrawingBuffer
lilleyse b7037d0
pickPositionCacheDirty added
ateshuseyin 4354961
merge with master
ateshuseyin 8003650
Tweak
lilleyse 5ea9b54
Merge branch 'master' into cache-pickposition
lilleyse e92cebd
Revert webstorm settings
lilleyse File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -321,6 +321,8 @@ define([ | |
this._cameraStartFired = false; | ||
this._cameraMovedTime = undefined; | ||
|
||
this._pickPositionCache = {}; | ||
|
||
/** | ||
* Exceptions occurring in <code>render</code> are always caught in order to raise the | ||
* <code>renderError</code> event. If this property is true, the error is rethrown | ||
|
@@ -2523,6 +2525,8 @@ define([ | |
var scratchEyeTranslation = new Cartesian3(); | ||
|
||
function render(scene, time) { | ||
scene._pickPositionCache = {}; //clean cache | ||
|
||
if (!defined(time)) { | ||
time = JulianDate.now(); | ||
} | ||
|
@@ -2954,6 +2958,12 @@ define([ | |
} | ||
//>>includeEnd('debug'); | ||
|
||
var cacheKey; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
if (this._pickPositionCache.hasOwnProperty(cacheKey)){ | ||
return Cartesian3.clone(this._pickPositionCache[cacheKey], result); | ||
} | ||
|
||
var context = this._context; | ||
var uniformState = context.uniformState; | ||
|
||
|
@@ -3015,10 +3025,12 @@ define([ | |
uniformState.update(this.frameState); | ||
} | ||
|
||
this._pickPositionCache[cacheKey] = Cartesian3.clone(result); | ||
return result; | ||
} | ||
} | ||
|
||
this._pickPositionCache[cacheKey] = undefined; | ||
return undefined; | ||
}; | ||
|
||
|
@@ -3053,6 +3065,7 @@ define([ | |
var cart = projection.unproject(result, scratchPickPositionCartographic); | ||
ellipsoid.cartographicToCartesian(cart, result); | ||
} | ||
|
||
return result; | ||
}; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we avoid doing this allocation per frame? We are really careful about not doing allocation per vertex, per command, per primitive, etc., but we even try to avoid per frame allocations.
Instead, perhaps set a flag like
_pickPositionCacheDirty
totrue
. Then inpickPositionWorldCoordinates
, clear the cache and set dirty to false if it was true.