Browse Source

Ability to retrieve first two components from Array3D.

pull/277/head
Vladimír Vondruš 13 years ago
parent
commit
8afb661f6d
  1. 7
      src/Array.h
  2. 3
      src/Test/ArrayTest.cpp

7
src/Array.h

@ -191,6 +191,13 @@ template<class T> class Array3D: public Array<3, T> {
constexpr T y() const { return (*this)[1]; } /**< @overload */
T& z() { return (*this)[2]; } /**< @brief Z component */
constexpr T z() const { return (*this)[2]; } /**< @overload */
/**
* @brief XY part of the array
* @return First two components of the array
*/
Array2D<T>& xy() { return reinterpret_cast<Array2D<T>&>(*this); }
constexpr Array2D<T> xy() const { return {(*this)[0], (*this)[1]}; } /**< @overload */
};
/** @debugoperator{Magnum::Array} */

3
src/Test/ArrayTest.cpp

@ -104,6 +104,9 @@ void ArrayTest::access() {
CORRADE_COMPARE(cc.x(), -5);
CORRADE_COMPARE(cc.y(), 6);
CORRADE_COMPARE(cc.z(), 7);
CORRADE_COMPARE(c.xy(), Array2D(-5, 6));
CORRADE_COMPARE(cc.xy(), Array2D(-5, 6));
}
}}

Loading…
Cancel
Save