Browse Source

SceneGraph: AbstractFeature compilation optimization.

Constructor, destructor and all virtual functions are moved into
implementation file, so they don't need to be recreated and add into
binary on every usage. Should save a bit on resulting file size.
pull/278/head
Vladimír Vondruš 13 years ago
parent
commit
d427b76d7b
  1. 30
      src/SceneGraph/AbstractFeature.h
  2. 49
      src/SceneGraph/AbstractFeature.hpp
  3. 1
      src/SceneGraph/CMakeLists.txt
  4. 3
      src/SceneGraph/Object.cpp

30
src/SceneGraph/AbstractFeature.h

@ -123,10 +123,20 @@ which is derived from
@ref AbstractTranslationRotation3D "AbstractTranslationRotation3D<>",
which is automatically extracted from the pointer in our constructor.
@section AbstractFeature-explicit-specializations Explicit template specializations
The following specialization are explicitly compiled into %SceneGraph library.
For other specializations (e.g. using Double type) you have to use
AbstractFeature.hpp implementation file to avoid linker errors. See also
@ref compilation-speedup-hpp for more information.
- @ref AbstractFeature "AbstractFeature<2, Float>"
- @ref AbstractFeature "AbstractFeature<3, Float>"
@see AbstractFeature2D, AbstractFeature3D
*/
#ifndef DOXYGEN_GENERATING_OUTPUT
template<UnsignedInt dimensions, class T> class AbstractFeature: private Corrade::Containers::LinkedListItem<AbstractFeature<dimensions, T>, AbstractObject<dimensions, T>>
template<UnsignedInt dimensions, class T> class MAGNUM_SCENEGRAPH_EXPORT AbstractFeature: private Corrade::Containers::LinkedListItem<AbstractFeature<dimensions, T>, AbstractObject<dimensions, T>>
#else
template<UnsignedInt dimensions, class T = Float> class AbstractFeature
#endif
@ -140,9 +150,7 @@ template<UnsignedInt dimensions, class T = Float> class AbstractFeature
* @brief Constructor
* @param object %Object holding this feature
*/
inline explicit AbstractFeature(AbstractObject<dimensions, T>* object) {
object->Corrade::Containers::template LinkedList<AbstractFeature<dimensions, T>>::insert(this);
}
explicit AbstractFeature(AbstractObject<dimensions, T>* object);
virtual ~AbstractFeature() = 0;
@ -229,7 +237,9 @@ template<UnsignedInt dimensions, class T = Float> class AbstractFeature
*
* @see @ref scenegraph-caching, clean(), cleanInverted()
*/
inline CachedTransformations cachedTransformations() const { return _cachedTransformations; }
inline CachedTransformations cachedTransformations() const {
return _cachedTransformations;
}
protected:
/**
@ -242,7 +252,9 @@ template<UnsignedInt dimensions, class T = Float> class AbstractFeature
* Nothing is enabled by default.
* @see @ref scenegraph-caching
*/
inline void setCachedTransformations(CachedTransformations transformations) { _cachedTransformations = transformations; }
inline void setCachedTransformations(CachedTransformations transformations) {
_cachedTransformations = transformations;
}
/**
* @brief Mark feature as dirty
@ -254,7 +266,7 @@ template<UnsignedInt dimensions, class T = Float> class AbstractFeature
* Default implementation does nothing.
* @see @ref scenegraph-caching
*/
inline virtual void markDirty() {}
virtual void markDirty();
/**
* @brief Clean data based on absolute transformation
@ -289,10 +301,6 @@ template<UnsignedInt dimensions, class T = Float> class AbstractFeature
CachedTransformations _cachedTransformations;
};
template<UnsignedInt dimensions, class T> inline AbstractFeature<dimensions, T>::~AbstractFeature() {}
template<UnsignedInt dimensions, class T> inline void AbstractFeature<dimensions, T>::clean(const typename DimensionTraits<dimensions, T>::MatrixType&) {}
template<UnsignedInt dimensions, class T> inline void AbstractFeature<dimensions, T>::cleanInverted(const typename DimensionTraits<dimensions, T>::MatrixType&) {}
#ifndef CORRADE_GCC46_COMPATIBILITY
/**
@brief Base for two-dimensional features

49
src/SceneGraph/AbstractFeature.hpp

@ -0,0 +1,49 @@
#ifndef Magnum_SceneGraph_AbstractFeature_hpp
#define Magnum_SceneGraph_AbstractFeature_hpp
/*
This file is part of Magnum.
Copyright © 2010, 2011, 2012, 2013 Vladimír Vondruš <mosra@centrum.cz>
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/
/** @file
* @brief @ref compilation-speedup-hpp "Template implementation" for AbstractFeature.h
*/
#include "AbstractFeature.h"
namespace Magnum { namespace SceneGraph {
template<UnsignedInt dimensions, class T> AbstractFeature<dimensions, T>::AbstractFeature(AbstractObject<dimensions, T>* object) {
object->Corrade::Containers::template LinkedList<AbstractFeature<dimensions, T>>::insert(this);
}
template<UnsignedInt dimensions, class T> AbstractFeature<dimensions, T>::~AbstractFeature() = default;
template<UnsignedInt dimensions, class T> void AbstractFeature<dimensions, T>::markDirty() {}
template<UnsignedInt dimensions, class T> void AbstractFeature<dimensions, T>::clean(const typename DimensionTraits<dimensions, T>::MatrixType&) {}
template<UnsignedInt dimensions, class T> void AbstractFeature<dimensions, T>::cleanInverted(const typename DimensionTraits<dimensions, T>::MatrixType&) {}
}}
#endif

1
src/SceneGraph/CMakeLists.txt

@ -41,6 +41,7 @@ set(MagnumSceneGraph_HEADERS
AbstractCamera.h
AbstractCamera.hpp
AbstractFeature.h
AbstractFeature.hpp
AbstractGroupedFeature.h
AbstractObject.h
AbstractTransformation.h

3
src/SceneGraph/Object.cpp

@ -23,6 +23,7 @@
*/
#include "Object.hpp"
#include "AbstractFeature.hpp"
#include "FeatureGroup.hpp"
namespace Magnum { namespace SceneGraph {
@ -32,6 +33,8 @@ template class AbstractObject<3>;
template class AbstractTransformation<2>;
template class AbstractTransformation<3>;
template class AbstractFeature<2>;
template class AbstractFeature<3>;
template class AbstractFeatureGroup<2>;
template class AbstractFeatureGroup<3>;

Loading…
Cancel
Save