Skip to content

Commit

Permalink
Merge pull request #1555 from jqntn/ellipsoid-tileset
Browse files Browse the repository at this point in the history
Add support for ellipsoid tileset loader
  • Loading branch information
kring authored Nov 21, 2024
2 parents 27e8740 + f230317 commit 41fee73
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 11 deletions.
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

### ? - 2024-12-02

##### Additions :tada:

- Added a "From Ellipsoid" option to `Cesium3DTileset` to generate a tileset by tesselating the surface of the ellipsoid, producing a simple globe tileset without terrain features.

##### Fixes :wrench:

- Fixed a crash that could occur when using `SampleHeightMostDetailed` on a `Cesium3DTileset` with a raster overlay.
Expand Down
28 changes: 18 additions & 10 deletions Source/CesiumRuntime/Private/Cesium3DTileset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "Async/Async.h"
#include "Camera/CameraTypes.h"
#include "Camera/PlayerCameraManager.h"
#include "Cesium3DTilesSelection/EllipsoidTilesetLoader.h"
#include "Cesium3DTilesSelection/IPrepareRendererResources.h"
#include "Cesium3DTilesSelection/Tile.h"
#include "Cesium3DTilesSelection/TilesetLoadFailureDetails.h"
Expand Down Expand Up @@ -93,7 +94,6 @@ ACesium3DTileset::ACesium3DTileset()
_beforeMovieUseLodTransitions{true},

_tilesetsBeingDestroyed(0) {

PrimaryActorTick.bCanEverTick = true;
PrimaryActorTick.TickGroup = ETickingGroup::TG_PostUpdateWork;

Expand Down Expand Up @@ -553,7 +553,6 @@ void ACesium3DTileset::PauseMovieSequencer() { this->StopMovieSequencer(); }

#if WITH_EDITOR
void ACesium3DTileset::OnFocusEditorViewportOnThis() {

UE_LOG(
LogCesium,
Verbose,
Expand Down Expand Up @@ -674,7 +673,6 @@ ACesium3DTileset::GetCesiumTilesetToUnrealRelativeWorldTransform() const {
}

void ACesium3DTileset::UpdateTransformFromCesium() {

const glm::dmat4& CesiumToUnreal =
this->GetCesiumTilesetToUnrealRelativeWorldTransform();
TArray<UCesiumGltfComponent*> gltfComponents;
Expand Down Expand Up @@ -928,7 +926,6 @@ class UnrealResourcePreparer
virtual void* prepareRasterInMainThread(
CesiumRasterOverlays::RasterOverlayTile& rasterTile,
void* pLoadThreadResult) override {

TUniquePtr<CesiumTextureUtility::LoadedTextureResult> pLoadedTexture{
static_cast<CesiumTextureUtility::LoadedTextureResult*>(
pLoadThreadResult)};
Expand Down Expand Up @@ -1067,15 +1064,13 @@ void ACesium3DTileset::UpdateLoadStatus() {
}

namespace {

const TSharedRef<CesiumViewExtension, ESPMode::ThreadSafe>&
getCesiumViewExtension() {
static TSharedRef<CesiumViewExtension, ESPMode::ThreadSafe>
cesiumViewExtension =
GEngine->ViewExtensions->NewExtension<CesiumViewExtension>();
return cesiumViewExtension;
}

} // namespace

void ACesium3DTileset::LoadTileset() {
Expand Down Expand Up @@ -1284,6 +1279,14 @@ void ACesium3DTileset::LoadTileset() {
options.contentOptions.applyTextureTransform = false;

switch (this->TilesetSource) {
case ETilesetSource::FromEllipsoid:
UE_LOG(LogCesium, Log, TEXT("Loading tileset from ellipsoid"));
this->_pTileset = TUniquePtr<Cesium3DTilesSelection::Tileset>(
Cesium3DTilesSelection::EllipsoidTilesetLoader::createTileset(
externals,
options)
.release());
break;
case ETilesetSource::FromUrl:
UE_LOG(LogCesium, Log, TEXT("Loading tileset from URL %s"), *this->Url);
this->_pTileset = MakeUnique<Cesium3DTilesSelection::Tileset>(
Expand Down Expand Up @@ -1336,6 +1339,9 @@ void ACesium3DTileset::LoadTileset() {
}

switch (this->TilesetSource) {
case ETilesetSource::FromEllipsoid:
UE_LOG(LogCesium, Log, TEXT("Loading tileset from ellipsoid done"));
break;
case ETilesetSource::FromUrl:
UE_LOG(
LogCesium,
Expand Down Expand Up @@ -1374,6 +1380,9 @@ void ACesium3DTileset::DestroyTileset() {
}

switch (this->TilesetSource) {
case ETilesetSource::FromEllipsoid:
UE_LOG(LogCesium, Verbose, TEXT("Destroying tileset from ellipsoid"));
break;
case ETilesetSource::FromUrl:
UE_LOG(
LogCesium,
Expand Down Expand Up @@ -1424,6 +1433,9 @@ void ACesium3DTileset::DestroyTileset() {
this->_pTileset.Reset();

switch (this->TilesetSource) {
case ETilesetSource::FromEllipsoid:
UE_LOG(LogCesium, Verbose, TEXT("Destroying tileset from ellipsoid done"));
break;
case ETilesetSource::FromUrl:
UE_LOG(
LogCesium,
Expand Down Expand Up @@ -1500,7 +1512,6 @@ std::vector<FCesiumCamera> ACesium3DTileset::GetPlayerCameras() const {
for (auto playerControllerIt = pWorld->GetPlayerControllerIterator();
playerControllerIt;
playerControllerIt++) {

const TWeakObjectPtr<APlayerController> pPlayerController =
*playerControllerIt;
if (pPlayerController == nullptr) {
Expand Down Expand Up @@ -1680,7 +1691,6 @@ ACesium3DTileset::CreateViewStateFromViewParameters(
const FCesiumCamera& camera,
const glm::dmat4& unrealWorldToTileset,
UCesiumEllipsoid* ellipsoid) {

double horizontalFieldOfView =
FMath::DegreesToRadians(camera.FieldOfViewDegrees);

Expand Down Expand Up @@ -1976,7 +1986,6 @@ void ACesium3DTileset::updateLastViewUpdateResultState(
check(Georeference);

for (Cesium3DTilesSelection::Tile* tile : result.tilesToRenderThisFrame) {

CesiumGeometry::OrientedBoundingBox obb =
Cesium3DTilesSelection::getOrientedBoundingBoxFromBoundingVolume(
tile->getBoundingVolume(),
Expand Down Expand Up @@ -2014,7 +2023,6 @@ void ACesium3DTileset::updateLastViewUpdateResultState(
result.tilesWaitingForOcclusionResults !=
this->_lastTilesWaitingForOcclusionResults ||
result.maxDepthVisited != this->_lastMaxDepthVisited) {

this->_lastTilesRendered = result.tilesToRenderThisFrame.size();
this->_lastWorkerThreadTileLoadQueueLength =
result.workerThreadTileLoadQueueLength;
Expand Down
7 changes: 6 additions & 1 deletion Source/CesiumRuntime/Public/Cesium3DTileset.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,12 @@ enum class ETilesetSource : uint8 {
/**
* The tileset will be loaded from the specified Url.
*/
FromUrl UMETA(DisplayName = "From Url")
FromUrl UMETA(DisplayName = "From Url"),

/**
* The tileset will be loaded from the georeference ellipsoid.
*/
FromEllipsoid UMETA(DisplayName = "From Ellipsoid")
};

UENUM(BlueprintType)
Expand Down

0 comments on commit 41fee73

Please sign in to comment.