From a2d31ef8d30f5cd59523095090cde39848841c91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Fri, 25 Oct 2013 16:48:09 +0200 Subject: [PATCH] Moved RGB(A) accessors from swizzle() to Math::swizzle(). As Math::Vector now contains them, there is no need to restrict them from the original swizzle implementation. --- src/Math/Swizzle.h | 4 ++++ src/Math/Test/SwizzleTest.cpp | 7 +++++++ src/Swizzle.h | 7 ------- src/Test/SwizzleTest.cpp | 9 +-------- 4 files changed, 12 insertions(+), 15 deletions(-) diff --git a/src/Math/Swizzle.h b/src/Math/Swizzle.h index 1ac9746b3..75046860d 100644 --- a/src/Math/Swizzle.h +++ b/src/Math/Swizzle.h @@ -44,6 +44,10 @@ namespace Implementation { template struct Component: public ComponentAtPosition {}; template struct Component: public ComponentAtPosition {}; template struct Component: public ComponentAtPosition {}; + template struct Component: public ComponentAtPosition {}; + template struct Component: public ComponentAtPosition {}; + template struct Component: public ComponentAtPosition {}; + template struct Component: public ComponentAtPosition {}; template struct Component { template constexpr static T value(const Math::Vector&) { return T(0); } }; diff --git a/src/Math/Test/SwizzleTest.cpp b/src/Math/Test/SwizzleTest.cpp index 5f01b4e62..19968ca72 100644 --- a/src/Math/Test/SwizzleTest.cpp +++ b/src/Math/Test/SwizzleTest.cpp @@ -34,6 +34,7 @@ class SwizzleTest: public Corrade::TestSuite::Tester { void components(); void constants(); + void rgba(); void sizes(); }; @@ -42,6 +43,7 @@ typedef Vector<4, Int> Vector4i; SwizzleTest::SwizzleTest() { addTests({&SwizzleTest::components, &SwizzleTest::constants, + &SwizzleTest::rgba, &SwizzleTest::sizes}); } @@ -55,6 +57,11 @@ void SwizzleTest::constants() { CORRADE_COMPARE(a, Vector4i(1, 7, 0, 4)); } +void SwizzleTest::rgba() { + constexpr auto a = swizzle<'b', 'r', 'a', 'g'>(Vector4i(2, 4, 5, 7)); + CORRADE_COMPARE(a, Vector4i(5, 2, 7, 4)); +} + void SwizzleTest::sizes() { constexpr auto a = swizzle<'y', 'x', 'x'>(Math::Vector<2, Int>(1, 2)); CORRADE_COMPARE(a, (Math::Vector<3, Int>(2, 1, 1))); diff --git a/src/Swizzle.h b/src/Swizzle.h index 2072f7223..194bb8e39 100644 --- a/src/Swizzle.h +++ b/src/Swizzle.h @@ -33,13 +33,6 @@ namespace Magnum { -namespace Math { namespace Implementation { - template struct Component: public ComponentAtPosition {}; - template struct Component: public ComponentAtPosition {}; - template struct Component: public ComponentAtPosition {}; - template struct Component: public ComponentAtPosition {}; -}} - namespace Implementation { template struct TypeForSize { typedef Math::Vector Type; diff --git a/src/Test/SwizzleTest.cpp b/src/Test/SwizzleTest.cpp index 2cf321668..2eeb9b37d 100644 --- a/src/Test/SwizzleTest.cpp +++ b/src/Test/SwizzleTest.cpp @@ -32,22 +32,15 @@ class SwizzleTest: public TestSuite::Tester { public: SwizzleTest(); - void rgba(); void type(); void defaultType(); }; SwizzleTest::SwizzleTest() { - addTests({&SwizzleTest::rgba, - &SwizzleTest::type, + addTests({&SwizzleTest::type, &SwizzleTest::defaultType}); } -void SwizzleTest::rgba() { - constexpr auto a = swizzle<'b', 'r', 'a', 'g'>(Vector4i(2, 4, 5, 7)); - CORRADE_COMPARE(a, Vector4i(5, 2, 7, 4)); -} - void SwizzleTest::type() { constexpr Vector4i orig; constexpr Color3 origColor3;