-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFrameAnimationMsgPack.h
More file actions
62 lines (55 loc) · 2.03 KB
/
Copy pathFrameAnimationMsgPack.h
File metadata and controls
62 lines (55 loc) · 2.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#pragma once
#include <cstdint>
#include <cstddef>
/**
* @brief MessagePack-based frame animation cache format
*
* References sprite frames by GUID rather than pixel coordinates.
* Supports multiple animations per file (e.g., idle, walk, run).
*
* The cache format is generated, not hand-written: FrameAnimationData is a
* DEKI_SERIALIZABLE struct, so the reflection codegen emits Serialize<T> (save)
* and DeserializeMsgPack (load). Keys are the struct field names, hashed the same
* way as component fields, so the map is:
* { "spritesheet_guid": "...", "animations": [
* { "name": "idle", "frames": [ { "frame_guid": "...", "duration": 100 } ],
* "loop": true } ] }
* To change the format, change the struct fields and re-export the .anim assets.
*/
// Forward declarations
struct FrameAnimationData;
/**
* @brief File extension for frame animation files
*/
constexpr const char* FRAMEANIM_EXTENSION = ".anim";
/**
* @brief Helper class for frame animation MessagePack format
*/
class FrameAnimationMsgPackHelper
{
public:
/**
* @brief Load frame animation from MessagePack format
* @param msgpack_path Path to .frameanim MessagePack file
* @param out_data Output animation data structure
* @return true on success
*/
static bool LoadAnimation(const char* msgpack_path, FrameAnimationData* out_data);
/**
* @brief Load frame animation from memory buffer
* @param data Pointer to MessagePack data
* @param size Size of data in bytes
* @param out_data Output animation data structure
* @return true on success
*/
static bool LoadAnimationFromMemory(const uint8_t* data, size_t size, FrameAnimationData* out_data);
#ifdef DEKI_EDITOR
/**
* @brief Save frame animation to MessagePack format (editor only)
* @param msgpack_path Output path for .frameanim file
* @param anim_data Animation data to save
* @return true on success
*/
static bool SaveAnimation(const char* msgpack_path, const FrameAnimationData* anim_data);
#endif
};