Working on state for location

This commit is contained in:
Vladislav Khorev committed 2026-06-18 21:48:27 +03:00
1 parent e0968b5522
commit b01e970554
13 files changed
+494 -101

No files matched your search

+27
View File
@@ -230,4 +230,31 @@ namespace ZL {
renderer.RenderUniform1f("uAlpha", 1.0f);
}
void InteractiveObjectState::save(nlohmann::json& out) const
{
out["positionX"] = position.x();
out["positionY"] = position.y();
out["positionZ"] = position.z();
out["rotationY"] = rotationY;
out["scale"] = scale;
out["alpha"] = alpha;
out["isActive"] = isActive;
// isAnimating and animTask are not saved: animations snap to their end
// state on load (the final position/scale/alpha is already in the fields above).
}
void InteractiveObjectState::load(const nlohmann::json& in)
{
position.x() = in.value("positionX", position.x());
position.y() = in.value("positionY", position.y());
position.z() = in.value("positionZ", position.z());
rotationY = in.value("rotationY", rotationY);
scale = in.value("scale", scale);
alpha = in.value("alpha", alpha);
isActive = in.value("isActive", isActive);
// Cancel any in-flight animation; state was restored to final values above.
isAnimating = false;
animTask.reset();
}
} // namespace ZL
+5
View File
@@ -4,6 +4,7 @@
#include <functional>
#include <Eigen/Core>
#include <Eigen/Geometry>
#include "external/nlohmann/json.hpp"
namespace ZL {
@@ -63,6 +64,10 @@ public:
bool isActive = true;
bool isAnimating = false;
std::optional<AnimTask> animTask;
// --- Serialisation (runtime mutable fields only) ---
void save(nlohmann::json& out) const;
void load(const nlohmann::json& in);
};
} // namespace ZL