diff --git a/src/SceneGraph/AbstractFeature.h b/src/SceneGraph/AbstractFeature.h index 3c27c6caf..a0f0e242c 100644 --- a/src/SceneGraph/AbstractFeature.h +++ b/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 class AbstractFeature: private Corrade::Containers::LinkedListItem, AbstractObject> +template class MAGNUM_SCENEGRAPH_EXPORT AbstractFeature: private Corrade::Containers::LinkedListItem, AbstractObject> #else template class AbstractFeature #endif @@ -140,9 +150,7 @@ template class AbstractFeature * @brief Constructor * @param object %Object holding this feature */ - inline explicit AbstractFeature(AbstractObject* object) { - object->Corrade::Containers::template LinkedList>::insert(this); - } + explicit AbstractFeature(AbstractObject* object); virtual ~AbstractFeature() = 0; @@ -229,7 +237,9 @@ template 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 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 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 class AbstractFeature CachedTransformations _cachedTransformations; }; -template inline AbstractFeature::~AbstractFeature() {} -template inline void AbstractFeature::clean(const typename DimensionTraits::MatrixType&) {} -template inline void AbstractFeature::cleanInverted(const typename DimensionTraits::MatrixType&) {} - #ifndef CORRADE_GCC46_COMPATIBILITY /** @brief Base for two-dimensional features diff --git a/src/SceneGraph/AbstractFeature.hpp b/src/SceneGraph/AbstractFeature.hpp new file mode 100644 index 000000000..19de9f3c3 --- /dev/null +++ b/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š + + 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 AbstractFeature::AbstractFeature(AbstractObject* object) { + object->Corrade::Containers::template LinkedList>::insert(this); +} + +template AbstractFeature::~AbstractFeature() = default; + +template void AbstractFeature::markDirty() {} + +template void AbstractFeature::clean(const typename DimensionTraits::MatrixType&) {} + +template void AbstractFeature::cleanInverted(const typename DimensionTraits::MatrixType&) {} + +}} + +#endif diff --git a/src/SceneGraph/CMakeLists.txt b/src/SceneGraph/CMakeLists.txt index 3279d44c5..42e0e095b 100644 --- a/src/SceneGraph/CMakeLists.txt +++ b/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 diff --git a/src/SceneGraph/Object.cpp b/src/SceneGraph/Object.cpp index 1522bf42b..c3071accf 100644 --- a/src/SceneGraph/Object.cpp +++ b/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>;