![]() |
vkmEngine 1.0.0
A C++ game engine · vkmengine.com
|
Per-component (de)serialization to JSON. More...
Classes | |
| struct | AssetRefs |
| Every asset a set of components references, one list per kind. More... | |
| struct | UnresolvedRef |
| An asset name a load failed to resolve, and the field it was read from. More... | |
| class | UnresolvedScope |
| Bounds one component load's share of the unresolved list. More... | |
Functions | |
| nlohmann::json | save (const Environment &) |
| The scene-global Environment (sky, night sky and fog). | |
| nlohmann::json | save (const Rigidbody &) |
| Rigidbody: dynamics and material fields. | |
| nlohmann::json | save (const Collider &, const ResourceManager &) |
| Collider: each part's shape tag plus the fields of every shape. | |
| nlohmann::json | save (const CharacterController &) |
| CharacterController: the tuning only. | |
| nlohmann::json | save (const Joint &, const EntityNamer &) |
| Joint: the reflected fields, and connected as the carrier's name for it. | |
| nlohmann::json | save (const Ragdoll &, const EntityNamer &) |
| Ragdoll: the switch, the group node, and the bone mapping. | |
| nlohmann::json | save (const Animator &, const ResourceManager &) |
| Animator: the rig, the clip and how it is authored to play. | |
| nlohmann::json | save (const BoneSocket &) |
| BoneSocket: the bone an attachment rides and its offset on it. | |
| nlohmann::json | save (const AudioSource &, const ResourceManager &) |
| AudioSource: the clip it names and how it should be heard. | |
| nlohmann::json | save (const Hierarchy &) |
| Hierarchy: only parent is serialized, as the parent's slot. | |
| uint32_t | loadParentIndex (const nlohmann::json &json) |
| Read a saved Hierarchy's parent reference as a saved slot. | |
| nlohmann::json | save (const Animation &) |
| Animation: the three tracks, each with its easing by name, and playback state. | |
| nlohmann::json | save (const ScriptComponent &) |
| ScriptComponent: each behavior by BehaviorRegistry type name, with its Behavior::visitFields properties. | |
| void | emitAssetRefs (const Collider &, AssetRefs &) |
Record every asset the component references into refs. | |
| std::vector< UnresolvedRef > | takeUnresolvedRefs () |
| Take the references the loads since the last call could not resolve. | |
Per-component (de)serialization to JSON.
A new component adds its save/load (and emitAssetRefs, if it references assets) here and a row to VKM_SCENE_COMPONENTS. Asset handles are stored by name (ResourceManager::findByName); Hierarchy::parent as the saved slot, which resolves directly because SceneSerializer recreates each entity at its saved slot.
| nlohmann::json Vkm::Engine::ComponentSerializer::save | ( | const Environment & | ) |
The scene-global Environment (sky, night sky and fog).
Missing keys keep the current values.
| nlohmann::json Vkm::Engine::ComponentSerializer::save | ( | const Rigidbody & | ) |
Rigidbody: dynamics and material fields.
The runtime sleep state (sleeping / sleepTimer) is not persisted.
| nlohmann::json Vkm::Engine::ComponentSerializer::save | ( | const Collider & | , |
| const ResourceManager & | ) |
Collider: each part's shape tag plus the fields of every shape.
A mesh part's triangles are built from its mesh on load (syncMeshCollider), never written.
| nlohmann::json Vkm::Engine::ComponentSerializer::save | ( | const CharacterController & | ) |
CharacterController: the tuning only.
The per-tick state is not saved: a half consumed jump request would replay on load.
| nlohmann::json Vkm::Engine::ComponentSerializer::save | ( | const Ragdoll & | , |
| const EntityNamer & | ) |
Ragdoll: the switch, the group node, and the bone mapping.
The bones are entities the scene saves anyway; this carries which body poses which bone and the offset between them, naming entities as the carrier does.
| nlohmann::json Vkm::Engine::ComponentSerializer::save | ( | const Animator & | , |
| const ResourceManager & | ) |
Animator: the rig, the clip and how it is authored to play.
The playback head and blend state are session state, not saved.
| nlohmann::json Vkm::Engine::ComponentSerializer::save | ( | const BoneSocket & | ) |
BoneSocket: the bone an attachment rides and its offset on it.
The bone name round-trips and the index is recovered at runtime: a stored index silently addresses a neighbour once a re-export inserts a joint.
| nlohmann::json Vkm::Engine::ComponentSerializer::save | ( | const AudioSource & | , |
| const ResourceManager & | ) |
AudioSource: the clip it names and how it should be heard.
playing and started are session state, not saved: a half finished sound would resume on load. playOnStart is the authored half.
| nlohmann::json Vkm::Engine::ComponentSerializer::save | ( | const Hierarchy & | ) |
Hierarchy: only parent is serialized, as the parent's slot.
Sibling links are rebuilt on load by HierarchyOperations::setParent.
| uint32_t Vkm::Engine::ComponentSerializer::loadParentIndex | ( | const nlohmann::json & | json | ) |
Read a saved Hierarchy's parent reference as a saved slot.
The caller links it once every entity exists at its saved slot. A root is saved as slot 0, which no entity occupies; a block without the key yields uint32_t max. Both read as a root.
| json | Hierarchy object written by save(const Hierarchy&). |
| nlohmann::json Vkm::Engine::ComponentSerializer::save | ( | const ScriptComponent & | ) |
ScriptComponent: each behavior by BehaviorRegistry type name, with its Behavior::visitFields properties.
An unregistered type is kept as an UnknownBehavior so the next save writes it back; a field whose key is absent keeps its default.
Record every asset the component references into refs.
One overload per R row of VKM_SCENE_COMPONENTS; a missing one is a compile error at the expansion.
| std::vector< UnresolvedRef > Vkm::Engine::ComponentSerializer::takeUnresolvedRefs | ( | ) |
Take the references the loads since the last call could not resolve.
An unresolved slot is left empty and the name is its only record; a save without it writes an empty string over it. Collected here because a loader has no room for a second output; drained by a caller that knows the entity and component (see SceneSerializer::loadComponents). Call it inside an UnresolvedScope. A reference read out of an array is not kept.