Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into fix-raster-overlay-ub
Browse files Browse the repository at this point in the history
  • Loading branch information
kring committed Nov 21, 2024
2 parents c5a0957 + 41fee73 commit 52741cd
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 13 deletions.
11 changes: 11 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# Change Log

### ? - 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.
- `CesiumPolygonRasterOverlay` now references `CesiumCartographicPolygon` instances using `TSoftObjectPtr`, which allows, for example, a raster overlay in the persistent level to use a polygon in a sub-level.

### v2.10.0 - 2024-11-01

##### Additions :tada:
Expand Down
34 changes: 24 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 @@ -131,6 +131,12 @@ void ACesium3DTileset::SetMobility(EComponentMobility::Type NewMobility) {
void ACesium3DTileset::SampleHeightMostDetailed(
const TArray<FVector>& LongitudeLatitudeHeightArray,
FCesiumSampleHeightMostDetailedCallback OnHeightsSampled) {
// It's possible to call this function before a Tick happens, so make sure
// that the necessary variables are resolved.
this->ResolveGeoreference();
this->ResolveCameraManager();
this->ResolveCreditSystem();

if (this->_pTileset == nullptr) {
this->LoadTileset();
}
Expand Down Expand Up @@ -547,7 +553,6 @@ void ACesium3DTileset::PauseMovieSequencer() { this->StopMovieSequencer(); }

#if WITH_EDITOR
void ACesium3DTileset::OnFocusEditorViewportOnThis() {

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

void ACesium3DTileset::UpdateTransformFromCesium() {

const glm::dmat4& CesiumToUnreal =
this->GetCesiumTilesetToUnrealRelativeWorldTransform();
TArray<UCesiumGltfComponent*> gltfComponents;
Expand Down Expand Up @@ -922,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 @@ -1061,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 @@ -1278,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 @@ -1330,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 @@ -1368,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 @@ -1418,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 @@ -1494,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 @@ -1674,7 +1691,6 @@ ACesium3DTileset::CreateViewStateFromViewParameters(
const FCesiumCamera& camera,
const glm::dmat4& unrealWorldToTileset,
UCesiumEllipsoid* ellipsoid) {

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

Expand Down Expand Up @@ -1970,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 @@ -2008,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
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ UCesiumPolygonRasterOverlay::CreateOverlay(
std::vector<CartographicPolygon> polygons;
polygons.reserve(this->Polygons.Num());

for (ACesiumCartographicPolygon* pPolygon : this->Polygons) {
for (auto& pPolygon : this->Polygons) {
if (!pPolygon) {
continue;
}
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
2 changes: 1 addition & 1 deletion Source/CesiumRuntime/Public/CesiumPolygonRasterOverlay.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class CESIUMRUNTIME_API UCesiumPolygonRasterOverlay
* The polygons to rasterize for this overlay.
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cesium")
TArray<ACesiumCartographicPolygon*> Polygons;
TArray<TSoftObjectPtr<ACesiumCartographicPolygon>> Polygons;

/**
* Whether to invert the selection specified by the polygons.
Expand Down

0 comments on commit 52741cd

Please sign in to comment.