Skip to content

Commit

Permalink
Merge branch 'ue5-main' into upgrade-feature-metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
j9liu committed Aug 10, 2023
2 parents 03f070d + 00f19df commit bdcbb9a
Show file tree
Hide file tree
Showing 19 changed files with 222 additions and 50 deletions.
19 changes: 19 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,25 @@

- The "Place Georeference Origin Here" action on CesiumGeoreference is now undoable.
- Cesium Actors now have the "Is Spatially Loaded" flag disabled by default. When using World Partition, this is essential for some, such as `CesiumGeoreference`.
- The `CesiumCameraManager` instance to use with a `Cesium3DTileset` can now be specified with a property on the tileset. In addition to offering more flexibility, this avoids the work of finding the camera manager in the level every frame.
- Cesium Actors created with the Quick Add or Cesium ion panels are now created inside the active sub-level, if there is one.
- Cesium objects in sub-levels can now explicitly reference `ACesiumGeoreference`, `ACesiumCreditSystem`, and `ACesiumCameraManager` instances in the Persistent Level.

##### Fixes :wrench:

- Fixed a bug in `ACesiumSunSky` that could cause an error when it was created inside a sub-level.
- `ACesiumGeoreference`, `ACesiumCameraManager`, and `ACesiumCreditSystem` are now created in the Persistent Level, even if the object that triggered their automatic creation (such as `ACesium3DTileset`) exists in a sub-level. It is very rarely useful to have instances of these objects within a sub-level.
- An instance of `ACesiumCreditSystem` in a sub-level will no longer cause overlapping and broken-looking credits. However, we still recommend deleting credit system instances from sub-levels.

### v1.29.0 - 2023-08-01

##### Fixes :wrench:

- Fixed a bug introduced in v1.28.0 that prevented point clouds from rendering with attenuation.
- Fixed a bug where Google Photorealistic 3D Tiles would sometimes not render in Movie Render Queue.
- Fixed a bug that caused `UnrealLightmass` to crash when attempting to build lighting containing static meshes created by a `Cesium3DTileset`.

