From 31e3665862a951236a4a32c1543086e60bc521f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A4r=20Winzell?= Date: Tue, 6 Aug 2019 17:22:30 -0700 Subject: [PATCH] Minor cleanup. --- src/fbx/Fbx2Raw.cpp | 2 +- src/raw/RawModel.cpp | 9 +++++++++ src/raw/RawModel.hpp | 21 ++++++--------------- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/fbx/Fbx2Raw.cpp b/src/fbx/Fbx2Raw.cpp index 4f56f0e..325b7e0 100644 --- a/src/fbx/Fbx2Raw.cpp +++ b/src/fbx/Fbx2Raw.cpp @@ -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) diff --git a/src/raw/RawModel.cpp b/src/raw/RawModel.cpp index f5c40d9..84b8ae9 100644 --- a/src/raw/RawModel.cpp +++ b/src/raw/RawModel.cpp @@ -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{}; + 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) && diff --git a/src/raw/RawModel.hpp b/src/raw/RawModel.hpp index 1c5aa36..81452d6 100644 --- a/src/raw/RawModel.hpp +++ b/src/raw/RawModel.hpp @@ -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 blends{}; + std::vector 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{}; - 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 {