-
Notifications
You must be signed in to change notification settings - Fork 212
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
Add height-query function to Tileset #783
Conversation
…he intersection succeeded
Also reuse the loading queue from the normal view tile selection Seems to have a significant speed improvement. My tests went 6-8 seconds to 3 secs.
I believe this is now ready to merge. However, because I've now done a fair bit of work on it, it's probably a good idea to get someone else's eyes on it first. |
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.
@kring this looks good to me! I didn't look over the tests or the algorithm too closely, but I'm sure I can verify correctness when I look at the corresponding Unity / Unreal PRs.
Most of my comments are doc / understanding related. I'm pushing a commit that addresses some of these, but I wanted to leave some up for input. But none of these have to hold up the PR before the release!
* {@link SampleHeightResult::positions} is unchanged from the original input | ||
* height. | ||
*/ | ||
std::vector<bool> heightSampled; |
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.
When I read heightSampled
my brain first thinks "oh, this is the height that was sampled," instead of "this was whether the sample actually happened." What do you think of this alternative?
std::vector<bool> heightSampled; | |
std::vector<bool> sampleSuccessful; |
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.
Actually I kind of prefer sampleSuccess
more, since that's briefer.
Other suggestions I could think of are
successfulSample
successfullySampled
heightWasSampled
wasHeightChanged
/heightWasChanged
.
* @brief The positions and sampled heights. | ||
* | ||
* The longitudes and latitudes will match the values at the same index in the | ||
* original input positions. Each height will either be the height sampled | ||
* from the tileset at that position, or the original input height if the | ||
* height could not be sampled. To determine which, look at the value of | ||
* {@link SampleHeightResult::heightSampled} at the same index. |
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.
* @brief The positions and sampled heights. | |
* | |
* The longitudes and latitudes will match the values at the same index in the | |
* original input positions. Each height will either be the height sampled | |
* from the tileset at that position, or the original input height if the | |
* height could not be sampled. To determine which, look at the value of | |
* {@link SampleHeightResult::heightSampled} at the same index. | |
* @brief The positions and their sampled heights. | |
* | |
* For each resulting position, its longitude and latitude values will match | |
* values from its input. Its height will either be the height sampled from | |
* the tileset at that position, or the original input height if the sample | |
* was unsuccessful. To determine which, look at the value of | |
* {@link SampleHeightResult::sampleSuccessful} at the same index. |
Cesium3DTilesSelection/include/Cesium3DTilesSelection/SampleHeightResult.h
Outdated
Show resolved
Hide resolved
One thing I noticed while testing CesiumGS/cesium-unreal#1421: if the tileset is invalid (e.g., invalid ion asset ID), it never completes the async action, and the |
Co-authored-by: Janine Liu <[email protected]>
Co-authored-by: Janine Liu <[email protected]>
Co-authored-by: Janine Liu <[email protected]>
And add documentation for createLatentChildrenIfNecessary.
I believe I fixed this in this commit, but cesium-unreal wasn't updated to use it yet: I'll write a test in cesium-native for this case, though. |
Thanks for the review @j9liu, this should be ready for another look. |
Looks great, thanks @kring ! 😄 |
Adds new functionality to
Tileset
to enable terrain height queries.Builds on previous cesium-native work for ray / triangle and ray / gltf intersections.
Approach
To find the height at a latitude / longitude, we must first load the terrain data for this location, construct a ray at that coordinate pointing towards the center of the earth, then intersect all the content in the tile, using the closest hit as our discovered height.
Height queries can happen for tiles not selected from a camera, so we introduce a parallel tile loading strategy that builds on the same system. Just as we use a camera frustum for
_visitTileIfNeeded
, we use our new height query requests and callvisitHeightRequests
. This discovers which tiles are needed to load and adds them to the same priority queues that the camera-based tiles go to.Once all relevant tiles are loaded, we ray intersect against all of their contents.
Fixes #636
TO DO
addTileToLoadQueue
for tiles added from query traversalfindCandidateTiles
for additive-refined tilesets.Support for instanced modelsWrote an issue: Add support for height queries against instanced models #948Return all heights, not just the highestNot urgent at this time.