Math: Add serialization specialization for all types

Former-commit-id: 7e45c50d3b4eabfc581736f290fc208592d3d46c
This commit is contained in:
Lynix
2016-03-06 01:54:13 +01:00
parent d6a436100c
commit e9d126b3a4
28 changed files with 699 additions and 80 deletions

View File

@@ -545,6 +545,60 @@ namespace Nz
return volume;
}
/*!
* \brief Serializes a BoundingVolume
* \return true if successfully serialized
*
* \param context Serialization context
* \param boundingVolume Input bounding volume
*
* \remark Does not save OBB corners
*/
template<typename T>
bool Serialize(SerializationContext& context, const BoundingVolume<T>& boundingVolume)
{
if (!Serialize(context, static_cast<UInt8>(boundingVolume.extend)))
return false;
if (!Serialize(context, boundingVolume.aabb))
return false;
if (!Serialize(context, boundingVolume.obb))
return false;
return true;
}
/*!
* \brief Unserializes a BoundingVolume
* \return true if successfully unserialized
*
* \param context Serialization context
* \param boundingVolume Output bounding volume
*
* \remark The resulting oriented box corners will *not* be updated, a call to Update is required
*/
template<typename T>
bool Unserialize(SerializationContext& context, BoundingVolume<T>* boundingVolume)
{
UInt8 extend;
if (!Unserialize(context, &extend))
return false;
if (extend > Extend_Max)
return false;
boundingVolume->extend = extend;
if (!Unserialize(context, &boundingVolume->aabb))
return false;
if (!Unserialize(context, &boundingVolume->obb))
return false;
return true;
}
}
/*!