From 7b662f7adf1a81489ceedda503674b2e8db47237 Mon Sep 17 00:00:00 2001 From: Duskhorn Date: Mon, 6 Mar 2023 10:50:54 +0100 Subject: [PATCH 1/6] added relevant std::hash and operator==() --- octa.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/octa.h b/octa.h index 51c71c7..2c3b232 100644 --- a/octa.h +++ b/octa.h @@ -280,6 +280,10 @@ class cube ushort material, tex; ivec n; int offset; + + bool operator==(const cfkey &o) { + return orient == o.orient && tex == o.tex && n == o.n && offset == o.offset && material == o.material; + } }; //need htcmp to be free functions to work with tools.h @@ -287,6 +291,14 @@ class cube friend bool htcmp(const cube::cfkey &x, const cube::cfkey &y); friend uint hthash(const cube::cfkey &k); friend std::hash; //for unordered_map + friend std::hash; //for unordered_map +}; + +template<> +struct std::hash { + size_t operator()(const cube::cfkey &k) const { + return hthash(k.n)^k.offset^k.tex^k.orient^k.material; + } }; /** From f210c96e3ffd481c9ede9e236c043efcf109c5d4 Mon Sep 17 00:00:00 2001 From: Duskhorn Date: Mon, 6 Mar 2023 10:53:34 +0100 Subject: [PATCH 2/6] removed hthash call in favor of std::hash --- octa.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/octa.h b/octa.h index 2c3b232..f13de84 100644 --- a/octa.h +++ b/octa.h @@ -297,7 +297,7 @@ class cube template<> struct std::hash { size_t operator()(const cube::cfkey &k) const { - return hthash(k.n)^k.offset^k.tex^k.orient^k.material; + return std::hash{}(k.n)^k.offset^k.tex^k.orient^k.material; } }; From 26cbc57b19f2d48516e6f65e023a624be8f8a2b5 Mon Sep 17 00:00:00 2001 From: Duskhorn Date: Mon, 6 Mar 2023 10:54:39 +0100 Subject: [PATCH 3/6] removed htcmp and hthash for ivec; not needed anymore :) --- geom.h | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/geom.h b/geom.h index a333afd..33eedf7 100644 --- a/geom.h +++ b/geom.h @@ -1750,16 +1750,6 @@ struct ivec inline vec::vec(const ivec &v) : x(v.x), y(v.y), z(v.z) {} -inline bool htcmp(const ivec &x, const ivec &y) -{ - return x == y; -} - -inline uint hthash(const ivec &k) -{ - return k.x^k.y^k.z; -} - template<> struct std::hash { size_t operator()(const ivec &k) const { From 3ec18319cc4df003550793ba4ae2dc729879c060 Mon Sep 17 00:00:00 2001 From: Duskhorn Date: Mon, 6 Mar 2023 10:57:33 +0100 Subject: [PATCH 4/6] removed undefined references --- octa.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/octa.h b/octa.h index f13de84..32d78b5 100644 --- a/octa.h +++ b/octa.h @@ -288,8 +288,6 @@ class cube //need htcmp to be free functions to work with tools.h //but nothing else needs it - friend bool htcmp(const cube::cfkey &x, const cube::cfkey &y); - friend uint hthash(const cube::cfkey &k); friend std::hash; //for unordered_map friend std::hash; //for unordered_map }; From a5d2c9a51d9d8bddc7c39f5964bd5a52cee2737e Mon Sep 17 00:00:00 2001 From: Duskhorn Date: Mon, 6 Mar 2023 10:58:15 +0100 Subject: [PATCH 5/6] removed irrelevant comments --- octa.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/octa.h b/octa.h index 32d78b5..52caa1d 100644 --- a/octa.h +++ b/octa.h @@ -286,8 +286,6 @@ class cube } }; - //need htcmp to be free functions to work with tools.h - //but nothing else needs it friend std::hash; //for unordered_map friend std::hash; //for unordered_map }; From 5172464f117429888c17a48873d1e38f5394a27c Mon Sep 17 00:00:00 2001 From: Duskhorn Date: Mon, 6 Mar 2023 11:01:08 +0100 Subject: [PATCH 6/6] reverted some deletions because it'd have broken the main libprimis(engine) branch --- geom.h | 10 ++++++++++ octa.h | 4 ++++ 2 files changed, 14 insertions(+) diff --git a/geom.h b/geom.h index 33eedf7..a333afd 100644 --- a/geom.h +++ b/geom.h @@ -1750,6 +1750,16 @@ struct ivec inline vec::vec(const ivec &v) : x(v.x), y(v.y), z(v.z) {} +inline bool htcmp(const ivec &x, const ivec &y) +{ + return x == y; +} + +inline uint hthash(const ivec &k) +{ + return k.x^k.y^k.z; +} + template<> struct std::hash { size_t operator()(const ivec &k) const { diff --git a/octa.h b/octa.h index 52caa1d..f13de84 100644 --- a/octa.h +++ b/octa.h @@ -286,6 +286,10 @@ class cube } }; + //need htcmp to be free functions to work with tools.h + //but nothing else needs it + friend bool htcmp(const cube::cfkey &x, const cube::cfkey &y); + friend uint hthash(const cube::cfkey &k); friend std::hash; //for unordered_map friend std::hash; //for unordered_map };