Polyphase Game Engine
Loading...
Searching...
No Matches
BoneMaskAsset.h
Go to the documentation of this file.
1#pragma once
2
3#include "Asset.h"
4#include "AssetRef.h"
5#include "Factory.h"
6
7#include <string>
8#include <vector>
9
10class SkeletalMesh;
11
12// Per-bone bitset addressed by name-based subtree includes/excludes.
13// Resolved lazily against any SkeletalMesh — masks are name-keyed at save
14// time so the same .bmask can drive any rig that names its bones the same
15// way. Resolution caches the bitset against the last queried mesh; rebuilds
16// happen on Resolve() when the mesh pointer changes or on explicit
17// InvalidateCache() (e.g. when the owning component swaps its mesh).
19{
20public:
21
23
26
27 virtual void LoadStream(Stream& stream, Platform platform) override;
28 virtual void SaveStream(Stream& stream, Platform platform) override;
29 virtual void Create() override;
30 virtual void Destroy() override;
31
32 virtual void GatherProperties(std::vector<Property>& outProps) override;
33 virtual glm::vec4 GetTypeColor() override;
34 virtual const char* GetTypeName() override;
35
36 SkeletalMesh* GetTargetMesh() const;
37 void SetTargetMesh(SkeletalMesh* mesh);
38
39 const std::vector<std::string>& GetIncludeRoots() const { return mIncludeRoots; }
40 const std::vector<std::string>& GetExcludeRoots() const { return mExcludeRoots; }
41 bool GetSelfOnly() const { return mSelfOnly; }
42
43 void SetIncludeRoots(const std::vector<std::string>& roots);
44 void SetExcludeRoots(const std::vector<std::string>& roots);
45 void SetSelfOnly(bool selfOnly);
46
47 void AddIncludeRoot(const std::string& boneName);
48 void RemoveIncludeRoot(const std::string& boneName);
49 void AddExcludeRoot(const std::string& boneName);
50 void RemoveExcludeRoot(const std::string& boneName);
51
52 // Resolve into a per-bone bitset against `mesh`. Empty rig => empty bitset.
53 // The bitset stays alive on the cache; the returned reference is valid
54 // until the next Resolve() / InvalidateCache() call.
55 const std::vector<uint8_t>& Resolve(const SkeletalMesh* mesh);
56
57 void InvalidateCache();
58
59 static bool HandlePropChange(Datum* datum, uint32_t index, const void* newValue);
60
61protected:
62
64 std::vector<std::string> mIncludeRoots;
65 std::vector<std::string> mExcludeRoots;
66 bool mSelfOnly = false;
67
69 {
70 const SkeletalMesh* mMesh = nullptr;
71 std::vector<uint8_t> mBitset;
72 };
74};
Platform
Definition EngineTypes.h:31
#define POLYPHASE_API
Definition PolyphaseAPI.h:31
Definition AssetRef.h:18
Definition Asset.h:119
virtual void Create()
Definition Asset.cpp:77
virtual void SaveStream(Stream &stream, Platform platform)
Definition Asset.cpp:284
virtual glm::vec4 GetTypeColor()
Definition Asset.cpp:302
virtual const char * GetTypeName()
Definition Asset.cpp:307
virtual void GatherProperties(std::vector< Property > &outProps) override
Definition Asset.cpp:297
virtual void LoadStream(Stream &stream, Platform platform)
Definition Asset.cpp:270
virtual void Destroy()
Definition Asset.cpp:92
Definition BoneMaskAsset.h:19
const std::vector< std::string > & GetExcludeRoots() const
Definition BoneMaskAsset.h:40
const std::vector< std::string > & GetIncludeRoots() const
Definition BoneMaskAsset.h:39
bool GetSelfOnly() const
Definition BoneMaskAsset.h:41
SkeletalMeshRef mTargetMesh
Definition BoneMaskAsset.h:63
ResolvedCache mCache
Definition BoneMaskAsset.h:73
DECLARE_ASSET(BoneMaskAsset, Asset)
std::vector< std::string > mExcludeRoots
Definition BoneMaskAsset.h:65
std::vector< std::string > mIncludeRoots
Definition BoneMaskAsset.h:64
Definition Datum.h:169
Definition SkeletalMesh.h:99
Definition Stream.h:21
Definition BoneMaskAsset.h:69
std::vector< uint8_t > mBitset
Definition BoneMaskAsset.h:71