Browse Source

SceneGraph: clean up the code a bit.

No need to copy `return static_cast<...>;` all over the place.
pull/23/head
Vladimír Vondruš 13 years ago
parent
commit
4e7c7925a7
  1. 26
      src/SceneGraph/DualComplexTransformation.h
  2. 26
      src/SceneGraph/DualQuaternionTransformation.h
  3. 18
      src/SceneGraph/MatrixTransformation2D.h
  4. 27
      src/SceneGraph/MatrixTransformation3D.h
  5. 29
      src/SceneGraph/RigidMatrixTransformation2D.h
  6. 38
      src/SceneGraph/RigidMatrixTransformation3D.h

26
src/SceneGraph/DualComplexTransformation.h

@ -60,14 +60,12 @@ template<class T> class BasicDualComplexTransformation: public AbstractBasicTran
CORRADE_ASSERT(transformation.isNormalized(),
"SceneGraph::DualComplexTransformation::setTransformation(): the dual complex number is not normalized",
static_cast<Object<BasicDualComplexTransformation<T>>&>(*this));
setTransformationInternal(transformation);
return static_cast<Object<BasicDualComplexTransformation<T>>&>(*this);
return setTransformationInternal(transformation);
}
/** @copydoc AbstractTranslationRotationScaling2D::resetTransformation() */
Object<BasicDualComplexTransformation<T>>& resetTransformation() {
setTransformationInternal({});
return static_cast<Object<BasicDualComplexTransformation<T>>&>(*this);
return setTransformationInternal({});
}
/**
@ -79,8 +77,7 @@ template<class T> class BasicDualComplexTransformation: public AbstractBasicTran
* @see DualComplex::normalized()
*/
Object<BasicDualComplexTransformation<T>>& normalizeRotation() {
setTransformationInternal(_transformation.normalized());
return static_cast<Object<BasicDualComplexTransformation<T>>&>(*this);
return setTransformationInternal(_transformation.normalized());
}
/**
@ -96,8 +93,7 @@ template<class T> class BasicDualComplexTransformation: public AbstractBasicTran
CORRADE_ASSERT(transformation.isNormalized(),
"SceneGraph::DualComplexTransformation::transform(): the dual complex number is not normalized",
static_cast<Object<BasicDualComplexTransformation<T>>&>(*this));
transformInternal(transformation, type);
return static_cast<Object<BasicDualComplexTransformation<T>>&>(*this);
return transformInternal(transformation, type);
}
/**
@ -105,8 +101,7 @@ template<class T> class BasicDualComplexTransformation: public AbstractBasicTran
* Same as calling transform() with DualComplex::translation().
*/
Object<BasicDualComplexTransformation<T>>& translate(const Math::Vector2<T>& vector, TransformationType type = TransformationType::Global) {
transformInternal(Math::DualComplex<T>::translation(vector), type);
return static_cast<Object<BasicDualComplexTransformation<T>>&>(*this);
return transformInternal(Math::DualComplex<T>::translation(vector), type);
}
/**
@ -119,8 +114,7 @@ template<class T> class BasicDualComplexTransformation: public AbstractBasicTran
* @see normalizeRotation()
*/
Object<BasicDualComplexTransformation<T>>& rotate(Math::Rad<T> angle, TransformationType type = TransformationType::Global) {
transformInternal(Math::DualComplex<T>::rotation(angle), type);
return static_cast<Object<BasicDualComplexTransformation<T>>&>(*this);
return transformInternal(Math::DualComplex<T>::rotation(angle), type);
}
/**
@ -150,7 +144,7 @@ template<class T> class BasicDualComplexTransformation: public AbstractBasicTran
}
/* No assertions fired, for internal use */
void setTransformationInternal(const Math::DualComplex<T>& transformation) {
Object<BasicDualComplexTransformation<T>>& setTransformationInternal(const Math::DualComplex<T>& transformation) {
/* Setting transformation is forbidden for the scene */
/** @todo Assert for this? */
/** @todo Do this in some common code so we don't need to include Object? */
@ -158,11 +152,13 @@ template<class T> class BasicDualComplexTransformation: public AbstractBasicTran
_transformation = transformation;
static_cast<Object<BasicDualComplexTransformation<T>>*>(this)->setDirty();
}
return static_cast<Object<BasicDualComplexTransformation<T>>&>(*this);
}
/* No assertions fired, for internal use */
void transformInternal(const Math::DualComplex<T>& transformation, TransformationType type) {
setTransformationInternal(type == TransformationType::Global ?
Object<BasicDualComplexTransformation<T>>& transformInternal(const Math::DualComplex<T>& transformation, TransformationType type) {
return setTransformationInternal(type == TransformationType::Global ?
transformation*_transformation : _transformation*transformation);
}

26
src/SceneGraph/DualQuaternionTransformation.h

@ -60,14 +60,12 @@ template<class T> class BasicDualQuaternionTransformation: public AbstractBasicT
CORRADE_ASSERT(transformation.isNormalized(),
"SceneGraph::DualQuaternionTransformation::setTransformation(): the dual quaternion is not normalized",
static_cast<Object<BasicDualQuaternionTransformation<T>>&>(*this));
setTransformationInternal(transformation);
return static_cast<Object<BasicDualQuaternionTransformation<T>>&>(*this);
return setTransformationInternal(transformation);
}
/** @copydoc AbstractTranslationRotationScaling3D::resetTransformation() */
Object<BasicDualQuaternionTransformation<T>>& resetTransformation() {
setTransformationInternal({});
return static_cast<Object<BasicDualQuaternionTransformation<T>>&>(*this);
return setTransformationInternal({});
}
/**
@ -79,8 +77,7 @@ template<class T> class BasicDualQuaternionTransformation: public AbstractBasicT
* @see DualQuaternion::normalized()
*/
Object<BasicDualQuaternionTransformation<T>>& normalizeRotation() {
setTransformationInternal(_transformation.normalized());
return static_cast<Object<BasicDualQuaternionTransformation<T>>&>(*this);
return setTransformationInternal(_transformation.normalized());
}
/**
@ -96,8 +93,7 @@ template<class T> class BasicDualQuaternionTransformation: public AbstractBasicT
CORRADE_ASSERT(transformation.isNormalized(),
"SceneGraph::DualQuaternionTransformation::transform(): the dual quaternion is not normalized",
static_cast<Object<BasicDualQuaternionTransformation<T>>&>(*this));
transformInternal(transformation, type);
return static_cast<Object<BasicDualQuaternionTransformation<T>>&>(*this);
return transformInternal(transformation, type);
}
/**
@ -105,8 +101,7 @@ template<class T> class BasicDualQuaternionTransformation: public AbstractBasicT
* Same as calling transform() with DualQuaternion::translation().
*/
Object<BasicDualQuaternionTransformation<T>>& translate(const Math::Vector3<T>& vector, TransformationType type = TransformationType::Global) {
transformInternal(Math::DualQuaternion<T>::translation(vector), type);
return static_cast<Object<BasicDualQuaternionTransformation<T>>&>(*this);
return transformInternal(Math::DualQuaternion<T>::translation(vector), type);
}
/**
@ -121,8 +116,7 @@ template<class T> class BasicDualQuaternionTransformation: public AbstractBasicT
* normalizeRotation()
*/
Object<BasicDualQuaternionTransformation<T>>& rotate(Math::Rad<T> angle, const Math::Vector3<T>& normalizedAxis, TransformationType type = TransformationType::Global) {
transformInternal(Math::DualQuaternion<T>::rotation(angle, normalizedAxis), type);
return static_cast<Object<BasicDualQuaternionTransformation<T>>&>(*this);
return transformInternal(Math::DualQuaternion<T>::rotation(angle, normalizedAxis), type);
}
/* Overloads to remove WTF-factor from method chaining order */
@ -154,7 +148,7 @@ template<class T> class BasicDualQuaternionTransformation: public AbstractBasicT
}
/* No assertions fired, for internal use */
void setTransformationInternal(const Math::DualQuaternion<T>& transformation) {
Object<BasicDualQuaternionTransformation<T>>& setTransformationInternal(const Math::DualQuaternion<T>& transformation) {
/* Setting transformation is forbidden for the scene */
/** @todo Assert for this? */
/** @todo Do this in some common code so we don't need to include Object? */
@ -162,11 +156,13 @@ template<class T> class BasicDualQuaternionTransformation: public AbstractBasicT
_transformation = transformation;
static_cast<Object<BasicDualQuaternionTransformation<T>>*>(this)->setDirty();
}
return static_cast<Object<BasicDualQuaternionTransformation<T>>&>(*this);
}
/* No assertions fired, for internal use */
void transformInternal(const Math::DualQuaternion<T>& transformation, TransformationType type) {
setTransformationInternal(type == TransformationType::Global ?
Object<BasicDualQuaternionTransformation<T>>& transformInternal(const Math::DualQuaternion<T>& transformation, TransformationType type) {
return setTransformationInternal(type == TransformationType::Global ?
transformation*_transformation : _transformation*transformation);
}

18
src/SceneGraph/MatrixTransformation2D.h

@ -71,15 +71,13 @@ template<class T> class BasicMatrixTransformation2D: public AbstractBasicTransla
* @return Reference to self (for method chaining)
*/
Object<BasicMatrixTransformation2D<T>>& transform(const Math::Matrix3<T>& transformation, TransformationType type = TransformationType::Global) {
setTransformation(type == TransformationType::Global ?
return setTransformation(type == TransformationType::Global ?
transformation*_transformation : _transformation*transformation);
return static_cast<Object<BasicMatrixTransformation2D<T>>&>(*this);
}
/** @copydoc AbstractTranslationRotationScaling2D::resetTransformation() */
Object<BasicMatrixTransformation2D<T>>& resetTransformation() {
setTransformation({});
return static_cast<Object<BasicMatrixTransformation2D<T>>&>(*this);
return setTransformation({});
}
/**
@ -87,8 +85,7 @@ template<class T> class BasicMatrixTransformation2D: public AbstractBasicTransla
* Same as calling transform() with Matrix3::translation().
*/
Object<BasicMatrixTransformation2D<T>>& translate(const Math::Vector2<T>& vector, TransformationType type = TransformationType::Global) {
transform(Math::Matrix3<T>::translation(vector), type);
return static_cast<Object<BasicMatrixTransformation2D<T>>&>(*this);
return transform(Math::Matrix3<T>::translation(vector), type);
}
/**
@ -96,8 +93,7 @@ template<class T> class BasicMatrixTransformation2D: public AbstractBasicTransla
* Same as calling transform() with Matrix3::rotation().
*/
Object<BasicMatrixTransformation2D<T>>& rotate(Math::Rad<T> angle, TransformationType type = TransformationType::Global) {
transform(Math::Matrix3<T>::rotation(angle), type);
return static_cast<Object<BasicMatrixTransformation2D<T>>&>(*this);
return transform(Math::Matrix3<T>::rotation(angle), type);
}
/**
@ -105,8 +101,7 @@ template<class T> class BasicMatrixTransformation2D: public AbstractBasicTransla
* Same as calling transform() with Matrix3::scaling().
*/
Object<BasicMatrixTransformation2D<T>>& scale(const Math::Vector2<T>& vector, TransformationType type = TransformationType::Global) {
transform(Math::Matrix3<T>::scaling(vector), type);
return static_cast<Object<BasicMatrixTransformation2D<T>>&>(*this);
return transform(Math::Matrix3<T>::scaling(vector), type);
}
/**
@ -119,8 +114,7 @@ template<class T> class BasicMatrixTransformation2D: public AbstractBasicTransla
* Same as calling transform() with Matrix3::reflection().
*/
Object<BasicMatrixTransformation2D<T>>& reflect(const Math::Vector2<T>& normal, TransformationType type = TransformationType::Global) {
transform(Math::Matrix3<T>::reflection(normal), type);
return static_cast<Object<BasicMatrixTransformation2D<T>>&>(*this);
return transform(Math::Matrix3<T>::reflection(normal), type);
}
/**

27
src/SceneGraph/MatrixTransformation3D.h

@ -66,8 +66,7 @@ template<class T> class BasicMatrixTransformation3D: public AbstractBasicTransla
/** @copydoc AbstractTranslationRotationScaling3D::resetTransformation() */
Object<BasicMatrixTransformation3D<T>>& resetTransformation() {
setTransformation({});
return static_cast<Object<BasicMatrixTransformation3D<T>>&>(*this);
return setTransformation({});
}
/**
@ -77,9 +76,8 @@ template<class T> class BasicMatrixTransformation3D: public AbstractBasicTransla
* @return Reference to self (for method chaining)
*/
Object<BasicMatrixTransformation3D<T>>& transform(const Math::Matrix4<T>& transformation, TransformationType type = TransformationType::Global) {
setTransformation(type == TransformationType::Global ?
return setTransformation(type == TransformationType::Global ?
transformation*_transformation : _transformation*transformation);
return static_cast<Object<BasicMatrixTransformation3D<T>>&>(*this);
}
/**
@ -87,8 +85,7 @@ template<class T> class BasicMatrixTransformation3D: public AbstractBasicTransla
* Same as calling transform() with Matrix4::translation().
*/
Object<BasicMatrixTransformation3D<T>>& translate(const Math::Vector3<T>& vector, TransformationType type = TransformationType::Global) {
transform(Math::Matrix4<T>::translation(vector), type);
return static_cast<Object<BasicMatrixTransformation3D<T>>&>(*this);
return transform(Math::Matrix4<T>::translation(vector), type);
}
/**
@ -96,8 +93,7 @@ template<class T> class BasicMatrixTransformation3D: public AbstractBasicTransla
* Same as calling transform() with Matrix4::rotation().
*/
Object<BasicMatrixTransformation3D<T>>& rotate(Math::Rad<T> angle, const Math::Vector3<T>& normalizedAxis, TransformationType type = TransformationType::Global) {
transform(Math::Matrix4<T>::rotation(angle, normalizedAxis), type);
return static_cast<Object<BasicMatrixTransformation3D<T>>&>(*this);
return transform(Math::Matrix4<T>::rotation(angle, normalizedAxis), type);
}
/**
@ -109,8 +105,7 @@ template<class T> class BasicMatrixTransformation3D: public AbstractBasicTransla
* Same as calling transform() with Matrix4::rotationX().
*/
Object<BasicMatrixTransformation3D<T>>& rotateX(Math::Rad<T> angle, TransformationType type = TransformationType::Global) {
transform(Math::Matrix4<T>::rotationX(angle), type);
return static_cast<Object<BasicMatrixTransformation3D<T>>&>(*this);
return transform(Math::Matrix4<T>::rotationX(angle), type);
}
/**
@ -122,8 +117,7 @@ template<class T> class BasicMatrixTransformation3D: public AbstractBasicTransla
* Same as calling transform() with Matrix4::rotationY().
*/
Object<BasicMatrixTransformation3D<T>>& rotateY(Math::Rad<T> angle, TransformationType type = TransformationType::Global) {
transform(Math::Matrix4<T>::rotationY(angle), type);
return static_cast<Object<BasicMatrixTransformation3D<T>>&>(*this);
return transform(Math::Matrix4<T>::rotationY(angle), type);
}
/**
@ -135,8 +129,7 @@ template<class T> class BasicMatrixTransformation3D: public AbstractBasicTransla
* Same as calling transform() with Matrix4::rotationZ().
*/
Object<BasicMatrixTransformation3D<T>>& rotateZ(Math::Rad<T> angle, TransformationType type = TransformationType::Global) {
transform(Math::Matrix4<T>::rotationZ(angle), type);
return static_cast<Object<BasicMatrixTransformation3D<T>>&>(*this);
return transform(Math::Matrix4<T>::rotationZ(angle), type);
}
/**
@ -144,8 +137,7 @@ template<class T> class BasicMatrixTransformation3D: public AbstractBasicTransla
* Same as calling transform() with Matrix4::scaling().
*/
Object<BasicMatrixTransformation3D<T>>& scale(const Math::Vector3<T>& vector, TransformationType type = TransformationType::Global) {
transform(Math::Matrix4<T>::scaling(vector), type);
return static_cast<Object<BasicMatrixTransformation3D<T>>&>(*this);
return transform(Math::Matrix4<T>::scaling(vector), type);
}
/**
@ -158,8 +150,7 @@ template<class T> class BasicMatrixTransformation3D: public AbstractBasicTransla
* Same as calling transform() with Matrix4::reflection().
*/
Object<BasicMatrixTransformation3D<T>>& reflect(const Math::Vector3<T>& normal, TransformationType type = TransformationType::Global) {
transform(Math::Matrix4<T>::reflection(normal), type);
return static_cast<Object<BasicMatrixTransformation3D<T>>&>(*this);
return transform(Math::Matrix4<T>::reflection(normal), type);
}
protected:

29
src/SceneGraph/RigidMatrixTransformation2D.h

@ -63,14 +63,12 @@ template<class T> class BasicRigidMatrixTransformation2D: public AbstractBasicTr
CORRADE_ASSERT(transformation.isRigidTransformation(),
"SceneGraph::RigidMatrixTransformation2D::setTransformation(): the matrix doesn't represent rigid transformation",
static_cast<Object<BasicRigidMatrixTransformation2D<T>>&>(*this));
setTransformationInternal(transformation);
return static_cast<Object<BasicRigidMatrixTransformation2D<T>>&>(*this);
return setTransformationInternal(transformation);
}
/** @copydoc AbstractTranslationRotationScaling2D::resetTransformation() */
Object<BasicRigidMatrixTransformation2D<T>>& resetTransformation() {
setTransformationInternal({});
return static_cast<Object<BasicRigidMatrixTransformation2D<T>>&>(*this);
return setTransformationInternal({});
}
/**
@ -81,10 +79,9 @@ template<class T> class BasicRigidMatrixTransformation2D: public AbstractBasicTr
* to prevent rounding errors when rotating the object subsequently.
*/
Object<BasicRigidMatrixTransformation2D<T>>& normalizeRotation() {
setTransformationInternal(Math::Matrix3<T>::from(
return setTransformationInternal(Math::Matrix3<T>::from(
Math::Algorithms::gramSchmidtOrthonormalize(_transformation.rotationScaling()),
_transformation.translation()));
return static_cast<Object<BasicRigidMatrixTransformation2D<T>>&>(*this);
}
/**
@ -100,8 +97,7 @@ template<class T> class BasicRigidMatrixTransformation2D: public AbstractBasicTr
CORRADE_ASSERT(transformation.isRigidTransformation(),
"SceneGraph::RigidMatrixTransformation2D::transform(): the matrix doesn't represent rigid transformation",
static_cast<Object<BasicRigidMatrixTransformation2D<T>>&>(*this));
transformInternal(transformation, type);
return static_cast<Object<BasicRigidMatrixTransformation2D<T>>&>(*this);
return transformInternal(transformation, type);
}
/**
@ -109,8 +105,7 @@ template<class T> class BasicRigidMatrixTransformation2D: public AbstractBasicTr
* Same as calling transform() with Matrix3::translation().
*/
Object<BasicRigidMatrixTransformation2D<T>>& translate(const Math::Vector2<T>& vector, TransformationType type = TransformationType::Global) {
transformInternal(Math::Matrix3<T>::translation(vector), type);
return static_cast<Object<BasicRigidMatrixTransformation2D<T>>&>(*this);
return transformInternal(Math::Matrix3<T>::translation(vector), type);
}
/**
@ -123,8 +118,7 @@ template<class T> class BasicRigidMatrixTransformation2D: public AbstractBasicTr
* @see normalizeRotation()
*/
Object<BasicRigidMatrixTransformation2D<T>>& rotate(Math::Rad<T> angle, TransformationType type = TransformationType::Global) {
transformInternal(Math::Matrix3<T>::rotation(angle), type);
return static_cast<Object<BasicRigidMatrixTransformation2D<T>>&>(*this);
return transformInternal(Math::Matrix3<T>::rotation(angle), type);
}
/**
@ -137,8 +131,7 @@ template<class T> class BasicRigidMatrixTransformation2D: public AbstractBasicTr
* Same as calling transform() with Matrix3::reflection().
*/
Object<BasicRigidMatrixTransformation2D<T>>& reflect(const Math::Vector2<T>& normal, TransformationType type = TransformationType::Global) {
transformInternal(Math::Matrix3<T>::reflection(normal), type);
return static_cast<Object<BasicRigidMatrixTransformation2D<T>>&>(*this);
return transformInternal(Math::Matrix3<T>::reflection(normal), type);
}
/**
@ -168,7 +161,7 @@ template<class T> class BasicRigidMatrixTransformation2D: public AbstractBasicTr
}
/* No assertions fired, for internal use */
void setTransformationInternal(const Math::Matrix3<T>& transformation) {
Object<BasicRigidMatrixTransformation2D<T>>& setTransformationInternal(const Math::Matrix3<T>& transformation) {
/* Setting transformation is forbidden for the scene */
/** @todo Assert for this? */
/** @todo Do this in some common code so we don't need to include Object? */
@ -176,11 +169,13 @@ template<class T> class BasicRigidMatrixTransformation2D: public AbstractBasicTr
_transformation = transformation;
static_cast<Object<BasicRigidMatrixTransformation2D<T>>*>(this)->setDirty();
}
return static_cast<Object<BasicRigidMatrixTransformation2D<T>>&>(*this);
}
/* No assertions fired, for internal use */
void transformInternal(const Math::Matrix3<T>& transformation, TransformationType type) {
setTransformationInternal(type == TransformationType::Global ?
Object<BasicRigidMatrixTransformation2D<T>>& transformInternal(const Math::Matrix3<T>& transformation, TransformationType type) {
return setTransformationInternal(type == TransformationType::Global ?
transformation*_transformation : _transformation*transformation);
}

38
src/SceneGraph/RigidMatrixTransformation3D.h

@ -63,14 +63,12 @@ template<class T> class BasicRigidMatrixTransformation3D: public AbstractBasicTr
CORRADE_ASSERT(transformation.isRigidTransformation(),
"SceneGraph::RigidMatrixTransformation3D::setTransformation(): the matrix doesn't represent rigid transformation",
static_cast<Object<BasicRigidMatrixTransformation3D<T>>&>(*this));
setTransformationInternal(transformation);
return static_cast<Object<BasicRigidMatrixTransformation3D<T>>&>(*this);
return setTransformationInternal(transformation);
}
/** @copydoc AbstractTranslationRotationScaling3D::resetTransformation() */
Object<BasicRigidMatrixTransformation3D<T>>& resetTransformation() {
setTransformationInternal({});
return static_cast<Object<BasicRigidMatrixTransformation3D<T>>&>(*this);
return setTransformationInternal({});
}
/**
@ -81,10 +79,9 @@ template<class T> class BasicRigidMatrixTransformation3D: public AbstractBasicTr
* to prevent rounding errors when rotating the object subsequently.
*/
Object<BasicRigidMatrixTransformation3D<T>>& normalizeRotation() {
setTransformationInternal(Math::Matrix4<T>::from(
return setTransformationInternal(Math::Matrix4<T>::from(
Math::Algorithms::gramSchmidtOrthonormalize(_transformation.rotationScaling()),
_transformation.translation()));
return static_cast<Object<BasicRigidMatrixTransformation3D<T>>&>(*this);
}
/**
@ -100,8 +97,7 @@ template<class T> class BasicRigidMatrixTransformation3D: public AbstractBasicTr
CORRADE_ASSERT(transformation.isRigidTransformation(),
"SceneGraph::RigidMatrixTransformation3D::transform(): the matrix doesn't represent rigid transformation",
static_cast<Object<BasicRigidMatrixTransformation3D<T>>&>(*this));
transformInternal(transformation, type);
return static_cast<Object<BasicRigidMatrixTransformation3D<T>>&>(*this);
return transformInternal(transformation, type);
}
/**
@ -109,8 +105,7 @@ template<class T> class BasicRigidMatrixTransformation3D: public AbstractBasicTr
* Same as calling transform() with Matrix4::translation().
*/
Object<BasicRigidMatrixTransformation3D<T>>& translate(const Math::Vector3<T>& vector, TransformationType type = TransformationType::Global) {
transformInternal(Math::Matrix4<T>::translation(vector), type);
return static_cast<Object<BasicRigidMatrixTransformation3D<T>>&>(*this);
return transformInternal(Math::Matrix4<T>::translation(vector), type);
}
/**
@ -125,8 +120,7 @@ template<class T> class BasicRigidMatrixTransformation3D: public AbstractBasicTr
* Vector3::yAxis(), Vector3::zAxis(), normalizeRotation()
*/
Object<BasicRigidMatrixTransformation3D<T>>& rotate(Math::Rad<T> angle, const Math::Vector3<T>& normalizedAxis, TransformationType type = TransformationType::Global) {
transformInternal(Math::Matrix4<T>::rotation(angle, normalizedAxis), type);
return static_cast<Object<BasicRigidMatrixTransformation3D<T>>&>(*this);
return transformInternal(Math::Matrix4<T>::rotation(angle, normalizedAxis), type);
}
/**
@ -139,8 +133,7 @@ template<class T> class BasicRigidMatrixTransformation3D: public AbstractBasicTr
* @see normalizeRotation()
*/
Object<BasicRigidMatrixTransformation3D<T>>& rotateX(Math::Rad<T> angle, TransformationType type = TransformationType::Global) {
transformInternal(Math::Matrix4<T>::rotationX(angle), type);
return static_cast<Object<BasicRigidMatrixTransformation3D<T>>&>(*this);
return transformInternal(Math::Matrix4<T>::rotationX(angle), type);
}
/**
@ -153,8 +146,7 @@ template<class T> class BasicRigidMatrixTransformation3D: public AbstractBasicTr
* @see normalizeRotation()
*/
Object<BasicRigidMatrixTransformation3D<T>>& rotateY(Math::Rad<T> angle, TransformationType type = TransformationType::Global) {
transformInternal(Math::Matrix4<T>::rotationY(angle), type);
return static_cast<Object<BasicRigidMatrixTransformation3D<T>>&>(*this);
return transformInternal(Math::Matrix4<T>::rotationY(angle), type);
}
/**
@ -167,8 +159,7 @@ template<class T> class BasicRigidMatrixTransformation3D: public AbstractBasicTr
* @see normalizeRotation()
*/
Object<BasicRigidMatrixTransformation3D<T>>& rotateZ(Math::Rad<T> angle, TransformationType type = TransformationType::Global) {
transformInternal(Math::Matrix4<T>::rotationZ(angle), type);
return static_cast<Object<BasicRigidMatrixTransformation3D<T>>&>(*this);
return transformInternal(Math::Matrix4<T>::rotationZ(angle), type);
}
/**
@ -181,8 +172,7 @@ template<class T> class BasicRigidMatrixTransformation3D: public AbstractBasicTr
* Same as calling transform() with Matrix4::reflection().
*/
Object<BasicRigidMatrixTransformation3D<T>>& reflect(const Math::Vector3<T>& normal, TransformationType type = TransformationType::Global) {
transformInternal(Math::Matrix4<T>::reflection(normal), type);
return static_cast<Object<BasicRigidMatrixTransformation3D<T>>&>(*this);
return transformInternal(Math::Matrix4<T>::reflection(normal), type);
}
protected:
@ -213,7 +203,7 @@ template<class T> class BasicRigidMatrixTransformation3D: public AbstractBasicTr
}
/* No assertions fired, for internal use */
void setTransformationInternal(const Math::Matrix4<T>& transformation) {
Object<BasicRigidMatrixTransformation3D<T>>& setTransformationInternal(const Math::Matrix4<T>& transformation) {
/* Setting transformation is forbidden for the scene */
/** @todo Assert for this? */
/** @todo Do this in some common code so we don't need to include Object? */
@ -221,11 +211,13 @@ template<class T> class BasicRigidMatrixTransformation3D: public AbstractBasicTr
_transformation = transformation;
static_cast<Object<BasicRigidMatrixTransformation3D<T>>*>(this)->setDirty();
}
return static_cast<Object<BasicRigidMatrixTransformation3D<T>>&>(*this);
}
/* No assertions fired, for internal use */
void transformInternal(const Math::Matrix4<T>& transformation, TransformationType type) {
setTransformationInternal(type == TransformationType::Global ?
Object<BasicRigidMatrixTransformation3D<T>>& transformInternal(const Math::Matrix4<T>& transformation, TransformationType type) {
return setTransformationInternal(type == TransformationType::Global ?
transformation*_transformation : _transformation*transformation);
}

Loading…
Cancel
Save