Add content deprecation system that auto-saves assets in Editor that use old data format
This commit is contained in:
@@ -154,6 +154,16 @@ Asset::LoadResult ParticleEmitter::load()
|
||||
LOG(Warning, "Cannot load Particle Emitter GPU graph '{0}'.", GetPath());
|
||||
return LoadResult::CannotLoadData;
|
||||
}
|
||||
if (ContentDeprecated::Clear())
|
||||
{
|
||||
// If encountered any deprecated data when loading graph then serialize it
|
||||
MemoryWriteStream writeStream(1024);
|
||||
if (!Graph.Save(&writeStream, true))
|
||||
{
|
||||
surfaceChunk->Data.Copy(ToSpan(writeStream));
|
||||
ContentDeprecated::Clear();
|
||||
}
|
||||
}
|
||||
generator.AddGraph(graph);
|
||||
|
||||
// Get chunk with material parameters
|
||||
@@ -199,7 +209,7 @@ Asset::LoadResult ParticleEmitter::load()
|
||||
|
||||
// Save to file
|
||||
#if USE_EDITOR
|
||||
if (Save())
|
||||
if (SaveShaderAsset())
|
||||
{
|
||||
LOG(Error, "Cannot save \'{0}\'", ToString());
|
||||
return LoadResult::Failed;
|
||||
@@ -318,10 +328,6 @@ void ParticleEmitter::OnDependencyModified(BinaryAsset* asset)
|
||||
Reload();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if USE_EDITOR
|
||||
|
||||
void ParticleEmitter::InitCompilationOptions(ShaderCompilationOptions& options)
|
||||
{
|
||||
// Base
|
||||
@@ -377,19 +383,10 @@ BytesContainer ParticleEmitter::LoadSurface(bool createDefaultIfMissing)
|
||||
|
||||
#if USE_EDITOR
|
||||
|
||||
bool ParticleEmitter::SaveSurface(BytesContainer& data)
|
||||
bool ParticleEmitter::SaveSurface(const BytesContainer& data)
|
||||
{
|
||||
// Wait for asset to be loaded or don't if last load failed (eg. by shader source compilation error)
|
||||
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);
|
||||
|
||||
// Release all chunks
|
||||
@@ -406,7 +403,7 @@ bool ParticleEmitter::SaveSurface(BytesContainer& data)
|
||||
ASSERT(visjectSurfaceChunk != nullptr);
|
||||
visjectSurfaceChunk->Data.Copy(data);
|
||||
|
||||
if (Save())
|
||||
if (SaveShaderAsset())
|
||||
{
|
||||
LOG(Error, "Cannot save \'{0}\'", ToString());
|
||||
return true;
|
||||
@@ -420,4 +417,23 @@ bool ParticleEmitter::SaveSurface(BytesContainer& data)
|
||||
return false;
|
||||
}
|
||||
|
||||
void ParticleEmitter::GetReferences(Array<Guid>& assets, Array<String>& files) const
|
||||
{
|
||||
BinaryAsset::GetReferences(assets, files);
|
||||
Graph.GetReferences(assets);
|
||||
}
|
||||
|
||||
bool ParticleEmitter::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