From ae4ee3488a3f8671e3d30448d4c56f022eea7876 Mon Sep 17 00:00:00 2001 From: lisyarus Date: Sat, 8 Jan 2022 15:44:57 +0300 Subject: [PATCH] Replace cg::body_traits::dimension with constexpr dimension template variable --- libs/cg/include/psemek/cg/body/body.hpp | 6 +++--- libs/cg/include/psemek/cg/body/box.hpp | 6 ------ libs/cg/include/psemek/cg/body/frustum.hpp | 6 ------ libs/cg/include/psemek/cg/body/icosahedron.hpp | 6 ------ libs/cg/include/psemek/cg/body/polygon.hpp | 6 ------ libs/cg/include/psemek/cg/body/prism.hpp | 6 ------ libs/cg/include/psemek/cg/convex/separation.hpp | 4 ++-- 7 files changed, 5 insertions(+), 35 deletions(-) diff --git a/libs/cg/include/psemek/cg/body/body.hpp b/libs/cg/include/psemek/cg/body/body.hpp index 03238531..1438600b 100644 --- a/libs/cg/include/psemek/cg/body/body.hpp +++ b/libs/cg/include/psemek/cg/body/body.hpp @@ -70,15 +70,15 @@ namespace psemek::cg } - template - struct body_traits; - template auto vertices(Body const & b) { return b.vertices; } + template + constexpr std::size_t dimension = std::decay_t())[0])>::static_dimension; + template auto faces(Body const & b) { diff --git a/libs/cg/include/psemek/cg/body/box.hpp b/libs/cg/include/psemek/cg/body/box.hpp index b89635e5..be00dc06 100644 --- a/libs/cg/include/psemek/cg/body/box.hpp +++ b/libs/cg/include/psemek/cg/body/box.hpp @@ -13,12 +13,6 @@ namespace psemek::cg template box(geom::box) -> box; - template - struct body_traits> - { - static constexpr std::size_t dimension = N; - }; - template struct box { diff --git a/libs/cg/include/psemek/cg/body/frustum.hpp b/libs/cg/include/psemek/cg/body/frustum.hpp index 3765ec23..657e17d4 100644 --- a/libs/cg/include/psemek/cg/body/frustum.hpp +++ b/libs/cg/include/psemek/cg/body/frustum.hpp @@ -25,12 +25,6 @@ namespace psemek::cg std::array, 8> vertices; }; - template - struct body_traits> - { - static constexpr std::size_t dimension = N; - }; - template frustum::frustum(geom::matrix const & m) { diff --git a/libs/cg/include/psemek/cg/body/icosahedron.hpp b/libs/cg/include/psemek/cg/body/icosahedron.hpp index f5e59435..00b7d2e1 100644 --- a/libs/cg/include/psemek/cg/body/icosahedron.hpp +++ b/libs/cg/include/psemek/cg/body/icosahedron.hpp @@ -14,12 +14,6 @@ namespace psemek::cg std::array, 12> vertices; }; - template - struct body_traits> - { - static constexpr std::size_t dimension = 3; - }; - template icosahedron::icosahedron(geom::point const & origin, T radius) { diff --git a/libs/cg/include/psemek/cg/body/polygon.hpp b/libs/cg/include/psemek/cg/body/polygon.hpp index daea6f16..db8676cb 100644 --- a/libs/cg/include/psemek/cg/body/polygon.hpp +++ b/libs/cg/include/psemek/cg/body/polygon.hpp @@ -26,12 +26,6 @@ namespace psemek::cg edges[i].points = {i, (i + 1) % vertices.size()}; } - template - struct body_traits> - { - static constexpr std::size_t dimension = 2; - }; - template auto const & vertices(polygon const & p) { diff --git a/libs/cg/include/psemek/cg/body/prism.hpp b/libs/cg/include/psemek/cg/body/prism.hpp index b77fc96a..0c317aa0 100644 --- a/libs/cg/include/psemek/cg/body/prism.hpp +++ b/libs/cg/include/psemek/cg/body/prism.hpp @@ -15,12 +15,6 @@ namespace psemek::cg std::array, 4> edge_directions; }; - template - struct body_traits> - { - static constexpr std::size_t dimension = 3; - }; - template triangular_prism::triangular_prism(geom::triangle> const & t, geom::vector const & d) { diff --git a/libs/cg/include/psemek/cg/convex/separation.hpp b/libs/cg/include/psemek/cg/convex/separation.hpp index ec6fe875..f80b43ae 100644 --- a/libs/cg/include/psemek/cg/convex/separation.hpp +++ b/libs/cg/include/psemek/cg/convex/separation.hpp @@ -173,8 +173,8 @@ namespace psemek::cg template auto separation(Body1 const & b1, Body2 const & b2) { - constexpr auto dim1 = body_traits::dimension; - constexpr auto dim2 = body_traits::dimension; + constexpr auto dim1 = dimension; + constexpr auto dim2 = dimension; static_assert(dim1 == dim2); static_assert(dim1 == 2 || dim1 == 3);