mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-05-13 14:42:39 +00:00
Common: add json utility functions for Vec3 serialization
This commit is contained in:
parent
7d6a5d3665
commit
edbf8f1772
2 changed files with 39 additions and 1 deletions
Source/Core/Common
20
Source/Core/Common/JsonUtil.cpp
Normal file
20
Source/Core/Common/JsonUtil.cpp
Normal file
|
@ -0,0 +1,20 @@
|
|||
// Copyright 2024 Dolphin Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include "Common/JsonUtil.h"
|
||||
|
||||
picojson::object ToJsonObject(const Common::Vec3& vec)
|
||||
{
|
||||
picojson::object obj;
|
||||
obj.emplace("x", vec.x);
|
||||
obj.emplace("y", vec.y);
|
||||
obj.emplace("z", vec.z);
|
||||
return obj;
|
||||
}
|
||||
|
||||
void FromJson(const picojson::object& obj, Common::Vec3& vec)
|
||||
{
|
||||
vec.x = ReadNumericOrDefault<float>(obj, "x");
|
||||
vec.y = ReadNumericOrDefault<float>(obj, "y");
|
||||
vec.z = ReadNumericOrDefault<float>(obj, "z");
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue