From c3b032626c841e180e67aed6093397b8caafbd6c Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Thu, 13 Oct 2022 20:00:30 +0100 Subject: Support searching node network by vec3 position --- game/network/network.h | 2 +- lib/sorting.hpp | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/game/network/network.h b/game/network/network.h index 79a4a2b..34e6a60 100644 --- a/game/network/network.h +++ b/game/network/network.h @@ -37,7 +37,7 @@ public: protected: static void joinLinks(const LinkPtr & l, const LinkPtr & ol); - using Nodes = std::set>; + using Nodes = std::set>; Nodes nodes; std::shared_ptr texture; }; diff --git a/lib/sorting.hpp b/lib/sorting.hpp index 6b9be6a..0604aaf 100644 --- a/lib/sorting.hpp +++ b/lib/sorting.hpp @@ -1,5 +1,7 @@ #pragma once +#include + template struct PtrSorter { bool operator()(const T & a, const T & b) const @@ -7,3 +9,22 @@ template struct PtrSorter { return *a < *b; } }; + +template struct PtrMemberSorter : public PtrSorter { + using MT = std::decay_t; + using is_transparent = MT; + + using PtrSorter::operator(); + + bool + operator()(const MT & a, const T & b) const + { + return a < (*b).*M; + } + + bool + operator()(const T & a, const MT & b) const + { + return (*a).*M < b; + } +}; -- cgit v1.2.3