Math: Add serialization specialization for all types
Former-commit-id: 7e45c50d3b4eabfc581736f290fc208592d3d46c
This commit is contained in:
@@ -674,6 +674,56 @@ namespace Nz
|
||||
<< " Right: " << m_planes[FrustumPlane_Right].ToString() << "\n"
|
||||
<< " Top: " << m_planes[FrustumPlane_Top].ToString() << ")\n";
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Serializes a Frustum
|
||||
* \return true if successfully serialized
|
||||
*
|
||||
* \param context Serialization context
|
||||
* \param matrix Input frustum
|
||||
*/
|
||||
template<typename T>
|
||||
bool Serialize(SerializationContext& context, const Frustum<T>& frustum)
|
||||
{
|
||||
for (unsigned int i = 0; i <= BoxCorner_Max; ++i)
|
||||
{
|
||||
if (!Serialize(context, m_corners[i]))
|
||||
return false;
|
||||
}
|
||||
|
||||
for (unsigned int i = 0; i <= FrustumPlane_Max; ++i)
|
||||
{
|
||||
if (!Serialize(context, m_planes[i]))
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Unserializes a Matrix4
|
||||
* \return true if successfully unserialized
|
||||
*
|
||||
* \param context Serialization context
|
||||
* \param matrix Output matrix
|
||||
*/
|
||||
template<typename T>
|
||||
bool Unserialize(SerializationContext& context, Frustum<T>* frustum)
|
||||
{
|
||||
for (unsigned int i = 0; i <= BoxCorner_Max; ++i)
|
||||
{
|
||||
if (!Unserialize(context, &m_corners[i]))
|
||||
return false;
|
||||
}
|
||||
|
||||
for (unsigned int i = 0; i <= FrustumPlane_Max; ++i)
|
||||
{
|
||||
if (!Unserialize(context, &m_planes[i]))
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
|
||||
Reference in New Issue
Block a user