Browse Source

Explicitly use *Matrix in names when appropriate.

* In shader uniforms (projectionMatrix makes more sense than projection
   alone)
 * For underlying types for SceneGraph transformation. It is already
   used in Drawable::clean() as transformationMatrix, so why not use it
   also in AbstractFeature::clean(). Moreover, clean() could be in
   future also done using something else, this helps to distinguish the
   type just from parameter name.
 * In Physics shapes - applyTransformationMatrix() (as it could be in
   future also done using something else).
pull/7/head
Vladimír Vondruš 14 years ago
parent
commit
231c002838
  1. 8
      src/Physics/AbstractShape.h
  2. 6
      src/Physics/AxisAlignedBox.cpp
  3. 2
      src/Physics/AxisAlignedBox.h
  4. 4
      src/Physics/Box.cpp
  5. 2
      src/Physics/Box.h
  6. 8
      src/Physics/Capsule.cpp
  7. 2
      src/Physics/Capsule.h
  8. 2
      src/Physics/Implementation/AxisAlignedBoxRenderer.cpp
  9. 2
      src/Physics/Implementation/BoxRenderer.cpp
  10. 6
      src/Physics/Line.cpp
  11. 2
      src/Physics/Line.h
  12. 4
      src/Physics/ObjectShape.cpp
  13. 2
      src/Physics/ObjectShape.h
  14. 6
      src/Physics/Plane.cpp
  15. 4
      src/Physics/Plane.h
  16. 4
      src/Physics/Point.cpp
  17. 2
      src/Physics/Point.h
  18. 6
      src/Physics/ShapeGroup.cpp
  19. 2
      src/Physics/ShapeGroup.h
  20. 6
      src/Physics/Sphere.cpp
  21. 2
      src/Physics/Sphere.h
  22. 4
      src/Physics/Test/AxisAlignedBoxTest.cpp
  23. 2
      src/Physics/Test/BoxTest.cpp
  24. 4
      src/Physics/Test/CapsuleTest.cpp
  25. 2
      src/Physics/Test/LineTest.cpp
  26. 4
      src/Physics/Test/PlaneTest.cpp
  27. 2
      src/Physics/Test/PointTest.cpp
  28. 4
      src/Physics/Test/ShapeGroupTest.cpp
  29. 2
      src/Physics/Test/ShapeTestBase.h
  30. 6
      src/Physics/Test/SphereTest.cpp
  31. 4
      src/SceneGraph/AbstractCamera.h
  32. 8
      src/SceneGraph/AbstractFeature.h
  33. 2
      src/Shaders/FlatShader.cpp
  34. 6
      src/Shaders/FlatShader.h
  35. 4
      src/Shaders/FlatShader2D.vert
  36. 6
      src/Shaders/PhongShader.h
  37. 2
      src/Shaders/VertexColorShader.cpp
  38. 8
      src/Shaders/VertexColorShader.h
  39. 4
      src/Shaders/VertexColorShader2D.vert

8
src/Physics/AbstractShape.h

