SceneSnapshot
Compressed in-memory snapshot of a Scene's serialized state.
- Module
- Game
- Header
#include "Scene/SceneSnapshot.h"- Namespace
Mowo
Used by PIE (edit → play state capture). The compressed buffer is owned by the SceneSnapshot — copy/move semantics are explicit so call sites stay obvious about lifetime.
Storage model: - Capture takes the Scene's serialized MDF text, re-encodes it to the compact mdfb binary form, then runs zstd on the binary and stores the compressed bytes — smaller than zstd(text) and cheaper to parse back on restore. - Restore decompresses into a temporary std::string holding the mdfb bytes; MdfDocument::ParseFromString auto-detects the MDFB magic, so Scene::DeserializeFromMDF consumes it unchanged (and old text snapshots would still parse).
This is intentionally not a full delta journal — the roadmap calls for per-mutation journaling for an additional ~20× win, but the immediate short-term goal is "stop holding the raw MDF string for the entire PIE session." Compression + immediate release accomplishes that.
Constructors
| Signature | Name | Description |
|---|---|---|
SceneSnapshot() = default | SceneSnapshot | |
~SceneSnapshot() = default | ~SceneSnapshot | |
SceneSnapshot(const SceneSnapshot&) = default | SceneSnapshot | |
SceneSnapshot(SceneSnapshot&&) noexcept = default | SceneSnapshot |
Public functions
| Returns | Name | Description |
|---|---|---|
SceneSnapshot& | operator= | |
SceneSnapshot& | operator= | |
SceneSnapshot | CaptureFromMdf | Capture from a raw serialized MDF string. |
std::string | DecompressToMdf | Decompress the snapshot back into an MDF string. |
bool | IsEmpty | |
void | Clear | |
size_t | CompressedBytes | Stats — useful for logging PIE memory cost. |
size_t | UncompressedBytes |
Function details
SceneSnapshot
SceneSnapshot() = default~SceneSnapshot
~SceneSnapshot() = defaultSceneSnapshot
SceneSnapshot(const SceneSnapshot&) = defaultSceneSnapshot
SceneSnapshot(SceneSnapshot&&) noexcept = defaultoperator=
SceneSnapshot& operator=(const SceneSnapshot&) = defaultoperator=
SceneSnapshot& operator=(SceneSnapshot&&) noexcept = defaultCaptureFromMdf
static SceneSnapshot CaptureFromMdf(const std::string& mdf)Capture from a raw serialized MDF string. The caller is responsible for producing the string (engine Scene::SerializeToMDF or the editor SceneSerializer::SerializeToString — different deserialize paths know how to handle each).
DecompressToMdf
std::string DecompressToMdf() constDecompress the snapshot back into an MDF string. Returns empty on failure (treat as a hard error — the snapshot is corrupt).
IsEmpty
bool IsEmpty() constClear
void Clear()CompressedBytes
size_t CompressedBytes() constStats — useful for logging PIE memory cost.
UncompressedBytes
size_t UncompressedBytes() const