大概整理了一下StreamingLevel相关的流程
更新StreamingLevel状态
- World::Tick中的InternalUpdateStreamingState
UWorld::ProcessLevelStreamingVolumes(FVector* OverrideViewLocation)
遍历所有LevelStreamingObject然后对不同的LevelStreaming设置对应的状态UWorldComposition::UpdateStreamingState()
UWorldComposition::EvaluateWorldOriginLocation(*const* FVector& ViewLocation)
UWorldComposition::UpdateStreamingStateCinematic(*const* FVector* InLocations, int32 Num)
类似于UpdateStreamingState,如果需要在摄像模式下加载所有tile就会全部加载UWorldComposition::UpdateStreamingState(*const* FVector* InLocations, int32 Num)
UWorldComposition::GetDistanceVisibleLevels
获取实际的可见与不可见的LevelUWorldComposition::CommitTileStreamingState(UWorld* PersistentWorld, int32 TileIdx, *bool* bShouldBeLoaded, *bool* bShouldBeVisible, *bool* bShouldBlock, int32 LODIdx)
提交实际状态
WorldSubsystem->UpdateStreamingState
各个世界子系统的更新UWorldPartitionSubsystem::UpdateStreamingState
ULevelInstanceSubsystem::UpdateStreamingState
等待Streaming完成
UEngine::BlockTillLevelStreamingCompleted
UWorld::BlockTillLevelStreamingCompleted
UWorld::UpdateLevelStreaming()
FStreamingLevelPrivateAccessor::UpdateStreamingState
更新Streaming状态ULevelStreaming::UpdateStreamingState
根据当前状态更新ECurrentState::MakingVisible
UWorld::AddToWorld
增量更新组件ULevel::IncrementalUpdateComponents
ULevel::IncrementalRegisterComponents
ULevel::IncrementalRunConstructionScripts
ULevel::InitializeNetworkActors
初始化网络ActorULevel::RouteActorInitialize
调度Actor初始化 广播Level可视化事件、Level改变事件
ULevelStreaming::DiscardPendingUnloadLevel
FScene::OnLevelAddedToWorld
更新场景几何信息ECurrentState::MakingInvisible
FScene::OnLevelRemovedFromWorld
更新场景几何信息UWorld::RemoveFromWorld
增量反注册组件,增量调度Endplay,释放渲染相关资源ECurrentState::Loading:
等待就行ECurrentState::Unloaded:
- 目标:
ETargetState::LoadedNotVisible:
**ULevelStreaming::RequestLevel
这里进入加载流程 这里会切换到Loading状态或者LoadFiled**- 回调:
ULevelStreaming::AsyncLevelLoadComplete
Level状态设置为ECurrentState::LoadedNotVisible
ULevelStreaming::PrepareLoadedLevel
广播给各个StreamingManager 处理需要加载到另一个包的情况 处理取消以及失败的情况
- 回调:
- 目标:
ETargetState::UnloadedAndRemoved:
UWorld::RemoveStreamingLevel
- 目标:
ECurrentState::LoadedNotVisible:
- 目标:
ETargetState::LoadedVisible:
切换到ECurrentState::MakingVisible;
- 目标:
ETargetState::Unloaded:
ULevelStreaming::DiscardPendingUnloadLevel
ULevelStreaming::ClearLoadedLevel
ULevelStreaming::DiscardPendingUnloadLevel
- 目标:
ETargetState::LoadedNotVisible:
ULevelStreaming::DiscardPendingUnloadLevel
- 目标:
ECurrentState::LoadedVisible:
- 目标:
ETargetState::LoadedNotVisible:
状态直接切换到ECurrentState::MakingInvisible;
- 目标:
ETargetState::LoadedVisible:
ULevelStreaming::RequestLevel
- 目标:
ECurrentState::FailedToLoad:
返回失败
FStreamingLevelPrivateAccessor::DetermineTargetState
确定更新之后的状态ULevelStreaming::DetermineTargetState()
根据返回的当前状态决定目标状态
UE5中的变化
主要流程没有变化,UE5额外支持了Per Actor Per File。