From 067dd3cefc2098422f2df0b04f2ed575e28e6b56 Mon Sep 17 00:00:00 2001 From: Tom Nixon Date: Wed, 23 Sep 2020 15:52:59 +0100 Subject: [PATCH 1/2] make facets non-const this allows using custom layouts by writing the required facets before constructing the renderer --- src/common/facets.cpp | 2 +- src/common/facets.hpp | 2 +- tools/create_facets_cpp.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/common/facets.cpp b/src/common/facets.cpp index 0a25b46..66cee57 100644 --- a/src/common/facets.cpp +++ b/src/common/facets.cpp @@ -80,7 +80,7 @@ namespace ear { {16, 3, 5, 14}, {16, 17, 5, 6}, {17, 4, 6, 15}, {9, 10, 5, 6}, }; - const std::map> FACETS = { + std::map> FACETS = { {"0+5+0", FACETS_0_5_0}, {"2+5+0", FACETS_2_5_0}, {"4+5+0", FACETS_4_5_0}, {"4+5+1", FACETS_4_5_1}, {"3+7+0", FACETS_3_7_0}, {"4+9+0", FACETS_4_9_0}, diff --git a/src/common/facets.hpp b/src/common/facets.hpp index 70eab4d..ca164c0 100644 --- a/src/common/facets.hpp +++ b/src/common/facets.hpp @@ -6,5 +6,5 @@ namespace ear { using Facet = std::set; - extern const std::map> FACETS; + extern std::map> FACETS; } // namespace ear diff --git a/tools/create_facets_cpp.py b/tools/create_facets_cpp.py index 82eaaa6..8a66776 100644 --- a/tools/create_facets_cpp.py +++ b/tools/create_facets_cpp.py @@ -22,7 +22,7 @@ positions_nominal = np.concatenate( (layout_extra.nominal_positions, virtual_positions)) facets = _convex_hull_facets(positions_nominal) - print('const std::vector FACETS_' + + print('std::vector FACETS_' + layout_name.replace('+', '_') + ' = {') for facet in facets: print(str(facet) + ',') From f5edb38d71bba8a7165ca584bcae8cf4390df109 Mon Sep 17 00:00:00 2001 From: Tom Nixon Date: Fri, 9 Oct 2020 19:24:01 +0100 Subject: [PATCH 2/2] add external interface for setting facets --- include/ear/layout.hpp | 9 +++++++++ src/common/facets.cpp | 4 ++++ src/common/facets.hpp | 3 +-- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/include/ear/layout.hpp b/include/ear/layout.hpp index c5371b3..6933aca 100644 --- a/include/ear/layout.hpp +++ b/include/ear/layout.hpp @@ -1,5 +1,6 @@ #pragma once #include +#include #include #include #include "common_types.hpp" @@ -95,4 +96,12 @@ namespace ear { boost::optional _screen; }; + using Facet = std::set; + /// Set the facets to be used when triangulating a named layout. + /// + /// This is used for rendering with custom loudspeaker layouts; see + /// tools/create_facets_cpp.py for code to generate these. In general the use + /// of this function can result in non-standard behaviour. + void EAR_EXPORT registerFacets(const std::string& layoutName, + std::vector facets); } // namespace ear diff --git a/src/common/facets.cpp b/src/common/facets.cpp index 66cee57..c3e8524 100644 --- a/src/common/facets.cpp +++ b/src/common/facets.cpp @@ -87,4 +87,8 @@ namespace ear { {"9+10+3", FACETS_9_10_3}, {"0+7+0", FACETS_0_7_0}, {"4+7+0", FACETS_4_7_0}, }; + + void registerFacets(const std::string &layoutName, std::vector facets) { + FACETS[layoutName] = std::move(facets); + } } // namespace ear diff --git a/src/common/facets.hpp b/src/common/facets.hpp index ca164c0..c579647 100644 --- a/src/common/facets.hpp +++ b/src/common/facets.hpp @@ -1,10 +1,9 @@ #pragma once #include -#include #include #include +#include "ear/layout.hpp" namespace ear { - using Facet = std::set; extern std::map> FACETS; } // namespace ear