From fbd02b5fbe5b0293cf8becf35181f4a42b16df9d Mon Sep 17 00:00:00 2001 From: Kp Date: Sun, 19 Feb 2017 19:33:38 +0000 Subject: [PATCH] Factor out template functor of create_vertex_lists_by_predicate --- similar/main/gameseg.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/similar/main/gameseg.cpp b/similar/main/gameseg.cpp index c60712c1d..e36783977 100644 --- a/similar/main/gameseg.cpp +++ b/similar/main/gameseg.cpp @@ -190,13 +190,9 @@ static void create_vertex_list_from_invalid_side(const vcsegptr_t segp, const si throw side::illegal_type(segp, sidep); } -template -static inline uint_fast32_t create_vertex_lists_by_predicate(T &va, const vcsegptr_t segp, const side *const sidep, const F &f) +template +static uint_fast32_t create_vertex_lists_from_values(T &va, const vcsegptr_t segp, const side *const sidep, const V &&f0, const V &&f1, const V &&f2, const V &&f3) { - const auto f0 = f(0); - const auto f1 = f(1); - const auto f2 = f(2); - const auto f3 = f(3); const auto type = sidep->get_type(); if (type == SIDE_IS_TRI_13) { @@ -232,6 +228,12 @@ static inline uint_fast32_t create_vertex_lists_by_predicate(T &va, const vcsegp } } +template +static inline uint_fast32_t create_vertex_lists_by_predicate(T &va, const vcsegptr_t segp, const side *const sidep, const F &&f) +{ + return create_vertex_lists_from_values(va, segp, sidep, f(0), f(1), f(2), f(3)); +} + #if DXX_USE_EDITOR // ----------------------------------------------------------------------------------- // Create all vertex lists (1 or 2) for faces on a side. @@ -248,10 +250,9 @@ uint_fast32_t create_all_vertex_lists(vertex_array_list_t &vertices, const vcseg { assert(sidenum < Side_to_verts_int.size()); auto &sv = Side_to_verts_int[sidenum]; - const auto a = [&sv](const uint_fast32_t vv) { + return create_vertex_lists_by_predicate(vertices, segp, sidep, [&sv](const uint_fast32_t vv) { return sv[vv]; - }; - return create_vertex_lists_by_predicate(vertices, segp, sidep, a); + }); } #endif