Skip to content

Commit 8dd281c

Browse files
committed
Fix transform save format
1 parent ad81bfa commit 8dd281c

1 file changed

Lines changed: 13 additions & 16 deletions

File tree

src/engine/scene/scene_saver.cpp

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -230,36 +230,33 @@ auto SceneSaver::save_entity(Entity entity) -> YAML::Node {
230230
// ---------------------------------------------------------------------------
231231
auto SceneSaver::save_transform(const Transform& t) -> YAML::Node {
232232
YAML::Node node;
233+
auto ser_ctx = SerializationContext{assets_};
233234

234235
// Only emit fields that differ from defaults (skip default-valued fields
235236
// for cleaner YAML output).
236237

237238
// Default position: [0, 0, 0]
238239
if (t.position.x != 0.0f || t.position.y != 0.0f || t.position.z != 0.0f) {
239-
YAML::Node pos;
240-
pos.push_back(t.position.x);
241-
pos.push_back(t.position.y);
242-
pos.push_back(t.position.z);
243-
node["position"] = pos;
240+
auto encoded = TypeRegistry::yaml_encode(t.position, ser_ctx);
241+
if (encoded) {
242+
node["position"] = *std::move(encoded);
243+
}
244244
}
245245

246246
// Default rotation: identity quaternion [1, 0, 0, 0]
247247
if (t.rotation.w != 1.0f || t.rotation.x != 0.0f || t.rotation.y != 0.0f || t.rotation.z != 0.0f) {
248-
YAML::Node rot;
249-
rot.push_back(t.rotation.w);
250-
rot.push_back(t.rotation.x);
251-
rot.push_back(t.rotation.y);
252-
rot.push_back(t.rotation.z);
253-
node["rotation"] = rot;
248+
auto encoded = TypeRegistry::yaml_encode(t.rotation, ser_ctx);
249+
if (encoded) {
250+
node["rotation"] = *std::move(encoded);
251+
}
254252
}
255253

256254
// Default scale: [1, 1, 1]
257255
if (t.scale.x != 1.0f || t.scale.y != 1.0f || t.scale.z != 1.0f) {
258-
YAML::Node scl;
259-
scl.push_back(t.scale.x);
260-
scl.push_back(t.scale.y);
261-
scl.push_back(t.scale.z);
262-
node["scale"] = scl;
256+
auto encoded = TypeRegistry::yaml_encode(t.scale, ser_ctx);
257+
if (encoded) {
258+
node["scale"] = *std::move(encoded);
259+
}
263260
}
264261

265262
return node;

0 commit comments

Comments
 (0)