Browse Source

Reducing pointer chasings, part 2: don't use `this->` so often.

It clarifies some things (e.g. from what base given member is). Not
changed where it would be too long to write.
pull/277/head
Vladimír Vondruš 13 years ago
parent
commit
845b8982e5
  1. 4
      src/DebugTools/Implementation/AbstractBoxRenderer.cpp
  2. 2
      src/DebugTools/Implementation/AbstractShapeRenderer.cpp
  3. 4
      src/DebugTools/Implementation/AxisAlignedBoxRenderer.cpp
  4. 4
      src/DebugTools/Implementation/BoxRenderer.cpp
  5. 6
      src/DebugTools/Implementation/LineSegmentRenderer.cpp
  6. 6
      src/DebugTools/Implementation/PointRenderer.cpp
  7. 4
      src/DebugTools/Implementation/SphereRenderer.cpp
  8. 2
      src/Image.h
  9. 22
      src/Math/DualComplex.h
  10. 12
      src/Math/DualQuaternion.h
  11. 4
      src/Math/Matrix.h
  12. 4
      src/SceneGraph/Animable.hpp
  13. 14
      src/SceneGraph/FeatureGroup.h
  14. 2
      src/SceneGraph/Object.hpp
  15. 2
      src/Shapes/AbstractShape.cpp
  16. 2
      src/Trade/ImageData.h

4
src/DebugTools/Implementation/AbstractBoxRenderer.cpp

