Skip to content
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 SampleHeightMostDetailed tileset load failure test #511

Merged
merged 3 commits into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions Tests/TestCesium3DTileset.cs
Original file line number Diff line number Diff line change
Expand Up @@ -126,4 +126,21 @@ public IEnumerator SampleHeightMostDetailedIndicatesNotSampledForPositionOutside
Assert.AreEqual(result.longitudeLatitudeHeightPositions[0].y, -33.87100, 1e-12);
Assert.AreEqual(result.longitudeLatitudeHeightPositions[0].z, 1.0, 1e-12);
}

[UnityTest]
public IEnumerator SampleHeightMostDetailedFailsIfTilesetFailsToLoad()
{
GameObject go = new GameObject();
go.name = "Invalid";
Cesium3DTileset tileset = go.AddComponent<Cesium3DTileset>();
tileset.tilesetSource = CesiumDataSource.FromUrl;
tileset.url = "http://localhost/notgonnawork";

Task<CesiumSampleHeightResult> task = tileset.SampleHeightMostDetailed(new double3(151.20972, -33.87100, 1.0));

yield return new WaitForTask(task);

Assert.NotNull(task.Exception);
Assert.IsTrue(task.Exception.Message.Contains("failed to load"));
}
}
4 changes: 3 additions & 1 deletion native~/Runtime/src/Cesium3DTilesetImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -412,13 +412,15 @@ Cesium3DTilesetImpl::SampleHeightMostDetailed(
position.z));
}

size_t count = positions.size();

CesiumAsync::Future<SampleHeightResult> future =
this->getTileset()
? this->getTileset()->sampleHeightMostDetailed(positions)
: getAsyncSystem().createResolvedFuture(
Cesium3DTilesSelection::SampleHeightResult{
std::move(positions),
std::vector<bool>(positions.size(), false),
std::vector<bool>(count, false),
{"Could not sample heights from tileset because it has not "
"been created."}});

Expand Down