Minor imporvements

This commit is contained in:
Wojtek Figat
2026-03-30 10:14:25 +02:00
parent 039407b6ee
commit 408c6d96b1
3 changed files with 31 additions and 29 deletions

View File

@@ -73,6 +73,13 @@ void ChangeIds(rapidjson_flax::Value& obj, rapidjson_flax::Document& document, c
}
}
void JsonTools::MergeObjects(Value& target, Value& source, Value::AllocatorType& allocator)
{
ASSERT(target.IsObject() && source.IsObject());
for (auto itr = source.MemberBegin(); itr != source.MemberEnd(); ++itr)
target.AddMember(itr->name, itr->value, allocator);
}
void JsonTools::ChangeIds(Document& doc, const Dictionary<Guid, Guid>& mapping)
{
if (mapping.IsEmpty())
@@ -236,6 +243,14 @@ Plane JsonTools::GetPlane(const Value& value)
return result;
}
Rectangle JsonTools::GetRectangle(const Value& value)
{
return Rectangle(
GetVector2(value, "Location", Vector2::Zero),
GetVector2(value, "Size", Vector2::Zero)
);
}
BoundingSphere JsonTools::GetBoundingSphere(const Value& value)
{
BoundingSphere result;
@@ -367,4 +382,16 @@ CommonValue JsonTools::GetCommonValue(const Value& value)
}
return result;
}
bool JsonTools::GetGuidIfValid(Guid& result, const Value& node, const char* name)
{
auto member = node.FindMember(name);
if (member != node.MemberEnd())
{
result = GetGuid(member->value);
return result.IsValid();
}
return false;
}
PRAGMA_ENABLE_DEPRECATION_WARNINGS