56 lines
1.1 KiB
C++
56 lines
1.1 KiB
C++
#pragma once
|
|
#include "../../inc/glm/common.hpp"
|
|
#include "../../core/Defines.h"
|
|
#include "../../core/BitHelper.h"
|
|
#include <vector>
|
|
|
|
class MaterialLibraryPointer :
|
|
public glm::u16vec2
|
|
{
|
|
public:
|
|
MaterialLibraryPointer() : glm::u16vec2() {}
|
|
MaterialLibraryPointer(const unsigned16 v) : glm::u16vec2(v) {}
|
|
MaterialLibraryPointer(const unsigned16 x, const unsigned16 y) : glm::u16vec2(x, y) {}
|
|
~MaterialLibraryPointer() {}
|
|
|
|
MaterialLibraryPointer& operator=(const unsigned& source)
|
|
{
|
|
x = (source & 0xFFFF0000) >> 16;
|
|
y = source & 0x0000FFFF;
|
|
return *this;
|
|
}
|
|
|
|
std::vector<unsigned8> Serialize()
|
|
{
|
|
return BitHelper::SplitInBytes(this->operator unsigned());
|
|
}
|
|
|
|
operator unsigned() const
|
|
{
|
|
return (((unsigned)x) << 16) | y;
|
|
}
|
|
|
|
bool operator==(const MaterialLibraryPointer& other) const
|
|
{
|
|
return x == other.x && y == other.y;
|
|
}
|
|
|
|
bool operator!=(const MaterialLibraryPointer& other) const
|
|
{
|
|
return !(*this == other);
|
|
}
|
|
};
|
|
|
|
// Perfect hash
|
|
namespace std
|
|
{
|
|
template<>
|
|
struct hash<MaterialLibraryPointer>
|
|
{
|
|
size_t operator()(MaterialLibraryPointer const &value) const
|
|
{
|
|
return (unsigned) value;
|
|
}
|
|
};
|
|
}
|