|
@@ -25,14 +25,14 @@ public:
|
|
|
virtual bool IsFailed() const = 0;
|
|
|
|
|
|
/// Read a primitive (e.g. float, int, etc.) from the binary stream
|
|
|
- template <class T>
|
|
|
+ template <class T, std::enable_if_t<std::is_trivially_copyable_v<T>, bool> = true>
|
|
|
void Read(T &outT)
|
|
|
{
|
|
|
ReadBytes(&outT, sizeof(outT));
|
|
|
}
|
|
|
|
|
|
/// Read a vector of primitives from the binary stream
|
|
|
- template <class T, class A>
|
|
|
+ template <class T, class A, std::enable_if_t<std::is_trivially_copyable_v<T>, bool> = true>
|
|
|
void Read(std::vector<T, A> &outT)
|
|
|
{
|
|
|
typename Array<T>::size_type len = outT.size(); // Initialize to previous array size, this is used for validation in the StateRecorder class
|
|
@@ -40,8 +40,17 @@ public:
|
|
|
if (!IsEOF() && !IsFailed())
|
|
|
{
|
|
|
outT.resize(len);
|
|
|
- for (typename Array<T>::size_type i = 0; i < len; ++i)
|
|
|
- Read(outT[i]);
|
|
|
+ if constexpr (std::is_same_v<T, Vec3> || std::is_same_v<T, DVec3> || std::is_same_v<T, DMat44>)
|
|
|
+ {
|
|
|
+ // These types have unused components that we don't want to read
|
|
|
+ for (typename Array<T>::size_type i = 0; i < len; ++i)
|
|
|
+ Read(outT[i]);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ // Read all elements at once
|
|
|
+ ReadBytes(outT.data(), len * sizeof(T));
|
|
|
+ }
|
|
|
}
|
|
|
else
|
|
|
outT.clear();
|