Browse Source

Use template aliases where possible.

Because with GCC 4.7 we can.
pull/59/head
Vladimír Vondruš 12 years ago
parent
commit
4a4768a12a
  1. 8
      src/Magnum/Math/Complex.h
  2. 34
      src/Magnum/Math/Matrix3.h
  3. 39
      src/Magnum/Math/Matrix4.h
  4. 12
      src/Magnum/Math/Quaternion.h
  5. 2
      src/Magnum/Math/Test/ComplexTest.cpp
  6. 2
      src/Magnum/Math/Test/Matrix3Test.cpp
  7. 5
      src/Magnum/SceneGraph/AbstractTranslationRotation2D.h
  8. 5
      src/Magnum/SceneGraph/AbstractTranslationRotation3D.h
  9. 8
      src/Magnum/SceneGraph/Camera2D.h
  10. 8
      src/Magnum/SceneGraph/Camera2D.hpp
  11. 8
      src/Magnum/SceneGraph/Camera3D.h
  12. 16
      src/Magnum/SceneGraph/Camera3D.hpp
  13. 2
      src/Magnum/SceneGraph/Test/TranslationTransformationTest.cpp

8
src/Magnum/Math/Complex.h

@ -41,7 +41,7 @@ namespace Magnum { namespace Math {
namespace Implementation {
/* No assertions fired, for internal use. Not private member because used
from outside the class. */
template<class T> constexpr static Complex<T> complexFromMatrix(const Matrix<2, T>& matrix) {
template<class T> constexpr static Complex<T> complexFromMatrix(const Matrix2x2<T>& matrix) {
return {matrix[0][0], matrix[0][1]};
}
}
@ -106,7 +106,7 @@ template<class T> class Complex {
* @see @ref toMatrix(), @ref DualComplex::fromMatrix(),
* @ref Matrix::isOrthogonal()
*/
static Complex<T> fromMatrix(const Matrix<2, T>& matrix) {
static Complex<T> fromMatrix(const Matrix2x2<T>& matrix) {
CORRADE_ASSERT(matrix.isOrthogonal(),
"Math::Complex::fromMatrix(): the matrix is not orthogonal", {});
return Implementation::complexFromMatrix(matrix);
@ -203,9 +203,9 @@ template<class T> class Complex {
* \end{pmatrix}
* @f]
* @see @ref fromMatrix(), @ref DualComplex::toMatrix(),
* @ref Matrix3::from(const Matrix<2, T>&, const Vector2<T>&)
* @ref Matrix3::from(const Matrix2x2<T>&, const Vector2<T>&)
*/
Matrix<2, T> toMatrix() const {
Matrix2x2<T> toMatrix() const {
return {Vector<2, T>(_real, _imaginary),
Vector<2, T>(-_imaginary, _real)};
}

34
src/Magnum/Math/Matrix3.h

@ -43,7 +43,7 @@ See @ref matrix-vector and @ref transformations for brief introduction.
@ref DualComplex, @ref SceneGraph::MatrixTransformation2D
@configurationvalueref{Magnum::Math::Matrix3}
*/
template<class T> class Matrix3: public Matrix<3, T> {
template<class T> class Matrix3: public Matrix3x3<T> {
public:
/**
* @brief 2D translation matrix
@ -95,7 +95,7 @@ template<class T> class Matrix3: public Matrix<3, T> {
static Matrix3<T> reflection(const Vector2<T>& normal) {
CORRADE_ASSERT(normal.isNormalized(),
"Math::Matrix3::reflection(): normal must be normalized", {});
return from(Matrix<2, T>() - T(2)*normal*RectangularMatrix<1, 2, T>(normal).transposed(), {});
return from(Matrix2x2<T>() - T(2)*normal*RectangularMatrix<1, 2, T>(normal).transposed(), {});
}
/**
@ -119,14 +119,14 @@ template<class T> class Matrix3: public Matrix<3, T> {
* @see @ref rotationScaling(), translation() const
* @todoc Explicit reference when Doxygen can handle const
*/
constexpr static Matrix3<T> from(const Matrix<2, T>& rotationScaling, const Vector2<T>& translation) {
constexpr static Matrix3<T> from(const Matrix2x2<T>& rotationScaling, const Vector2<T>& translation) {
return {{rotationScaling[0], T(0)},
{rotationScaling[1], T(0)},
{ translation, T(1)}};
}
/** @copydoc Matrix::Matrix(ZeroType) */
constexpr explicit Matrix3(typename Matrix<3, T>::ZeroType): Matrix<3, T>(Matrix<3, T>::Zero) {}
constexpr explicit Matrix3(typename Matrix3x3<T>::ZeroType): Matrix3x3<T>(Matrix3x3<T>::Zero) {}
/**
* @brief Default constructor
@ -135,19 +135,19 @@ template<class T> class Matrix3: public Matrix<3, T> {
* constructor with `%Matrix3 m(Matrix3::Identity);`. Optional
* parameter @p value allows you to specify value on diagonal.
*/
constexpr /*implicit*/ Matrix3(typename Matrix<3, T>::IdentityType = (Matrix<3, T>::Identity), T value = T(1)): Matrix<3, T>(Matrix<3, T>::Identity, value) {}
constexpr /*implicit*/ Matrix3(typename Matrix3x3<T>::IdentityType = (Matrix3x3<T>::Identity), T value = T(1)): Matrix3x3<T>(Matrix3x3<T>::Identity, value) {}
/** @brief %Matrix from column vectors */
constexpr /*implicit*/ Matrix3(const Vector3<T>& first, const Vector3<T>& second, const Vector3<T>& third): Matrix<3, T>(first, second, third) {}
constexpr /*implicit*/ Matrix3(const Vector3<T>& first, const Vector3<T>& second, const Vector3<T>& third): Matrix3x3<T>(first, second, third) {}
/** @copydoc Matrix::Matrix(const RectangularMatrix<size, size, U>&) */
template<class U> constexpr explicit Matrix3(const RectangularMatrix<3, 3, U>& other): Matrix<3, T>(other) {}
template<class U> constexpr explicit Matrix3(const RectangularMatrix<3, 3, U>& other): Matrix3x3<T>(other) {}
/** @brief Construct matrix from external representation */
template<class U, class V = decltype(Implementation::RectangularMatrixConverter<3, 3, T, U>::from(std::declval<U>()))> constexpr explicit Matrix3(const U& other): Matrix<3, T>(Implementation::RectangularMatrixConverter<3, 3, T, U>::from(other)) {}
template<class U, class V = decltype(Implementation::RectangularMatrixConverter<3, 3, T, U>::from(std::declval<U>()))> constexpr explicit Matrix3(const U& other): Matrix3x3<T>(Implementation::RectangularMatrixConverter<3, 3, T, U>::from(other)) {}
/** @brief Copy constructor */
constexpr Matrix3(const RectangularMatrix<3, 3, T>& other): Matrix<3, T>(other) {}
constexpr Matrix3(const RectangularMatrix<3, 3, T>& other): Matrix3x3<T>(other) {}
/**
* @brief Check whether the matrix represents rigid transformation
@ -164,13 +164,13 @@ template<class T> class Matrix3: public Matrix<3, T> {
* @brief 2D rotation and scaling part of the matrix
*
* Upper-left 2x2 part of the matrix.
* @see @ref from(const Matrix<2, T>&, const Vector2<T>&),
* @see @ref from(const Matrix2x2<T>&, const Vector2<T>&),
* rotation() const, @ref rotationNormalized(),
* @ref uniformScaling(), @ref rotation(Rad<T>),
* @ref Matrix4::rotationScaling()
* @todoc Explicit reference when Doxygen can handle const
*/
constexpr Matrix<2, T> rotationScaling() const {
constexpr Matrix2x2<T> rotationScaling() const {
return {(*this)[0].xy(),
(*this)[1].xy()};
}
@ -185,7 +185,7 @@ template<class T> class Matrix3: public Matrix<3, T> {
* @todo assert also orthogonality or this is good enough?
* @todoc Explicit reference when Doxygen can handle const
*/
Matrix<2, T> rotationNormalized() const {
Matrix2x2<T> rotationNormalized() const {
CORRADE_ASSERT((*this)[0].xy().isNormalized() && (*this)[1].xy().isNormalized(),
"Math::Matrix3::rotationNormalized(): the rotation part is not normalized", {});
return {(*this)[0].xy(),
@ -202,7 +202,7 @@ template<class T> class Matrix3: public Matrix<3, T> {
* Matrix4::rotation() const
* @todoc Explicit reference when Doxygen can handle const
*/
Matrix<2, T> rotation() const {
Matrix2x2<T> rotation() const {
CORRADE_ASSERT(TypeTraits<T>::equals((*this)[0].xy().dot(), (*this)[1].xy().dot()),
"Math::Matrix3::rotation(): the matrix doesn't have uniform scaling", {});
return {(*this)[0].xy().normalized(),
@ -263,7 +263,7 @@ template<class T> class Matrix3: public Matrix<3, T> {
* @brief 2D translation part of the matrix
*
* First two elements of third column.
* @see @ref from(const Matrix<2, T>&, const Vector2<T>&),
* @see @ref from(const Matrix2x2<T>&, const Vector2<T>&),
* @ref translation(const Vector2<T>&),
* @ref Matrix4::translation()
*/
@ -323,7 +323,7 @@ MAGNUM_MATRIXn_OPERATOR_IMPLEMENTATION(3, Matrix3)
/** @debugoperator{Magnum::Math::Matrix3} */
template<class T> inline Corrade::Utility::Debug operator<<(Corrade::Utility::Debug debug, const Matrix3<T>& value) {
return debug << static_cast<const Matrix<3, T>&>(value);
return debug << static_cast<const Matrix3x3<T>&>(value);
}
template<class T> Matrix3<T> Matrix3<T>::rotation(const Rad<T> angle) {
@ -339,7 +339,7 @@ template<class T> inline Matrix3<T> Matrix3<T>::invertedRigid() const {
CORRADE_ASSERT(isRigidTransformation(),
"Math::Matrix3::invertedRigid(): the matrix doesn't represent rigid transformation", {});
Matrix<2, T> inverseRotation = rotationScaling().transposed();
Matrix2x2<T> inverseRotation = rotationScaling().transposed();
return from(inverseRotation, inverseRotation*-translation());
}
@ -347,7 +347,7 @@ template<class T> inline Matrix3<T> Matrix3<T>::invertedRigid() const {
namespace Corrade { namespace Utility {
/** @configurationvalue{Magnum::Math::Matrix3} */
template<class T> struct ConfigurationValue<Magnum::Math::Matrix3<T>>: public ConfigurationValue<Magnum::Math::Matrix<3, T>> {};
template<class T> struct ConfigurationValue<Magnum::Math::Matrix3<T>>: public ConfigurationValue<Magnum::Math::Matrix3x3<T>> {};
}}
#endif

39
src/Magnum/Math/Matrix4.h

@ -48,7 +48,7 @@ See @ref matrix-vector and @ref transformations for brief introduction.
@ref DualQuaternion, @ref SceneGraph::MatrixTransformation3D
@configurationvalueref{Magnum::Math::Matrix4}
*/
template<class T> class Matrix4: public Matrix<4, T> {
template<class T> class Matrix4: public Matrix4x4<T> {
public:
/**
* @brief 3D translation
@ -187,7 +187,7 @@ template<class T> class Matrix4: public Matrix<4, T> {
* @see @ref rotationScaling(), translation() const
* @todoc Explicit reference when Doxygen can handle const
*/
constexpr static Matrix4<T> from(const Matrix<3, T>& rotationScaling, const Vector3<T>& translation) {
constexpr static Matrix4<T> from(const Matrix3x3<T>& rotationScaling, const Vector3<T>& translation) {
return {{rotationScaling[0], T(0)},
{rotationScaling[1], T(0)},
{rotationScaling[2], T(0)},
@ -195,7 +195,7 @@ template<class T> class Matrix4: public Matrix<4, T> {
}
/** @copydoc Matrix::Matrix(ZeroType) */
constexpr explicit Matrix4(typename Matrix<4, T>::ZeroType): Matrix<4, T>(Matrix<4, T>::Zero) {}
constexpr explicit Matrix4(typename Matrix4x4<T>::ZeroType): Matrix4x4<T>(Matrix4x4<T>::Zero) {}
/**
* @brief Default constructor
@ -204,19 +204,19 @@ template<class T> class Matrix4: public Matrix<4, T> {
* constructor with `%Matrix4 m(Matrix4::Identity);`. Optional
* parameter @p value allows you to specify value on diagonal.
*/
constexpr /*implicit*/ Matrix4(typename Matrix<4, T>::IdentityType = (Matrix<4, T>::Identity), T value = T(1)): Matrix<4, T>(Matrix<4, T>::Identity, value) {}
constexpr /*implicit*/ Matrix4(typename Matrix4x4<T>::IdentityType = (Matrix4x4<T>::Identity), T value = T(1)): Matrix4x4<T>(Matrix4x4<T>::Identity, value) {}
/** @brief %Matrix from column vectors */
constexpr /*implicit*/ Matrix4(const Vector4<T>& first, const Vector4<T>& second, const Vector4<T>& third, const Vector4<T>& fourth): Matrix<4, T>(first, second, third, fourth) {}
constexpr /*implicit*/ Matrix4(const Vector4<T>& first, const Vector4<T>& second, const Vector4<T>& third, const Vector4<T>& fourth): Matrix4x4<T>(first, second, third, fourth) {}
/** @copydoc Matrix::Matrix(const RectangularMatrix<size, size, U>&) */
template<class U> constexpr explicit Matrix4(const RectangularMatrix<4, 4, U>& other): Matrix<4, T>(other) {}
template<class U> constexpr explicit Matrix4(const RectangularMatrix<4, 4, U>& other): Matrix4x4<T>(other) {}
/** @brief Construct matrix from external representation */
template<class U, class V = decltype(Implementation::RectangularMatrixConverter<4, 4, T, U>::from(std::declval<U>()))> constexpr explicit Matrix4(const U& other): Matrix<4, T>(Implementation::RectangularMatrixConverter<4, 4, T, U>::from(other)) {}
template<class U, class V = decltype(Implementation::RectangularMatrixConverter<4, 4, T, U>::from(std::declval<U>()))> constexpr explicit Matrix4(const U& other): Matrix4x4<T>(Implementation::RectangularMatrixConverter<4, 4, T, U>::from(other)) {}
/** @brief Copy constructor */
constexpr Matrix4(const RectangularMatrix<4, 4, T>& other): Matrix<4, T>(other) {}
constexpr Matrix4(const RectangularMatrix<4, 4, T>& other): Matrix4x4<T>(other) {}
/**
* @brief Check whether the matrix represents rigid transformation
@ -233,14 +233,13 @@ template<class T> class Matrix4: public Matrix<4, T> {
* @brief 3D rotation and scaling part of the matrix
*
* Upper-left 3x3 part of the matrix.
* @see @ref from(const Matrix<3, T>&, const Vector3<T>&),
* @see @ref from(const Matrix3x3<T>&, const Vector3<T>&),
* rotation() const, @ref rotationNormalized(),
* @ref uniformScaling(), @ref rotation(Rad, const Vector3<T>&),
* Matrix3::rotationScaling() const
* @todoc Explicit reference when Doxygen can handle const
*/
/* Not Matrix3, because it is for affine 2D transformations */
constexpr Matrix<3, T> rotationScaling() const {
constexpr Matrix3x3<T> rotationScaling() const {
return {(*this)[0].xyz(),
(*this)[1].xyz(),
(*this)[2].xyz()};
@ -256,8 +255,7 @@ template<class T> class Matrix4: public Matrix<4, T> {
* @todo assert also orthogonality or this is good enough?
* @todoc Explicit reference when Doxygen can handle const
*/
/* Not Matrix3, because it is for affine 2D transformations */
Matrix<3, T> rotationNormalized() const {
Matrix3x3<T> rotationNormalized() const {
CORRADE_ASSERT((*this)[0].xyz().isNormalized() && (*this)[1].xyz().isNormalized() && (*this)[2].xyz().isNormalized(),
"Math::Matrix4::rotationNormalized(): the rotation part is not normalized", {});
return {(*this)[0].xyz(),
@ -275,8 +273,7 @@ template<class T> class Matrix4: public Matrix<4, T> {
* Matrix3::rotation() const
* @todoc Explicit reference when Doxygen can handle const
*/
/* Not Matrix3, because it is for affine 2D transformations */
Matrix<3, T> rotation() const;
Matrix3x3<T> rotation() const;
/**
* @brief Uniform scaling part of the matrix, squared
@ -338,7 +335,7 @@ template<class T> class Matrix4: public Matrix<4, T> {
* @brief 3D translation part of the matrix
*
* First three elements of fourth column.
* @see @ref from(const Matrix<3, T>&, const Vector3<T>&),
* @see @ref from(const Matrix3x3<T>&, const Vector3<T>&),
* @ref translation(const Vector3<T>&),
* @ref Matrix3::translation()
*/
@ -398,7 +395,7 @@ MAGNUM_MATRIXn_OPERATOR_IMPLEMENTATION(4, Matrix4)
/** @debugoperator{Magnum::Math::Matrix4} */
template<class T> inline Corrade::Utility::Debug operator<<(Corrade::Utility::Debug debug, const Matrix4<T>& value) {
return debug << static_cast<const Matrix<4, T>&>(value);
return debug << static_cast<const Matrix4x4<T>&>(value);
}
template<class T> Matrix4<T> Matrix4<T>::rotation(const Rad<T> angle, const Vector3<T>& normalizedAxis) {
@ -466,7 +463,7 @@ template<class T> Matrix4<T> Matrix4<T>::rotationZ(const Rad<T> angle) {
template<class T> Matrix4<T> Matrix4<T>::reflection(const Vector3<T>& normal) {
CORRADE_ASSERT(normal.isNormalized(),
"Math::Matrix4::reflection(): normal must be normalized", {});
return from(Matrix<3, T>() - T(2)*normal*RectangularMatrix<1, 3, T>(normal).transposed(), {});
return from(Matrix3x3<T>() - T(2)*normal*RectangularMatrix<1, 3, T>(normal).transposed(), {});
}
template<class T> Matrix4<T> Matrix4<T>::orthographicProjection(const Vector2<T>& size, const T near, const T far) {
@ -489,7 +486,7 @@ template<class T> Matrix4<T> Matrix4<T>::perspectiveProjection(const Vector2<T>&
{ T(0), T(0), T(2)*far*near*zScale, T(0)}};
}
template<class T> inline Matrix<3, T> Matrix4<T>::rotation() const {
template<class T> inline Matrix3x3<T> Matrix4<T>::rotation() const {
CORRADE_ASSERT(TypeTraits<T>::equals((*this)[0].xyz().dot(), (*this)[1].xyz().dot()) &&
TypeTraits<T>::equals((*this)[1].xyz().dot(), (*this)[2].xyz().dot()),
"Math::Matrix4::rotation(): the matrix doesn't have uniform scaling", {});
@ -510,7 +507,7 @@ template<class T> Matrix4<T> Matrix4<T>::invertedRigid() const {
CORRADE_ASSERT(isRigidTransformation(),
"Math::Matrix4::invertedRigid(): the matrix doesn't represent rigid transformation", {});
Matrix<3, T> inverseRotation = rotationScaling().transposed();
Matrix3x3<T> inverseRotation = rotationScaling().transposed();
return from(inverseRotation, inverseRotation*-translation());
}
@ -518,7 +515,7 @@ template<class T> Matrix4<T> Matrix4<T>::invertedRigid() const {
namespace Corrade { namespace Utility {
/** @configurationvalue{Magnum::Math::Matrix4} */
template<class T> struct ConfigurationValue<Magnum::Math::Matrix4<T>>: public ConfigurationValue<Magnum::Math::Matrix<4, T>> {};
template<class T> struct ConfigurationValue<Magnum::Math::Matrix4<T>>: public ConfigurationValue<Magnum::Math::Matrix4x4<T>> {};
}}
#endif

12
src/Magnum/Math/Quaternion.h

@ -126,7 +126,7 @@ template<class T> class Quaternion {
* @see @ref toMatrix(), @ref DualComplex::fromMatrix(),
* @ref Matrix::isOrthogonal()
*/
static Quaternion<T> fromMatrix(const Matrix<3, T>& matrix);
static Quaternion<T> fromMatrix(const Matrix3x3<T>& matrix);
/**
* @brief Default constructor
@ -210,9 +210,9 @@ template<class T> class Quaternion {
* @brief Convert quaternion to rotation matrix
*
* @see @ref fromMatrix(), @ref DualQuaternion::toMatrix(),
* @ref Matrix4::from(const Matrix<3, T>&, const Vector3<T>&)
* @ref Matrix4::from(const Matrix3x3<T>&, const Vector3<T>&)
*/
Matrix<3, T> toMatrix() const;
Matrix3x3<T> toMatrix() const;
/**
* @brief Add and assign quaternion
@ -474,7 +474,7 @@ namespace Implementation {
/* No assertions fired, for internal use. Not private member because used from
outside the class. */
template<class T> Quaternion<T> quaternionFromMatrix(const Matrix<3, T>& m) {
template<class T> Quaternion<T> quaternionFromMatrix(const Matrix3x3<T>& m) {
const Vector<3, T> diagonal = m.diagonal();
const T trace = diagonal.sum();
@ -530,7 +530,7 @@ template<class T> inline Quaternion<T> Quaternion<T>::rotation(const Rad<T> angl
return {normalizedAxis*std::sin(T(angle)/2), std::cos(T(angle)/2)};
}
template<class T> inline Quaternion<T> Quaternion<T>::fromMatrix(const Matrix<3, T>& matrix) {
template<class T> inline Quaternion<T> Quaternion<T>::fromMatrix(const Matrix3x3<T>& matrix) {
CORRADE_ASSERT(matrix.isOrthogonal(), "Math::Quaternion::fromMatrix(): the matrix is not orthogonal", {});
return Implementation::quaternionFromMatrix(matrix);
}
@ -546,7 +546,7 @@ template<class T> inline Vector3<T> Quaternion<T>::axis() const {
return _vector/std::sqrt(1-pow2(_scalar));
}
template<class T> Matrix<3, T> Quaternion<T>::toMatrix() const {
template<class T> Matrix3x3<T> Quaternion<T>::toMatrix() const {
return {
Vector<3, T>(T(1) - 2*pow2(_vector.y()) - 2*pow2(_vector.z()),
2*_vector.x()*_vector.y() + 2*_vector.z()*_scalar,

2
src/Magnum/Math/Test/ComplexTest.cpp

@ -101,7 +101,7 @@ typedef Math::Rad<Float> Rad;
typedef Math::Complex<Float> Complex;
typedef Math::Vector2<Float> Vector2;
typedef Math::Matrix3<Float> Matrix3;
typedef Math::Matrix<2, Float> Matrix2x2;
typedef Math::Matrix2x2<Float> Matrix2x2;
void ComplexTest::construct() {
constexpr Complex a(0.5f, -3.7f);

2
src/Magnum/Math/Test/Matrix3Test.cpp

@ -91,7 +91,7 @@ class Matrix3Test: public Corrade::TestSuite::Tester {
typedef Math::Deg<Float> Deg;
typedef Math::Matrix3<Float> Matrix3;
typedef Math::Matrix3<Int> Matrix3i;
typedef Math::Matrix<2, Float> Matrix2x2;
typedef Math::Matrix2x2<Float> Matrix2x2;
typedef Math::Vector3<Float> Vector3;
typedef Math::Vector2<Float> Vector2;

5
src/Magnum/SceneGraph/AbstractTranslationRotation2D.h

@ -39,9 +39,8 @@ namespace Magnum { namespace SceneGraph {
@see @ref AbstractTranslationRotation2D, @ref scenegraph,
@ref AbstractBasicTranslationRotation3D,
@ref BasicRigidMatrixTransformation2D, @ref BasicDualComplexTransformation
@todo Use AbstractBasicTransformation2D<T> when support for GCC 4.6 is dropped
*/
template<class T> class AbstractBasicTranslationRotation2D: public AbstractTranslation<2, T> {
template<class T> class AbstractBasicTranslationRotation2D: public AbstractBasicTranslation2D<T> {
public:
explicit AbstractBasicTranslationRotation2D() = default;
@ -59,7 +58,7 @@ template<class T> class AbstractBasicTranslationRotation2D: public AbstractTrans
/* Overloads to remove WTF-factor from method chaining order */
#ifndef DOXYGEN_GENERATING_OUTPUT
AbstractBasicTranslationRotation2D<T>& resetTransformation() {
AbstractTransformation<2, T>::resetTransformation();
AbstractBasicTranslation2D<T>::resetTransformation();
return *this;
}
#endif

5
src/Magnum/SceneGraph/AbstractTranslationRotation3D.h

@ -40,9 +40,8 @@ namespace Magnum { namespace SceneGraph {
@ref AbstractBasicTranslationRotation2D,
@ref BasicRigidMatrixTransformation3D,
@ref BasicDualQuaternionTransformation
@todo Use AbstractBasicTransformation3D<T> when support for GCC 4.6 is dropped
*/
template<class T> class AbstractBasicTranslationRotation3D: public AbstractTranslation<3, T> {
template<class T> class AbstractBasicTranslationRotation3D: public AbstractBasicTranslation3D<T> {
public:
explicit AbstractBasicTranslationRotation3D() = default;
@ -110,7 +109,7 @@ template<class T> class AbstractBasicTranslationRotation3D: public AbstractTrans
/* Overloads to remove WTF-factor from method chaining order */
#ifndef DOXYGEN_GENERATING_OUTPUT
AbstractBasicTranslationRotation3D<T>& resetTransformation() {
AbstractTransformation<3, T>::resetTransformation();
AbstractBasicTranslation3D<T>::resetTransformation();
return *this;
}
#endif

8
src/Magnum/SceneGraph/Camera2D.h

@ -58,7 +58,7 @@ class documentation or @ref compilation-speedup-hpp for more information.
@see @ref scenegraph, @ref Camera2D, @ref BasicCamera3D, @ref Drawable,
@ref DrawableGroup
*/
template<class T> class BasicCamera2D: public AbstractCamera<2, T> {
template<class T> class BasicCamera2D: public AbstractBasicCamera2D<T> {
public:
/**
* @brief Constructor
@ -67,13 +67,13 @@ template<class T> class BasicCamera2D: public AbstractCamera<2, T> {
* Sets orthographic projection to the default OpenGL cube (range @f$ [-1; 1] @f$ in all directions).
* @see @ref setProjection()
*/
explicit BasicCamera2D(AbstractObject<2, T>& object);
explicit BasicCamera2D(AbstractBasicObject2D<T>& object);
#ifndef DOXYGEN_GENERATING_OUTPUT
/* This is here to avoid ambiguity with deleted copy constructor when
passing `*this` from class subclassing both BasicCamera2D and
AbstractObject */
template<class U, class = typename std::enable_if<std::is_base_of<AbstractObject<2, T>, U>::value>::type> BasicCamera2D(U& object): BasicCamera2D(static_cast<AbstractObject<2, T>&>(object)) {}
template<class U, class = typename std::enable_if<std::is_base_of<AbstractBasicObject2D<T>, U>::value>::type> BasicCamera2D(U& object): BasicCamera2D(static_cast<AbstractBasicObject2D<T>&>(object)) {}
#endif
/**
@ -88,7 +88,7 @@ template<class T> class BasicCamera2D: public AbstractCamera<2, T> {
/* Overloads to remove WTF-factor from method chaining order */
#ifndef DOXYGEN_GENERATING_OUTPUT
BasicCamera2D<T>& setAspectRatioPolicy(AspectRatioPolicy policy) {
AbstractCamera<2, T>::setAspectRatioPolicy(policy);
AbstractBasicCamera2D<T>::setAspectRatioPolicy(policy);
return *this;
}
#endif

8
src/Magnum/SceneGraph/Camera2D.hpp

@ -32,16 +32,14 @@
#include "Magnum/SceneGraph/AbstractCamera.hpp"
#include "Magnum/SceneGraph/Camera2D.h"
/** @todo Use AbstractBasicCamera2D<T> when support for GCC 4.6 is dropped (also in header) */
namespace Magnum { namespace SceneGraph {
template<class T> BasicCamera2D<T>::BasicCamera2D(AbstractObject<2, T>& object): AbstractCamera<2, T>(object) {}
template<class T> BasicCamera2D<T>::BasicCamera2D(AbstractBasicObject2D<T>& object): AbstractBasicCamera2D<T>(object) {}
template<class T> BasicCamera2D<T>& BasicCamera2D<T>::setProjection(const Math::Vector2<T>& size) {
AbstractCamera<2, T>::rawProjectionMatrix = Math::Matrix3<T>::projection(size);
AbstractBasicCamera2D<T>::rawProjectionMatrix = Math::Matrix3<T>::projection(size);
AbstractCamera<2, T>::fixAspectRatio();
AbstractBasicCamera2D<T>::fixAspectRatio();
return *this;
}

8
src/Magnum/SceneGraph/Camera3D.h

@ -63,19 +63,19 @@ class documentation or @ref compilation-speedup-hpp for more information.
@see @ref scenegraph, @ref Camera3D, @ref BasicCamera2D, @ref Drawable,
@ref DrawableGroup
*/
template<class T> class BasicCamera3D: public AbstractCamera<3, T> {
template<class T> class BasicCamera3D: public AbstractBasicCamera3D<T> {
public:
/**
* @brief Constructor
* @param object %Object holding this feature
*/
explicit BasicCamera3D(AbstractObject<3, T>& object);
explicit BasicCamera3D(AbstractBasicObject3D<T>& object);
#ifndef DOXYGEN_GENERATING_OUTPUT
/* This is here to avoid ambiguity with deleted copy constructor when
passing `*this` from class subclassing both BasicCamera3D and
AbstractObject */
template<class U, class = typename std::enable_if<std::is_base_of<AbstractObject<3, T>, U>::value>::type> BasicCamera3D(U& object): BasicCamera3D(static_cast<AbstractObject<3, T>&>(object)) {}
template<class U, class = typename std::enable_if<std::is_base_of<AbstractBasicObject3D<T>, U>::value>::type> BasicCamera3D(U& object): BasicCamera3D(static_cast<AbstractBasicObject3D<T>&>(object)) {}
#endif
/**
@ -121,7 +121,7 @@ template<class T> class BasicCamera3D: public AbstractCamera<3, T> {
/* Overloads to remove WTF-factor from method chaining order */
#ifndef DOXYGEN_GENERATING_OUTPUT
BasicCamera3D<T>& setAspectRatioPolicy(AspectRatioPolicy policy) {
AbstractCamera<3, T>::setAspectRatioPolicy(policy);
AbstractBasicCamera3D<T>::setAspectRatioPolicy(policy);
return *this;
}
#endif

16
src/Magnum/SceneGraph/Camera3D.hpp

@ -32,19 +32,17 @@
#include "Magnum/SceneGraph/AbstractCamera.hpp"
#include "Magnum/SceneGraph/Camera3D.h"
/** @todo Use AbstractBasicCamera3D<T> when support for GCC 4.6 is dropped (also in header) */
namespace Magnum { namespace SceneGraph {
template<class T> BasicCamera3D<T>::BasicCamera3D(AbstractObject<3, T>& object): AbstractCamera<3, T>(object), _near(T(0)), _far(T(0)) {}
template<class T> BasicCamera3D<T>::BasicCamera3D(AbstractBasicObject3D<T>& object): AbstractBasicCamera3D<T>(object), _near(T(0)), _far(T(0)) {}
template<class T> BasicCamera3D<T>& BasicCamera3D<T>::setOrthographic(const Math::Vector2<T>& size, T near, T far) {
/** @todo Get near/far from the matrix */
_near = near;
_far = far;
AbstractCamera<3, T>::rawProjectionMatrix = Math::Matrix4<T>::orthographicProjection(size, near, far);
AbstractCamera<3, T>::fixAspectRatio();
AbstractBasicCamera3D<T>::rawProjectionMatrix = Math::Matrix4<T>::orthographicProjection(size, near, far);
AbstractBasicCamera3D<T>::fixAspectRatio();
return *this;
}
@ -53,8 +51,8 @@ template<class T> BasicCamera3D<T>& BasicCamera3D<T>::setPerspective(const Math:
_near = near;
_far = far;
AbstractCamera<3, T>::rawProjectionMatrix = Math::Matrix4<T>::perspectiveProjection(size, near, far);
AbstractCamera<3, T>::fixAspectRatio();
AbstractBasicCamera3D<T>::rawProjectionMatrix = Math::Matrix4<T>::perspectiveProjection(size, near, far);
AbstractBasicCamera3D<T>::fixAspectRatio();
return *this;
}
@ -63,8 +61,8 @@ template<class T> BasicCamera3D<T>& BasicCamera3D<T>::setPerspective(Math::Rad<T
_near = near;
_far = far;
AbstractCamera<3, T>::rawProjectionMatrix = Math::Matrix4<T>::perspectiveProjection(fov, aspectRatio, near, far);
AbstractCamera<3, T>::fixAspectRatio();
AbstractBasicCamera3D<T>::rawProjectionMatrix = Math::Matrix4<T>::perspectiveProjection(fov, aspectRatio, near, far);
AbstractBasicCamera3D<T>::fixAspectRatio();
return *this;
}

2
src/Magnum/SceneGraph/Test/TranslationTransformationTest.cpp

@ -133,7 +133,7 @@ void TranslationTransformationTest::translate() {
}
void TranslationTransformationTest::integral() {
typedef Object<TranslationTransformation<2, Float, Short>> Object2Di;
typedef Object<BasicTranslationTransformation2D<Float, Short>> Object2Di;
Object2Di o;
o.translate({3, -7});

Loading…
Cancel
Save