Add memory usage info to Animation details
This commit is contained in:
@@ -75,6 +75,7 @@ namespace FlaxEditor.Windows.Assets
|
||||
group.Label("Frames: " + info.FramesCount);
|
||||
group.Label("Channels: " + info.ChannelsCount);
|
||||
group.Label("Keyframes: " + info.KeyframesCount);
|
||||
group.Label("Memory Usage: " + Utilities.Utils.FormatBytesCount(info.MemoryUsage));
|
||||
}
|
||||
|
||||
// Import Settings
|
||||
|
||||
@@ -564,7 +564,6 @@ public:
|
||||
/// <summary>
|
||||
/// Gets the keyframes collection (for read-only).
|
||||
/// </summary>
|
||||
/// <returns>The keyframes.</returns>
|
||||
FORCE_INLINE const KeyFrameCollection& GetKeyframes() const
|
||||
{
|
||||
return _keyframes;
|
||||
@@ -573,7 +572,6 @@ public:
|
||||
/// <summary>
|
||||
/// Gets the keyframes collection.
|
||||
/// </summary>
|
||||
/// <returns>The keyframes.</returns>
|
||||
FORCE_INLINE KeyFrameCollection& GetKeyframes()
|
||||
{
|
||||
return _keyframes;
|
||||
@@ -582,7 +580,6 @@ public:
|
||||
/// <summary>
|
||||
/// Determines whether this curve is empty (has no keyframes).
|
||||
/// </summary>
|
||||
/// <returns><c>true</c> if this curve is empty; otherwise, <c>false</c>.</returns>
|
||||
FORCE_INLINE bool IsEmpty() const
|
||||
{
|
||||
return _keyframes.IsEmpty();
|
||||
|
||||
@@ -21,13 +21,23 @@ Animation::Animation(const SpawnParams& params, const AssetInfo* info)
|
||||
|
||||
Animation::InfoData Animation::GetInfo() const
|
||||
{
|
||||
ScopeLock lock(Locker);
|
||||
InfoData info;
|
||||
info.MemoryUsage = sizeof(Animation);
|
||||
if (IsLoaded())
|
||||
{
|
||||
info.Length = Data.GetLength();
|
||||
info.FramesCount = (int32)Data.Duration;
|
||||
info.ChannelsCount = Data.Channels.Count();
|
||||
info.KeyframesCount = Data.GetKeyframesCount();
|
||||
info.MemoryUsage += Data.Channels.Capacity() * sizeof(NodeAnimationData);
|
||||
for (auto& e : Data.Channels)
|
||||
{
|
||||
info.MemoryUsage += (e.NodeName.Length() + 1) * sizeof(Char);
|
||||
info.MemoryUsage += e.Position.GetKeyframes().Capacity() * sizeof(LinearCurveKeyframe<Vector3>);
|
||||
info.MemoryUsage += e.Rotation.GetKeyframes().Capacity() * sizeof(LinearCurveKeyframe<Quaternion>);
|
||||
info.MemoryUsage += e.Scale.GetKeyframes().Capacity() * sizeof(LinearCurveKeyframe<Vector3>);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -36,6 +46,9 @@ Animation::InfoData Animation::GetInfo() const
|
||||
info.ChannelsCount = 0;
|
||||
info.KeyframesCount = 0;
|
||||
}
|
||||
info.MemoryUsage += MappingCache.Capacity() * (sizeof(void*) + sizeof(NodeToChannel) + 1);
|
||||
for (auto& e : MappingCache)
|
||||
info.MemoryUsage += e.Value.Capacity() * sizeof(int32);
|
||||
return info;
|
||||
}
|
||||
|
||||
|
||||
@@ -15,8 +15,6 @@ API_CLASS(NoSpawn) class FLAXENGINE_API Animation : public BinaryAsset
|
||||
{
|
||||
DECLARE_BINARY_ASSET_HEADER(Animation, 1);
|
||||
|
||||
public:
|
||||
|
||||
/// <summary>
|
||||
/// Contains basic information about the animation asset contents.
|
||||
/// </summary>
|
||||
@@ -43,6 +41,11 @@ public:
|
||||
/// The total amount of keyframes in the animation tracks.
|
||||
/// </summary>
|
||||
API_FIELD() int32 KeyframesCount;
|
||||
|
||||
/// <summary>
|
||||
/// The estimated memory usage (in bytes) of the animation (all tracks and keyframes size in memory).
|
||||
/// </summary>
|
||||
API_FIELD() int32 MemoryUsage;
|
||||
};
|
||||
|
||||
public:
|
||||
@@ -68,7 +71,6 @@ public:
|
||||
/// <summary>
|
||||
/// Gets the length of the animation (in seconds).
|
||||
/// </summary>
|
||||
/// <returns>The length in seconds.</returns>
|
||||
API_PROPERTY() float GetLength() const
|
||||
{
|
||||
return IsLoaded() ? Data.GetLength() : 0.0f;
|
||||
@@ -77,7 +79,6 @@ public:
|
||||
/// <summary>
|
||||
/// Gets the duration of the animation (in frames).
|
||||
/// </summary>
|
||||
/// <returns>The duration in frames.</returns>
|
||||
API_PROPERTY() float GetDuration() const
|
||||
{
|
||||
return (float)Data.Duration;
|
||||
@@ -86,7 +87,6 @@ public:
|
||||
/// <summary>
|
||||
/// Gets the amount of the animation frames per second.
|
||||
/// </summary>
|
||||
/// <returns>The frames per second.</returns>
|
||||
API_PROPERTY() float GetFramesPerSecond() const
|
||||
{
|
||||
return (float)Data.FramesPerSecond;
|
||||
@@ -95,7 +95,6 @@ public:
|
||||
/// <summary>
|
||||
/// Gets the animation clip info.
|
||||
/// </summary>
|
||||
/// <returns>The animation info.</returns>
|
||||
API_PROPERTY() InfoData GetInfo() const;
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user