#ifndef CACHE_HPP
#define CACHE_HPP
#include "Constants.hpp"
#include "GlslLayout.hpp"
#include "Id.hpp"
#include "Mesh.hpp"
#include "Primitive.hpp"
namespace wren {
class StaticMesh;
class Texture2d;
namespace cache {
uint64_t sipHash13c(const char *bytes, const size_t size);
struct Key {
Key();
explicit Key(const uint64_t hashValue);
bool operator==(const Key &other) const;
size_t mHash;
};
struct PhongMaterialData : public IdPhongMaterial {
explicit PhongMaterialData(const GlslLayout::PhongMaterial &material);
size_t mNumUsers;
GlslLayout::PhongMaterial mMaterial;
};
struct PbrMaterialData : public IdPbrMaterial {
explicit PbrMaterialData(const GlslLayout::PbrMaterial &material);
size_t mNumUsers;
GlslLayout::PbrMaterial mMaterial;
};
struct MeshData : public IdMesh {
MeshData();
~MeshData() {}
size_t mNumUsers;
unsigned int mGlNameVertexArrayObject;
unsigned int mGlNameBufferCoords;
unsigned int mGlNameBufferNormals;
unsigned int mGlNameBufferTexCoords;
unsigned int mGlNameBufferIndices;
unsigned int mGlNameBufferColors;
unsigned int mGlNameBufferUnwrappedTexCoords;
unsigned int mGlNameVertexArrayObjectShadow;
unsigned int mGlNameBufferShadowCoords;
unsigned int mIndexCount;
unsigned int mVertexCount;
bool mIsCachePersistent;
bool mSupportShadows;
std::vector<glm::vec4> mShadowCoords;
std::vector<Mesh::Triangle> mTriangles;
std::vector<Mesh::Edge> mEdges;
primitive::Sphere mBoundingSphere;
primitive::Aabb mAabb;
};
struct Texture2dData {
explicit Texture2dData(const Texture2d &texture);
size_t mNumUsers;
unsigned int mGlName;
int mWidth;
int mHeight;
bool mIsTranslucent;
bool mIsCachePersistent;
};
} }
namespace std {
template<> struct hash<wren::cache::Key> { size_t operator()(const wren::cache::Key &key) const; };
template<> struct hash<glm::vec3> { size_t operator()(const glm::vec3 &key) const; };
template<> struct hash<std::pair<size_t, size_t>> { size_t operator()(const std::pair<size_t, size_t> &key) const; };
}
#endif