// Copyright (c) Wojciech Figat. All rights reserved.
#pragma once
#include "../BinaryAsset.h"
#include "Engine/Content/Assets/SkinnedModel.h"
#include "Engine/Core/Collections/BitArray.h"
class MemoryReadStream;
class MemoryWriteStream;
///
/// The skinned model skeleton bones boolean masking data.
///
API_CLASS(NoSpawn) class FLAXENGINE_API SkeletonMask : public BinaryAsset
{
DECLARE_BINARY_ASSET_HEADER(SkeletonMask, 2);
private:
Array _maskedNodes;
BitArray<> _mask;
public:
///
/// The referenced skinned model skeleton that defines the masked nodes hierarchy.
///
API_FIELD() AssetReference Skeleton;
///
/// Gets the per-skeleton node mask (by name).
///
/// The masked nodes names list.
API_PROPERTY() const Array& GetMaskedNodes() const
{
return _maskedNodes;
}
///
/// Sets the per-skeleton node mask (by name).
///
/// The masked nodes names list.
API_PROPERTY() void SetMaskedNodes(const Array& value)
{
_maskedNodes = value;
_mask.Resize(0);
}
public:
///
/// Gets the per-skeleton-node boolean mask (read-only).
///
/// The constant reference to the skeleton nodes mask.
API_PROPERTY() const BitArray<>& GetNodesMask();
private:
void OnSkeletonUnload();
public:
// [BinaryAsset]
#if USE_EDITOR
void GetReferences(Array& assets, Array& files) const override
{
BinaryAsset::GetReferences(assets, files);
assets.Add(Skeleton.GetID());
}
bool Save(const StringView& path = StringView::Empty) override;
#endif
protected:
// [BinaryAsset]
LoadResult load() override;
void unload(bool isReloading) override;
AssetChunksFlag getChunksToPreload() const override;
};