Skip to content

Commit

Permalink
Merge pull request #1454 from CesiumGS/fix-warnings
Browse files Browse the repository at this point in the history
Fix warnings in UE 5.2.
  • Loading branch information
j9liu committed Jun 17, 2024
2 parents 9a20e1a + 06a8612 commit b6b26aa
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 51 deletions.
2 changes: 1 addition & 1 deletion Source/CesiumRuntime/Private/CesiumCreditSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ void ACesiumCreditSystem::removeCreditsFromViewports() {
#endif

if (IsValid(CreditsWidget)) {
CreditsWidget->RemoveFromViewport();
CreditsWidget->RemoveFromParent();
}
}

Expand Down
80 changes: 30 additions & 50 deletions Source/CesiumRuntime/Private/CesiumSubLevelSwitcherComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,6 @@ void UCesiumSubLevelSwitcherComponent::SetTargetSubLevel(
}
}

#if ENGINE_VERSION_5_3_OR_HIGHER
#define StreamState ELevelStreamingState
#else
#define StreamState ULevelStreaming::ECurrentState
#endif

void UCesiumSubLevelSwitcherComponent::TickComponent(
float DeltaTime,
enum ELevelTick TickType,
Expand Down Expand Up @@ -140,29 +134,24 @@ void UCesiumSubLevelSwitcherComponent::TickComponent(

ULevelStreaming* pStreaming =
this->_getLevelStreamingForSubLevel(pSubLevel);
StreamState state =
IsValid(pStreaming)
#if ENGINE_VERSION_5_3_OR_HIGHER
? pStreaming->GetLevelStreamingState() //->GetCurrentState()
#else
? pStreaming->GetCurrentState()
#endif
: StreamState::Unloaded;
ELevelStreamingState state = IsValid(pStreaming)
? pStreaming->GetLevelStreamingState()
: ELevelStreamingState::Unloaded;

switch (state) {
case StreamState::Loading:
case StreamState::MakingInvisible:
case StreamState::MakingVisible:
case ELevelStreamingState::Loading:
case ELevelStreamingState::MakingInvisible:
case ELevelStreamingState::MakingVisible:
anyLevelsStillLoaded = true;
break;
case StreamState::FailedToLoad:
case StreamState::LoadedNotVisible:
case StreamState::LoadedVisible:
case ELevelStreamingState::FailedToLoad:
case ELevelStreamingState::LoadedNotVisible:
case ELevelStreamingState::LoadedVisible:
pSubLevel->UnloadLevelInstance();
anyLevelsStillLoaded = true;
break;
case StreamState::Removed:
case StreamState::Unloaded:
case ELevelStreamingState::Removed:
case ELevelStreamingState::Unloaded:
break;
}
}
Expand Down Expand Up @@ -211,13 +200,9 @@ void UCesiumSubLevelSwitcherComponent::_updateSubLevelStateGame() {
ULevelStreaming* pStreaming =
this->_getLevelStreamingForSubLevel(this->_pCurrent.Get());

StreamState state = StreamState::Unloaded;
ELevelStreamingState state = ELevelStreamingState::Unloaded;
if (IsValid(pStreaming)) {
#if ENGINE_VERSION_5_3_OR_HIGHER
state = pStreaming->GetLevelStreamingState();
#else
state = pStreaming->GetCurrentState();
#endif

} else if (this->_pCurrent->GetWorldAsset().IsNull()) {
// There is no level associated with the target at all, so mark it
Expand All @@ -226,9 +211,9 @@ void UCesiumSubLevelSwitcherComponent::_updateSubLevelStateGame() {
}

switch (state) {
case StreamState::Loading:
case StreamState::MakingInvisible:
case StreamState::MakingVisible:
case ELevelStreamingState::Loading:
case ELevelStreamingState::MakingInvisible:
case ELevelStreamingState::MakingVisible:
// Wait for these transitions to finish before doing anything further.
// TODO: maybe we can cancel these transitions somehow?
UE_LOG(
Expand All @@ -239,9 +224,9 @@ void UCesiumSubLevelSwitcherComponent::_updateSubLevelStateGame() {
*GetActorLabel(this->_pCurrent.Get()));
this->_isTransitioningSubLevels = true;
break;
case StreamState::FailedToLoad:
case StreamState::LoadedNotVisible:
case StreamState::LoadedVisible:
case ELevelStreamingState::FailedToLoad:
case ELevelStreamingState::LoadedNotVisible:
case ELevelStreamingState::LoadedVisible:
UE_LOG(
LogCesium,
Display,
Expand All @@ -250,8 +235,8 @@ void UCesiumSubLevelSwitcherComponent::_updateSubLevelStateGame() {
this->_isTransitioningSubLevels = true;
this->_pCurrent->UnloadLevelInstance();
break;
case StreamState::Removed:
case StreamState::Unloaded:
case ELevelStreamingState::Removed:
case ELevelStreamingState::Unloaded:
UE_LOG(
LogCesium,
Display,
Expand All @@ -278,24 +263,19 @@ void UCesiumSubLevelSwitcherComponent::_updateSubLevelStateGame() {
ULevelStreaming* pStreaming =
this->_getLevelStreamingForSubLevel(this->_pTarget.Get());

StreamState state = StreamState::Unloaded;
ELevelStreamingState state = ELevelStreamingState::Unloaded;
if (IsValid(pStreaming)) {
#if ENGINE_VERSION_5_3_OR_HIGHER
state = pStreaming->GetLevelStreamingState();
#else

state = pStreaming->GetCurrentState();
#endif
} else if (this->_pTarget.Get()->GetWorldAsset().IsNull()) {
// There is no level associated with the target at all, so mark it failed
// to load because this is as loaded as it will ever be.
state = StreamState::FailedToLoad;
state = ELevelStreamingState::FailedToLoad;
}

switch (state) {
case StreamState::Loading:
case StreamState::MakingInvisible:
case StreamState::MakingVisible:
case ELevelStreamingState::Loading:
case ELevelStreamingState::MakingInvisible:
case ELevelStreamingState::MakingVisible:
// Wait for these transitions to finish before doing anything further.
UE_LOG(
LogCesium,
Expand All @@ -305,9 +285,9 @@ void UCesiumSubLevelSwitcherComponent::_updateSubLevelStateGame() {
*GetActorLabel(this->_pTarget.Get()));
this->_isTransitioningSubLevels = true;
break;
case StreamState::FailedToLoad:
case StreamState::LoadedNotVisible:
case StreamState::LoadedVisible:
case ELevelStreamingState::FailedToLoad:
case ELevelStreamingState::LoadedNotVisible:
case ELevelStreamingState::LoadedVisible:
// Loading complete!
UE_LOG(
LogCesium,
Expand All @@ -324,8 +304,8 @@ void UCesiumSubLevelSwitcherComponent::_updateSubLevelStateGame() {
this->_isTransitioningSubLevels = true;
}
break;
case StreamState::Removed:
case StreamState::Unloaded:
case ELevelStreamingState::Removed:
case ELevelStreamingState::Unloaded:
// Start loading this level
UE_LOG(
LogCesium,
Expand Down

0 comments on commit b6b26aa

Please sign in to comment.