@ -32,11 +32,11 @@
namespace Magnum { namespace DebugTools { namespace Implementation {
AbstractBoxRenderer<2>::AbstractBoxRenderer(): AbstractShapeRenderer<2>("box2d", "box2d-vertices", {}) {
if(!wireframeMesh) this->createResources(Primitives::Square::wireframe());
if(!wireframeMesh) AbstractShapeRenderer<2>::createResources(Primitives::Square::wireframe());
}
AbstractBoxRenderer<3>::AbstractBoxRenderer(): AbstractShapeRenderer<3>("box3d", "box3d-vertices", "box3d-indices") {
if(!wireframeMesh) this->createResources(Primitives::Cube::wireframe());
if(!wireframeMesh) AbstractShapeRenderer<3>::createResources(Primitives::Cube::wireframe());
}
template class AbstractBoxRenderer<2>;

2
src/DebugTools/Implementation/AbstractShapeRenderer.cpp

@ -102,7 +102,7 @@ template<UnsignedInt dimensions> AbstractShapeRenderer<dimensions>::AbstractShap
template<UnsignedInt dimensions> AbstractShapeRenderer<dimensions>::~AbstractShapeRenderer() {}
template<UnsignedInt dimensions> void AbstractShapeRenderer<dimensions>::createResources(typename MeshData<dimensions>::Type data) {
create<dimensions>(data, this->wireframeMesh, this->vertexBuffer, this->indexBuffer);
create<dimensions>(data, wireframeMesh, vertexBuffer, indexBuffer);
}
template class AbstractShapeRenderer<2>;

4
src/DebugTools/Implementation/AxisAlignedBoxRenderer.cpp

@ -34,12 +34,12 @@ namespace Magnum { namespace DebugTools { namespace Implementation {
template<UnsignedInt dimensions> AxisAlignedBoxRenderer<dimensions>::AxisAlignedBoxRenderer(const Shapes::Implementation::AbstractShape<dimensions>* axisAlignedBox): axisAlignedBox(static_cast<const Shapes::Implementation::Shape<Shapes::AxisAlignedBox<dimensions>>*>(axisAlignedBox)->shape) {}
template<UnsignedInt dimensions> void AxisAlignedBoxRenderer<dimensions>::draw(Resource<ShapeRendererOptions>& options, const typename DimensionTraits<dimensions, Float>::MatrixType& projectionMatrix) {
this->wireframeShader->setTransformationProjectionMatrix(projectionMatrix*
AbstractBoxRenderer<dimensions>::wireframeShader->setTransformationProjectionMatrix(projectionMatrix*
DimensionTraits<dimensions, Float>::MatrixType::translation((axisAlignedBox.min()+axisAlignedBox.max())/2)*
DimensionTraits<dimensions, Float>::MatrixType::scaling(axisAlignedBox.max()-axisAlignedBox.min()))
.setColor(options->color())
.use();
this->wireframeMesh->draw();
AbstractBoxRenderer<dimensions>::wireframeMesh->draw();
}
template class AxisAlignedBoxRenderer<2>;

4
src/DebugTools/Implementation/BoxRenderer.cpp

@ -34,10 +34,10 @@ namespace Magnum { namespace DebugTools { namespace Implementation {
template<UnsignedInt dimensions> BoxRenderer<dimensions>::BoxRenderer(const Shapes::Implementation::AbstractShape<dimensions>* box): box(static_cast<const Shapes::Implementation::Shape<Shapes::Box<dimensions>>*>(box)->shape) {}
template<UnsignedInt dimensions> void BoxRenderer<dimensions>::draw(Resource<ShapeRendererOptions>& options, const typename DimensionTraits<dimensions, Float>::MatrixType& projectionMatrix) {
this->wireframeShader->setTransformationProjectionMatrix(projectionMatrix*box.transformation())
AbstractBoxRenderer<dimensions>::wireframeShader->setTransformationProjectionMatrix(projectionMatrix*box.transformation())
.setColor(options->color())
.use();
this->wireframeMesh->draw();
AbstractBoxRenderer<dimensions>::wireframeMesh->draw();
}
template class BoxRenderer<2>;

6
src/DebugTools/Implementation/LineSegmentRenderer.cpp

@ -51,15 +51,15 @@ namespace {
}
template<UnsignedInt dimensions> LineSegmentRenderer<dimensions>::LineSegmentRenderer(const Shapes::Implementation::AbstractShape<dimensions>* line): AbstractShapeRenderer<dimensions>(meshKey<dimensions>(), vertexBufferKey<dimensions>(), {}), line(static_cast<const Shapes::Implementation::Shape<Shapes::LineSegment<dimensions>>*>(line)->shape) {
if(!this->wireframeMesh) this->createResources(meshData<dimensions>());
if(!AbstractShapeRenderer<dimensions>::wireframeMesh) AbstractShapeRenderer<dimensions>::createResources(meshData<dimensions>());
}
template<UnsignedInt dimensions> void LineSegmentRenderer<dimensions>::draw(Resource<ShapeRendererOptions>& options, const typename DimensionTraits<dimensions, Float>::MatrixType& projectionMatrix) {
this->wireframeShader->setTransformationProjectionMatrix(projectionMatrix*
AbstractShapeRenderer<dimensions>::wireframeShader->setTransformationProjectionMatrix(projectionMatrix*
Implementation::lineSegmentRendererTransformation<dimensions>(line.a(), line.b()))
.setColor(options->color())
.use();
this->wireframeMesh->draw();
AbstractShapeRenderer<dimensions>::wireframeMesh->draw();
}
template class LineSegmentRenderer<2>;

6
src/DebugTools/Implementation/PointRenderer.cpp

@ -49,17 +49,17 @@ namespace {
}
template<UnsignedInt dimensions> PointRenderer<dimensions>::PointRenderer(const Shapes::Implementation::AbstractShape<dimensions>* point): AbstractShapeRenderer<dimensions>(meshKey<dimensions>(), vertexBufferKey<dimensions>(), {}), point(static_cast<const Shapes::Implementation::Shape<Shapes::Point<dimensions>>*>(point)->shape) {
if(!this->wireframeMesh) this->createResources(meshData<dimensions>());
if(!AbstractShapeRenderer<dimensions>::wireframeMesh) AbstractShapeRenderer<dimensions>::createResources(meshData<dimensions>());
}
template<UnsignedInt dimensions> void PointRenderer<dimensions>::draw(Resource<ShapeRendererOptions>& options, const typename DimensionTraits<dimensions, Float>::MatrixType& projectionMatrix) {
/* Half scale, because the point is 2x2(x2) */
this->wireframeShader->setTransformationProjectionMatrix(projectionMatrix*
AbstractShapeRenderer<dimensions>::wireframeShader->setTransformationProjectionMatrix(projectionMatrix*
DimensionTraits<dimensions, Float>::MatrixType::translation(point.position())*
DimensionTraits<dimensions, Float>::MatrixType::scaling(typename DimensionTraits<dimensions, Float>::VectorType(options->pointSize()/2)))
.setColor(options->color())
.use();
this->wireframeMesh->draw();
AbstractShapeRenderer<dimensions>::wireframeMesh->draw();
}
template class PointRenderer<2>;

4
src/DebugTools/Implementation/SphereRenderer.cpp

@ -46,12 +46,12 @@ AbstractSphereRenderer<3>::AbstractSphereRenderer(): AbstractShapeRenderer<3>("s
template<UnsignedInt dimensions> SphereRenderer<dimensions>::SphereRenderer(const Shapes::Implementation::AbstractShape<dimensions>* sphere): sphere(static_cast<const Shapes::Implementation::Shape<Shapes::Sphere<dimensions>>*>(sphere)->shape) {}
template<UnsignedInt dimensions> void SphereRenderer<dimensions>::draw(Resource<ShapeRendererOptions>& options, const typename DimensionTraits<dimensions, Float>::MatrixType& projectionMatrix) {
this->wireframeShader->setTransformationProjectionMatrix(projectionMatrix*
AbstractShapeRenderer<dimensions>::wireframeShader->setTransformationProjectionMatrix(projectionMatrix*
DimensionTraits<dimensions, Float>::MatrixType::translation(sphere.position())*
DimensionTraits<dimensions, Float>::MatrixType::scaling(typename DimensionTraits<dimensions, Float>::VectorType(sphere.radius())))
.setColor(options->color())
.use();
this->wireframeMesh->draw();
AbstractShapeRenderer<dimensions>::wireframeMesh->draw();
}
template class SphereRenderer<2>;

2
src/Image.h

@ -133,7 +133,7 @@ template<UnsignedInt dimensions> inline Image<dimensions>& Image<dimensions>::op
}
template<UnsignedInt dimensions> inline Image<dimensions>::operator ImageReference<dimensions>() const {
return ImageReference<dimensions>(this->format(), this->type(), _size, _data);
return ImageReference<dimensions>(AbstractImage::format(), AbstractImage::type(), _size, _data);
}
}

22
src/Math/DualComplex.h

@ -145,7 +145,7 @@ template<class T> class DualComplex: public Dual<Complex<T>> {
* @see Complex::angle()
*/
constexpr Complex<T> rotation() const {
return this->real();
return Dual<Complex<T>>::real();
}
/**
@ -157,7 +157,7 @@ template<class T> class DualComplex: public Dual<Complex<T>> {
* @see translation(const Vector2&)
*/
Vector2<T> translation() const {
return Vector2<T>(this->dual());
return Vector2<T>(Dual<Complex<T>>::dual());
}
/**
@ -166,7 +166,7 @@ template<class T> class DualComplex: public Dual<Complex<T>> {
* @see fromMatrix(), Complex::toMatrix()
*/
Matrix3<T> toMatrix() const {
return Matrix3<T>::from(this->real().toMatrix(), translation());
return Matrix3<T>::from(Dual<Complex<T>>::real().toMatrix(), translation());
}
/**
@ -178,7 +178,7 @@ template<class T> class DualComplex: public Dual<Complex<T>> {
* @todo can this be done similarly to dual quaternions?
*/
DualComplex<T> operator*(const DualComplex<T>& other) const {
return {this->real()*other.real(), this->real()*other.dual() + this->dual()};
return {Dual<Complex<T>>::real()*other.real(), Dual<Complex<T>>::real()*other.dual() + Dual<Complex<T>>::dual()};
}
/**
@ -190,7 +190,7 @@ template<class T> class DualComplex: public Dual<Complex<T>> {
* @see dualConjugated(), conjugated(), Complex::conjugated()
*/
DualComplex<T> complexConjugated() const {
return {this->real().conjugated(), this->dual().conjugated()};
return {Dual<Complex<T>>::real().conjugated(), Dual<Complex<T>>::dual().conjugated()};
}
/**
@ -215,7 +215,7 @@ template<class T> class DualComplex: public Dual<Complex<T>> {
* Dual::conjugated()
*/
DualComplex<T> conjugated() const {
return {this->real().conjugated(), {-this->dual().real(), this->dual().imaginary()}};
return {Dual<Complex<T>>::real().conjugated(), {-Dual<Complex<T>>::dual().real(), Dual<Complex<T>>::dual().imaginary()}};
}
/**
@ -228,7 +228,7 @@ template<class T> class DualComplex: public Dual<Complex<T>> {
* @todo Can this be done similarly to dual quaternins?
*/
T lengthSquared() const {
return this->real().dot();
return Dual<Complex<T>>::real().dot();
}
/**
@ -241,7 +241,7 @@ template<class T> class DualComplex: public Dual<Complex<T>> {
* @todo can this be done similarly to dual quaternions?
*/
T length() const {
return this->real().length();
return Dual<Complex<T>>::real().length();
}
/**
@ -254,7 +254,7 @@ template<class T> class DualComplex: public Dual<Complex<T>> {
* @todo can this be done similarly to dual quaternions?
*/
DualComplex<T> normalized() const {
return {this->real()/length(), this->dual()};
return {Dual<Complex<T>>::real()/length(), Dual<Complex<T>>::dual()};
}
/**
@ -267,7 +267,7 @@ template<class T> class DualComplex: public Dual<Complex<T>> {
* @todo can this be done similarly to dual quaternions?
*/
DualComplex<T> inverted() const {
return DualComplex<T>(this->real().inverted(), {{}, {}})*DualComplex<T>({}, -this->dual());
return DualComplex<T>(Dual<Complex<T>>::real().inverted(), {{}, {}})*DualComplex<T>({}, -Dual<Complex<T>>::dual());
}
/**
@ -280,7 +280,7 @@ template<class T> class DualComplex: public Dual<Complex<T>> {
* @todo can this be done similarly to dual quaternions?
*/
DualComplex<T> invertedNormalized() const {
return DualComplex<T>(this->real().invertedNormalized(), {{}, {}})*DualComplex<T>({}, -this->dual());
return DualComplex<T>(Dual<Complex<T>>::real().invertedNormalized(), {{}, {}})*DualComplex<T>({}, -Dual<Complex<T>>::dual());
}
/**

12
src/Math/DualQuaternion.h

@ -155,7 +155,7 @@ template<class T> class DualQuaternion: public Dual<Quaternion<T>> {
* @see Quaternion::angle(), Quaternion::axis()
*/
constexpr Quaternion<T> rotation() const {
return this->real();
return Dual<Quaternion<T>>::real();
}
/**
@ -167,7 +167,7 @@ template<class T> class DualQuaternion: public Dual<Quaternion<T>> {
* @see translation(const Vector3&)
*/
Vector3<T> translation() const {
return (this->dual()*this->real().conjugated()).vector()*T(2);
return (Dual<Quaternion<T>>::dual()*Dual<Quaternion<T>>::real().conjugated()).vector()*T(2);
}
/**
@ -176,7 +176,7 @@ template<class T> class DualQuaternion: public Dual<Quaternion<T>> {
* @see fromMatrix(), Quaternion::toMatrix()
*/
Matrix4<T> toMatrix() const {
return Matrix4<T>::from(this->real().toMatrix(), translation());
return Matrix4<T>::from(Dual<Quaternion<T>>::real().toMatrix(), translation());
}
/**
@ -188,7 +188,7 @@ template<class T> class DualQuaternion: public Dual<Quaternion<T>> {
* @see dualConjugated(), conjugated(), Quaternion::conjugated()
*/
DualQuaternion<T> quaternionConjugated() const {
return {this->real().conjugated(), this->dual().conjugated()};
return {Dual<Quaternion<T>>::real().conjugated(), Dual<Quaternion<T>>::dual().conjugated()};
}
/**
@ -213,7 +213,7 @@ template<class T> class DualQuaternion: public Dual<Quaternion<T>> {
* Dual::conjugated()
*/
DualQuaternion<T> conjugated() const {
return {this->real().conjugated(), {this->dual().vector(), -this->dual().scalar()}};
return {Dual<Quaternion<T>>::real().conjugated(), {Dual<Quaternion<T>>::dual().vector(), -Dual<Quaternion<T>>::dual().scalar()}};
}
/**
@ -225,7 +225,7 @@ template<class T> class DualQuaternion: public Dual<Quaternion<T>> {
* @f]
*/
Dual<T> lengthSquared() const {
return {this->real().dot(), T(2)*Quaternion<T>::dot(this->real(), this->dual())};
return {Dual<Quaternion<T>>::real().dot(), T(2)*Quaternion<T>::dot(Dual<Quaternion<T>>::real(), Dual<Quaternion<T>>::dual())};
}
/**

4
src/Math/Matrix.h

@ -121,7 +121,7 @@ template<std::size_t size, class T> class Matrix: public RectangularMatrix<size,
* tr(A) = \sum_{i=1}^n a_{i,i}
* @f]
*/
T trace() const { return this->diagonal().sum(); }
T trace() const { return RectangularMatrix<size, size, T>::diagonal().sum(); }
/** @brief %Matrix without given column and row */
Matrix<size-1, T> ij(std::size_t skipCol, std::size_t skipRow) const;
@ -162,7 +162,7 @@ template<std::size_t size, class T> class Matrix: public RectangularMatrix<size,
Matrix<size, T> invertedOrthogonal() const {
CORRADE_ASSERT(isOrthogonal(),
"Math::Matrix::invertedOrthogonal(): the matrix is not orthogonal", {});
return this->transposed();
return RectangularMatrix<size, size, T>::transposed();
}
#ifndef DOXYGEN_GENERATING_OUTPUT

4
src/SceneGraph/Animable.hpp

@ -64,7 +64,7 @@ template<UnsignedInt dimensions, class T> void AnimableGroup<dimensions, T>::ste
if(!_runningCount && !wakeUp) return;
wakeUp = false;
for(std::size_t i = 0; i != this->size(); ++i) {
for(std::size_t i = 0; i != AnimableGroup<dimensions, T>::size(); ++i) {
Animable<dimensions, T>* animable = (*this)[i];
/* The animation was stopped recently, just decrease count of running
@ -132,7 +132,7 @@ template<UnsignedInt dimensions, class T> void AnimableGroup<dimensions, T>::ste
animable->animationStep(time - animable->startTime, delta);
}
CORRADE_INTERNAL_ASSERT(_runningCount <= this->size());
CORRADE_INTERNAL_ASSERT(_runningCount <= AnimableGroup<dimensions, T>::size());
}
}}

14
src/SceneGraph/FeatureGroup.h

@ -74,19 +74,23 @@ template<UnsignedInt dimensions, class Feature, class T> class FeatureGroup: pub
~FeatureGroup();
/** @brief Whether the group is empty */
bool isEmpty() const { return this->features.empty(); }
bool isEmpty() const {
return AbstractFeatureGroup<dimensions, T>::features.empty();
}
/** @brief Count of features in the group */
std::size_t size() const { return this->features.size(); }
std::size_t size() const {
return AbstractFeatureGroup<dimensions, T>::features.size();
}
/** @brief Feature at given index */
Feature* operator[](std::size_t index) {
return static_cast<Feature*>(this->features[index]);
return static_cast<Feature*>(AbstractFeatureGroup<dimensions, T>::features[index]);
}
/** @overload */
const Feature* operator[](std::size_t index) const {
return static_cast<Feature*>(this->features[index]);
return static_cast<Feature*>(AbstractFeatureGroup<dimensions, T>::features[index]);
}
/**
@ -155,7 +159,7 @@ template<class Feature> using FeatureGroup3D = BasicFeatureGroup3D<Feature, Floa
#endif
template<UnsignedInt dimensions, class Feature, class T> FeatureGroup<dimensions, Feature, T>::~FeatureGroup() {
for(auto i: this->features) static_cast<Feature*>(i)->_group = nullptr;
for(auto i: AbstractFeatureGroup<dimensions, T>::features) static_cast<Feature*>(i)->_group = nullptr;
}
template<UnsignedInt dimensions, class Feature, class T> FeatureGroup<dimensions, Feature, T>& FeatureGroup<dimensions, Feature, T>::add(Feature* feature) {

2
src/SceneGraph/Object.hpp

@ -94,7 +94,7 @@ template<class Transformation> Object<Transformation>& Object<Transformation>::s
const auto transformation = Transformation::compose(
Transformation::inverted(parent->absoluteTransformation()), absoluteTransformation());
setParent(parent);
this->setTransformation(transformation);
Transformation::setTransformation(transformation);
return *this;
}

2
src/Shapes/AbstractShape.cpp

@ -32,7 +32,7 @@
namespace Magnum { namespace Shapes {
template<UnsignedInt dimensions> AbstractShape<dimensions>::AbstractShape(SceneGraph::AbstractObject<dimensions, Float>* object, ShapeGroup<dimensions>* group): SceneGraph::AbstractGroupedFeature<dimensions, AbstractShape<dimensions>, Float>(object, group) {
this->setCachedTransformations(SceneGraph::CachedTransformation::Absolute);
SceneGraph::AbstractFeature<dimensions, Float>::setCachedTransformations(SceneGraph::CachedTransformation::Absolute);
}
template<UnsignedInt dimensions> ShapeGroup<dimensions>* AbstractShape<dimensions>::group() {

2
src/Trade/ImageData.h

@ -111,7 +111,7 @@ template<UnsignedInt dimensions> inline ImageData<dimensions>& ImageData<dimensi
}
template<UnsignedInt dimensions> inline ImageData<dimensions>::operator ImageReference<dimensions>() const {
return ImageReference<dimensions>(this->format(), this->type(), _size, _data);
return ImageReference<dimensions>(AbstractImage::format(), AbstractImage::type(), _size, _data);
}
}}

Loading…
Cancel
Save