/* * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ #pragma once #include "Base/UUID.hpp" #include "Math/AABB.hpp" #include "Math/Pose.hpp" #include #include #include namespace YAML { template<> struct convert { static Node encode(const OpenVulkano::UUID& uuid) { return Node(uuid.string()); } static bool decode(const Node& node, OpenVulkano::UUID& uuid) { if (node.IsScalar()) { uuid.assign(node.Scalar()); return true; } return false; } }; template<> struct convert { static Node encode(const OpenVulkano::Math::AABB& bbox) { return Node(fmt::format("({},{},{}),({},{},{})", bbox.min.x, bbox.min.y, bbox.min.z, bbox.max.x, bbox.max.y, bbox.max.z)); } static bool decode(const Node& node, OpenVulkano::Math::AABB& bbox) { if (node.IsScalar()) { size_t ret = c4::unformat(c4::to_csubstr(node.Scalar().c_str()), "({},{},{}),({},{},{})", bbox.min.x, bbox.min.y, bbox.min.z, bbox.max.x, bbox.max.y, bbox.max.z); return ret != c4::csubstr::npos; } return false; } }; template<> struct convert { static Node encode(const OpenVulkano::Math::PoseF& pose) { return Node(fmt::format("({},{},{}),({},{},{},{})", pose.GetPosition().x, pose.GetPosition().y, pose.GetPosition().z, pose.GetOrientation().x, pose.GetOrientation().y, pose.GetOrientation().z, pose.GetOrientation().w)); } static bool decode(const Node& node, OpenVulkano::Math::PoseF& pose) { if (node.IsScalar()) { size_t ret = c4::unformat(c4::to_csubstr(node.Scalar().c_str()), "({},{},{}),({},{},{},{})", pose.GetPosition().x, pose.GetPosition().y, pose.GetPosition().z, pose.GetOrientation().x, pose.GetOrientation().y, pose.GetOrientation().z, pose.GetOrientation().w); return ret != c4::csubstr::npos; } return false; } }; }