Merge pull request #5217 from larsbrubaker/main
When loading from zip it is important that we cache the assets
This commit is contained in:
commit
abd5ef3159
3 changed files with 22 additions and 4 deletions
|
|
@ -188,7 +188,7 @@ namespace MatterHackers.MatterControl
|
||||||
var fileNames = GetFileNamesFromMcx(fileLocation);
|
var fileNames = GetFileNamesFromMcx(fileLocation);
|
||||||
foreach (var file in fileNames)
|
foreach (var file in fileNames)
|
||||||
{
|
{
|
||||||
var fullPath = await Object3DExtensions.ResolveFilePath(file, null, CancellationToken.None);
|
var fullPath = Object3DExtensions.ResolveFilePath(file, null, CancellationToken.None);
|
||||||
if (File.Exists(fullPath))
|
if (File.Exists(fullPath))
|
||||||
{
|
{
|
||||||
hashCode = File.GetLastWriteTime(fullPath).ToString().GetLongHashCode(hashCode);
|
hashCode = File.GetLastWriteTime(fullPath).ToString().GetLongHashCode(hashCode);
|
||||||
|
|
|
||||||
|
|
@ -38,9 +38,11 @@ namespace MatterHackers.MatterControl
|
||||||
using MatterHackers.Agg.Platform;
|
using MatterHackers.Agg.Platform;
|
||||||
using MatterHackers.DataConverters3D;
|
using MatterHackers.DataConverters3D;
|
||||||
using MatterHackers.ImageProcessing;
|
using MatterHackers.ImageProcessing;
|
||||||
|
using MatterHackers.MatterControl.DataStorage;
|
||||||
using MatterHackers.MatterControl.DesignTools.Operations;
|
using MatterHackers.MatterControl.DesignTools.Operations;
|
||||||
using MatterHackers.MatterControl.Library;
|
using MatterHackers.MatterControl.Library;
|
||||||
using MatterHackers.RayTracer;
|
using MatterHackers.PolygonMesh.Processors;
|
||||||
|
using MatterHackers.RayTracer;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Loads IObject3D objects for mesh based ILibraryItems
|
/// Loads IObject3D objects for mesh based ILibraryItems
|
||||||
|
|
@ -90,7 +92,23 @@ namespace MatterHackers.MatterControl
|
||||||
if (contentStream != null)
|
if (contentStream != null)
|
||||||
{
|
{
|
||||||
// TODO: Wire up caching
|
// TODO: Wire up caching
|
||||||
loadedItem = Object3D.Load(contentStream.Stream, Path.GetExtension(streamInterface.FileName), CancellationToken.None, null /*itemCache*/, progressReporter);
|
var cacheContext = new CacheContext();
|
||||||
|
loadedItem = Object3D.Load(contentStream.Stream, Path.GetExtension(streamInterface.FileName), CancellationToken.None, cacheContext, progressReporter);
|
||||||
|
|
||||||
|
foreach(var meshItem in cacheContext.Meshes)
|
||||||
|
{
|
||||||
|
var meshPath = meshItem.Key;
|
||||||
|
if (!string.IsNullOrEmpty(meshPath)
|
||||||
|
&& meshItem.Value != null
|
||||||
|
&& meshItem.Value.Faces.Count > 0)
|
||||||
|
{
|
||||||
|
var assetsPath = Path.Combine(ApplicationDataStorage.Instance.ApplicationLibraryDataPath, "Assets", meshPath);
|
||||||
|
if (!File.Exists(assetsPath))
|
||||||
|
{
|
||||||
|
StlProcessing.Save(meshItem.Value, assetsPath, CancellationToken.None);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Set MeshPath for non-mcx content. Avoid on mcx to ensure serialization of children
|
// Set MeshPath for non-mcx content. Avoid on mcx to ensure serialization of children
|
||||||
if (loadedItem != null
|
if (loadedItem != null
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
Subproject commit f8a6ce095e4a653cb714b1816e00949722497b3e
|
Subproject commit d3202dd3aa31d18b9ca937daac5634d72fb2f7c7
|
||||||
Loading…
Add table
Add a link
Reference in a new issue