| 957 | } |
| 958 | |
| 959 | Task* 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 | |
| 1003 | void ModelBase::CancelStreamingTasks() |
| 1004 | { |
nothing calls this directly
no test coverage detected