diff --git a/doc/compilation-speedup.dox b/doc/compilation-speedup.dox index 13dfef0ee..d67a69c6b 100644 --- a/doc/compilation-speedup.dox +++ b/doc/compilation-speedup.dox @@ -20,6 +20,7 @@ typedefs etc. In this case a header with forward declarations is usually available, each namespace has its own: - Magnum.h + - Physics/Physics.h - SceneGraph/SceneGraph.h - Shaders/Shaders.h diff --git a/src/Physics/CMakeLists.txt b/src/Physics/CMakeLists.txt index f577e1594..c2b35ce8a 100644 --- a/src/Physics/CMakeLists.txt +++ b/src/Physics/CMakeLists.txt @@ -25,10 +25,11 @@ set(MagnumPhysics_HEADERS DebugDrawResourceManager.h Line.h LineSegment.h - Plane.h - Point.h ObjectShape.h ObjectShapeGroup.h + Physics.h + Plane.h + Point.h ShapeGroup.h Sphere.h diff --git a/src/Physics/Capsule.h b/src/Physics/Capsule.h index c493f1db9..af8a19a36 100644 --- a/src/Physics/Capsule.h +++ b/src/Physics/Capsule.h @@ -21,14 +21,12 @@ #include "Math/Vector3.h" #include "AbstractShape.h" +#include "Physics.h" #include "magnumCompatibility.h" namespace Magnum { namespace Physics { -template class Point; -template class Sphere; - /** @brief %Capsule defined by cylinder start and end point and radius diff --git a/src/Physics/DebugDrawResourceManager.h b/src/Physics/DebugDrawResourceManager.h index c8253dfbf..041e77134 100644 --- a/src/Physics/DebugDrawResourceManager.h +++ b/src/Physics/DebugDrawResourceManager.h @@ -28,15 +28,12 @@ #include "ResourceManager.h" #include "SceneGraph/SceneGraph.h" +#include "Physics.h" #include "magnumPhysicsVisibility.h" namespace Magnum { -class AbstractShaderProgram; -class Buffer; -class Mesh; - #ifndef DOXYGEN_GENERATING_OUTPUT namespace Physics { namespace Implementation { struct Options { @@ -50,14 +47,6 @@ extern template ResourceManager class AbstractShape; -typedef AbstractShape<2> AbstractShape2D; -typedef AbstractShape<3> AbstractShape3D; - -template class ObjectShape; -typedef ObjectShape<2> ObjectShape2D; -typedef ObjectShape<3> ObjectShape3D; - /** @brief %Resource manager for physics debug draw diff --git a/src/Physics/ObjectShape.h b/src/Physics/ObjectShape.h index 1a651a8ee..8a2d23d6a 100644 --- a/src/Physics/ObjectShape.h +++ b/src/Physics/ObjectShape.h @@ -26,9 +26,6 @@ namespace Magnum { namespace Physics { -template class ObjectShapeGroup; -template class AbstractShape; - /** @brief Object shape diff --git a/src/Physics/ObjectShapeGroup.h b/src/Physics/ObjectShapeGroup.h index 93eb61659..cca7d18c9 100644 --- a/src/Physics/ObjectShapeGroup.h +++ b/src/Physics/ObjectShapeGroup.h @@ -23,17 +23,15 @@ #include #include "SceneGraph/FeatureGroup.h" +#include "Physics.h" #include "magnumPhysicsVisibility.h" namespace Magnum { namespace Physics { -template class ObjectShape; - /** @brief Group of object shapes - @see ObjectShapeGroup2D, ObjectShapeGroup3D */ template class PHYSICS_EXPORT ObjectShapeGroup: public SceneGraph::FeatureGroup> { diff --git a/src/Physics/Physics.h b/src/Physics/Physics.h new file mode 100644 index 000000000..aca5325fe --- /dev/null +++ b/src/Physics/Physics.h @@ -0,0 +1,76 @@ +#ifndef Magnum_Physics_Physics_h +#define Magnum_Physics_Physics_h +/* + Copyright © 2010, 2011, 2012 Vladimír Vondruš + + This file is part of Magnum. + + Magnum is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License version 3 + only, as published by the Free Software Foundation. + + Magnum is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License version 3 for more details. +*/ + +#include + +/** @file + * @brief Forward declarations for Magnum::Physics namespace + */ + +namespace Magnum { namespace Physics { + +template class AbstractShape; +typedef AbstractShape<2> AbstractShape2D; +typedef AbstractShape<3> AbstractShape3D; + +template class AxisAlignedBox; +typedef AxisAlignedBox<2> AxisAlignedBox2D; +typedef AxisAlignedBox<3> AxisAlignedBox3D; + +template class Box; +typedef Box<2> Box2D; +typedef Box<3> Box3D; + +template class Capsule; +typedef Capsule<2> Capsule2D; +typedef Capsule<3> Capsule3D; + +class DebugDrawResourceManager; + +template class Line; +typedef Line<2> Line2D; +typedef Line<3> Line3D; + +template class LineSegment; +typedef LineSegment<2> LineSegment2D; +typedef LineSegment<3> LineSegment3D; + +template class ObjectShape; +typedef ObjectShape<2> ObjectShape2D; +typedef ObjectShape<3> ObjectShape3D; + +template class ObjectShapeGroup; +typedef ObjectShapeGroup<2> ObjectShapeGroup2D; +typedef ObjectShapeGroup<3> ObjectShapeGroup3D; + +class Plane; + +template class Point; +typedef Point<2> Point2D; +typedef Point<3> Point3D; + +template class ShapeGroup; +typedef ShapeGroup<2> ShapeGroup2D; +typedef ShapeGroup<3> ShapeGroup3D; + +template class Sphere; +typedef Sphere<2> Sphere2D; +typedef Sphere<3> Sphere3D; + +}} + +#endif diff --git a/src/Physics/Plane.cpp b/src/Physics/Plane.cpp index b55c1d7a2..e1ddf5ac5 100644 --- a/src/Physics/Plane.cpp +++ b/src/Physics/Plane.cpp @@ -28,7 +28,7 @@ using namespace Magnum::Math::Geometry; namespace Magnum { namespace Physics { void Plane::applyTransformation(const Matrix4& transformation) { - _transformedPosition = (transformation*Point3D(_position)).xyz(); + _transformedPosition = (transformation*Magnum::Point3D(_position)).xyz(); _transformedNormal = transformation.rotation()*_normal; } diff --git a/src/Physics/Plane.h b/src/Physics/Plane.h index c17114b16..2397aa2e2 100644 --- a/src/Physics/Plane.h +++ b/src/Physics/Plane.h @@ -21,16 +21,12 @@ #include "Math/Vector3.h" #include "AbstractShape.h" +#include "Physics.h" #include "magnumCompatibility.h" namespace Magnum { namespace Physics { -template class Line; -typedef Line<3> Line3D; -template class LineSegment; -typedef LineSegment<3> LineSegment3D; - /** @brief Infinite plane, defined by position and normal (3D only) */ class PHYSICS_EXPORT Plane: public AbstractShape<3> { public: diff --git a/src/Physics/Sphere.h b/src/Physics/Sphere.h index 9a91966ca..1fd8cc378 100644 --- a/src/Physics/Sphere.h +++ b/src/Physics/Sphere.h @@ -21,15 +21,12 @@ #include "Math/Vector3.h" #include "AbstractShape.h" +#include "Physics.h" #include "magnumCompatibility.h" namespace Magnum { namespace Physics { -template class Line; -template class LineSegment; -template class Point; - /** @brief %Sphere defined by position and radius