Add content deprecation system that auto-saves assets in Editor that use old data format
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
#include "Engine/Threading/Threading.h"
|
||||
#if USE_EDITOR
|
||||
#include "Engine/Core/Types/DataContainer.h"
|
||||
#include "Engine/Serialization/MemoryWriteStream.h"
|
||||
#endif
|
||||
#include "Engine/Content/Factories/BinaryAssetFactory.h"
|
||||
|
||||
@@ -44,7 +45,7 @@ Asset::LoadResult ParticleEmitterFunction::load()
|
||||
if (!surfaceChunk || !surfaceChunk->IsLoaded())
|
||||
return LoadResult::MissingDataChunk;
|
||||
MemoryReadStream stream(surfaceChunk->Get(), surfaceChunk->Size());
|
||||
if (Graph.Load(&stream, false))
|
||||
if (Graph.Load(&stream, USE_EDITOR))
|
||||
return LoadResult::Failed;
|
||||
for (int32 i = 0; i < Graph.Nodes.Count(); i++)
|
||||
{
|
||||
@@ -103,7 +104,7 @@ AssetChunksFlag ParticleEmitterFunction::getChunksToPreload() const
|
||||
return GET_CHUNK_FLAG(0);
|
||||
}
|
||||
|
||||
bool ParticleEmitterFunction::LoadSurface(ParticleEmitterGraphCPU& graph)
|
||||
bool ParticleEmitterFunction::LoadSurface(ParticleEmitterGraphCPU& graph, bool loadMeta)
|
||||
{
|
||||
if (WaitForLoaded())
|
||||
return true;
|
||||
@@ -114,7 +115,7 @@ bool ParticleEmitterFunction::LoadSurface(ParticleEmitterGraphCPU& graph)
|
||||
{
|
||||
const auto surfaceChunk = GetChunk(0);
|
||||
MemoryReadStream stream(surfaceChunk->Get(), surfaceChunk->Size());
|
||||
return graph.Load(&stream, false);
|
||||
return graph.Load(&stream, loadMeta);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
@@ -141,7 +142,7 @@ BytesContainer ParticleEmitterFunction::LoadSurface()
|
||||
|
||||
#if COMPILE_WITH_PARTICLE_GPU_GRAPH
|
||||
|
||||
bool ParticleEmitterFunction::LoadSurface(ParticleEmitterGraphGPU& graph)
|
||||
bool ParticleEmitterFunction::LoadSurface(ParticleEmitterGraphGPU& graph) const
|
||||
{
|
||||
if (WaitForLoaded())
|
||||
return true;
|
||||
@@ -178,19 +179,10 @@ void ParticleEmitterFunction::GetSignature(Array<StringView, FixedAllocation<32>
|
||||
}
|
||||
}
|
||||
|
||||
bool ParticleEmitterFunction::SaveSurface(BytesContainer& data)
|
||||
bool ParticleEmitterFunction::SaveSurface(const BytesContainer& data) const
|
||||
{
|
||||
// Wait for asset to be loaded or don't if last load failed
|
||||
if (LastLoadFailed())
|
||||
{
|
||||
LOG(Warning, "Saving asset that failed to load.");
|
||||
}
|
||||
else if (WaitForLoaded())
|
||||
{
|
||||
LOG(Error, "Asset loading failed. Cannot save it.");
|
||||
if (OnCheckSave())
|
||||
return true;
|
||||
}
|
||||
|
||||
ScopeLock lock(Locker);
|
||||
|
||||
// Set Visject Surface data
|
||||
@@ -210,4 +202,17 @@ bool ParticleEmitterFunction::SaveSurface(BytesContainer& data)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ParticleEmitterFunction::Save(const StringView& path)
|
||||
{
|
||||
if (OnCheckSave(path))
|
||||
return true;
|
||||
ScopeLock lock(Locker);
|
||||
MemoryWriteStream writeStream;
|
||||
if (Graph.Save(&writeStream, true))
|
||||
return true;
|
||||
BytesContainer data;
|
||||
data.Link(ToSpan(writeStream));
|
||||
return SaveSurface(data);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user