In addition to the above, this release updates [cesium-native](https://github.com/CesiumGS/cesium-native) from v0.25.1 to v0.26.0. See the [changelog](https://github.com/CesiumGS/cesium-native/blob/main/CHANGES.md) for a complete list of changes in cesium-native.

### v1.28.0 - 2023-07-03

Expand Down
4 changes: 2 additions & 2 deletions CesiumForUnreal.uplugin
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"FileVersion": 3,
"Version": 46,
"VersionName": "1.28.0",
"Version": 47,
"VersionName": "1.29.0",
"FriendlyName": "Cesium for Unreal",
"Description": "Unlock the 3D geospatial ecosystem in Unreal Engine with real-world 3D content and a high accuracy full-scale WGS84 globe.",
"Category": "Geospatial",
Expand Down
12 changes: 8 additions & 4 deletions Shaders/Private/CesiumPointAttenuationVertexFactory.ush
Original file line number Diff line number Diff line change
Expand Up @@ -235,15 +235,19 @@ float4 VertexFactoryGetPreviousWorldPosition(FVertexFactoryInput Input, FVertexF
}

float4 ApplyAttenuation(float4 WorldPosition, uint CornerIndex) {
// Unreal uses counter-clockwise winding order.
// These offsets generate the quad like so:
// 1 --- 2
// | / |
// 0 --- 3
// | \ |
// 1 --- 2
// Unreal uses counter-clockwise winding order, but Cesium models are created
// with a y-inverting transform. To compensate, we create the quad facing the
// wrong way, such that when the transform is applied, the quad faces the right
// way.

// Results in -0.5 for 0, 1 and 0.5 for 2, 3
float OffsetX = CornerIndex / 2 - 0.5;
float OffsetY = -0.5f;
if (CornerIndex == 0 || CornerIndex == 3) {
if (CornerIndex == 1 || CornerIndex == 2) {
OffsetY = 0.5;
}

Expand Down
20 changes: 17 additions & 3 deletions Source/CesiumEditor/Private/CesiumEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,13 @@ FCesiumEditorModule::FindFirstTilesetWithAssetID(int64_t assetID) {

for (TActorIterator<ACesium3DTileset> it(pCurrentWorld); !pTilesetActor && it;
++it) {
ACesium3DTileset* pActor = *it;

// The existing Actor must be in the current level. Because it's sometimes
// useful to add the same tileset to multiple sub-levels.
if (!IsValid(pActor) || pActor->GetLevel() != pCurrentLevel)
continue;

const Cesium3DTilesSelection::Tileset* pTileset = it->GetTileset();
if (pTileset && it->GetIonAssetID() == assetID) {
return *it;
Expand Down Expand Up @@ -573,7 +580,7 @@ AActor* GetFirstCurrentLevelActorWithClass(UClass* pActorClass) {
UWorld* pCurrentWorld = GEditor->GetEditorWorldContext().World();
ULevel* pCurrentLevel = pCurrentWorld->GetCurrentLevel();
for (TActorIterator<AActor> it(pCurrentWorld); it; ++it) {
if (it->GetClass() == pActorClass) {
if (it->GetClass() == pActorClass && it->GetLevel() == pCurrentLevel) {
return *it;
}
}
Expand Down Expand Up @@ -602,9 +609,16 @@ AActor* SpawnActorWithClass(UClass* actorClass) {
if (!actorClass) {
return nullptr;
}

UWorld* pCurrentWorld = GEditor->GetEditorWorldContext().World();
AActor* pNewActor = pCurrentWorld->SpawnActor<AActor>(actorClass);
return pNewActor;
ULevel* pCurrentLevel = pCurrentWorld->GetCurrentLevel();

return GEditor->AddActor(
pCurrentLevel,
actorClass,
FTransform(),
false,
RF_Transactional);
}
} // namespace

Expand Down
1 change: 1 addition & 0 deletions Source/CesiumRuntime/CesiumRuntime.Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ public CesiumRuntime(ReadOnlyTargetRules Target) : base(Target)
"draco",
"ktx_read",
//"MikkTSpace",
"meshoptimizer",
"modp_b64",
"s2geometry",
"spdlog",
Expand Down
69 changes: 57 additions & 12 deletions Source/CesiumRuntime/Private/Cesium3DTileset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ ACesium3DTileset::ACesium3DTileset()

ACesium3DTileset::~ACesium3DTileset() { this->DestroyTileset(); }

ACesiumGeoreference* ACesium3DTileset::GetGeoreference() const {
TSoftObjectPtr<ACesiumGeoreference> ACesium3DTileset::GetGeoreference() const {
return this->Georeference;
}

Expand All @@ -125,7 +125,8 @@ void ACesium3DTileset::SetMobility(EComponentMobility::Type NewMobility) {
}
}

void ACesium3DTileset::SetGeoreference(ACesiumGeoreference* NewGeoreference) {
void ACesium3DTileset::SetGeoreference(
TSoftObjectPtr<ACesiumGeoreference> NewGeoreference) {
this->Georeference = NewGeoreference;
this->InvalidateResolvedGeoreference();
this->ResolveGeoreference();
Expand All @@ -136,8 +137,8 @@ ACesiumGeoreference* ACesium3DTileset::ResolveGeoreference() {
return this->ResolvedGeoreference;
}

if (IsValid(this->Georeference)) {
this->ResolvedGeoreference = this->Georeference;
if (IsValid(this->Georeference.Get())) {
this->ResolvedGeoreference = this->Georeference.Get();
} else {
this->ResolvedGeoreference =
ACesiumGeoreference::GetDefaultGeoreference(this);
Expand All @@ -164,11 +165,12 @@ void ACesium3DTileset::InvalidateResolvedGeoreference() {
this->ResolvedGeoreference = nullptr;
}

ACesiumCreditSystem* ACesium3DTileset::GetCreditSystem() const {
TSoftObjectPtr<ACesiumCreditSystem> ACesium3DTileset::GetCreditSystem() const {
return this->CreditSystem;
}

void ACesium3DTileset::SetCreditSystem(ACesiumCreditSystem* NewCreditSystem) {
void ACesium3DTileset::SetCreditSystem(
TSoftObjectPtr<ACesiumCreditSystem> NewCreditSystem) {
this->CreditSystem = NewCreditSystem;
this->InvalidateResolvedCreditSystem();
this->ResolveCreditSystem();
Expand All @@ -179,8 +181,8 @@ ACesiumCreditSystem* ACesium3DTileset::ResolveCreditSystem() {
return this->ResolvedCreditSystem;
}

if (IsValid(this->CreditSystem)) {
this->ResolvedCreditSystem = this->CreditSystem;
if (IsValid(this->CreditSystem.Get())) {
this->ResolvedCreditSystem = this->CreditSystem.Get();
} else {
this->ResolvedCreditSystem =
ACesiumCreditSystem::GetDefaultCreditSystem(this);
Expand All @@ -197,6 +199,38 @@ void ACesium3DTileset::InvalidateResolvedCreditSystem() {
this->RefreshTileset();
}

TSoftObjectPtr<ACesiumCameraManager>
ACesium3DTileset::GetCameraManager() const {
return this->CameraManager;
}

void ACesium3DTileset::SetCameraManager(
TSoftObjectPtr<ACesiumCameraManager> NewCameraManager) {
this->CameraManager = NewCameraManager;
this->InvalidateResolvedCameraManager();
this->ResolveCameraManager();
}

ACesiumCameraManager* ACesium3DTileset::ResolveCameraManager() {
if (IsValid(this->ResolvedCameraManager)) {
return this->ResolvedCameraManager;
}

if (IsValid(this->CameraManager.Get())) {
this->ResolvedCameraManager = this->CameraManager.Get();
} else {
this->ResolvedCameraManager =
ACesiumCameraManager::GetDefaultCameraManager(this);
}

return this->ResolvedCameraManager;
}

void ACesium3DTileset::InvalidateResolvedCameraManager() {
this->ResolvedCameraManager = nullptr;
this->RefreshTileset();
}

void ACesium3DTileset::RefreshTileset() { this->DestroyTileset(); }

void ACesium3DTileset::TroubleshootToken() {
Expand Down Expand Up @@ -572,6 +606,10 @@ void ACesium3DTileset::UpdateTransformFromCesium() {
void ACesium3DTileset::BeginPlay() {
Super::BeginPlay();

this->ResolveGeoreference();
this->ResolveCameraManager();
this->ResolveCreditSystem();

this->LoadTileset();

// Search for level sequence.
Expand All @@ -598,6 +636,10 @@ void ACesium3DTileset::BeginPlay() {
}

void ACesium3DTileset::OnConstruction(const FTransform& Transform) {
this->ResolveGeoreference();
this->ResolveCameraManager();
this->ResolveCreditSystem();

this->LoadTileset();

// Hide all existing tiles. The still-visible ones will be shown next time we
Expand Down Expand Up @@ -944,8 +986,6 @@ void ACesium3DTileset::LoadTileset() {
this->_encodedMetadataDescription = {};
}

ACesiumCreditSystem* pCreditSystem = this->ResolveCreditSystem();

this->_cesiumViewExtension = cesiumViewExtension;

if (GetDefault<UCesiumRuntimeSettings>()
Expand All @@ -967,6 +1007,8 @@ void ACesium3DTileset::LoadTileset() {
this->BoundingVolumePoolComponent->initPool(this->OcclusionPoolSize);
}

ACesiumCreditSystem* pCreditSystem = this->ResolvedCreditSystem;

Cesium3DTilesSelection::TilesetExternals externals{
pAssetAccessor,
std::make_shared<UnrealResourcePreparer>(this),
Expand Down Expand Up @@ -1216,8 +1258,7 @@ std::vector<FCesiumCamera> ACesium3DTileset::GetCameras() const {
std::make_move_iterator(editorCameras.end()));
#endif

ACesiumCameraManager* pCameraManager =
ACesiumCameraManager::GetDefaultCameraManager(this->GetWorld());
ACesiumCameraManager* pCameraManager = this->ResolvedCameraManager;
if (pCameraManager) {
const TMap<int32, FCesiumCamera>& extraCameras =
pCameraManager->GetCameras();
Expand Down Expand Up @@ -1929,6 +1970,10 @@ void ACesium3DTileset::Tick(float DeltaTime) {

Super::Tick(DeltaTime);

this->ResolveGeoreference();
this->ResolveCameraManager();
this->ResolveCreditSystem();

UCesium3DTilesetRoot* pRoot = Cast<UCesium3DTilesetRoot>(this->RootComponent);
if (!pRoot) {
return;
Expand Down
4 changes: 3 additions & 1 deletion Source/CesiumRuntime/Private/CesiumCameraManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ FName ACesiumCameraManager::DEFAULT_CAMERAMANAGER_TAG =
actorIterator;
++actorIterator) {
AActor* actor = *actorIterator;
if (actor->ActorHasTag(DEFAULT_CAMERAMANAGER_TAG)) {
if (actor->GetLevel() == world->PersistentLevel &&
actor->ActorHasTag(DEFAULT_CAMERAMANAGER_TAG)) {
pCameraManager = Cast<ACesiumCameraManager>(actor);
break;
}
Expand All @@ -58,6 +59,7 @@ FName ACesiumCameraManager::DEFAULT_CAMERAMANAGER_TAG =
FActorSpawnParameters spawnParameters;
spawnParameters.SpawnCollisionHandlingOverride =
ESpawnActorCollisionHandlingMethod::AlwaysSpawn;
spawnParameters.OverrideLevel = world->PersistentLevel;
pCameraManager = world->SpawnActor<ACesiumCameraManager>(spawnParameters);
// Null check so the editor doesn't crash when it makes arbitrary calls to
// this function without a valid world context object.
Expand Down
25 changes: 24 additions & 1 deletion Source/CesiumRuntime/Private/CesiumCreditSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,20 @@ ACesiumCreditSystem* findValidDefaultCreditSystem(ULevel* Level) {
AActor* DefaultCreditSystem = *DefaultCreditSystemPtr;
return Cast<ACesiumCreditSystem>(DefaultCreditSystem);
}

bool checkIfInSubLevel(ACesiumCreditSystem* pCreditSystem) {
if (pCreditSystem->GetLevel() != pCreditSystem->GetWorld()->PersistentLevel) {
UE_LOG(
LogCesium,
Warning,
TEXT(
"CesiumCreditSystem should only exist in the Persistent Level. Adding it to a sub-level may cause credits to be lost."));
return true;
} else {
return false;
}
}

} // namespace

FName ACesiumCreditSystem::DEFAULT_CREDITSYSTEM_TAG =
Expand Down Expand Up @@ -105,7 +119,8 @@ ACesiumCreditSystem::GetDefaultCreditSystem(const UObject* WorldContextObject) {
actorIterator;
++actorIterator) {
AActor* actor = *actorIterator;
if (actor->ActorHasTag(DEFAULT_CREDITSYSTEM_TAG)) {
if (actor->GetLevel() == world->PersistentLevel &&
actor->ActorHasTag(DEFAULT_CREDITSYSTEM_TAG)) {
pCreditSystem = Cast<ACesiumCreditSystem>(actor);
break;
}
Expand All @@ -131,6 +146,7 @@ ACesiumCreditSystem::GetDefaultCreditSystem(const UObject* WorldContextObject) {
FActorSpawnParameters spawnParameters;
spawnParameters.SpawnCollisionHandlingOverride =
ESpawnActorCollisionHandlingMethod::AlwaysSpawn;
spawnParameters.OverrideLevel = world->PersistentLevel;
pCreditSystem = world->SpawnActor<ACesiumCreditSystem>(
Cast<UClass>(CesiumCreditSystemBP),
spawnParameters);
Expand Down Expand Up @@ -162,6 +178,10 @@ ACesiumCreditSystem::ACesiumCreditSystem()

void ACesiumCreditSystem::BeginPlay() {
Super::BeginPlay();

if (checkIfInSubLevel(this))
return;

this->updateCreditsViewport(true);
}

Expand All @@ -175,6 +195,9 @@ static const FName LevelEditorName("LevelEditor");
void ACesiumCreditSystem::OnConstruction(const FTransform& Transform) {
Super::OnConstruction(Transform);

if (checkIfInSubLevel(this))
return;

this->updateCreditsViewport(false);

#if WITH_EDITOR
Expand Down
4 changes: 3 additions & 1 deletion Source/CesiumRuntime/Private/CesiumGeoreference.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ ACesiumGeoreference::GetDefaultGeoreference(const UObject* WorldContextObject) {
actorIterator;
++actorIterator) {
AActor* actor = *actorIterator;
if (actor->ActorHasTag(DEFAULT_GEOREFERENCE_TAG)) {
if (actor->GetLevel() == world->PersistentLevel &&
actor->ActorHasTag(DEFAULT_GEOREFERENCE_TAG)) {
pGeoreference = Cast<ACesiumGeoreference>(actor);
break;
}
Expand All @@ -101,6 +102,7 @@ ACesiumGeoreference::GetDefaultGeoreference(const UObject* WorldContextObject) {
FActorSpawnParameters spawnParameters;
spawnParameters.SpawnCollisionHandlingOverride =
ESpawnActorCollisionHandlingMethod::AlwaysSpawn;
spawnParameters.OverrideLevel = world->PersistentLevel;
pGeoreference = world->SpawnActor<ACesiumGeoreference>(spawnParameters);
// Null check so the editor doesn't crash when it makes arbitrary calls to
// this function without a valid world context object.
Expand Down
9 changes: 5 additions & 4 deletions Source/CesiumRuntime/Private/CesiumGlobeAnchorComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,13 @@
// * Ignores `AdjustOrientationForGlobeWhenMoving` because the globe position is
// not changing.

ACesiumGeoreference* UCesiumGlobeAnchorComponent::GetGeoreference() const {
TSoftObjectPtr<ACesiumGeoreference>
UCesiumGlobeAnchorComponent::GetGeoreference() const {
return this->Georeference;
}

void UCesiumGlobeAnchorComponent::SetGeoreference(
ACesiumGeoreference* NewGeoreference) {
TSoftObjectPtr<ACesiumGeoreference> NewGeoreference) {
this->Georeference = NewGeoreference;
this->InvalidateResolvedGeoreference();
this->ResolveGeoreference();
Expand Down Expand Up @@ -177,8 +178,8 @@ ACesiumGeoreference* UCesiumGlobeAnchorComponent::ResolveGeoreference() {
return this->ResolvedGeoreference;
}

if (IsValid(this->Georeference)) {
this->ResolvedGeoreference = this->Georeference;
if (IsValid(this->Georeference.Get())) {
this->ResolvedGeoreference = this->Georeference.Get();
} else {
this->ResolvedGeoreference =
ACesiumGeoreference::GetDefaultGeoreference(this);
Expand Down
1 change: 1 addition & 0 deletions Source/CesiumRuntime/Private/CesiumGltfComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2107,6 +2107,7 @@ static void loadPrimitiveGameThreadPart(

pStaticMesh->AddMaterial(pMaterial);

pStaticMesh->SetLightingGuid();
pStaticMesh->InitResources();

// Set up RenderData bounds and LOD data
Expand Down
Loading

0 comments on commit bdcbb9a

Please sign in to comment.