Math: Add serialization specialization for all types
Former-commit-id: 7e45c50d3b4eabfc581736f290fc208592d3d46c
This commit is contained in:
parent
d6a436100c
commit
e9d126b3a4
|
|
@ -5,6 +5,7 @@
|
|||
#ifndef NAZARA_BOUNDINGVOLUME_HPP
|
||||
#define NAZARA_BOUNDINGVOLUME_HPP
|
||||
|
||||
#include <Nazara/Core/Serialization.hpp>
|
||||
#include <Nazara/Core/String.hpp>
|
||||
#include <Nazara/Math/Box.hpp>
|
||||
#include <Nazara/Math/Enums.hpp>
|
||||
|
|
@ -66,6 +67,9 @@ namespace Nz
|
|||
|
||||
typedef BoundingVolume<double> BoundingVolumed;
|
||||
typedef BoundingVolume<float> BoundingVolumef;
|
||||
|
||||
template<typename T> bool Serialize(SerializationContext& context, const BoundingVolume<T>& boundingVolume);
|
||||
template<typename T> bool Unserialize(SerializationContext& context, BoundingVolume<T>* boundingVolume);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
#ifndef NAZARA_BOX_HPP
|
||||
#define NAZARA_BOX_HPP
|
||||
|
||||
#include <Nazara/Core/Serialization.hpp>
|
||||
#include <Nazara/Core/String.hpp>
|
||||
#include <Nazara/Math/Enums.hpp>
|
||||
#include <Nazara/Math/Matrix4.hpp>
|
||||
|
|
@ -96,6 +97,9 @@ namespace Nz
|
|||
typedef Box<unsigned int> Boxui;
|
||||
typedef Box<Int32> Boxi32;
|
||||
typedef Box<UInt32> Boxui32;
|
||||
|
||||
template<typename T> bool Serialize(SerializationContext& context, const Box<T>& box);
|
||||
template<typename T> bool Unserialize(SerializationContext& context, Box<T>* box);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
|
|
|
|||
|
|
@ -920,6 +920,68 @@ namespace Nz
|
|||
|
||||
return box;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Serializes a Box
|
||||
* \return true if successfully serialized
|
||||
*
|
||||
* \param context Serialization context
|
||||
* \param box Input Box
|
||||
*/
|
||||
template<typename T>
|
||||
bool Serialize(SerializationContext& context, const Box<T>& box)
|
||||
{
|
||||
if (!Serialize(context, box.x))
|
||||
return false;
|
||||
|
||||
if (!Serialize(context, box.y))
|
||||
return false;
|
||||
|
||||
if (!Serialize(context, box.z))
|
||||
return false;
|
||||
|
||||
if (!Serialize(context, box.width))
|
||||
return false;
|
||||
|
||||
if (!Serialize(context, box.height))
|
||||
return false;
|
||||
|
||||
if (!Serialize(context, box.depth))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Unserializes a Box
|
||||
* \return true if successfully unserialized
|
||||
*
|
||||
* \param context Serialization context
|
||||
* \param box Output Box
|
||||
*/
|
||||
template<typename T>
|
||||
bool Unserialize(SerializationContext& context, Box<T>* box)
|
||||
{
|
||||
if (!Unserialize(context, &box->x))
|
||||
return false;
|
||||
|
||||
if (!Unserialize(context, &box->y))
|
||||
return false;
|
||||
|
||||
if (!Unserialize(context, &box->z))
|
||||
return false;
|
||||
|
||||
if (!Unserialize(context, &box->width))
|
||||
return false;
|
||||
|
||||
if (!Unserialize(context, &box->height))
|
||||
return false;
|
||||
|
||||
if (!Unserialize(context, &box->depth))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
#ifndef NAZARA_EULERANGLES_HPP
|
||||
#define NAZARA_EULERANGLES_HPP
|
||||
|
||||
#include <Nazara/Core/Serialization.hpp>
|
||||
#include <Nazara/Core/String.hpp>
|
||||
#include <Nazara/Math/Quaternion.hpp>
|
||||
#include <Nazara/Math/Vector3.hpp>
|
||||
|
|
@ -61,6 +62,9 @@ namespace Nz
|
|||
|
||||
typedef EulerAngles<double> EulerAnglesd;
|
||||
typedef EulerAngles<float> EulerAnglesf;
|
||||
|
||||
template<typename T> bool Serialize(SerializationContext& context, const EulerAngles<T>& eulerAngles);
|
||||
template<typename T> bool Unserialize(SerializationContext& context, EulerAngles<T>* eulerAngles);
|
||||
}
|
||||
|
||||
template<typename T> std::ostream& operator<<(std::ostream& out, const Nz::EulerAngles<T>& angles);
|
||||
|
|
|
|||
|
|
@ -330,6 +330,50 @@ namespace Nz
|
|||
|
||||
return angles;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Serializes a EulerAngles
|
||||
* \return true if successfully serialized
|
||||
*
|
||||
* \param context Serialization context
|
||||
* \param angles Input euler angles
|
||||
*/
|
||||
template<typename T>
|
||||
bool Serialize(SerializationContext& context, const EulerAngles<T>& angles)
|
||||
{
|
||||
if (!Serialize(context, angles.pitch))
|
||||
return false;
|
||||
|
||||
if (!Serialize(context, angles.yaw))
|
||||
return false;
|
||||
|
||||
if (!Serialize(context, angles.roll))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Unserializes a EulerAngles
|
||||
* \return true if successfully unserialized
|
||||
*
|
||||
* \param context Serialization context
|
||||
* \param angles Output euler angles
|
||||
*/
|
||||
template<typename T>
|
||||
bool Unserialize(SerializationContext& context, EulerAngles<T>* angles)
|
||||
{
|
||||
if (!Unserialize(context, &angles->pitch))
|
||||
return false;
|
||||
|
||||
if (!Unserialize(context, &angles->yaw))
|
||||
return false;
|
||||
|
||||
if (!Unserialize(context, &angles->roll))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
#ifndef NAZARA_FRUSTUM_HPP
|
||||
#define NAZARA_FRUSTUM_HPP
|
||||
|
||||
#include <Nazara/Core/Serialization.hpp>
|
||||
#include <Nazara/Core/String.hpp>
|
||||
#include <Nazara/Math/BoundingVolume.hpp>
|
||||
#include <Nazara/Math/Enums.hpp>
|
||||
|
|
@ -60,6 +61,9 @@ namespace Nz
|
|||
|
||||
typedef Frustum<double> Frustumd;
|
||||
typedef Frustum<float> Frustumf;
|
||||
|
||||
template<typename T> bool Serialize(SerializationContext& context, const Frustum<T>& frustum);
|
||||
template<typename T> bool Unserialize(SerializationContext& context, Frustum<T>* frustum);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@
|
|||
|
||||
///FIXME: Matrices column-major, difficile de bosser avec (Tout passer en row-major et transposer dans les shaders ?)
|
||||
|
||||
#include <Nazara/Core/Serialization.hpp>
|
||||
#include <Nazara/Core/String.hpp>
|
||||
#include <Nazara/Math/Config.hpp>
|
||||
|
||||
|
|
@ -138,6 +139,9 @@ namespace Nz
|
|||
|
||||
typedef Matrix4<double> Matrix4d;
|
||||
typedef Matrix4<float> Matrix4f;
|
||||
|
||||
template<typename T> bool Serialize(SerializationContext& context, const Matrix4<T>& matrix);
|
||||
template<typename T> bool Unserialize(SerializationContext& context, Matrix4<T>* matrix);
|
||||
}
|
||||
|
||||
template<typename T> std::ostream& operator<<(std::ostream& out, const Nz::Matrix4<T>& matrix);
|
||||
|
|
|
|||
|
|
@ -1761,6 +1761,44 @@ namespace Nz
|
|||
|
||||
return matrix;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Serializes a Matrix4
|
||||
* \return true if successfully serialized
|
||||
*
|
||||
* \param context Serialization context
|
||||
* \param matrix Input matrix
|
||||
*/
|
||||
template<typename T>
|
||||
bool Serialize(SerializationContext& context, const Matrix4<T>& matrix)
|
||||
{
|
||||
for (unsigned int i = 0; i < 16; ++i)
|
||||
{
|
||||
if (!Serialize(context, matrix[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, Matrix4<T>* matrix)
|
||||
{
|
||||
for (unsigned int i = 0; i < 16; ++i)
|
||||
{
|
||||
if (!Unserialize(context, &matrix[i]))
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
#ifndef NAZARA_ORIENTEDBOX_HPP
|
||||
#define NAZARA_ORIENTEDBOX_HPP
|
||||
|
||||
#include <Nazara/Core/Serialization.hpp>
|
||||
#include <Nazara/Core/String.hpp>
|
||||
#include <Nazara/Math/Box.hpp>
|
||||
#include <Nazara/Math/Matrix4.hpp>
|
||||
|
|
@ -67,6 +68,9 @@ namespace Nz
|
|||
|
||||
typedef OrientedBox<double> OrientedBoxd;
|
||||
typedef OrientedBox<float> OrientedBoxf;
|
||||
|
||||
template<typename T> bool Serialize(SerializationContext& context, const OrientedBox<T>& obb);
|
||||
template<typename T> bool Unserialize(SerializationContext& context, OrientedBox<T>* obb);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
|
|
|
|||
|
|
@ -430,6 +430,42 @@ namespace Nz
|
|||
|
||||
return orientedBox;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Serializes a OrientedBox
|
||||
* \return true if successfully serialized
|
||||
*
|
||||
* \param context Serialization context
|
||||
* \param obb Input oriented box
|
||||
*
|
||||
* \remark Does not save OBB corners
|
||||
*/
|
||||
template<typename T>
|
||||
bool Serialize(SerializationContext& context, const OrientedBox<T>& obb)
|
||||
{
|
||||
if (!Serialize(context, obb.localBox))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Unserializes a Matrix4
|
||||
* \return true if successfully unserialized
|
||||
*
|
||||
* \param context Serialization context
|
||||
* \param obb Output oriented box
|
||||
*
|
||||
* \remark The resulting oriented box corners will *not* be updated, a call to Update is required
|
||||
*/
|
||||
template<typename T>
|
||||
bool Unserialize(SerializationContext& context, OrientedBox<T>* obb)
|
||||
{
|
||||
if (!Unserialize(context, &obb->localBox))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
#ifndef NAZARA_PLANE_HPP
|
||||
#define NAZARA_PLANE_HPP
|
||||
|
||||
#include <Nazara/Core/Serialization.hpp>
|
||||
#include <Nazara/Core/String.hpp>
|
||||
#include <Nazara/Math/Vector3.hpp>
|
||||
|
||||
|
|
@ -57,6 +58,9 @@ namespace Nz
|
|||
|
||||
typedef Plane<double> Planed;
|
||||
typedef Plane<float> Planef;
|
||||
|
||||
template<typename T> bool Serialize(SerializationContext& context, const Plane<T>& plane);
|
||||
template<typename T> bool Unserialize(SerializationContext& context, Plane<T>* plane);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
|
|
|
|||
|
|
@ -424,6 +424,44 @@ namespace Nz
|
|||
|
||||
return plane;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Serializes a Vector2
|
||||
* \return true if successfully serialized
|
||||
*
|
||||
* \param context Serialization context
|
||||
* \param plane Input Vector2
|
||||
*/
|
||||
template<typename T>
|
||||
bool Serialize(SerializationContext& context, const Plane<T>& plane)
|
||||
{
|
||||
if (!Serialize(context, plane.normal))
|
||||
return false;
|
||||
|
||||
if (!Serialize(context, plane.distance))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Unserializes a Plane
|
||||
* \return true if successfully unserialized
|
||||
*
|
||||
* \param context Serialization context
|
||||
* \param plane Output Plane
|
||||
*/
|
||||
template<typename T>
|
||||
bool Unserialize(SerializationContext& context, Plane<T>* plane)
|
||||
{
|
||||
if (!Unserialize(context, &plane->normal))
|
||||
return false;
|
||||
|
||||
if (!Unserialize(context, &plane->distance))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
#ifndef NAZARA_QUATERNION_HPP
|
||||
#define NAZARA_QUATERNION_HPP
|
||||
|
||||
#include <Nazara/Core/Serialization.hpp>
|
||||
#include <Nazara/Core/String.hpp>
|
||||
|
||||
namespace Nz
|
||||
|
|
@ -88,6 +89,9 @@ namespace Nz
|
|||
|
||||
typedef Quaternion<double> Quaterniond;
|
||||
typedef Quaternion<float> Quaternionf;
|
||||
|
||||
template<typename T> bool Serialize(SerializationContext& context, const Quaternion<T>& quat);
|
||||
template<typename T> bool Unserialize(SerializationContext& context, Quaternion<T>* quat);
|
||||
}
|
||||
|
||||
template<typename T> std::ostream& operator<<(std::ostream& out, const Nz::Quaternion<T>& quat);
|
||||
|
|
|
|||
|
|
@ -831,6 +831,57 @@ namespace Nz
|
|||
|
||||
return quaternion;
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
* \brief Serializes a Quaternion
|
||||
* \return true if successfully serialized
|
||||
*
|
||||
* \param context Serialization context
|
||||
* \param quat Input Quaternion
|
||||
*/
|
||||
template<typename T>
|
||||
bool Serialize(SerializationContext& context, const Quaternion<T>& quat)
|
||||
{
|
||||
if (!Serialize(context, quat.x))
|
||||
return false;
|
||||
|
||||
if (!Serialize(context, quat.y))
|
||||
return false;
|
||||
|
||||
if (!Serialize(context, quat.z))
|
||||
return false;
|
||||
|
||||
if (!Serialize(context, quat.w))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Unserializes a Quaternion
|
||||
* \return true if successfully unserialized
|
||||
*
|
||||
* \param context Serialization context
|
||||
* \param quat Output Quaternion
|
||||
*/
|
||||
template<typename T>
|
||||
bool Unserialize(SerializationContext& context, Quaternion<T>* quat)
|
||||
{
|
||||
if (!Unserialize(context, &quat->x))
|
||||
return false;
|
||||
|
||||
if (!Unserialize(context, &quat->y))
|
||||
return false;
|
||||
|
||||
if (!Unserialize(context, &quat->z))
|
||||
return false;
|
||||
|
||||
if (!Unserialize(context, &quat->w))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
#ifndef NAZARA_RAY_HPP
|
||||
#define NAZARA_RAY_HPP
|
||||
|
||||
#include <Nazara/Core/Serialization.hpp>
|
||||
#include <Nazara/Core/String.hpp>
|
||||
#include <Nazara/Math/Box.hpp>
|
||||
#include <Nazara/Math/Frustum.hpp>
|
||||
|
|
@ -73,6 +74,9 @@ namespace Nz
|
|||
|
||||
typedef Ray<double> Rayd;
|
||||
typedef Ray<float> Rayf;
|
||||
|
||||
template<typename T> bool Serialize(SerializationContext& context, const Ray<T>& ray);
|
||||
template<typename T> bool Unserialize(SerializationContext& context, Ray<T>* ray);
|
||||
}
|
||||
|
||||
template<typename T> std::ostream& operator<<(std::ostream& out, const Nz::Ray<T>& vec);
|
||||
|
|
|
|||
|
|
@ -762,6 +762,44 @@ namespace Nz
|
|||
{
|
||||
return Ray<T>(Nz::Vector3<T>::Lerp(from.origin, to.origin, interpolation), Nz::Vector3<T>::Lerp(from.direction, to.direction, interpolation));
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Serializes a Ray
|
||||
* \return true if successfully serialized
|
||||
*
|
||||
* \param context Serialization context
|
||||
* \param ray Input Ray
|
||||
*/
|
||||
template<typename T>
|
||||
bool Serialize(SerializationContext& context, const Ray<T>& ray)
|
||||
{
|
||||
if (!Serialize(context, ray.origin))
|
||||
return false;
|
||||
|
||||
if (!Serialize(context, ray.direction))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Unserializes a Ray
|
||||
* \return true if successfully unserialized
|
||||
*
|
||||
* \param context Serialization context
|
||||
* \param ray Output Ray
|
||||
*/
|
||||
template<typename T>
|
||||
bool Unserialize(SerializationContext& context, Ray<T>* ray)
|
||||
{
|
||||
if (!Unserialize(context, &ray->origin))
|
||||
return false;
|
||||
|
||||
if (!Unserialize(context, &ray->direction))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
#ifndef NAZARA_RECT_HPP
|
||||
#define NAZARA_RECT_HPP
|
||||
|
||||
#include <Nazara/Core/Serialization.hpp>
|
||||
#include <Nazara/Core/String.hpp>
|
||||
#include <Nazara/Math/Enums.hpp>
|
||||
#include <Nazara/Math/Vector2.hpp>
|
||||
|
|
@ -90,6 +91,9 @@ namespace Nz
|
|||
typedef Rect<unsigned int> Rectui;
|
||||
typedef Rect<Int32> Recti32;
|
||||
typedef Rect<UInt32> Rectui32;
|
||||
|
||||
template<typename T> bool Serialize(SerializationContext& context, const Rect<T>& rect);
|
||||
template<typename T> bool Unserialize(SerializationContext& context, Rect<T>* rect);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
|
|
|
|||
|
|
@ -816,6 +816,56 @@ namespace Nz
|
|||
|
||||
return rect;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Serializes a Rect
|
||||
* \return true if successfully serialized
|
||||
*
|
||||
* \param context Serialization context
|
||||
* \param rect Input Rect
|
||||
*/
|
||||
template<typename T>
|
||||
bool Serialize(SerializationContext& context, const Rect<T>& rect)
|
||||
{
|
||||
if (!Serialize(context, rect.x))
|
||||
return false;
|
||||
|
||||
if (!Serialize(context, rect.y))
|
||||
return false;
|
||||
|
||||
if (!Serialize(context, rect.width))
|
||||
return false;
|
||||
|
||||
if (!Serialize(context, rect.height))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Unserializes a Rect
|
||||
* \return true if successfully unserialized
|
||||
*
|
||||
* \param context Serialization context
|
||||
* \param rect Output Rect
|
||||
*/
|
||||
template<typename T>
|
||||
bool Unserialize(SerializationContext& context, Rect<T>* rect)
|
||||
{
|
||||
if (!Unserialize(context, &rect->x))
|
||||
return false;
|
||||
|
||||
if (!Unserialize(context, &rect->y))
|
||||
return false;
|
||||
|
||||
if (!Unserialize(context, &rect->width))
|
||||
return false;
|
||||
|
||||
if (!Unserialize(context, &rect->height))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
#ifndef NAZARA_SPHERE_HPP
|
||||
#define NAZARA_SPHERE_HPP
|
||||
|
||||
#include <Nazara/Core/Serialization.hpp>
|
||||
#include <Nazara/Core/String.hpp>
|
||||
#include <Nazara/Math/Vector3.hpp>
|
||||
|
||||
|
|
@ -80,6 +81,9 @@ namespace Nz
|
|||
|
||||
typedef Sphere<double> Sphered;
|
||||
typedef Sphere<float> Spheref;
|
||||
|
||||
template<typename T> bool Serialize(SerializationContext& context, const Sphere<T>& sphere);
|
||||
template<typename T> bool Unserialize(SerializationContext& context, Sphere<T>* sphere);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
|
|
|
|||
|
|
@ -674,6 +674,56 @@ namespace Nz
|
|||
|
||||
return sphere;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Serializes a Sphere
|
||||
* \return true if successfully serialized
|
||||
*
|
||||
* \param context Serialization context
|
||||
* \param sphere Input Sphere
|
||||
*/
|
||||
template<typename T>
|
||||
bool Serialize(SerializationContext& context, const Sphere<T>& sphere)
|
||||
{
|
||||
if (!Serialize(context, sphere.x))
|
||||
return false;
|
||||
|
||||
if (!Serialize(context, sphere.y))
|
||||
return false;
|
||||
|
||||
if (!Serialize(context, sphere.z))
|
||||
return false;
|
||||
|
||||
if (!Serialize(context, sphere.radius))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Unserializes a Sphere
|
||||
* \return true if successfully unserialized
|
||||
*
|
||||
* \param context Serialization context
|
||||
* \param sphere Output Sphere
|
||||
*/
|
||||
template<typename T>
|
||||
bool Unserialize(SerializationContext& context, Sphere<T>* sphere)
|
||||
{
|
||||
if (!Unserialize(context, &sphere->x))
|
||||
return false;
|
||||
|
||||
if (!Unserialize(context, &sphere->y))
|
||||
return false;
|
||||
|
||||
if (!Unserialize(context, &sphere->z))
|
||||
return false;
|
||||
|
||||
if (!Unserialize(context, &sphere->radius))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
#ifndef NAZARA_VECTOR2_HPP
|
||||
#define NAZARA_VECTOR2_HPP
|
||||
|
||||
#include <Nazara/Core/Serialization.hpp>
|
||||
#include <Nazara/Core/String.hpp>
|
||||
|
||||
namespace Nz
|
||||
|
|
@ -106,6 +107,9 @@ namespace Nz
|
|||
typedef Vector2<unsigned int> Vector2ui;
|
||||
typedef Vector2<Int32> Vector2i32;
|
||||
typedef Vector2<UInt32> Vector2ui32;
|
||||
|
||||
template<typename T> bool Serialize(SerializationContext& context, const Vector2<T>& vector);
|
||||
template<typename T> bool Unserialize(SerializationContext& context, Vector2<T>* vector);
|
||||
}
|
||||
|
||||
template<typename T> std::ostream& operator<<(std::ostream& out, const Nz::Vector2<T>& vec);
|
||||
|
|
|
|||
|
|
@ -940,7 +940,6 @@ namespace Nz
|
|||
*
|
||||
* \see MakeUnitY
|
||||
*/
|
||||
|
||||
template<typename T>
|
||||
Vector2<T> Vector2<T>::UnitY()
|
||||
{
|
||||
|
|
@ -956,7 +955,6 @@ namespace Nz
|
|||
*
|
||||
* \see MakeZero
|
||||
*/
|
||||
|
||||
template<typename T>
|
||||
Vector2<T> Vector2<T>::Zero()
|
||||
{
|
||||
|
|
@ -965,6 +963,44 @@ namespace Nz
|
|||
|
||||
return vector;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Serializes a Vector2
|
||||
* \return true if successfully serialized
|
||||
*
|
||||
* \param context Serialization context
|
||||
* \param vector Input Vector2
|
||||
*/
|
||||
template<typename T>
|
||||
bool Serialize(SerializationContext& context, const Vector2<T>& vector)
|
||||
{
|
||||
if (!Serialize(context, vector.x))
|
||||
return false;
|
||||
|
||||
if (!Serialize(context, vector.y))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Unserializes a Vector2
|
||||
* \return true if successfully unserialized
|
||||
*
|
||||
* \param context Serialization context
|
||||
* \param vector Output Vector2
|
||||
*/
|
||||
template<typename T>
|
||||
bool Unserialize(SerializationContext& context, Vector2<T>* vector)
|
||||
{
|
||||
if (!Unserialize(context, &vector->x))
|
||||
return false;
|
||||
|
||||
if (!Unserialize(context, &vector->y))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
#ifndef NAZARA_VECTOR3_HPP
|
||||
#define NAZARA_VECTOR3_HPP
|
||||
|
||||
#include <Nazara/Core/Serialization.hpp>
|
||||
#include <Nazara/Core/String.hpp>
|
||||
|
||||
namespace Nz
|
||||
|
|
@ -125,6 +126,9 @@ namespace Nz
|
|||
typedef Vector3<unsigned int> Vector3ui;
|
||||
typedef Vector3<Int32> Vector3i32;
|
||||
typedef Vector3<UInt32> Vector3ui32;
|
||||
|
||||
template<typename T> bool Serialize(SerializationContext& context, const Vector3<T>& vector);
|
||||
template<typename T> bool Unserialize(SerializationContext& context, Vector3<T>* vector);
|
||||
}
|
||||
|
||||
template<typename T> std::ostream& operator<<(std::ostream& out, const Nz::Vector3<T>& vec);
|
||||
|
|
|
|||
|
|
@ -28,7 +28,6 @@ namespace Nz
|
|||
* \param Y Y component
|
||||
* \param Z Z component
|
||||
*/
|
||||
|
||||
template<typename T>
|
||||
Vector3<T>::Vector3(T X, T Y, T Z)
|
||||
{
|
||||
|
|
@ -41,7 +40,6 @@ namespace Nz
|
|||
* \param X X component
|
||||
* \param vec vec.X = Y component and vec.y = Z component
|
||||
*/
|
||||
|
||||
template<typename T>
|
||||
Vector3<T>::Vector3(T X, const Vector2<T>& vec)
|
||||
{
|
||||
|
|
@ -53,7 +51,6 @@ namespace Nz
|
|||
*
|
||||
* \param scale X component = Y component = Z component
|
||||
*/
|
||||
|
||||
template<typename T>
|
||||
Vector3<T>::Vector3(T scale)
|
||||
{
|
||||
|
|
@ -65,7 +62,6 @@ namespace Nz
|
|||
*
|
||||
* \param vec[3] vec[0] is X component, vec[1] is Y component and vec[2] is Z component
|
||||
*/
|
||||
|
||||
template<typename T>
|
||||
Vector3<T>::Vector3(const T vec[3])
|
||||
{
|
||||
|
|
@ -78,7 +74,6 @@ namespace Nz
|
|||
* \param vec vec.X = X component and vec.y = Y component
|
||||
* \param Z Z component
|
||||
*/
|
||||
|
||||
template<typename T>
|
||||
Vector3<T>::Vector3(const Vector2<T>& vec, T Z)
|
||||
{
|
||||
|
|
@ -90,7 +85,6 @@ namespace Nz
|
|||
*
|
||||
* \param vec Vector of type U to convert to type T
|
||||
*/
|
||||
|
||||
template<typename T>
|
||||
template<typename U>
|
||||
Vector3<T>::Vector3(const Vector3<U>& vec)
|
||||
|
|
@ -103,7 +97,6 @@ namespace Nz
|
|||
*
|
||||
* \param vec Vector4 where only the first three components are taken
|
||||
*/
|
||||
|
||||
template<typename T>
|
||||
Vector3<T>::Vector3(const Vector4<T>& vec)
|
||||
{
|
||||
|
|
@ -118,7 +111,6 @@ namespace Nz
|
|||
*
|
||||
* \see DotProduct
|
||||
*/
|
||||
|
||||
template<typename T>
|
||||
T Vector3<T>::AbsDotProduct(const Vector3& vec) const
|
||||
{
|
||||
|
|
@ -137,7 +129,6 @@ namespace Nz
|
|||
*
|
||||
* \see NormalizeAngle
|
||||
*/
|
||||
|
||||
template<typename T>
|
||||
T Vector3<T>::AngleBetween(const Vector3& vec) const
|
||||
{
|
||||
|
|
@ -166,7 +157,6 @@ namespace Nz
|
|||
*
|
||||
* \see CrossProduct
|
||||
*/
|
||||
|
||||
template<typename T>
|
||||
Vector3<T> Vector3<T>::CrossProduct(const Vector3& vec) const
|
||||
{
|
||||
|
|
@ -181,7 +171,6 @@ namespace Nz
|
|||
*
|
||||
* \see SquaredDistance
|
||||
*/
|
||||
|
||||
template<typename T>
|
||||
T Vector3<T>::Distance(const Vector3& vec) const
|
||||
{
|
||||
|
|
@ -194,7 +183,6 @@ namespace Nz
|
|||
*
|
||||
* \param vec The other vector to measure the distance with
|
||||
*/
|
||||
|
||||
template<typename T>
|
||||
float Vector3<T>::Distancef(const Vector3& vec) const
|
||||
{
|
||||
|
|
@ -209,7 +197,6 @@ namespace Nz
|
|||
*
|
||||
* \see AbsDotProduct, DotProduct
|
||||
*/
|
||||
|
||||
template<typename T>
|
||||
T Vector3<T>::DotProduct(const Vector3& vec) const
|
||||
{
|
||||
|
|
@ -222,7 +209,6 @@ namespace Nz
|
|||
*
|
||||
* \see GetSquaredLength
|
||||
*/
|
||||
|
||||
template<typename T>
|
||||
T Vector3<T>::GetLength() const
|
||||
{
|
||||
|
|
@ -233,7 +219,6 @@ namespace Nz
|
|||
* \brief Calculates the length (magnitude) of the vector
|
||||
* \return The length in float of the vector
|
||||
*/
|
||||
|
||||
template<typename T>
|
||||
float Vector3<T>::GetLengthf() const
|
||||
{
|
||||
|
|
@ -250,7 +235,6 @@ namespace Nz
|
|||
*
|
||||
* \see Normalize
|
||||
*/
|
||||
|
||||
template<typename T>
|
||||
Vector3<T> Vector3<T>::GetNormal(T* length) const
|
||||
{
|
||||
|
|
@ -266,7 +250,6 @@ namespace Nz
|
|||
*
|
||||
* \see GetLength
|
||||
*/
|
||||
|
||||
template<typename T>
|
||||
T Vector3<T>::GetSquaredLength() const
|
||||
{
|
||||
|
|
@ -279,7 +262,6 @@ namespace Nz
|
|||
*
|
||||
* \see Backward
|
||||
*/
|
||||
|
||||
template<typename T>
|
||||
Vector3<T>& Vector3<T>::MakeBackward()
|
||||
{
|
||||
|
|
@ -292,7 +274,6 @@ namespace Nz
|
|||
*
|
||||
* \see Down
|
||||
*/
|
||||
|
||||
template<typename T>
|
||||
Vector3<T>& Vector3<T>::MakeDown()
|
||||
{
|
||||
|
|
@ -305,7 +286,6 @@ namespace Nz
|
|||
*
|
||||
* \see Forward
|
||||
*/
|
||||
|
||||
template<typename T>
|
||||
Vector3<T>& Vector3<T>::MakeForward()
|
||||
{
|
||||
|
|
@ -318,7 +298,6 @@ namespace Nz
|
|||
*
|
||||
* \see Left
|
||||
*/
|
||||
|
||||
template<typename T>
|
||||
Vector3<T>& Vector3<T>::MakeLeft()
|
||||
{
|
||||
|
|
@ -331,7 +310,6 @@ namespace Nz
|
|||
*
|
||||
* \see Right
|
||||
*/
|
||||
|
||||
template<typename T>
|
||||
Vector3<T>& Vector3<T>::MakeRight()
|
||||
{
|
||||
|
|
@ -344,7 +322,6 @@ namespace Nz
|
|||
*
|
||||
* \see Unit
|
||||
*/
|
||||
|
||||
template<typename T>
|
||||
Vector3<T>& Vector3<T>::MakeUnit()
|
||||
{
|
||||
|
|
@ -357,7 +334,6 @@ namespace Nz
|
|||
*
|
||||
* \see UnitX
|
||||
*/
|
||||
|
||||
template<typename T>
|
||||
Vector3<T>& Vector3<T>::MakeUnitX()
|
||||
{
|
||||
|
|
@ -370,7 +346,6 @@ namespace Nz
|
|||
*
|
||||
* \see UnitY
|
||||
*/
|
||||
|
||||
template<typename T>
|
||||
Vector3<T>& Vector3<T>::MakeUnitY()
|
||||
{
|
||||
|
|
@ -383,7 +358,6 @@ namespace Nz
|
|||
*
|
||||
* \see UnitZ
|
||||
*/
|
||||
|
||||
template<typename T>
|
||||
Vector3<T>& Vector3<T>::MakeUnitZ()
|
||||
{
|
||||
|
|
@ -396,7 +370,6 @@ namespace Nz
|
|||
*
|
||||
* \see Up
|
||||
*/
|
||||
|
||||
template<typename T>
|
||||
Vector3<T>& Vector3<T>::MakeUp()
|
||||
{
|
||||
|
|
@ -409,7 +382,6 @@ namespace Nz
|
|||
*
|
||||
* \see Zero
|
||||
*/
|
||||
|
||||
template<typename T>
|
||||
Vector3<T>& Vector3<T>::MakeZero()
|
||||
{
|
||||
|
|
@ -424,7 +396,6 @@ namespace Nz
|
|||
*
|
||||
* \see Minimize
|
||||
*/
|
||||
|
||||
template<typename T>
|
||||
Vector3<T>& Vector3<T>::Maximize(const Vector3& vec)
|
||||
{
|
||||
|
|
@ -448,7 +419,6 @@ namespace Nz
|
|||
*
|
||||
* \see Maximize
|
||||
*/
|
||||
|
||||
template<typename T>
|
||||
Vector3<T>& Vector3<T>::Minimize(const Vector3& vec)
|
||||
{
|
||||
|
|
@ -474,7 +444,6 @@ namespace Nz
|
|||
*
|
||||
* \see GetNormal
|
||||
*/
|
||||
|
||||
template<typename T>
|
||||
Vector3<T>& Vector3<T>::Normalize(T* length)
|
||||
{
|
||||
|
|
@ -501,7 +470,6 @@ namespace Nz
|
|||
* \param Y Y component
|
||||
* \param Z Z component
|
||||
*/
|
||||
|
||||
template<typename T>
|
||||
Vector3<T>& Vector3<T>::Set(T X, T Y, T Z)
|
||||
{
|
||||
|
|
@ -518,7 +486,6 @@ namespace Nz
|
|||
* \param X X component
|
||||
* \param vec vec.X = Y component and vec.y = Z component
|
||||
*/
|
||||
|
||||
template<typename T>
|
||||
Vector3<T>& Vector3<T>::Set(T X, const Vector2<T>& vec)
|
||||
{
|
||||
|
|
@ -535,7 +502,6 @@ namespace Nz
|
|||
*
|
||||
* \param scale X component = Y component = Z component
|
||||
*/
|
||||
|
||||
template<typename T>
|
||||
Vector3<T>& Vector3<T>::Set(T scale)
|
||||
{
|
||||
|
|
@ -552,7 +518,6 @@ namespace Nz
|
|||
*
|
||||
* \param vec[3] vec[0] is X component, vec[1] is Y component and vec[2] is Z component
|
||||
*/
|
||||
|
||||
template<typename T>
|
||||
Vector3<T>& Vector3<T>::Set(const T vec[3])
|
||||
{
|
||||
|
|
@ -567,7 +532,6 @@ namespace Nz
|
|||
* \param vec vec.X = X component and vec.y = Y component
|
||||
* \param Z Z component
|
||||
*/
|
||||
|
||||
template<typename T>
|
||||
Vector3<T>& Vector3<T>::Set(const Vector2<T>& vec, T Z)
|
||||
{
|
||||
|
|
@ -584,7 +548,6 @@ namespace Nz
|
|||
*
|
||||
* \param vec The other vector
|
||||
*/
|
||||
|
||||
template<typename T>
|
||||
Vector3<T>& Vector3<T>::Set(const Vector3& vec)
|
||||
{
|
||||
|
|
@ -599,7 +562,6 @@ namespace Nz
|
|||
*
|
||||
* \param vec Vector of type U to convert its components
|
||||
*/
|
||||
|
||||
template<typename T>
|
||||
template<typename U>
|
||||
Vector3<T>& Vector3<T>::Set(const Vector3<U>& vec)
|
||||
|
|
@ -617,7 +579,6 @@ namespace Nz
|
|||
*
|
||||
* \param vec Vector4 where only the first three components are taken
|
||||
*/
|
||||
|
||||
template<typename T>
|
||||
Vector3<T>& Vector3<T>::Set(const Vector4<T>& vec)
|
||||
{
|
||||
|
|
@ -636,7 +597,6 @@ namespace Nz
|
|||
*
|
||||
* \see Distance
|
||||
*/
|
||||
|
||||
template<typename T>
|
||||
T Vector3<T>::SquaredDistance(const Vector3& vec) const
|
||||
{
|
||||
|
|
@ -647,7 +607,6 @@ namespace Nz
|
|||
* \brief Gives a string representation
|
||||
* \return A string representation of the object: "Vector3(x, y, z)"
|
||||
*/
|
||||
|
||||
template<typename T>
|
||||
String Vector3<T>::ToString() const
|
||||
{
|
||||
|
|
@ -662,7 +621,6 @@ namespace Nz
|
|||
*
|
||||
* \remark Access to index greather than 2 is undefined behavior
|
||||
*/
|
||||
|
||||
template<typename T>
|
||||
Vector3<T>::operator T* ()
|
||||
{
|
||||
|
|
@ -675,7 +633,6 @@ namespace Nz
|
|||
*
|
||||
* \remark Access to index greather than 2 is undefined behavior
|
||||
*/
|
||||
|
||||
template<typename T>
|
||||
Vector3<T>::operator const T* () const
|
||||
{
|
||||
|
|
@ -686,7 +643,6 @@ namespace Nz
|
|||
* \brief Helps to represent the sign of the vector
|
||||
* \return A constant reference to this vector
|
||||
*/
|
||||
|
||||
template<typename T>
|
||||
const Vector3<T>& Vector3<T>::operator+() const
|
||||
{
|
||||
|
|
@ -697,7 +653,6 @@ namespace Nz
|
|||
* \brief Negates the components of the vector
|
||||
* \return A constant reference to this vector with negate components
|
||||
*/
|
||||
|
||||
template<typename T>
|
||||
Vector3<T> Vector3<T>::operator-() const
|
||||
{
|
||||
|
|
@ -710,7 +665,6 @@ namespace Nz
|
|||
*
|
||||
* \param vec The other vector to add components with
|
||||
*/
|
||||
|
||||
template<typename T>
|
||||
Vector3<T> Vector3<T>::operator+(const Vector3& vec) const
|
||||
{
|
||||
|
|
@ -723,7 +677,6 @@ namespace Nz
|
|||
*
|
||||
* \param vec The other vector to substract components with
|
||||
*/
|
||||
|
||||
template<typename T>
|
||||
Vector3<T> Vector3<T>::operator-(const Vector3& vec) const
|
||||
{
|
||||
|
|
@ -736,7 +689,6 @@ namespace Nz
|
|||
*
|
||||
* \param vec The other vector to multiply components with
|
||||
*/
|
||||
|
||||
template<typename T>
|
||||
Vector3<T> Vector3<T>::operator*(const Vector3& vec) const
|
||||
{
|
||||
|
|
@ -749,7 +701,6 @@ namespace Nz
|
|||
*
|
||||
* \param scale The scalar to multiply components with
|
||||
*/
|
||||
|
||||
template<typename T>
|
||||
Vector3<T> Vector3<T>::operator*(T scale) const
|
||||
{
|
||||
|
|
@ -765,7 +716,6 @@ namespace Nz
|
|||
* \remark Produce a NazaraError if one of the vec components is null with NAZARA_MATH_SAFE defined
|
||||
* \throw std::domain_error if NAZARA_MATH_SAFE is defined and one of the vec components is null
|
||||
*/
|
||||
|
||||
template<typename T>
|
||||
Vector3<T> Vector3<T>::operator/(const Vector3& vec) const
|
||||
{
|
||||
|
|
@ -791,7 +741,6 @@ namespace Nz
|
|||
* \remark Produce a NazaraError if scale is null with NAZARA_MATH_SAFE defined
|
||||
* \throw std::domain_error if NAZARA_MATH_SAFE is defined and scale is null
|
||||
*/
|
||||
|
||||
template<typename T>
|
||||
Vector3<T> Vector3<T>::operator/(T scale) const
|
||||
{
|
||||
|
|
@ -814,7 +763,6 @@ namespace Nz
|
|||
*
|
||||
* \param vec The other vector to add components with
|
||||
*/
|
||||
|
||||
template<typename T>
|
||||
Vector3<T>& Vector3<T>::operator+=(const Vector3& vec)
|
||||
{
|
||||
|
|
@ -831,7 +779,6 @@ namespace Nz
|
|||
*
|
||||
* \param vec The other vector to substract components with
|
||||
*/
|
||||
|
||||
template<typename T>
|
||||
Vector3<T>& Vector3<T>::operator-=(const Vector3& vec)
|
||||
{
|
||||
|
|
@ -848,7 +795,6 @@ namespace Nz
|
|||
*
|
||||
* \param vec The other vector to multiply components with
|
||||
*/
|
||||
|
||||
template<typename T>
|
||||
Vector3<T>& Vector3<T>::operator*=(const Vector3& vec)
|
||||
{
|
||||
|
|
@ -865,7 +811,6 @@ namespace Nz
|
|||
*
|
||||
* \param vec The other vector to multiply components with
|
||||
*/
|
||||
|
||||
template<typename T>
|
||||
Vector3<T>& Vector3<T>::operator*=(T scale)
|
||||
{
|
||||
|
|
@ -885,7 +830,6 @@ namespace Nz
|
|||
* \remark Produce a NazaraError if one of the vec components is null with NAZARA_MATH_SAFE defined
|
||||
* \throw std::domain_error if NAZARA_MATH_SAFE is defined and one of the vec components is null
|
||||
*/
|
||||
|
||||
template<typename T>
|
||||
Vector3<T>& Vector3<T>::operator/=(const Vector3& vec)
|
||||
{
|
||||
|
|
@ -913,7 +857,6 @@ namespace Nz
|
|||
* \remark Produce a NazaraError if scale is null with NAZARA_MATH_SAFE defined
|
||||
* \throw std::domain_error if NAZARA_MATH_SAFE is defined and scale is null
|
||||
*/
|
||||
|
||||
template<typename T>
|
||||
Vector3<T>& Vector3<T>::operator/=(T scale)
|
||||
{
|
||||
|
|
@ -938,7 +881,6 @@ namespace Nz
|
|||
*
|
||||
* \param vec Other vector to compare with
|
||||
*/
|
||||
|
||||
template<typename T>
|
||||
bool Vector3<T>::operator==(const Vector3& vec) const
|
||||
{
|
||||
|
|
@ -953,7 +895,6 @@ namespace Nz
|
|||
*
|
||||
* \param vec Other vector to compare with
|
||||
*/
|
||||
|
||||
template<typename T>
|
||||
bool Vector3<T>::operator!=(const Vector3& vec) const
|
||||
{
|
||||
|
|
@ -966,7 +907,6 @@ namespace Nz
|
|||
*
|
||||
* \param vec Other vector to compare with
|
||||
*/
|
||||
|
||||
template<typename T>
|
||||
bool Vector3<T>::operator<(const Vector3& vec) const
|
||||
{
|
||||
|
|
@ -987,7 +927,6 @@ namespace Nz
|
|||
*
|
||||
* \param vec Other vector to compare with
|
||||
*/
|
||||
|
||||
template<typename T>
|
||||
bool Vector3<T>::operator<=(const Vector3& vec) const
|
||||
{
|
||||
|
|
@ -1008,7 +947,6 @@ namespace Nz
|
|||
*
|
||||
* \param vec Other vector to compare with
|
||||
*/
|
||||
|
||||
template<typename T>
|
||||
bool Vector3<T>::operator>(const Vector3& vec) const
|
||||
{
|
||||
|
|
@ -1021,7 +959,6 @@ namespace Nz
|
|||
*
|
||||
* \param vec Other vector to compare with
|
||||
*/
|
||||
|
||||
template<typename T>
|
||||
bool Vector3<T>::operator>=(const Vector3& vec) const
|
||||
{
|
||||
|
|
@ -1037,7 +974,6 @@ namespace Nz
|
|||
*
|
||||
* \see CrossProduct
|
||||
*/
|
||||
|
||||
template<typename T>
|
||||
Vector3<T> Vector3<T>::CrossProduct(const Vector3& vec1, const Vector3& vec2)
|
||||
{
|
||||
|
|
@ -1053,7 +989,6 @@ namespace Nz
|
|||
*
|
||||
* \see AbsDotProduct, DotProduct
|
||||
*/
|
||||
|
||||
template<typename T>
|
||||
T Vector3<T>::DotProduct(const Vector3& vec1, const Vector3& vec2)
|
||||
{
|
||||
|
|
@ -1066,7 +1001,6 @@ namespace Nz
|
|||
*
|
||||
* \see MakeBackward
|
||||
*/
|
||||
|
||||
template<typename T>
|
||||
Vector3<T> Vector3<T>::Backward()
|
||||
{
|
||||
|
|
@ -1082,7 +1016,6 @@ namespace Nz
|
|||
*
|
||||
* \see MakeDown
|
||||
*/
|
||||
|
||||
template<typename T>
|
||||
Vector3<T> Vector3<T>::Down()
|
||||
{
|
||||
|
|
@ -1098,7 +1031,6 @@ namespace Nz
|
|||
*
|
||||
* \see Forward
|
||||
*/
|
||||
|
||||
template<typename T>
|
||||
Vector3<T> Vector3<T>::Forward()
|
||||
{
|
||||
|
|
@ -1114,7 +1046,6 @@ namespace Nz
|
|||
*
|
||||
* \see MakeLeft
|
||||
*/
|
||||
|
||||
template<typename T>
|
||||
Vector3<T> Vector3<T>::Left()
|
||||
{
|
||||
|
|
@ -1136,7 +1067,6 @@ namespace Nz
|
|||
*
|
||||
* \see Lerp
|
||||
*/
|
||||
|
||||
template<typename T>
|
||||
Vector3<T> Vector3<T>::Lerp(const Vector3& from, const Vector3& to, T interpolation)
|
||||
{
|
||||
|
|
@ -1158,7 +1088,6 @@ namespace Nz
|
|||
*
|
||||
* \see GetNormal
|
||||
*/
|
||||
|
||||
template<typename T>
|
||||
Vector3<T> Vector3<T>::Normalize(const Vector3& vec)
|
||||
{
|
||||
|
|
@ -1171,7 +1100,6 @@ namespace Nz
|
|||
*
|
||||
* \see MakeRight
|
||||
*/
|
||||
|
||||
template<typename T>
|
||||
Vector3<T> Vector3<T>::Right()
|
||||
{
|
||||
|
|
@ -1187,7 +1115,6 @@ namespace Nz
|
|||
*
|
||||
* \see MakeUnit
|
||||
*/
|
||||
|
||||
template<typename T>
|
||||
Vector3<T> Vector3<T>::Unit()
|
||||
{
|
||||
|
|
@ -1203,7 +1130,6 @@ namespace Nz
|
|||
*
|
||||
* \see MakeUnitX
|
||||
*/
|
||||
|
||||
template<typename T>
|
||||
Vector3<T> Vector3<T>::UnitX()
|
||||
{
|
||||
|
|
@ -1219,7 +1145,6 @@ namespace Nz
|
|||
*
|
||||
* \see MakeUnitY
|
||||
*/
|
||||
|
||||
template<typename T>
|
||||
Vector3<T> Vector3<T>::UnitY()
|
||||
{
|
||||
|
|
@ -1235,7 +1160,6 @@ namespace Nz
|
|||
*
|
||||
* \see MakeUnitZ
|
||||
*/
|
||||
|
||||
template<typename T>
|
||||
Vector3<T> Vector3<T>::UnitZ()
|
||||
{
|
||||
|
|
@ -1251,7 +1175,6 @@ namespace Nz
|
|||
*
|
||||
* \see MakeUp
|
||||
*/
|
||||
|
||||
template<typename T>
|
||||
Vector3<T> Vector3<T>::Up()
|
||||
{
|
||||
|
|
@ -1267,7 +1190,6 @@ namespace Nz
|
|||
*
|
||||
* \see MakeZero
|
||||
*/
|
||||
|
||||
template<typename T>
|
||||
Vector3<T> Vector3<T>::Zero()
|
||||
{
|
||||
|
|
@ -1276,6 +1198,50 @@ namespace Nz
|
|||
|
||||
return vector;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Serializes a Vector3
|
||||
* \return true if successfully serialized
|
||||
*
|
||||
* \param context Serialization context
|
||||
* \param vector Input Vector3
|
||||
*/
|
||||
template<typename T>
|
||||
bool Serialize(SerializationContext& context, const Vector3<T>& vector)
|
||||
{
|
||||
if (!Serialize(context, vector.x))
|
||||
return false;
|
||||
|
||||
if (!Serialize(context, vector.y))
|
||||
return false;
|
||||
|
||||
if (!Serialize(context, vector.z))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Unserializes a Vector3
|
||||
* \return true if successfully unserialized
|
||||
*
|
||||
* \param context Serialization context
|
||||
* \param vector Output Vector3
|
||||
*/
|
||||
template<typename T>
|
||||
bool Unserialize(SerializationContext& context, Vector3<T>* vector)
|
||||
{
|
||||
if (!Unserialize(context, &vector->x))
|
||||
return false;
|
||||
|
||||
if (!Unserialize(context, &vector->y))
|
||||
return false;
|
||||
|
||||
if (!Unserialize(context, &vector->z))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
#ifndef NAZARA_VECTOR4_HPP
|
||||
#define NAZARA_VECTOR4_HPP
|
||||
|
||||
#include <Nazara/Core/Serialization.hpp>
|
||||
#include <Nazara/Core/String.hpp>
|
||||
|
||||
namespace Nz
|
||||
|
|
@ -104,6 +105,9 @@ namespace Nz
|
|||
typedef Vector4<unsigned int> Vector4ui;
|
||||
typedef Vector4<Int32> Vector4i32;
|
||||
typedef Vector4<UInt32> Vector4ui32;
|
||||
|
||||
template<typename T> bool Serialize(SerializationContext& context, const Vector4<T>& vector);
|
||||
template<typename T> bool Unserialize(SerializationContext& context, Vector4<T>* vector);
|
||||
}
|
||||
|
||||
template<typename T> std::ostream& operator<<(std::ostream& out, const Nz::Vector4<T>& vec);
|
||||
|
|
|
|||
|
|
@ -1013,6 +1013,56 @@ namespace Nz
|
|||
|
||||
return vector;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Serializes a Vector4
|
||||
* \return true if successfully serialized
|
||||
*
|
||||
* \param context Serialization context
|
||||
* \param vector Input Vector3
|
||||
*/
|
||||
template<typename T>
|
||||
bool Serialize(SerializationContext& context, const Vector4<T>& vector)
|
||||
{
|
||||
if (!Serialize(context, vector.x))
|
||||
return false;
|
||||
|
||||
if (!Serialize(context, vector.y))
|
||||
return false;
|
||||
|
||||
if (!Serialize(context, vector.z))
|
||||
return false;
|
||||
|
||||
if (!Serialize(context, vector.w))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Unserializes a Vector4
|
||||
* \return true if successfully unserialized
|
||||
*
|
||||
* \param context Serialization context
|
||||
* \param vector Output Vector3
|
||||
*/
|
||||
template<typename T>
|
||||
bool Unserialize(SerializationContext& context, Vector4<T>* vector)
|
||||
{
|
||||
if (!Unserialize(context, &vector->x))
|
||||
return false;
|
||||
|
||||
if (!Unserialize(context, &vector->y))
|
||||
return false;
|
||||
|
||||
if (!Unserialize(context, &vector->z))
|
||||
return false;
|
||||
|
||||
if (!Unserialize(context, &vector->w))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
|
|
|
|||
Loading…
Reference in New Issue