Browse Source

SceneGraph: de-inlined some constructors & destructor, hidden internals.

Might help reducing application size.
pull/7/head
Vladimír Vondruš 13 years ago
parent
commit
63086fdebe
  1. 6
      src/SceneGraph/AbstractCamera.h
  2. 6
      src/SceneGraph/AbstractCamera.hpp
  3. 8
      src/SceneGraph/AbstractObject.h
  4. 8
      src/SceneGraph/AbstractTransformation.h
  5. 2
      src/SceneGraph/Animable.h
  6. 2
      src/SceneGraph/Animable.hpp
  7. 3
      src/SceneGraph/CMakeLists.txt
  8. 8
      src/SceneGraph/Camera.cpp
  9. 2
      src/SceneGraph/Camera2D.h
  10. 2
      src/SceneGraph/Camera2D.hpp
  11. 2
      src/SceneGraph/Camera3D.h
  12. 2
      src/SceneGraph/Camera3D.hpp
  13. 25
      src/SceneGraph/Object.cpp
  14. 6
      src/SceneGraph/Object.h
  15. 7
      src/SceneGraph/Object.hpp

6
src/SceneGraph/AbstractCamera.h

@ -76,9 +76,7 @@ class MAGNUM_SCENEGRAPH_EXPORT AbstractCamera: public AbstractFeature<dimensions
* @brief Constructor * @brief Constructor
* @param object Object holding the camera * @param object Object holding the camera
*/ */
inline explicit AbstractCamera(AbstractObject<dimensions, T>* object): AbstractFeature<dimensions, T>(object), _aspectRatioPolicy(AspectRatioPolicy::NotPreserved) { explicit AbstractCamera(AbstractObject<dimensions, T>* object);
AbstractFeature<dimensions, T>::setCachedTransformations(AbstractFeature<dimensions, T>::CachedTransformation::InvertedAbsolute);
}
virtual ~AbstractCamera() = 0; virtual ~AbstractCamera() = 0;
@ -162,8 +160,6 @@ class MAGNUM_SCENEGRAPH_EXPORT AbstractCamera: public AbstractFeature<dimensions
Vector2i _viewport; Vector2i _viewport;
}; };
template<std::uint8_t dimensions, class T> inline AbstractCamera<dimensions, T>::~AbstractCamera() {}
#ifndef CORRADE_GCC46_COMPATIBILITY #ifndef CORRADE_GCC46_COMPATIBILITY
/** /**
@brief Base for two-dimensional cameras @brief Base for two-dimensional cameras

6
src/SceneGraph/AbstractCamera.hpp

@ -63,6 +63,12 @@ template<std::uint8_t dimensions, class T> typename DimensionTraits<dimensions,
} }
#endif #endif
template<std::uint8_t dimensions, class T> AbstractCamera<dimensions, T>::AbstractCamera(AbstractObject<dimensions, T>* object): AbstractFeature<dimensions, T>(object), _aspectRatioPolicy(AspectRatioPolicy::NotPreserved) {
AbstractFeature<dimensions, T>::setCachedTransformations(AbstractFeature<dimensions, T>::CachedTransformation::InvertedAbsolute);
}
template<std::uint8_t dimensions, class T> AbstractCamera<dimensions, T>::~AbstractCamera() {}
template<std::uint8_t dimensions, class T> AbstractCamera<dimensions, T>* AbstractCamera<dimensions, T>::setAspectRatioPolicy(AspectRatioPolicy policy) { template<std::uint8_t dimensions, class T> AbstractCamera<dimensions, T>* AbstractCamera<dimensions, T>::setAspectRatioPolicy(AspectRatioPolicy policy) {
_aspectRatioPolicy = policy; _aspectRatioPolicy = policy;
fixAspectRatio(); fixAspectRatio();

8
src/SceneGraph/AbstractObject.h

@ -25,6 +25,8 @@
#include "DimensionTraits.h" #include "DimensionTraits.h"
#include "SceneGraph.h" #include "SceneGraph.h"
#include "SceneGraph/magnumSceneGraphVisibility.h"
namespace Magnum { namespace SceneGraph { namespace Magnum { namespace SceneGraph {
/** /**
@ -46,7 +48,7 @@ for(AbstractFeature* feature = o->firstFeature(); feature; feature = feature->ne
@see AbstractObject2D, AbstractObject3D @see AbstractObject2D, AbstractObject3D
*/ */
#ifndef DOXYGEN_GENERATING_OUTPUT #ifndef DOXYGEN_GENERATING_OUTPUT
template<std::uint8_t dimensions, class T> class AbstractObject: private Corrade::Containers::LinkedList<AbstractFeature<dimensions, T>> template<std::uint8_t dimensions, class T> class MAGNUM_SCENEGRAPH_EXPORT AbstractObject: private Corrade::Containers::LinkedList<AbstractFeature<dimensions, T>>
#else #else
template<std::uint8_t dimensions, class T = GLfloat> class AbstractObject template<std::uint8_t dimensions, class T = GLfloat> class AbstractObject
#endif #endif
@ -59,8 +61,8 @@ template<std::uint8_t dimensions, class T = GLfloat> class AbstractObject
/** @brief Feature object type */ /** @brief Feature object type */
typedef AbstractFeature<dimensions, T> FeatureType; typedef AbstractFeature<dimensions, T> FeatureType;
explicit AbstractObject() = default; explicit AbstractObject();
inline virtual ~AbstractObject() {} virtual ~AbstractObject();
/** @brief Whether this object has features */ /** @brief Whether this object has features */
inline bool hasFeatures() const { inline bool hasFeatures() const {

8
src/SceneGraph/AbstractTransformation.h

@ -24,6 +24,8 @@
#include "DimensionTraits.h" #include "DimensionTraits.h"
#include "SceneGraph.h" #include "SceneGraph.h"
#include "SceneGraph/magnumSceneGraphVisibility.h"
namespace Magnum { namespace SceneGraph { namespace Magnum { namespace SceneGraph {
/** /**
@ -46,7 +48,7 @@ template<std::uint8_t dimensions, class T>
#else #else
template<std::uint8_t dimensions, class T = GLfloat> template<std::uint8_t dimensions, class T = GLfloat>
#endif #endif
class AbstractTransformation { class MAGNUM_SCENEGRAPH_EXPORT AbstractTransformation {
public: public:
/** @brief Underlying floating-point type */ /** @brief Underlying floating-point type */
typedef T Type; typedef T Type;
@ -54,7 +56,7 @@ class AbstractTransformation {
/** @brief Dimension count */ /** @brief Dimension count */
static const std::uint8_t Dimensions = dimensions; static const std::uint8_t Dimensions = dimensions;
explicit AbstractTransformation() = default; explicit AbstractTransformation();
virtual ~AbstractTransformation() = 0; virtual ~AbstractTransformation() = 0;
#ifdef DOXYGEN_GENERATING_OUTPUT #ifdef DOXYGEN_GENERATING_OUTPUT
@ -137,8 +139,6 @@ enum class TransformationType: std::uint8_t {
Local = 0x01 Local = 0x01
}; };
template<std::uint8_t dimensions, class T> inline AbstractTransformation<dimensions, T>::~AbstractTransformation() {}
#ifndef CORRADE_GCC46_COMPATIBILITY #ifndef CORRADE_GCC46_COMPATIBILITY
/** /**
@brief Base for two-dimensional transformations @brief Base for two-dimensional transformations

2
src/SceneGraph/Animable.h

@ -150,6 +150,8 @@ class MAGNUM_SCENEGRAPH_EXPORT Animable: public AbstractGroupedFeature<dimension
*/ */
explicit Animable(AbstractObject<dimensions, T>* object, AnimableGroup<dimensions, T>* group = nullptr); explicit Animable(AbstractObject<dimensions, T>* object, AnimableGroup<dimensions, T>* group = nullptr);
~Animable();
/** @brief Animation duration */ /** @brief Animation duration */
inline GLfloat duration() const { return _duration; } inline GLfloat duration() const { return _duration; }

2
src/SceneGraph/Animable.hpp

@ -28,6 +28,8 @@ namespace Magnum { namespace SceneGraph {
template<std::uint8_t dimensions, class T> Animable<dimensions, T>::Animable(AbstractObject<dimensions, T>* object, AnimableGroup<dimensions, T>* group): AbstractGroupedFeature<dimensions, Animable<dimensions, T>, T>(object, group), _duration(0.0f), startTime(std::numeric_limits<GLfloat>::infinity()), pauseTime(-std::numeric_limits<GLfloat>::infinity()), previousState(AnimationState::Stopped), currentState(AnimationState::Stopped), _repeated(false), _repeatCount(0), repeats(0) {} template<std::uint8_t dimensions, class T> Animable<dimensions, T>::Animable(AbstractObject<dimensions, T>* object, AnimableGroup<dimensions, T>* group): AbstractGroupedFeature<dimensions, Animable<dimensions, T>, T>(object, group), _duration(0.0f), startTime(std::numeric_limits<GLfloat>::infinity()), pauseTime(-std::numeric_limits<GLfloat>::infinity()), previousState(AnimationState::Stopped), currentState(AnimationState::Stopped), _repeated(false), _repeatCount(0), repeats(0) {}
template<std::uint8_t dimensions, class T> Animable<dimensions, T>::~Animable() {}
template<std::uint8_t dimensions, class T> Animable<dimensions, T>* Animable<dimensions, T>::setState(AnimationState state) { template<std::uint8_t dimensions, class T> Animable<dimensions, T>* Animable<dimensions, T>::setState(AnimationState state) {
if(currentState == state) return this; if(currentState == state) return this;

3
src/SceneGraph/CMakeLists.txt

@ -2,7 +2,8 @@ set(MagnumSceneGraph_SRCS
Animable.cpp Animable.cpp
Camera.cpp Camera.cpp
EuclideanMatrixTransformation2D.cpp EuclideanMatrixTransformation2D.cpp
EuclideanMatrixTransformation3D.cpp) EuclideanMatrixTransformation3D.cpp
Object.cpp)
set(MagnumSceneGraph_HEADERS set(MagnumSceneGraph_HEADERS
AbstractCamera.h AbstractCamera.h
AbstractCamera.hpp AbstractCamera.hpp

8
src/SceneGraph/Camera.cpp

@ -19,10 +19,10 @@
namespace Magnum { namespace SceneGraph { namespace Magnum { namespace SceneGraph {
#ifndef DOXYGEN_GENERATING_OUTPUT #ifndef DOXYGEN_GENERATING_OUTPUT
template class MAGNUM_SCENEGRAPH_EXPORT AbstractCamera<2, GLfloat>; template class AbstractCamera<2, GLfloat>;
template class MAGNUM_SCENEGRAPH_EXPORT AbstractCamera<3, GLfloat>; template class AbstractCamera<3, GLfloat>;
template class MAGNUM_SCENEGRAPH_EXPORT Camera2D<GLfloat>; template class Camera2D<GLfloat>;
template class MAGNUM_SCENEGRAPH_EXPORT Camera3D<GLfloat>; template class Camera3D<GLfloat>;
#endif #endif
}} }}

2
src/SceneGraph/Camera2D.h

@ -60,7 +60,7 @@ class MAGNUM_SCENEGRAPH_EXPORT Camera2D: public AbstractCamera<2, T> {
* Sets orthographic projection to the default OpenGL cube (range @f$ [-1; 1] @f$ in all directions). * Sets orthographic projection to the default OpenGL cube (range @f$ [-1; 1] @f$ in all directions).
* @see setProjection() * @see setProjection()
*/ */
inline explicit Camera2D(AbstractObject<2, T>* object): AbstractCamera<2, T>(object) {} explicit Camera2D(AbstractObject<2, T>* object);
/** /**
* @brief Set projection * @brief Set projection

2
src/SceneGraph/Camera2D.hpp

@ -26,6 +26,8 @@ using namespace std;
namespace Magnum { namespace SceneGraph { namespace Magnum { namespace SceneGraph {
template<class T> Camera2D<T>::Camera2D(AbstractObject<2, T>* object): AbstractCamera<2, T>(object) {}
template<class T> Camera2D<T>* Camera2D<T>::setProjection(const Math::Vector2<T>& size) { template<class T> Camera2D<T>* Camera2D<T>::setProjection(const Math::Vector2<T>& size) {
AbstractCamera<2, T>::rawProjectionMatrix = Math::Matrix3<T>::projection(size); AbstractCamera<2, T>::rawProjectionMatrix = Math::Matrix3<T>::projection(size);

2
src/SceneGraph/Camera3D.h

@ -62,7 +62,7 @@ class MAGNUM_SCENEGRAPH_EXPORT Camera3D: public AbstractCamera<3, T> {
* @brief Constructor * @brief Constructor
* @param object %Object holding this feature * @param object %Object holding this feature
*/ */
inline explicit Camera3D(AbstractObject<3, T>* object): AbstractCamera<3, T>(object), _near(0.0f), _far(0.0f) {} explicit Camera3D(AbstractObject<3, T>* object);
/** /**
* @brief Set orthographic projection * @brief Set orthographic projection

2
src/SceneGraph/Camera3D.hpp

@ -24,6 +24,8 @@
namespace Magnum { namespace SceneGraph { namespace Magnum { namespace SceneGraph {
template<class T> Camera3D<T>::Camera3D(AbstractObject<3, T>* object): AbstractCamera<3, T>(object) {}
template<class T> Camera3D<T>* Camera3D<T>::setOrthographic(const Math::Vector2<T>& size, T near, T far) { template<class T> Camera3D<T>* Camera3D<T>::setOrthographic(const Math::Vector2<T>& size, T near, T far) {
/** @todo Get near/far from the matrix */ /** @todo Get near/far from the matrix */
_near = near; _near = near;

25
src/SceneGraph/Object.cpp

@ -0,0 +1,25 @@
/*
Copyright © 2010, 2011, 2012 Vladimír Vondruš <mosra@centrum.cz>
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 "Object.hpp"
namespace Magnum { namespace SceneGraph {
template class AbstractObject<2>;
template class AbstractObject<3>;
template class AbstractTransformation<2>;
template class AbstractTransformation<3>;
}}

6
src/SceneGraph/Object.h

@ -79,7 +79,7 @@ See @ref compilation-speedup-hpp for more information.
@see Scene, AbstractFeature, AbstractTransformation, DebugTools::ObjectRenderer @see Scene, AbstractFeature, AbstractTransformation, DebugTools::ObjectRenderer
*/ */
template<class Transformation> class Object: public AbstractObject<Transformation::Dimensions, typename Transformation::Type>, public Transformation template<class Transformation> class MAGNUM_SCENEGRAPH_EXPORT Object: public AbstractObject<Transformation::Dimensions, typename Transformation::Type>, public Transformation
#ifndef DOXYGEN_GENERATING_OUTPUT #ifndef DOXYGEN_GENERATING_OUTPUT
, private Corrade::Containers::LinkedList<Object<Transformation>>, private Corrade::Containers::LinkedListItem<Object<Transformation>, Object<Transformation>> , private Corrade::Containers::LinkedList<Object<Transformation>>, private Corrade::Containers::LinkedListItem<Object<Transformation>, Object<Transformation>>
#endif #endif
@ -241,11 +241,11 @@ template<class Transformation> class Object: public AbstractObject<Transformatio
std::vector<typename DimensionTraits<Transformation::Dimensions, typename Transformation::Type>::MatrixType> transformationMatrices(const std::vector<AbstractObject<Transformation::Dimensions, typename Transformation::Type>*>& objects, const typename DimensionTraits<Transformation::Dimensions, typename Transformation::Type>::MatrixType& initialTransformationMatrix = typename DimensionTraits<Transformation::Dimensions, typename Transformation::Type>::MatrixType()) const override; std::vector<typename DimensionTraits<Transformation::Dimensions, typename Transformation::Type>::MatrixType> transformationMatrices(const std::vector<AbstractObject<Transformation::Dimensions, typename Transformation::Type>*>& objects, const typename DimensionTraits<Transformation::Dimensions, typename Transformation::Type>::MatrixType& initialTransformationMatrix = typename DimensionTraits<Transformation::Dimensions, typename Transformation::Type>::MatrixType()) const override;
typename Transformation::DataType computeJointTransformation(const std::vector<Object<Transformation>*>& jointObjects, std::vector<typename Transformation::DataType>& jointTransformations, const std::size_t joint, const typename Transformation::DataType& initialTransformation) const; typename Transformation::DataType MAGNUM_SCENEGRAPH_LOCAL computeJointTransformation(const std::vector<Object<Transformation>*>& jointObjects, std::vector<typename Transformation::DataType>& jointTransformations, const std::size_t joint, const typename Transformation::DataType& initialTransformation) const;
void setClean(const std::vector<AbstractObject<Transformation::Dimensions, typename Transformation::Type>*>& objects) const override; void setClean(const std::vector<AbstractObject<Transformation::Dimensions, typename Transformation::Type>*>& objects) const override;
void setClean(const typename Transformation::DataType& absoluteTransformation); void MAGNUM_SCENEGRAPH_LOCAL setClean(const typename Transformation::DataType& absoluteTransformation);
typedef Implementation::ObjectFlag Flag; typedef Implementation::ObjectFlag Flag;
typedef Implementation::ObjectFlags Flags; typedef Implementation::ObjectFlags Flags;

7
src/SceneGraph/Object.hpp

@ -19,6 +19,7 @@
* @brief @ref compilation-speedup-hpp "Template implementation" for Object.h * @brief @ref compilation-speedup-hpp "Template implementation" for Object.h
*/ */
#include "AbstractTransformation.h"
#include "Object.h" #include "Object.h"
#include <algorithm> #include <algorithm>
@ -28,6 +29,12 @@
namespace Magnum { namespace SceneGraph { namespace Magnum { namespace SceneGraph {
template<std::uint8_t dimensions, class T> AbstractObject<dimensions, T>::AbstractObject() {}
template<std::uint8_t dimensions, class T> AbstractObject<dimensions, T>::~AbstractObject() {}
template<std::uint8_t dimensions, class T> inline AbstractTransformation<dimensions, T>::AbstractTransformation() {}
template<std::uint8_t dimensions, class T> inline AbstractTransformation<dimensions, T>::~AbstractTransformation() {}
template<class Transformation> Scene<Transformation>* Object<Transformation>::scene() { template<class Transformation> Scene<Transformation>* Object<Transformation>::scene() {
return static_cast<Scene<Transformation>*>(sceneObject()); return static_cast<Scene<Transformation>*>(sceneObject());
} }

Loading…
Cancel
Save