I am trying to serialize a glm::vec3 variable in my Camera class.
class Camera
{
glm::vec3 Position;
float Yaw;
private:
friend class boost::serialization::access;
template<typename Archive>
void save(Archive& ar, const unsigned int version) const {
ar & Position & Yaw;
}
template<typename Archive>
void load(Archive& ar, const unsigned int version) {
ar & Position & Yaw;
}
BOOST_SERIALIZATION_SPLIT_MEMBER()
}
Now i am creating another header file with the name of BoostGlm.h with the following content.
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <boost/serialization/map.hpp>
#include <boost/serialization/split_free.hpp>
namespace boost
{
namespace serialization
{
template<class Archive>
void save(Archive & ar, glm::tvec3<float>& vec, const unsigned int version)
{
ar & boost::serialization::make_nvp("x", vec.x);
ar & boost::serialization::make_nvp("y", vec.y);
ar & boost::serialization::make_nvp("z", vec.z);
}
template<class Archive>
void load(Archive & ar, glm::tvec3<float>& vec, const unsigned int version)
{
ar & boost::serialization::make_nvp("x", vec.x);
ar & boost::serialization::make_nvp("y", vec.y);
ar & boost::serialization::make_nvp("z", vec.z);
}
}
}
My question is now how do i make boost understand how to serialize glm::vec3 , where do i need to add this file.