Build orthographic thumbnails for large content
This commit is contained in:
parent
cead79bb42
commit
cc9d986e4b
2 changed files with 16 additions and 4 deletions
|
|
@ -49,8 +49,10 @@ namespace MatterHackers.MatterControl
|
|||
private static readonly bool Is32Bit = IntPtr.Size == 4;
|
||||
private static readonly Point2D BigRenderSize = new Point2D(460, 460);
|
||||
|
||||
// TODO: Trying out an 8 MB mesh max for thumbnail generation
|
||||
private long MaxFileSizeForTracing = 8 * 1000 * 1000;
|
||||
// For 32 bit max size to ray trace is 8 MB mesh for 64 bit the max size is 40 MB.
|
||||
private long MaxFileSizeForTracing => Is32Bit ? 8 * 1000 * 1000 : 40 * 1000 * 1000;
|
||||
|
||||
private long MaxFileSizeForThumbnail => Is32Bit ? 16 * 1000 * 1000 : 100 * 1000 * 1000;
|
||||
|
||||
public Task<IObject3D> CreateItem(ILibraryItem item, Action<double, string> progressReporter)
|
||||
{
|
||||
|
|
@ -105,11 +107,13 @@ namespace MatterHackers.MatterControl
|
|||
{
|
||||
IObject3D object3D = null;
|
||||
|
||||
long fileSize = 0;
|
||||
if (item is ILibraryAssetStream contentModel
|
||||
// Only load the stream if it's available - prevents download of internet content simply for thumbnails
|
||||
&& contentModel.LocalContentExists
|
||||
&& (!Is32Bit || contentModel.FileSize < MaxFileSizeForTracing))
|
||||
&& contentModel.FileSize < MaxFileSizeForThumbnail)
|
||||
{
|
||||
fileSize = contentModel.FileSize;
|
||||
// TODO: Wire up limits for thumbnail generation. If content is too big, return null allowing the thumbnail to fall back to content default
|
||||
object3D = await contentModel.CreateContent();
|
||||
}
|
||||
|
|
@ -122,6 +126,14 @@ namespace MatterHackers.MatterControl
|
|||
{
|
||||
bool RenderOrthographic = UserSettings.Instance.get(UserSettingsKey.ThumbnailRenderingMode) == "orthographic";
|
||||
|
||||
// if we are tracing and the file is too big
|
||||
if(!RenderOrthographic
|
||||
&& fileSize > MaxFileSizeForTracing)
|
||||
{
|
||||
// switch to orthographic
|
||||
RenderOrthographic = true;
|
||||
}
|
||||
|
||||
var thumbnail = ThumbnailEngine.Generate(
|
||||
object3D,
|
||||
RenderOrthographic ? RenderType.ORTHOGROPHIC : RenderType.RAY_TRACE,
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit b1de779ab7eef1c5a29ec4bb5a2198ae7385197e
|
||||
Subproject commit 9d4a2ac1a2a1fc44ecf5a551cde59db213c334de
|
||||
Loading…
Add table
Add a link
Reference in a new issue