-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVertex.h
36 lines (30 loc) · 853 Bytes
/
Vertex.h
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
#pragma once
#include "Basics.h"
struct Vertex {
float posX, posY, posZ;
float normalX, normalY, normalZ;
float u, v;
uint32_t matID = 0;
//needed for unordnered map
bool operator==(const Vertex& other) const {
return posX == other.posX && posY == other.posY && posZ == other.posZ &&
normalX == other.normalX && normalY == other.normalY && normalZ == other.normalZ &&
u == other.u && v == other.v;
}
};
//TODO: quickly done, research alternatives
namespace std {
template <>
struct hash<Vertex>
{
std::size_t operator()(const Vertex& k) const
{
size_t h1 = std::hash<float>()(k.posX);
size_t h2 = std::hash<float>()(k.posY);
size_t h3 = std::hash<float>()(k.posZ);
size_t h4 = std::hash<float>()(k.u);
size_t h5 = std::hash<float>()(k.v);
return h1 ^ (h2 << 1) ^ (h3 << 2) ^ (h4 << 3) ^ (h5 << 4);
}
};
}