diff --git a/Source/Editor/Content/Proxy/CubeTextureProxy.cs b/Source/Editor/Content/Proxy/CubeTextureProxy.cs
index 137376673..efccfdbe5 100644
--- a/Source/Editor/Content/Proxy/CubeTextureProxy.cs
+++ b/Source/Editor/Content/Proxy/CubeTextureProxy.cs
@@ -47,8 +47,6 @@ namespace FlaxEditor.Content
_preview = new CubeTexturePreview(false);
InitAssetPreview(_preview);
}
-
- // TODO: disable streaming for asset during thumbnail rendering (and restore it after)
}
///
diff --git a/Source/Editor/Content/Proxy/IESProfileProxy.cs b/Source/Editor/Content/Proxy/IESProfileProxy.cs
index 4a9320a9f..6b6918567 100644
--- a/Source/Editor/Content/Proxy/IESProfileProxy.cs
+++ b/Source/Editor/Content/Proxy/IESProfileProxy.cs
@@ -50,16 +50,12 @@ namespace FlaxEditor.Content
Offsets = Margin.Zero,
};
}
-
- // TODO: disable streaming for asset during thumbnail rendering (and restore it after)
}
///
public override bool CanDrawThumbnail(ThumbnailRequest request)
{
- // Check if asset is streamed enough
- var asset = (IESProfile)request.Asset;
- return asset.ResidentMipLevels >= Mathf.Max(1, (int)(asset.MipLevels * ThumbnailsModule.MinimumRequiredResourcesQuality));
+ return ThumbnailsModule.HasMinimumQuality((IESProfile)request.Asset);
}
///
diff --git a/Source/Editor/Content/Proxy/MaterialInstanceProxy.cs b/Source/Editor/Content/Proxy/MaterialInstanceProxy.cs
index 672b02701..fc4fcdbc1 100644
--- a/Source/Editor/Content/Proxy/MaterialInstanceProxy.cs
+++ b/Source/Editor/Content/Proxy/MaterialInstanceProxy.cs
@@ -55,8 +55,6 @@ namespace FlaxEditor.Content
_preview = new MaterialPreview(false);
InitAssetPreview(_preview);
}
-
- // TODO: disable streaming for dependant assets during thumbnail rendering (and restore it after)
}
///
diff --git a/Source/Editor/Content/Proxy/MaterialProxy.cs b/Source/Editor/Content/Proxy/MaterialProxy.cs
index db0f9c810..4769ca548 100644
--- a/Source/Editor/Content/Proxy/MaterialProxy.cs
+++ b/Source/Editor/Content/Proxy/MaterialProxy.cs
@@ -99,8 +99,6 @@ namespace FlaxEditor.Content
_preview = new MaterialPreview(false);
InitAssetPreview(_preview);
}
-
- // TODO: disable streaming for dependant assets during thumbnail rendering (and restore it after)
}
///
diff --git a/Source/Editor/Content/Proxy/ModelProxy.cs b/Source/Editor/Content/Proxy/ModelProxy.cs
index 6dd9ea193..8b20073d8 100644
--- a/Source/Editor/Content/Proxy/ModelProxy.cs
+++ b/Source/Editor/Content/Proxy/ModelProxy.cs
@@ -78,8 +78,6 @@ namespace FlaxEditor.Content
};
InitAssetPreview(_preview);
}
-
- // TODO: disable streaming for asset during thumbnail rendering (and restore it after)
}
///
diff --git a/Source/Editor/Content/Proxy/PrefabProxy.cs b/Source/Editor/Content/Proxy/PrefabProxy.cs
index 191193c66..1c2e6f79f 100644
--- a/Source/Editor/Content/Proxy/PrefabProxy.cs
+++ b/Source/Editor/Content/Proxy/PrefabProxy.cs
@@ -113,8 +113,6 @@ namespace FlaxEditor.Content
_preview = new PrefabPreview(false);
InitAssetPreview(_preview);
}
-
- // TODO: disable streaming for asset during thumbnail rendering (and restore it after)
}
///
@@ -125,6 +123,7 @@ namespace FlaxEditor.Content
// Check if asset is streamed enough
var asset = (Prefab)request.Asset;
+ // TODO: check all prefab actors to have loaded resources (models/textures/etc.)
return asset.IsLoaded;
}
diff --git a/Source/Editor/Content/Proxy/SkinnedModelProxy.cs b/Source/Editor/Content/Proxy/SkinnedModelProxy.cs
index f9d043a21..95f2f7510 100644
--- a/Source/Editor/Content/Proxy/SkinnedModelProxy.cs
+++ b/Source/Editor/Content/Proxy/SkinnedModelProxy.cs
@@ -101,8 +101,6 @@ namespace FlaxEditor.Content
_preview = new AnimatedModelPreview(false);
InitAssetPreview(_preview);
}
-
- // TODO: disable streaming for asset during thumbnail rendering (and restore it after)
}
///
diff --git a/Source/Editor/Content/Proxy/SpriteAtlasProxy.cs b/Source/Editor/Content/Proxy/SpriteAtlasProxy.cs
index 2217be358..03a3ef147 100644
--- a/Source/Editor/Content/Proxy/SpriteAtlasProxy.cs
+++ b/Source/Editor/Content/Proxy/SpriteAtlasProxy.cs
@@ -50,16 +50,12 @@ namespace FlaxEditor.Content
Offsets = Margin.Zero,
};
}
-
- // TODO: disable streaming for asset during thumbnail rendering (and restore it after)
}
///
public override bool CanDrawThumbnail(ThumbnailRequest request)
{
- // Check if asset is streamed enough
- var asset = (SpriteAtlas)request.Asset;
- return asset.ResidentMipLevels >= Mathf.Max(1, (int)(asset.MipLevels * ThumbnailsModule.MinimumRequiredResourcesQuality));
+ return ThumbnailsModule.HasMinimumQuality((SpriteAtlas)request.Asset);
}
///
diff --git a/Source/Editor/Content/Proxy/TextureProxy.cs b/Source/Editor/Content/Proxy/TextureProxy.cs
index 361f4c3f6..45deb0b39 100644
--- a/Source/Editor/Content/Proxy/TextureProxy.cs
+++ b/Source/Editor/Content/Proxy/TextureProxy.cs
@@ -50,8 +50,6 @@ namespace FlaxEditor.Content
Offsets = Margin.Zero,
};
}
-
- // TODO: disable streaming for asset during thumbnail rendering (and restore it after)
}
///
diff --git a/Source/Editor/Content/Thumbnails/ThumbnailsModule.cs b/Source/Editor/Content/Thumbnails/ThumbnailsModule.cs
index 2fca96ba2..75ab79c4d 100644
--- a/Source/Editor/Content/Thumbnails/ThumbnailsModule.cs
+++ b/Source/Editor/Content/Thumbnails/ThumbnailsModule.cs
@@ -122,39 +122,43 @@ namespace FlaxEditor.Content.Thumbnails
internal static bool HasMinimumQuality(TextureBase asset)
{
+ // Don't block thumbnails queue when texture fails to stream in (eg. unsupported format)
if (asset.HasStreamingError)
- return true; // Don't block thumbnails queue when texture fails to stream in (eg. unsupported format)
+ return true;
+
+ // Check if enough mip levels are loaded
var mipLevels = asset.MipLevels;
var minMipLevels = Mathf.Min(mipLevels, 7);
- return asset.IsLoaded && asset.ResidentMipLevels >= Mathf.Max(minMipLevels, (int)(mipLevels * MinimumRequiredResourcesQuality));
+ if (asset.IsLoaded && asset.ResidentMipLevels >= Mathf.Max(minMipLevels, (int)(mipLevels * MinimumRequiredResourcesQuality)))
+ return true;
+
+ // Inform streaming about resource usage to stream it in for the thumbnail
+ asset.SetStreamingVisible();
+
+ return false;
}
- internal static bool HasMinimumQuality(Model asset)
+ internal static bool HasMinimumQuality(ModelBase asset)
{
if (!asset.IsLoaded)
return false;
- var lods = asset.LODs.Length;
+ var lods = asset.LODsCount;
var slots = asset.MaterialSlots;
- foreach (var slot in slots)
- {
- if (slot.Material && !HasMinimumQuality(slot.Material))
- return false;
- }
- return asset.LoadedLODs >= Mathf.Max(1, (int)(lods * MinimumRequiredResourcesQuality));
- }
- internal static bool HasMinimumQuality(SkinnedModel asset)
- {
- var lods = asset.LODs.Length;
- if (asset.IsLoaded && lods == 0)
- return true; // Skeleton-only model
- var slots = asset.MaterialSlots;
+ // Check if all materials are loaded (incl. dependent resources)
foreach (var slot in slots)
{
if (slot.Material && !HasMinimumQuality(slot.Material))
return false;
}
- return asset.LoadedLODs >= Mathf.Max(1, (int)(lods * MinimumRequiredResourcesQuality));
+
+ // Check if enough LODs are loaded
+ if (asset.LoadedLODs >= Mathf.Max(1, (int)(lods * MinimumRequiredResourcesQuality)))
+ return true;
+
+ // TODO: impl SetStreamingVisible for models similar to textures (ModelsStreamingHandler needs to use it)
+
+ return false;
}
internal static bool HasMinimumQuality(MaterialBase asset)
diff --git a/Source/Engine/Graphics/Textures/TextureBase.cpp b/Source/Engine/Graphics/Textures/TextureBase.cpp
index b5f020611..ddd0498bc 100644
--- a/Source/Engine/Graphics/Textures/TextureBase.cpp
+++ b/Source/Engine/Graphics/Textures/TextureBase.cpp
@@ -302,6 +302,12 @@ bool TextureBase::HasStreamingError() const
return _texture.Streaming.Error;
}
+void TextureBase::SetStreamingVisible() const
+{
+ if (_texture.GetTexture())
+ _texture.GetTexture()->LastRenderTime = Platform::GetTimeSeconds();
+}
+
BytesContainer TextureBase::GetMipData(int32 mipIndex, int32& rowPitch, int32& slicePitch)
{
BytesContainer result;
diff --git a/Source/Engine/Graphics/Textures/TextureBase.h b/Source/Engine/Graphics/Textures/TextureBase.h
index b8ae267c8..a461a1018 100644
--- a/Source/Engine/Graphics/Textures/TextureBase.h
+++ b/Source/Engine/Graphics/Textures/TextureBase.h
@@ -153,6 +153,11 @@ public:
///
API_PROPERTY() bool HasStreamingError() const;
+ ///
+ /// Sets the texture as visible this frame to inform streaming about usage which will stream boost its priority for the streaming.
+ ///
+ API_FUNCTION() void SetStreamingVisible() const;
+
public:
///
/// Gets the mip data.