Minor cleanup.

This commit is contained in:
Pär Winzell 2019-08-06 17:22:30 -07:00
parent 7b39358f46
commit 31e3665862
3 changed files with 16 additions and 16 deletions

View File

@ -34,7 +34,7 @@
float scaleFactor;
static std::string NativeToUTF8(const std::string &str) {
static std::string NativeToUTF8(const std::string& str) {
#if _WIN32
char* u8cstr = nullptr;
#if (_UNICODE || UNICODE)

View File

@ -22,6 +22,15 @@
#include "utils/Image_Utils.hpp"
#include "utils/String_Utils.hpp"
size_t VertexHasher::operator()(const RawVertex& v) const {
size_t seed = 5381;
const auto hasher = std::hash<float>{};
seed ^= hasher(v.position[0]) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
seed ^= hasher(v.position[1]) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
seed ^= hasher(v.position[2]) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
return seed;
}
bool RawVertex::operator==(const RawVertex& other) const {
return (position == other.position) && (normal == other.normal) && (tangent == other.tangent) &&
(binormal == other.binormal) && (color == other.color) && (uv0 == other.uv0) &&

View File

@ -39,8 +39,6 @@ struct RawBlendVertex {
};
struct RawVertex {
RawVertex() : polarityUv0(false), pad1(false), pad2(false), pad3(false) {}
Vec3f position{0.0f};
Vec3f normal{0.0f};
Vec3f binormal{0.0f};
@ -57,12 +55,12 @@ struct RawVertex {
int blendSurfaceIx = -1;
// the size of this vector is always identical to the size of the corresponding
// RawSurface.blendChannels
std::vector<RawBlendVertex> blends{};
std::vector<RawBlendVertex> blends;
bool polarityUv0;
bool pad1;
bool pad2;
bool pad3;
bool polarityUv0 = false;
bool pad1 = false;
bool pad2 = false;
bool pad3 = false;
bool operator==(const RawVertex& other) const;
size_t Difference(const RawVertex& other) const;
@ -70,14 +68,7 @@ struct RawVertex {
class VertexHasher {
public:
size_t operator()(const RawVertex& v) const {
size_t seed = 5381;
const auto hasher = std::hash<float>{};
seed ^= hasher(v.position[0]) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
seed ^= hasher(v.position[1]) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
seed ^= hasher(v.position[2]) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
return seed;
}
size_t operator()(const RawVertex& v) const;
};
struct RawTriangle {