@ -100,12 +100,12 @@ template<std::uint8_t dimensions> class MAGNUM_PHYSICS_EXPORT AbstractShape {
virtual Type type() const = 0; virtual Type type() const = 0;
/** /**
* @brief Apply transformation * @brief Apply transformation matrix
* *
* Applies transformation to user-defined shape properties and caches * Applies transformation matrix to user-defined shape properties and
* them for later usage in collision detection. * caches them for later usage in collision detection.
*/ */
virtual void applyTransformation(const typename DimensionTraits<dimensions>::MatrixType& transformation) = 0; virtual void applyTransformationMatrix(const typename DimensionTraits<dimensions>::MatrixType& matrix) = 0;
/** /**
* @brief Detect collision with other shape * @brief Detect collision with other shape

6
src/Physics/AxisAlignedBox.cpp

@ -20,9 +20,9 @@
namespace Magnum { namespace Physics { namespace Magnum { namespace Physics {
template<std::uint8_t dimensions> void AxisAlignedBox<dimensions>::applyTransformation(const typename DimensionTraits<dimensions>::MatrixType& transformation) { template<std::uint8_t dimensions> void AxisAlignedBox<dimensions>::applyTransformationMatrix(const typename DimensionTraits<dimensions>::MatrixType& matrix) {
_transformedPosition = (transformation*typename DimensionTraits<dimensions>::PointType(_position)).vector(); _transformedPosition = (matrix*typename DimensionTraits<dimensions>::PointType(_position)).vector();
_transformedSize = transformation.rotationScaling()*_size; _transformedSize = matrix.rotationScaling()*_size;
} }
template class AxisAlignedBox<2>; template class AxisAlignedBox<2>;

2
src/Physics/AxisAlignedBox.h

@ -40,7 +40,7 @@ template<std::uint8_t dimensions> class MAGNUM_PHYSICS_EXPORT AxisAlignedBox: pu
return AbstractShape<dimensions>::Type::AxisAlignedBox; return AbstractShape<dimensions>::Type::AxisAlignedBox;
} }
void applyTransformation(const typename DimensionTraits<dimensions>::MatrixType& transformation) override; void applyTransformationMatrix(const typename DimensionTraits<dimensions>::MatrixType& matrix) override;
/** @brief Position */ /** @brief Position */
inline typename DimensionTraits<dimensions>::VectorType position() const { inline typename DimensionTraits<dimensions>::VectorType position() const {

4
src/Physics/Box.cpp

@ -20,8 +20,8 @@
namespace Magnum { namespace Physics { namespace Magnum { namespace Physics {
template<std::uint8_t dimensions> void Box<dimensions>::applyTransformation(const typename DimensionTraits<dimensions>::MatrixType& transformation) { template<std::uint8_t dimensions> void Box<dimensions>::applyTransformationMatrix(const typename DimensionTraits<dimensions>::MatrixType& matrix) {
_transformedTransformation = (transformation*_transformation); _transformedTransformation = matrix*_transformation;
} }
template class Box<2>; template class Box<2>;

2
src/Physics/Box.h

@ -42,7 +42,7 @@ template<std::uint8_t dimensions> class MAGNUM_PHYSICS_EXPORT Box: public Abstra
return AbstractShape<dimensions>::Type::Box; return AbstractShape<dimensions>::Type::Box;
} }
void applyTransformation(const typename DimensionTraits<dimensions>::MatrixType& transformation) override; void applyTransformationMatrix(const typename DimensionTraits<dimensions>::MatrixType& matrix) override;
/** @brief Transformation */ /** @brief Transformation */
inline typename DimensionTraits<dimensions>::MatrixType transformation() const { inline typename DimensionTraits<dimensions>::MatrixType transformation() const {

8
src/Physics/Capsule.cpp

@ -27,10 +27,10 @@ using namespace Magnum::Math::Geometry;
namespace Magnum { namespace Physics { namespace Magnum { namespace Physics {
template<std::uint8_t dimensions> void Capsule<dimensions>::applyTransformation(const typename DimensionTraits<dimensions>::MatrixType& transformation) { template<std::uint8_t dimensions> void Capsule<dimensions>::applyTransformationMatrix(const typename DimensionTraits<dimensions>::MatrixType& matrix) {
_transformedA = (transformation*typename DimensionTraits<dimensions>::PointType(_a)).vector(); _transformedA = (matrix*typename DimensionTraits<dimensions>::PointType(_a)).vector();
_transformedB = (transformation*typename DimensionTraits<dimensions>::PointType(_b)).vector(); _transformedB = (matrix*typename DimensionTraits<dimensions>::PointType(_b)).vector();
float scaling = (transformation.rotationScaling()*typename DimensionTraits<dimensions>::VectorType(1/Constants::sqrt3())).length(); float scaling = (matrix.rotationScaling()*typename DimensionTraits<dimensions>::VectorType(1/Constants::sqrt3())).length();
_transformedRadius = scaling*_radius; _transformedRadius = scaling*_radius;
} }

2
src/Physics/Capsule.h

@ -43,7 +43,7 @@ template<std::uint8_t dimensions> class MAGNUM_PHYSICS_EXPORT Capsule: public Ab
return AbstractShape<dimensions>::Type::Capsule; return AbstractShape<dimensions>::Type::Capsule;
} }
void applyTransformation(const typename DimensionTraits<dimensions>::MatrixType& transformation) override; void applyTransformationMatrix(const typename DimensionTraits<dimensions>::MatrixType& matrix) override;
bool collides(const AbstractShape<dimensions>* other) const override; bool collides(const AbstractShape<dimensions>* other) const override;

2
src/Physics/Implementation/AxisAlignedBoxRenderer.cpp

@ -26,7 +26,7 @@ template<std::uint8_t dimensions> void AxisAlignedBoxRenderer<dimensions>::draw(
typename DimensionTraits<dimensions>::MatrixType transformation = typename DimensionTraits<dimensions>::MatrixType transformation =
DimensionTraits<dimensions>::MatrixType::translation(axisAlignedBox.transformedPosition())* DimensionTraits<dimensions>::MatrixType::translation(axisAlignedBox.transformedPosition())*
DimensionTraits<dimensions>::MatrixType::scaling(axisAlignedBox.transformedSize()); DimensionTraits<dimensions>::MatrixType::scaling(axisAlignedBox.transformedSize());
this->shader->setTransformationProjection(camera->projectionMatrix()*camera->cameraMatrix()*transformation) this->shader->setTransformationProjectionMatrix(camera->projectionMatrix()*camera->cameraMatrix()*transformation)
->setColor(options->color) ->setColor(options->color)
->use(); ->use();
this->mesh->draw(); this->mesh->draw();

2
src/Physics/Implementation/BoxRenderer.cpp

@ -23,7 +23,7 @@
namespace Magnum { namespace Physics { namespace Implementation { namespace Magnum { namespace Physics { namespace Implementation {
template<std::uint8_t dimensions> void BoxRenderer<dimensions>::draw(Resource<Options>& options, const typename DimensionTraits<dimensions>::MatrixType&, typename SceneGraph::AbstractCamera<dimensions>* camera) { template<std::uint8_t dimensions> void BoxRenderer<dimensions>::draw(Resource<Options>& options, const typename DimensionTraits<dimensions>::MatrixType&, typename SceneGraph::AbstractCamera<dimensions>* camera) {
this->shader->setTransformationProjection(camera->projectionMatrix()*camera->cameraMatrix()*box.transformedTransformation()) this->shader->setTransformationProjectionMatrix(camera->projectionMatrix()*camera->cameraMatrix()*box.transformedTransformation())
->setColor(options->color) ->setColor(options->color)
->use(); ->use();
this->mesh->draw(); this->mesh->draw();

6
src/Physics/Line.cpp

@ -20,9 +20,9 @@
namespace Magnum { namespace Physics { namespace Magnum { namespace Physics {
template<std::uint8_t dimensions> void Line<dimensions>::applyTransformation(const typename DimensionTraits<dimensions>::MatrixType& transformation) { template<std::uint8_t dimensions> void Line<dimensions>::applyTransformationMatrix(const typename DimensionTraits<dimensions>::MatrixType& matrix) {
_transformedA = (transformation*typename DimensionTraits<dimensions>::PointType(_a)).vector(); _transformedA = (matrix*typename DimensionTraits<dimensions>::PointType(_a)).vector();
_transformedB = (transformation*typename DimensionTraits<dimensions>::PointType(_b)).vector(); _transformedB = (matrix*typename DimensionTraits<dimensions>::PointType(_b)).vector();
} }
/* Explicitly instantiate the templates */ /* Explicitly instantiate the templates */

2
src/Physics/Line.h

@ -41,7 +41,7 @@ template<std::uint8_t dimensions> class MAGNUM_PHYSICS_EXPORT Line: public Abstr
return AbstractShape<dimensions>::Type::Line; return AbstractShape<dimensions>::Type::Line;
} }
void applyTransformation(const typename DimensionTraits<dimensions>::MatrixType& transformation) override; void applyTransformationMatrix(const typename DimensionTraits<dimensions>::MatrixType& matrix) override;
/** @brief First point */ /** @brief First point */
inline typename DimensionTraits<dimensions>::VectorType a() const { inline typename DimensionTraits<dimensions>::VectorType a() const {

4
src/Physics/ObjectShape.cpp

@ -36,8 +36,8 @@ template<uint8_t dimensions> void ObjectShape<dimensions>::markDirty() {
group()->setDirty(); group()->setDirty();
} }
template<uint8_t dimensions> void ObjectShape<dimensions>::clean(const typename DimensionTraits<dimensions>::MatrixType& absoluteTransformation) { template<uint8_t dimensions> void ObjectShape<dimensions>::clean(const typename DimensionTraits<dimensions>::MatrixType& absoluteTransformationMatrix) {
if(_shape) _shape->applyTransformation(absoluteTransformation); if(_shape) _shape->applyTransformationMatrix(absoluteTransformationMatrix);
} }
template class ObjectShape<2>; template class ObjectShape<2>;

2
src/Physics/ObjectShape.h

@ -78,7 +78,7 @@ template<std::uint8_t dimensions> class MAGNUM_PHYSICS_EXPORT ObjectShape: publi
void markDirty() override; void markDirty() override;
/** Applies transformation to associated shape. */ /** Applies transformation to associated shape. */
void clean(const typename DimensionTraits<dimensions>::MatrixType& absoluteTransformation) override; void clean(const typename DimensionTraits<dimensions>::MatrixType& absoluteTransformationMatrix) override;
private: private:
AbstractShape<dimensions>* _shape; AbstractShape<dimensions>* _shape;

6
src/Physics/Plane.cpp

@ -27,9 +27,9 @@ using namespace Magnum::Math::Geometry;
namespace Magnum { namespace Physics { namespace Magnum { namespace Physics {
void Plane::applyTransformation(const Matrix4& transformation) { void Plane::applyTransformationMatrix(const Matrix4& matrix) {
_transformedPosition = (transformation*Magnum::Point3D(_position)).xyz(); _transformedPosition = (matrix*Magnum::Point3D(_position)).xyz();
_transformedNormal = transformation.rotation()*_normal; _transformedNormal = matrix.rotation()*_normal;
} }
bool Plane::collides(const AbstractShape<3>* other) const { bool Plane::collides(const AbstractShape<3>* other) const {

4
src/Physics/Plane.h

@ -36,10 +36,10 @@ class MAGNUM_PHYSICS_EXPORT Plane: public AbstractShape<3> {
inline Type type() const override { return Type::Plane; } inline Type type() const override { return Type::Plane; }
#ifndef DOXYGEN_GENERATING_OUTPUT #ifndef DOXYGEN_GENERATING_OUTPUT
void applyTransformation(const Matrix4& transformation) override; void applyTransformationMatrix(const Matrix4& matrix) override;
bool collides(const AbstractShape<3>* other) const override; bool collides(const AbstractShape<3>* other) const override;
#else #else
void applyTransformation(const typename DimensionTraits<dimensions>::MatrixType& transformation) override; void applyTransformationMatrix(const typename DimensionTraits<dimensions>::MatrixType& matrix) override;
bool collides(const AbstractShape* other) const override; bool collides(const AbstractShape* other) const override;
#endif #endif

4
src/Physics/Point.cpp

@ -20,8 +20,8 @@
namespace Magnum { namespace Physics { namespace Magnum { namespace Physics {
template<std::uint8_t dimensions> void Point<dimensions>::applyTransformation(const typename DimensionTraits<dimensions>::MatrixType& transformation) { template<std::uint8_t dimensions> void Point<dimensions>::applyTransformationMatrix(const typename DimensionTraits<dimensions>::MatrixType& matrix) {
_transformedPosition = (transformation*typename DimensionTraits<dimensions>::PointType(_position)).vector(); _transformedPosition = (matrix*typename DimensionTraits<dimensions>::PointType(_position)).vector();
} }
template class Point<2>; template class Point<2>;

2
src/Physics/Point.h

@ -40,7 +40,7 @@ template<std::uint8_t dimensions> class MAGNUM_PHYSICS_EXPORT Point: public Abst
return AbstractShape<dimensions>::Type::Point; return AbstractShape<dimensions>::Type::Point;
} }
void applyTransformation(const typename DimensionTraits<dimensions>::MatrixType& transformation) override; void applyTransformationMatrix(const typename DimensionTraits<dimensions>::MatrixType& matrix) override;
/** @brief Position */ /** @brief Position */
inline typename DimensionTraits<dimensions>::VectorType position() const { inline typename DimensionTraits<dimensions>::VectorType position() const {

6
src/Physics/ShapeGroup.cpp

@ -43,9 +43,9 @@ template<std::uint8_t dimensions> ShapeGroup<dimensions>& ShapeGroup<dimensions>
return *this; return *this;
} }
template<std::uint8_t dimensions> void ShapeGroup<dimensions>::applyTransformation(const typename DimensionTraits<dimensions>::MatrixType& transformation) { template<std::uint8_t dimensions> void ShapeGroup<dimensions>::applyTransformationMatrix(const typename DimensionTraits<dimensions>::MatrixType& matrix) {
if(a) a->applyTransformation(transformation); if(a) a->applyTransformationMatrix(matrix);
if(b) b->applyTransformation(transformation); if(b) b->applyTransformationMatrix(matrix);
} }
template<std::uint8_t dimensions> bool ShapeGroup<dimensions>::collides(const AbstractShape<dimensions>* other) const { template<std::uint8_t dimensions> bool ShapeGroup<dimensions>::collides(const AbstractShape<dimensions>* other) const {

2
src/Physics/ShapeGroup.h

@ -105,7 +105,7 @@ template<std::uint8_t dimensions> class MAGNUM_PHYSICS_EXPORT ShapeGroup: public
return AbstractShape<dimensions>::Type::ShapeGroup; return AbstractShape<dimensions>::Type::ShapeGroup;
} }
void applyTransformation(const typename DimensionTraits<dimensions>::MatrixType& transformation) override; void applyTransformationMatrix(const typename DimensionTraits<dimensions>::MatrixType& matrix) override;
bool collides(const AbstractShape<dimensions>* other) const override; bool collides(const AbstractShape<dimensions>* other) const override;

6
src/Physics/Sphere.cpp

@ -39,9 +39,9 @@ namespace {
} }
} }
template<std::uint8_t dimensions> void Sphere<dimensions>::applyTransformation(const typename DimensionTraits<dimensions>::MatrixType& transformation) { template<std::uint8_t dimensions> void Sphere<dimensions>::applyTransformationMatrix(const typename DimensionTraits<dimensions>::MatrixType& matrix) {
_transformedPosition = (transformation*typename DimensionTraits<dimensions>::PointType(_position)).vector(); _transformedPosition = (matrix*typename DimensionTraits<dimensions>::PointType(_position)).vector();
float scaling = (transformation.rotationScaling()*unitVector<dimensions>()).length(); float scaling = (matrix.rotationScaling()*unitVector<dimensions>()).length();
_transformedRadius = scaling*_radius; _transformedRadius = scaling*_radius;
} }

2
src/Physics/Sphere.h

@ -43,7 +43,7 @@ template<std::uint8_t dimensions> class MAGNUM_PHYSICS_EXPORT Sphere: public Abs
return AbstractShape<dimensions>::Type::Sphere; return AbstractShape<dimensions>::Type::Sphere;
} }
void applyTransformation(const typename DimensionTraits<dimensions>::MatrixType& transformation) override; void applyTransformationMatrix(const typename DimensionTraits<dimensions>::MatrixType& matrix) override;
bool collides(const AbstractShape<dimensions>* other) const override; bool collides(const AbstractShape<dimensions>* other) const override;

4
src/Physics/Test/AxisAlignedBoxTest.cpp

@ -30,11 +30,11 @@ AxisAlignedBoxTest::AxisAlignedBoxTest() {
void AxisAlignedBoxTest::applyTransformation() { void AxisAlignedBoxTest::applyTransformation() {
Physics::AxisAlignedBox3D box({-1.0f, -2.0f, -3.0f}, {1.0f, 2.0f, 3.0f}); Physics::AxisAlignedBox3D box({-1.0f, -2.0f, -3.0f}, {1.0f, 2.0f, 3.0f});
box.applyTransformation(Matrix4::scaling({2.0f, -1.0f, 1.5f})); box.applyTransformationMatrix(Matrix4::scaling({2.0f, -1.0f, 1.5f}));
CORRADE_COMPARE(box.transformedPosition(), Vector3(-2.0f, 2.0f, -4.5f)); CORRADE_COMPARE(box.transformedPosition(), Vector3(-2.0f, 2.0f, -4.5f));
CORRADE_COMPARE(box.transformedSize(), Vector3(2.0f, -2.0f, 4.5f)); CORRADE_COMPARE(box.transformedSize(), Vector3(2.0f, -2.0f, 4.5f));
box.applyTransformation(Matrix4::translation(Vector3(1.0f))*Matrix4::rotation(deg(90.0f), Vector3::xAxis())); box.applyTransformationMatrix(Matrix4::translation(Vector3(1.0f))*Matrix4::rotation(deg(90.0f), Vector3::xAxis()));
CORRADE_COMPARE(box.transformedPosition(), Vector3(0.0f, 4.0f, -1.0f)); CORRADE_COMPARE(box.transformedPosition(), Vector3(0.0f, 4.0f, -1.0f));
CORRADE_COMPARE(box.transformedSize(), Vector3(1.0f, -3.0f, 2.0f)); CORRADE_COMPARE(box.transformedSize(), Vector3(1.0f, -3.0f, 2.0f));
} }

2
src/Physics/Test/BoxTest.cpp

@ -29,7 +29,7 @@ BoxTest::BoxTest() {
void BoxTest::applyTransformation() { void BoxTest::applyTransformation() {
Physics::Box3D box(Matrix4::translation({1.0f, 2.0f, -3.0f})); Physics::Box3D box(Matrix4::translation({1.0f, 2.0f, -3.0f}));
box.applyTransformation(Matrix4::scaling({2.0f, -1.0f, 1.5f})); box.applyTransformationMatrix(Matrix4::scaling({2.0f, -1.0f, 1.5f}));
CORRADE_COMPARE(box.transformedTransformation(), Matrix4::scaling({2.0f, -1.0f, 1.5f})*Matrix4::translation({1.0f, 2.0f, -3.0f})); CORRADE_COMPARE(box.transformedTransformation(), Matrix4::scaling({2.0f, -1.0f, 1.5f})*Matrix4::translation({1.0f, 2.0f, -3.0f}));
} }

4
src/Physics/Test/CapsuleTest.cpp

@ -32,13 +32,13 @@ CapsuleTest::CapsuleTest() {
void CapsuleTest::applyTransformation() { void CapsuleTest::applyTransformation() {
Physics::Capsule3D capsule({1.0f, 2.0f, 3.0f}, {-1.0f, -2.0f, -3.0f}, 7.0f); Physics::Capsule3D capsule({1.0f, 2.0f, 3.0f}, {-1.0f, -2.0f, -3.0f}, 7.0f);
capsule.applyTransformation(Matrix4::rotation(deg(90.0f), Vector3::zAxis())); capsule.applyTransformationMatrix(Matrix4::rotation(deg(90.0f), Vector3::zAxis()));
CORRADE_COMPARE(capsule.transformedA(), Vector3(-2.0f, 1.0f, 3.0f)); CORRADE_COMPARE(capsule.transformedA(), Vector3(-2.0f, 1.0f, 3.0f));
CORRADE_COMPARE(capsule.transformedB(), Vector3(2.0f, -1.0f, -3.0f)); CORRADE_COMPARE(capsule.transformedB(), Vector3(2.0f, -1.0f, -3.0f));
CORRADE_COMPARE(capsule.radius(), 7.0f); CORRADE_COMPARE(capsule.radius(), 7.0f);
/* Apply average scaling to radius */ /* Apply average scaling to radius */
capsule.applyTransformation(Matrix4::scaling({Constants::sqrt3(), -Constants::sqrt2(), 2.0f})); capsule.applyTransformationMatrix(Matrix4::scaling({Constants::sqrt3(), -Constants::sqrt2(), 2.0f}));
CORRADE_COMPARE(capsule.transformedRadius(), Constants::sqrt3()*7.0f); CORRADE_COMPARE(capsule.transformedRadius(), Constants::sqrt3()*7.0f);
} }

2
src/Physics/Test/LineTest.cpp

@ -29,7 +29,7 @@ LineTest::LineTest() {
void LineTest::applyTransformation() { void LineTest::applyTransformation() {
Physics::Line3D line({1.0f, 2.0f, 3.0f}, {-1.0f, -2.0f, -3.0f}); Physics::Line3D line({1.0f, 2.0f, 3.0f}, {-1.0f, -2.0f, -3.0f});
line.applyTransformation(Matrix4::rotation(deg(90.0f), Vector3::zAxis())); line.applyTransformationMatrix(Matrix4::rotation(deg(90.0f), Vector3::zAxis()));
CORRADE_COMPARE(line.transformedA(), Vector3(-2.0f, 1.0f, 3.0f)); CORRADE_COMPARE(line.transformedA(), Vector3(-2.0f, 1.0f, 3.0f));
CORRADE_COMPARE(line.transformedB(), Vector3(2.0f, -1.0f, -3.0f)); CORRADE_COMPARE(line.transformedB(), Vector3(2.0f, -1.0f, -3.0f));
} }

4
src/Physics/Test/PlaneTest.cpp

@ -33,12 +33,12 @@ PlaneTest::PlaneTest() {
void PlaneTest::applyTransformation() { void PlaneTest::applyTransformation() {
Physics::Plane plane({1.0f, 2.0f, 3.0f}, {Constants::sqrt2(), -Constants::sqrt2(), 0}); Physics::Plane plane({1.0f, 2.0f, 3.0f}, {Constants::sqrt2(), -Constants::sqrt2(), 0});
plane.applyTransformation(Matrix4::rotation(deg(90.0f), Vector3::xAxis())); plane.applyTransformationMatrix(Matrix4::rotation(deg(90.0f), Vector3::xAxis()));
CORRADE_COMPARE(plane.transformedPosition(), Vector3(1.0f, -3.0f, 2.0f)); CORRADE_COMPARE(plane.transformedPosition(), Vector3(1.0f, -3.0f, 2.0f));
CORRADE_COMPARE(plane.transformedNormal(), Vector3(Constants::sqrt2(), 0, -Constants::sqrt2())); CORRADE_COMPARE(plane.transformedNormal(), Vector3(Constants::sqrt2(), 0, -Constants::sqrt2()));
/* The normal should stay normalized */ /* The normal should stay normalized */
plane.applyTransformation(Matrix4::scaling({1.5f, 2.0f, 3.0f})); plane.applyTransformationMatrix(Matrix4::scaling({1.5f, 2.0f, 3.0f}));
CORRADE_COMPARE(plane.transformedPosition(), Vector3(1.5f, 4.0f, 9.0f)); CORRADE_COMPARE(plane.transformedPosition(), Vector3(1.5f, 4.0f, 9.0f));
CORRADE_COMPARE(plane.transformedNormal(), Vector3(Constants::sqrt2(), -Constants::sqrt2(), 0)); CORRADE_COMPARE(plane.transformedNormal(), Vector3(Constants::sqrt2(), -Constants::sqrt2(), 0));
} }

2
src/Physics/Test/PointTest.cpp

@ -28,7 +28,7 @@ PointTest::PointTest() {
void PointTest::applyTransformation() { void PointTest::applyTransformation() {
Physics::Point3D point({1.0f, 2.0f, 3.0f}); Physics::Point3D point({1.0f, 2.0f, 3.0f});
point.applyTransformation(Matrix4::translation({5.0f, 6.0f, 7.0f})); point.applyTransformationMatrix(Matrix4::translation({5.0f, 6.0f, 7.0f}));
CORRADE_COMPARE(point.transformedPosition(), Vector3(6.0f, 8.0f, 10.0f)); CORRADE_COMPARE(point.transformedPosition(), Vector3(6.0f, 8.0f, 10.0f));
} }

4
src/Physics/Test/ShapeGroupTest.cpp

@ -41,7 +41,7 @@ void ShapeGroupTest::copy() {
} }
/* Just to test that it doesn't crash */ /* Just to test that it doesn't crash */
group.applyTransformation(Matrix4::translation(Vector3::xAxis(1.0f))); group.applyTransformationMatrix(Matrix4::translation(Vector3::xAxis(1.0f)));
CORRADE_VERIFY(true); CORRADE_VERIFY(true);
} }
@ -52,7 +52,7 @@ void ShapeGroupTest::reference() {
ShapeGroup3D group = !(ref(point) || ref(segment)); ShapeGroup3D group = !(ref(point) || ref(segment));
group.applyTransformation(Matrix4::translation(Vector3(1.0f))); group.applyTransformationMatrix(Matrix4::translation(Vector3(1.0f)));
CORRADE_VERIFY((point.transformedPosition() == Vector3(2.0f, 3.0f, 4.0f))); CORRADE_VERIFY((point.transformedPosition() == Vector3(2.0f, 3.0f, 4.0f)));
CORRADE_VERIFY((segment.transformedA() == Vector3(3.0f, 2.0f, 31.0f))); CORRADE_VERIFY((segment.transformedA() == Vector3(3.0f, 2.0f, 31.0f)));

2
src/Physics/Test/ShapeTestBase.h

@ -25,7 +25,7 @@ namespace Magnum { namespace Physics { namespace Test {
class ShapeTestBase { class ShapeTestBase {
protected: protected:
template<class T> void randomTransformation(T& shape) { template<class T> void randomTransformation(T& shape) {
shape.applyTransformation(Matrix4::translation({7.0f, 8.0f, -9.0f})); shape.applyTransformationMatrix(Matrix4::translation({7.0f, 8.0f, -9.0f}));
} }
}; };

6
src/Physics/Test/SphereTest.cpp

@ -35,17 +35,17 @@ SphereTest::SphereTest() {
void SphereTest::applyTransformation() { void SphereTest::applyTransformation() {
Physics::Sphere3D sphere({1.0f, 2.0f, 3.0f}, 7.0f); Physics::Sphere3D sphere({1.0f, 2.0f, 3.0f}, 7.0f);
sphere.applyTransformation(Matrix4::rotation(deg(90.0f), Vector3::yAxis())); sphere.applyTransformationMatrix(Matrix4::rotation(deg(90.0f), Vector3::yAxis()));
CORRADE_COMPARE(sphere.transformedPosition(), Vector3(3.0f, 2.0f, -1.0f)); CORRADE_COMPARE(sphere.transformedPosition(), Vector3(3.0f, 2.0f, -1.0f));
CORRADE_COMPARE(sphere.transformedRadius(), 7.0f); CORRADE_COMPARE(sphere.transformedRadius(), 7.0f);
/* Symmetric scaling */ /* Symmetric scaling */
sphere.applyTransformation(Matrix4::scaling(Vector3(2.0f))); sphere.applyTransformationMatrix(Matrix4::scaling(Vector3(2.0f)));
CORRADE_COMPARE(sphere.transformedPosition(), Vector3(2.0f, 4.0f, 6.0f)); CORRADE_COMPARE(sphere.transformedPosition(), Vector3(2.0f, 4.0f, 6.0f));
CORRADE_COMPARE(sphere.transformedRadius(), 14.0f); CORRADE_COMPARE(sphere.transformedRadius(), 14.0f);
/* Apply average scaling to radius */ /* Apply average scaling to radius */
sphere.applyTransformation(Matrix4::scaling({Constants::sqrt3(), -Constants::sqrt2(), 2.0f})); sphere.applyTransformationMatrix(Matrix4::scaling({Constants::sqrt3(), -Constants::sqrt2(), 2.0f}));
CORRADE_COMPARE(sphere.transformedRadius(), Constants::sqrt3()*7.0f); CORRADE_COMPARE(sphere.transformedRadius(), Constants::sqrt3()*7.0f);
} }

4
src/SceneGraph/AbstractCamera.h

@ -141,8 +141,8 @@ class MAGNUM_SCENEGRAPH_EXPORT AbstractCamera: public AbstractFeature<dimensions
protected: protected:
/** Recalculates camera matrix */ /** Recalculates camera matrix */
inline void cleanInverted(const typename DimensionTraits<dimensions, T>::MatrixType& invertedAbsoluteTransformation) override { inline void cleanInverted(const typename DimensionTraits<dimensions, T>::MatrixType& invertedAbsoluteTransformationMatrix) override {
_cameraMatrix = invertedAbsoluteTransformation; _cameraMatrix = invertedAbsoluteTransformationMatrix;
} }
#ifndef DOXYGEN_GENERATING_OUTPUT #ifndef DOXYGEN_GENERATING_OUTPUT

8
src/SceneGraph/AbstractFeature.h

@ -72,8 +72,8 @@ class CachingFeature: public SceneGraph::AbstractFeature3D<> {
} }
protected: protected:
void clean(const Matrix4& absoluteTransformation) override { void clean(const Matrix4& absoluteTransformationMatrix) override {
absolutePosition = absoluteTransformation.translation(); absolutePosition = absoluteTransformationMatrix.translation();
} }
private: private:
@ -258,7 +258,7 @@ template<std::uint8_t dimensions, class T = GLfloat> class AbstractFeature
* Default implementation does nothing. * Default implementation does nothing.
* @see @ref scenegraph-caching, cleanInverted() * @see @ref scenegraph-caching, cleanInverted()
*/ */
virtual void clean(const typename DimensionTraits<dimensions, T>::MatrixType& absoluteTransformation); virtual void clean(const typename DimensionTraits<dimensions, T>::MatrixType& absoluteTransformationMatrix);
/** /**
* @brief Clean data based on inverted absolute transformation * @brief Clean data based on inverted absolute transformation
@ -272,7 +272,7 @@ template<std::uint8_t dimensions, class T = GLfloat> class AbstractFeature
* Default implementation does nothing. * Default implementation does nothing.
* @see @ref scenegraph-caching, clean() * @see @ref scenegraph-caching, clean()
*/ */
virtual void cleanInverted(const typename DimensionTraits<dimensions, T>::MatrixType& invertedAbsoluteTransformation); virtual void cleanInverted(const typename DimensionTraits<dimensions, T>::MatrixType& invertedAbsoluteTransformationMatrix);
/*@}*/ /*@}*/

2
src/Shaders/FlatShader.cpp

@ -65,7 +65,7 @@ template<std::uint8_t dimensions> FlatShader<dimensions>::FlatShader() {
link(); link();
transformationProjectionUniform = uniformLocation("transformationProjection"); transformationProjectionMatrixUniform = uniformLocation("transformationProjectionMatrix");
colorUniform = uniformLocation("color"); colorUniform = uniformLocation("color");
} }

6
src/Shaders/FlatShader.h

@ -46,8 +46,8 @@ template<std::uint8_t dimensions> class MAGNUM_SHADERS_EXPORT FlatShader: public
* @brief Set transformation and projection matrix * @brief Set transformation and projection matrix
* @return Pointer to self (for method chaining) * @return Pointer to self (for method chaining)
*/ */
FlatShader<dimensions>* setTransformationProjection(const typename DimensionTraits<dimensions>::MatrixType& matrix) { FlatShader<dimensions>* setTransformationProjectionMatrix(const typename DimensionTraits<dimensions>::MatrixType& matrix) {
setUniform(transformationProjectionUniform, matrix); setUniform(transformationProjectionMatrixUniform, matrix);
return this; return this;
} }
@ -61,7 +61,7 @@ template<std::uint8_t dimensions> class MAGNUM_SHADERS_EXPORT FlatShader: public
} }
private: private:
GLint transformationProjectionUniform, GLint transformationProjectionMatrixUniform,
colorUniform; colorUniform;
}; };

4
src/Shaders/FlatShader2D.vert

@ -2,7 +2,7 @@
#define in attribute #define in attribute
#endif #endif
uniform highp mat3 transformationProjection; uniform highp mat3 transformationProjectionMatrix;
#ifdef EXPLICIT_ATTRIB_LOCATION #ifdef EXPLICIT_ATTRIB_LOCATION
layout(location = 0) in highp vec3 position; layout(location = 0) in highp vec3 position;
@ -11,5 +11,5 @@ in highp vec3 position;
#endif #endif
void main() { void main() {
gl_Position.xywz = vec4(transformationProjection*position, 0.0); gl_Position.xywz = vec4(transformationProjectionMatrix*position, 0.0);
} }

6
src/Shaders/PhongShader.h

@ -84,10 +84,10 @@ class MAGNUM_SHADERS_EXPORT PhongShader: public AbstractShaderProgram {
} }
/** /**
* @brief Set transformation matrix and normal matrix * @brief Set transformation and normal matrix
* @return Pointer to self (for method chaining) * @return Pointer to self (for method chaining)
*/ */
inline PhongShader* setTransformation(const Matrix4& matrix) { inline PhongShader* setTransformationMatrix(const Matrix4& matrix) {
setUniform(transformationMatrixUniform, matrix); setUniform(transformationMatrixUniform, matrix);
setUniform(normalMatrixUniform, matrix.rotation()); setUniform(normalMatrixUniform, matrix.rotation());
return this; return this;
@ -97,7 +97,7 @@ class MAGNUM_SHADERS_EXPORT PhongShader: public AbstractShaderProgram {
* @brief Set projection matrix * @brief Set projection matrix
* @return Pointer to self (for method chaining) * @return Pointer to self (for method chaining)
*/ */
inline PhongShader* setProjection(const Matrix4& matrix) { inline PhongShader* setProjectionMatrix(const Matrix4& matrix) {
setUniform(projectionMatrixUniform, matrix); setUniform(projectionMatrixUniform, matrix);
return this; return this;
} }

2
src/Shaders/VertexColorShader.cpp

@ -66,7 +66,7 @@ template<std::uint8_t dimensions> VertexColorShader<dimensions>::VertexColorShad
link(); link();
transformationProjectionUniform = uniformLocation("transformationProjection"); transformationProjectionMatrixUniform = uniformLocation("transformationProjectionMatrix");
} }
template class VertexColorShader<2>; template class VertexColorShader<2>;

8
src/Shaders/VertexColorShader.h

@ -46,16 +46,16 @@ template<std::uint8_t dimensions> class MAGNUM_SHADERS_EXPORT VertexColorShader:
VertexColorShader(); VertexColorShader();
/** /**
* @brief Set transformation and projection * @brief Set transformation and projection matrix
* @return Pointer to self (for method chaining) * @return Pointer to self (for method chaining)
*/ */
inline VertexColorShader<dimensions>* setTransformationProjection(const typename DimensionTraits<dimensions>::MatrixType& matrix) { inline VertexColorShader<dimensions>* setTransformationProjectionMatrix(const typename DimensionTraits<dimensions>::MatrixType& matrix) {
setUniform(transformationProjectionUniform, matrix); setUniform(transformationProjectionMatrixUniform, matrix);
return this; return this;
} }
private: private:
GLint transformationProjectionUniform; GLint transformationProjectionMatrixUniform;
}; };
/** @brief 2D vertex color shader */ /** @brief 2D vertex color shader */

4
src/Shaders/VertexColorShader2D.vert

@ -3,7 +3,7 @@
#define out varying #define out varying
#endif #endif
uniform highp mat3 transformationProjection; uniform highp mat3 transformationProjectionMatrix;
#ifdef EXPLICIT_ATTRIB_LOCATION #ifdef EXPLICIT_ATTRIB_LOCATION
layout(location = 0) in highp vec3 position; layout(location = 0) in highp vec3 position;
@ -16,6 +16,6 @@ in lowp vec3 color;
out lowp vec3 interpolatedColor; out lowp vec3 interpolatedColor;
void main() { void main() {
gl_Position.xywz = vec4(transformationProjection*position, 0.0); gl_Position.xywz = vec4(transformationProjectionMatrix*position, 0.0);
interpolatedColor = color; interpolatedColor = color;
} }

Loading…
Cancel
Save