Browse Source

SceneGraph: extracted CachedTransformation[s] enum out of AbstractFeature.

Less typing, less confusion.
pull/278/head
Vladimír Vondruš 13 years ago
parent
commit
980cc48642
  1. 2
      src/SceneGraph/AbstractCamera.hpp
  2. 85
      src/SceneGraph/AbstractFeature.h
  3. 3
      src/SceneGraph/Object.hpp
  4. 2
      src/SceneGraph/SceneGraph.h
  5. 2
      src/Shapes/AbstractShape.cpp

2
src/SceneGraph/AbstractCamera.hpp

@ -71,7 +71,7 @@ template<UnsignedInt dimensions, class T> typename DimensionTraits<dimensions, T
}
template<UnsignedInt 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);
AbstractFeature<dimensions, T>::setCachedTransformations(CachedTransformation::InvertedAbsolute);
}
template<UnsignedInt dimensions, class T> AbstractCamera<dimensions, T>::~AbstractCamera() {}

85
src/SceneGraph/AbstractFeature.h

@ -25,7 +25,7 @@
*/
/** @file
* @brief Class Magnum::SceneGraph::AbstractFeature, alias Magnum::SceneGraph::AbstractFeature2D, Magnum::SceneGraph::AbstractFeature3D
* @brief Class Magnum::SceneGraph::AbstractFeature, alias Magnum::SceneGraph::AbstractFeature2D, Magnum::SceneGraph::AbstractFeature3D, enum Magnum::SceneGraph::CachedTransformation, enum set Magnum::SceneGraph::CachedTransformations
*/
#include <Containers/EnumSet.h>
@ -36,16 +36,41 @@
namespace Magnum { namespace SceneGraph {
namespace Implementation {
enum class FeatureCachedTransformation: UnsignedByte {
Absolute = 1 << 0,
InvertedAbsolute = 1 << 1
};
/**
@brief Which transformation to cache in given feature
@see @ref scenegraph-caching, CachedTransformations,
AbstractFeature::setCachedTransformations(), AbstractFeature::clean(),
AbstractFeature::cleanInverted()
@todo Provide also simpler representations from which could benefit
other transformation implementations, as they won't need to
e.g. create transformation matrix from quaternion?
*/
enum class CachedTransformation: UnsignedByte {
/**
* Absolute transformation is cached.
*
* If enabled, clean() is called when cleaning object.
*/
Absolute = 1 << 0,
/**
* Inverted absolute transformation is cached.
*
* If enabled, cleanInverted() is called when cleaning object.
*/
InvertedAbsolute = 1 << 1
};
typedef Containers::EnumSet<FeatureCachedTransformation, UnsignedByte> FeatureCachedTransformations;
/**
@brief Which transformations to cache in this feature
CORRADE_ENUMSET_OPERATORS(FeatureCachedTransformations)
}
@see @ref scenegraph-caching, AbstractFeature::setCachedTransformations(),
AbstractFeature::clean(), AbstractFeature::cleanInverted()
*/
typedef Containers::EnumSet<CachedTransformation, UnsignedByte> CachedTransformations;
CORRADE_ENUMSET_OPERATORS(CachedTransformations)
/**
@brief Base for object features
@ -190,48 +215,6 @@ template<UnsignedInt dimensions, class T = Float> class AbstractFeature
* See @ref scenegraph-caching for more information.
*/
/**
* @brief Which transformation to cache in this feature
*
* @see @ref scenegraph-caching, CachedTransformations,
* setCachedTransformations(), clean(), cleanInverted()
* @todo Provide also simpler representations from which could benefit
* other transformation implementations, as they won't need to
* e.g. create transformation matrix from quaternion?
* @todo Move outside templated class so it's easier to type
*/
#ifndef DOXYGEN_GENERATING_OUTPUT
typedef Implementation::FeatureCachedTransformation CachedTransformation;
#else
enum class CachedTransformation: UnsignedByte {
/**
* Absolute transformation is cached.
*
* If enabled, clean() is called when cleaning object.
*/
Absolute = 1 << 0,
/**
* Inverted absolute transformation is cached.
*
* If enabled, cleanInverted() is called when cleaning object.
*/
InvertedAbsolute = 1 << 1
};
#endif
/**
* @brief Which transformations to cache in this feature
*
* @see @ref scenegraph-caching, setCachedTransformations(), clean(),
* cleanInverted()
*/
#ifndef DOXYGEN_GENERATING_OUTPUT
typedef Implementation::FeatureCachedTransformations CachedTransformations;
#else
typedef Containers::EnumSet<CachedTransformation, UnsignedByte> CachedTransformations;
#endif
/**
* @brief Which transformations are cached
*

3
src/SceneGraph/Object.hpp

@ -373,8 +373,7 @@ template<class Transformation> void Object<Transformation>::setClean(std::vector
template<class Transformation> void Object<Transformation>::setClean(const typename Transformation::DataType& absoluteTransformation) {
/* "Lazy storage" for transformation matrix and inverted transformation matrix */
typedef typename AbstractFeature<Transformation::Dimensions, typename Transformation::Type>::CachedTransformation CachedTransformation;
typename AbstractFeature<Transformation::Dimensions, typename Transformation::Type>::CachedTransformations cached;
CachedTransformations cached;
MatrixType matrix, invertedMatrix;
/* Clean all features */

2
src/SceneGraph/SceneGraph.h

@ -44,6 +44,8 @@ template<class T = Float> using AbstractCamera2D = AbstractCamera<2, T>;
template<class T = Float> using AbstractCamera3D = AbstractCamera<3, T>;
#endif
/* Enum CachedTransformation and CachedTransformations used only directly */
template<UnsignedInt dimensions, class T = Float> class AbstractFeature;
#ifndef CORRADE_GCC46_COMPATIBILITY
template<class T = Float> using AbstractFeature2D = AbstractFeature<2, T>;

2
src/Shapes/AbstractShape.cpp

@ -32,7 +32,7 @@
namespace Magnum { namespace Shapes {
template<UnsignedInt dimensions> AbstractShape<dimensions>::AbstractShape(SceneGraph::AbstractObject<dimensions>* object, ShapeGroup<dimensions>* group): SceneGraph::AbstractGroupedFeature<dimensions, AbstractShape<dimensions>>(object, group) {
this->setCachedTransformations(SceneGraph::AbstractFeature<dimensions>::CachedTransformation::Absolute);
this->setCachedTransformations(SceneGraph::CachedTransformation::Absolute);
}
template<UnsignedInt dimensions> ShapeGroup<dimensions>* AbstractShape<dimensions>::group() {

Loading…
Cancel
Save