forked from Shell4026/ShellEngine
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathModelLoader.h
More file actions
62 lines (53 loc) · 1.2 KB
/
Copy pathModelLoader.h
File metadata and controls
62 lines (53 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#pragma once
#include "Export.h"
#include "Core/Util.h"
#include "glm/vec3.hpp"
#include "glm/vec2.hpp"
#define GLM_ENABLE_EXPERIMENTAL
#include <glm/gtx/hash.hpp>
#include <string_view>
namespace sh::render
{
class Renderer;
class Mesh;
}
namespace sh::game
{
class ModelLoader
{
private:
struct Indices
{
uint32_t vert;
uint32_t normal;
uint32_t uv;
bool operator==(const Indices& other) const
{
return vert == other.vert
&& normal == other.normal
&& uv == other.uv;
}
};
friend std::hash<sh::game::ModelLoader::Indices>;
public:
const render::Renderer& renderer;
public:
SH_GAME_API ModelLoader(const render::Renderer& renderer);
SH_GAME_API virtual ~ModelLoader() = default;
SH_GAME_API virtual auto Load(std::string_view filename) -> render::Mesh*;
};
}//namespace
namespace std
{
template <>
class hash<sh::game::ModelLoader::Indices>
{
public:
auto operator()(const sh::game::ModelLoader::Indices& indices) const -> std::uint64_t
{
std::hash<uint32_t> hasher{};
std::size_t hash1 = sh::core::Util::CombineHash(hasher(indices.vert), hasher(indices.normal));
return sh::core::Util::CombineHash(hash1, hasher(indices.uv));
}
};
}