MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / CreateStreamingTask

Method CreateStreamingTask

Source/Engine/Content/Assets/ModelBase.cpp:959–1001  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

957}
958
959Task* ModelBase::CreateStreamingTask(int32 residency)
960{
961 ScopeLock lock(Locker);
962
963 const int32 lodMax = GetLODsCount();
964 ASSERT(IsInitialized() && Math::IsInRange(residency, 0, lodMax) && _streamingTask == nullptr);
965 Task* result = nullptr;
966 const int32 lodCount = residency - GetCurrentResidency();
967
968 // Switch if go up or down with residency
969 if (lodCount > 0)
970 {
971 // Allow only to change LODs count by 1
972 ASSERT(Math::Abs(lodCount) == 1);
973
974 int32 lodIndex = HighestResidentLODIndex() - 1;
975
976 // Request LOD data
977 result = (Task*)RequestLODDataAsync(lodIndex);
978
979 // Add upload data task
980 _streamingTask = New<StreamModelLODTask>(this, lodIndex);
981 if (result)
982 result->ContinueWith(_streamingTask);
983 else
984 result = _streamingTask;
985 }
986 else
987 {
988 // Do the quick data release
989 Array<MeshBase*> meshes;
990 for (int32 i = HighestResidentLODIndex(); i < lodMax - residency; i++)
991 {
992 GetMeshes(meshes, i);
993 for (MeshBase* mesh : meshes)
994 mesh->Release();
995 }
996 _loadedLODs = residency;
997 ResidencyChanged();
998 }
999
1000 return result;
1001}
1002
1003void ModelBase::CancelStreamingTasks()
1004{

Callers

nothing calls this directly

Calls 6

IsInRangeFunction · 0.85
HighestResidentLODIndexFunction · 0.85
ContinueWithMethod · 0.80
IsInitializedFunction · 0.70
AbsFunction · 0.50
ReleaseMethod · 0.45

Tested by

no test coverage detected