// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
#pragma once
#include "../BinaryAsset.h"
#include "Engine/Animations/Graph/AnimGraph.h"
///
/// The Animation Graph is used to evaluate a final pose for the animated model for the current frame.
///
API_CLASS(NoSpawn) class FLAXENGINE_API AnimationGraph : public BinaryAsset
{
DECLARE_BINARY_ASSET_HEADER(AnimationGraph, 1);
public:
///
/// The animation graph.
///
AnimGraph Graph;
///
/// The animation graph runtime executor.
///
AnimGraphExecutor GraphExecutor;
public:
///
/// Gets the base model asset used for the animation preview and the skeleton layout source.
///
/// The base model.
API_PROPERTY() SkinnedModel* GetBaseModel() const
{
return Graph.BaseModel.Get();
}
///
/// Tries to load surface graph from the asset.
///
/// The surface data or empty if failed to load it.
API_FUNCTION() BytesContainer LoadSurface();
#if USE_EDITOR
///
/// Updates the animation graph surface (save new one, discard cached data, reload asset).
///
/// Stream with graph data.
/// True if cannot save it, otherwise false.
API_FUNCTION() bool SaveSurface(BytesContainer& data);
private:
void FindDependencies(AnimGraphBase* graph);
#endif
public:
// [BinaryAsset]
#if USE_EDITOR
void GetReferences(Array& output) const override
{
// Base
BinaryAsset::GetReferences(output);
Graph.GetReferences(output);
}
#endif
protected:
// [BinaryAsset]
LoadResult load() override;
void unload(bool isReloading) override;
AssetChunksFlag getChunksToPreload() const override;
#if USE_EDITOR
void OnDependencyModified(BinaryAsset* asset) override;
#endif
};