Browse Source

Better usage of *Basic* in class names, part 1: SceneGraph object.

Use AbstractObject<dimensions, T> like before and add two kinds of
aliases instead of only one:
AbstractBasicObject2D<T>/AbstractBasicObject3D<T> for abstract type and
AbstractObject2D/AbstractObject2D for Float.

Makes it easier to use AbstractObject in templates of fixed dimensions
(e.g. Bullet integration, where it can now be written as
`AbstractBasicObject2D<btScalar>` instead of potentially confusing
`AbstractBasicObject<2, btScalar>`).

Partially reverts commit cfd405c32c.
pull/278/head
Vladimír Vondruš 13 years ago
parent
commit
7636c6adc3
  1. 2
      src/DebugTools/ForceRenderer.cpp
  2. 2
      src/DebugTools/ForceRenderer.h
  3. 2
      src/DebugTools/ObjectRenderer.cpp
  4. 2
      src/DebugTools/ObjectRenderer.h
  5. 2
      src/SceneGraph/AbstractCamera.h
  6. 6
      src/SceneGraph/AbstractCamera.hpp
  7. 24
      src/SceneGraph/AbstractFeature.h
  8. 2
      src/SceneGraph/AbstractFeature.hpp
  9. 2
      src/SceneGraph/AbstractGroupedFeature.h
  10. 65
      src/SceneGraph/AbstractObject.h
  11. 2
      src/SceneGraph/Animable.h
  12. 2
      src/SceneGraph/Animable.hpp
  13. 2
      src/SceneGraph/Camera2D.h
  14. 2
      src/SceneGraph/Camera2D.hpp
  15. 2
      src/SceneGraph/Camera3D.h
  16. 2
      src/SceneGraph/Camera3D.hpp
  17. 2
      src/SceneGraph/Drawable.h
  18. 14
      src/SceneGraph/Object.h
  19. 8
      src/SceneGraph/Object.hpp
  20. 13
      src/SceneGraph/SceneGraph.h
  21. 4
      src/SceneGraph/instantiation.cpp
  22. 2
      src/Shapes/AbstractShape.cpp
  23. 2
      src/Shapes/AbstractShape.h
  24. 6
      src/Shapes/Shape.h
  25. 4
      src/Shapes/ShapeGroup.cpp

2
src/DebugTools/ForceRenderer.cpp

@ -64,7 +64,7 @@ const std::array<UnsignedByte, 6> indices{{
} }
template<UnsignedInt dimensions> ForceRenderer<dimensions>::ForceRenderer(SceneGraph::AbstractBasicObject<dimensions, Float>* object, const typename DimensionTraits<dimensions, Float>::VectorType& forcePosition, const typename DimensionTraits<dimensions, Float>::VectorType* force, ResourceKey options, SceneGraph::BasicDrawableGroup<dimensions, Float>* drawables): SceneGraph::BasicDrawable<dimensions, Float>(object, drawables), forcePosition(forcePosition), force(force), options(ResourceManager::instance()->get<ForceRendererOptions>(options)) { template<UnsignedInt dimensions> ForceRenderer<dimensions>::ForceRenderer(SceneGraph::AbstractObject<dimensions, Float>* object, const typename DimensionTraits<dimensions, Float>::VectorType& forcePosition, const typename DimensionTraits<dimensions, Float>::VectorType* force, ResourceKey options, SceneGraph::BasicDrawableGroup<dimensions, Float>* drawables): SceneGraph::BasicDrawable<dimensions, Float>(object, drawables), forcePosition(forcePosition), force(force), options(ResourceManager::instance()->get<ForceRendererOptions>(options)) {
/* Shader */ /* Shader */
shader = ResourceManager::instance()->get<AbstractShaderProgram, Shaders::Flat<dimensions>>(shaderKey<dimensions>()); shader = ResourceManager::instance()->get<AbstractShaderProgram, Shaders::Flat<dimensions>>(shaderKey<dimensions>());
if(!shader) ResourceManager::instance()->set<AbstractShaderProgram>(shader.key(), new Shaders::Flat<dimensions>); if(!shader) ResourceManager::instance()->set<AbstractShaderProgram>(shader.key(), new Shaders::Flat<dimensions>);

2
src/DebugTools/ForceRenderer.h

@ -117,7 +117,7 @@ template<UnsignedInt dimensions> class MAGNUM_DEBUGTOOLS_EXPORT ForceRenderer: p
* saved as reference to original vector and thus it must be available * saved as reference to original vector and thus it must be available
* for the whole lifetime of the renderer. * for the whole lifetime of the renderer.
*/ */
explicit ForceRenderer(SceneGraph::AbstractBasicObject<dimensions, Float>* object, const typename DimensionTraits<dimensions, Float>::VectorType& forcePosition, const typename DimensionTraits<dimensions, Float>::VectorType* force, ResourceKey options = ResourceKey(), SceneGraph::BasicDrawableGroup<dimensions, Float>* drawables = nullptr); explicit ForceRenderer(SceneGraph::AbstractObject<dimensions, Float>* object, const typename DimensionTraits<dimensions, Float>::VectorType& forcePosition, const typename DimensionTraits<dimensions, Float>::VectorType* force, ResourceKey options = ResourceKey(), SceneGraph::BasicDrawableGroup<dimensions, Float>* drawables = nullptr);
protected: protected:
void draw(const typename DimensionTraits<dimensions, Float>::MatrixType& transformationMatrix, SceneGraph::AbstractBasicCamera<dimensions, Float>* camera) override; void draw(const typename DimensionTraits<dimensions, Float>::MatrixType& transformationMatrix, SceneGraph::AbstractBasicCamera<dimensions, Float>* camera) override;

2
src/DebugTools/ObjectRenderer.cpp

@ -142,7 +142,7 @@ const std::array<UnsignedByte, 18> Renderer<3>::indices{{
} }
template<UnsignedInt dimensions> ObjectRenderer<dimensions>::ObjectRenderer(SceneGraph::AbstractBasicObject<dimensions, Float>* object, ResourceKey options, SceneGraph::BasicDrawableGroup<dimensions, Float>* drawables): SceneGraph::BasicDrawable<dimensions, Float>(object, drawables), options(ResourceManager::instance()->get<ObjectRendererOptions>(options)) { template<UnsignedInt dimensions> ObjectRenderer<dimensions>::ObjectRenderer(SceneGraph::AbstractObject<dimensions, Float>* object, ResourceKey options, SceneGraph::BasicDrawableGroup<dimensions, Float>* drawables): SceneGraph::BasicDrawable<dimensions, Float>(object, drawables), options(ResourceManager::instance()->get<ObjectRendererOptions>(options)) {
/* Shader */ /* Shader */
shader = ResourceManager::instance()->get<AbstractShaderProgram, Shaders::VertexColor<dimensions>>(Renderer<dimensions>::shader()); shader = ResourceManager::instance()->get<AbstractShaderProgram, Shaders::VertexColor<dimensions>>(Renderer<dimensions>::shader());
if(!shader) ResourceManager::instance()->set<AbstractShaderProgram>(shader.key(), new Shaders::VertexColor<dimensions>); if(!shader) ResourceManager::instance()->set<AbstractShaderProgram>(shader.key(), new Shaders::VertexColor<dimensions>);

2
src/DebugTools/ObjectRenderer.h

@ -96,7 +96,7 @@ template<UnsignedInt dimensions> class MAGNUM_DEBUGTOOLS_EXPORT ObjectRenderer:
* *
* The renderer is automatically added to object's features. * The renderer is automatically added to object's features.
*/ */
explicit ObjectRenderer(SceneGraph::AbstractBasicObject<dimensions, Float>* object, ResourceKey options = ResourceKey(), SceneGraph::BasicDrawableGroup<dimensions, Float>* drawables = nullptr); explicit ObjectRenderer(SceneGraph::AbstractObject<dimensions, Float>* object, ResourceKey options = ResourceKey(), SceneGraph::BasicDrawableGroup<dimensions, Float>* drawables = nullptr);
protected: protected:
void draw(const typename DimensionTraits<dimensions, Float>::MatrixType& transformationMatrix, SceneGraph::AbstractBasicCamera<dimensions, Float>* camera) override; void draw(const typename DimensionTraits<dimensions, Float>::MatrixType& transformationMatrix, SceneGraph::AbstractBasicCamera<dimensions, Float>* camera) override;

2
src/SceneGraph/AbstractCamera.h

@ -78,7 +78,7 @@ template<UnsignedInt dimensions, class T> class MAGNUM_SCENEGRAPH_EXPORT Abstrac
* @brief Constructor * @brief Constructor
* @param object Object holding the camera * @param object Object holding the camera
*/ */
explicit AbstractBasicCamera(AbstractBasicObject<dimensions, T>* object); explicit AbstractBasicCamera(AbstractObject<dimensions, T>* object);
virtual ~AbstractBasicCamera() = 0; virtual ~AbstractBasicCamera() = 0;

6
src/SceneGraph/AbstractCamera.hpp

@ -70,7 +70,7 @@ template<UnsignedInt dimensions, class T> typename DimensionTraits<dimensions, T
} }
template<UnsignedInt dimensions, class T> AbstractBasicCamera<dimensions, T>::AbstractBasicCamera(AbstractBasicObject<dimensions, T>* object): AbstractBasicFeature<dimensions, T>(object), _aspectRatioPolicy(AspectRatioPolicy::NotPreserved) { template<UnsignedInt dimensions, class T> AbstractBasicCamera<dimensions, T>::AbstractBasicCamera(AbstractObject<dimensions, T>* object): AbstractBasicFeature<dimensions, T>(object), _aspectRatioPolicy(AspectRatioPolicy::NotPreserved) {
AbstractBasicFeature<dimensions, T>::setCachedTransformations(CachedTransformation::InvertedAbsolute); AbstractBasicFeature<dimensions, T>::setCachedTransformations(CachedTransformation::InvertedAbsolute);
} }
@ -88,14 +88,14 @@ template<UnsignedInt dimensions, class T> void AbstractBasicCamera<dimensions, T
} }
template<UnsignedInt dimensions, class T> void AbstractBasicCamera<dimensions, T>::draw(BasicDrawableGroup<dimensions, T>& group) { template<UnsignedInt dimensions, class T> void AbstractBasicCamera<dimensions, T>::draw(BasicDrawableGroup<dimensions, T>& group) {
AbstractBasicObject<dimensions, T>* scene = AbstractBasicFeature<dimensions, T>::object()->scene(); AbstractObject<dimensions, T>* scene = AbstractBasicFeature<dimensions, T>::object()->scene();
CORRADE_ASSERT(scene, "Camera::draw(): cannot draw when camera is not part of any scene", ); CORRADE_ASSERT(scene, "Camera::draw(): cannot draw when camera is not part of any scene", );
/* Compute camera matrix */ /* Compute camera matrix */
AbstractBasicFeature<dimensions, T>::object()->setClean(); AbstractBasicFeature<dimensions, T>::object()->setClean();
/* Compute transformations of all objects in the group relative to the camera */ /* Compute transformations of all objects in the group relative to the camera */
std::vector<AbstractBasicObject<dimensions, T>*> objects(group.size()); std::vector<AbstractObject<dimensions, T>*> objects(group.size());
for(std::size_t i = 0; i != group.size(); ++i) for(std::size_t i = 0; i != group.size(); ++i)
objects[i] = group[i]->object(); objects[i] = group[i]->object();
std::vector<typename DimensionTraits<dimensions, T>::MatrixType> transformations = std::vector<typename DimensionTraits<dimensions, T>::MatrixType> transformations =

24
src/SceneGraph/AbstractFeature.h

@ -141,7 +141,7 @@ class TransformingFeature: public SceneGraph::AbstractFeature3D {
}; };
@endcode @endcode
If we take for example @ref Object "Object<MatrixTransformation3D>", it is If we take for example @ref Object "Object<MatrixTransformation3D>", it is
derived from @ref AbstractBasicObject "AbstractObject3D" and derived from @ref AbstractObject "AbstractObject3D" and
@ref BasicMatrixTransformation3D "MatrixTransformation3D", which is derived @ref BasicMatrixTransformation3D "MatrixTransformation3D", which is derived
from @ref AbstractBasicTranslationRotationScaling3D "AbstractTranslationRotationScaling3D", from @ref AbstractBasicTranslationRotationScaling3D "AbstractTranslationRotationScaling3D",
which is derived from @ref AbstractBasicTranslationRotation3D "AbstractTranslationRotation3D", which is derived from @ref AbstractBasicTranslationRotation3D "AbstractTranslationRotation3D",
@ -161,11 +161,11 @@ AbstractFeature.hpp implementation file to avoid linker errors. See also
*/ */
template<UnsignedInt dimensions, class T> class MAGNUM_SCENEGRAPH_EXPORT AbstractBasicFeature template<UnsignedInt dimensions, class T> class MAGNUM_SCENEGRAPH_EXPORT AbstractBasicFeature
#ifndef DOXYGEN_GENERATING_OUTPUT #ifndef DOXYGEN_GENERATING_OUTPUT
: private Containers::LinkedListItem<AbstractBasicFeature<dimensions, T>, AbstractBasicObject<dimensions, T>> : private Containers::LinkedListItem<AbstractBasicFeature<dimensions, T>, AbstractObject<dimensions, T>>
#endif #endif
{ {
friend class Containers::LinkedList<AbstractBasicFeature<dimensions, T>>; friend class Containers::LinkedList<AbstractBasicFeature<dimensions, T>>;
friend class Containers::LinkedListItem<AbstractBasicFeature<dimensions, T>, AbstractBasicObject<dimensions, T>>; friend class Containers::LinkedListItem<AbstractBasicFeature<dimensions, T>, AbstractObject<dimensions, T>>;
template<class Transformation> friend class Object; template<class Transformation> friend class Object;
public: public:
@ -173,38 +173,38 @@ template<UnsignedInt dimensions, class T> class MAGNUM_SCENEGRAPH_EXPORT Abstrac
* @brief Constructor * @brief Constructor
* @param object %Object holding this feature * @param object %Object holding this feature
*/ */
explicit AbstractBasicFeature(AbstractBasicObject<dimensions, T>* object); explicit AbstractBasicFeature(AbstractObject<dimensions, T>* object);
virtual ~AbstractBasicFeature() = 0; virtual ~AbstractBasicFeature() = 0;
/** @brief %Object holding this feature */ /** @brief %Object holding this feature */
AbstractBasicObject<dimensions, T>* object() { AbstractObject<dimensions, T>* object() {
return Containers::LinkedListItem<AbstractBasicFeature<dimensions, T>, AbstractBasicObject<dimensions, T>>::list(); return Containers::LinkedListItem<AbstractBasicFeature<dimensions, T>, AbstractObject<dimensions, T>>::list();
} }
/** @overload */ /** @overload */
const AbstractBasicObject<dimensions, T>* object() const { const AbstractObject<dimensions, T>* object() const {
return Containers::LinkedListItem<AbstractBasicFeature<dimensions, T>, AbstractBasicObject<dimensions, T>>::list(); return Containers::LinkedListItem<AbstractBasicFeature<dimensions, T>, AbstractObject<dimensions, T>>::list();
} }
/** @brief Previous feature or `nullptr`, if this is first feature */ /** @brief Previous feature or `nullptr`, if this is first feature */
AbstractBasicFeature<dimensions, T>* previousFeature() { AbstractBasicFeature<dimensions, T>* previousFeature() {
return Containers::LinkedListItem<AbstractBasicFeature<dimensions, T>, AbstractBasicObject<dimensions, T>>::previous(); return Containers::LinkedListItem<AbstractBasicFeature<dimensions, T>, AbstractObject<dimensions, T>>::previous();
} }
/** @overload */ /** @overload */
const AbstractBasicFeature<dimensions, T>* previousFeature() const { const AbstractBasicFeature<dimensions, T>* previousFeature() const {
return Containers::LinkedListItem<AbstractBasicFeature<dimensions, T>, AbstractBasicObject<dimensions, T>>::previous(); return Containers::LinkedListItem<AbstractBasicFeature<dimensions, T>, AbstractObject<dimensions, T>>::previous();
} }
/** @brief Next feature or `nullptr`, if this is last feature */ /** @brief Next feature or `nullptr`, if this is last feature */
AbstractBasicFeature<dimensions, T>* nextFeature() { AbstractBasicFeature<dimensions, T>* nextFeature() {
return Containers::LinkedListItem<AbstractBasicFeature<dimensions, T>, AbstractBasicObject<dimensions, T>>::next(); return Containers::LinkedListItem<AbstractBasicFeature<dimensions, T>, AbstractObject<dimensions, T>>::next();
} }
/** @overload */ /** @overload */
const AbstractBasicFeature<dimensions, T>* nextFeature() const { const AbstractBasicFeature<dimensions, T>* nextFeature() const {
return Containers::LinkedListItem<AbstractBasicFeature<dimensions, T>, AbstractBasicObject<dimensions, T>>::next(); return Containers::LinkedListItem<AbstractBasicFeature<dimensions, T>, AbstractObject<dimensions, T>>::next();
} }
/** /**

2
src/SceneGraph/AbstractFeature.hpp

@ -32,7 +32,7 @@
namespace Magnum { namespace SceneGraph { namespace Magnum { namespace SceneGraph {
template<UnsignedInt dimensions, class T> AbstractBasicFeature<dimensions, T>::AbstractBasicFeature(AbstractBasicObject<dimensions, T>* object) { template<UnsignedInt dimensions, class T> AbstractBasicFeature<dimensions, T>::AbstractBasicFeature(AbstractObject<dimensions, T>* object) {
object->Containers::template LinkedList<AbstractBasicFeature<dimensions, T>>::insert(this); object->Containers::template LinkedList<AbstractBasicFeature<dimensions, T>>::insert(this);
} }

2
src/SceneGraph/AbstractGroupedFeature.h

@ -78,7 +78,7 @@ template<UnsignedInt dimensions, class Derived, class T> class AbstractBasicGrou
* Adds the feature to the object and to group, if specified. * Adds the feature to the object and to group, if specified.
* @see FeatureGroup::add() * @see FeatureGroup::add()
*/ */
explicit AbstractBasicGroupedFeature(AbstractBasicObject<dimensions, T>* object, BasicFeatureGroup<dimensions, Derived, T>* group = nullptr): AbstractBasicFeature<dimensions, T>(object), _group(nullptr) { explicit AbstractBasicGroupedFeature(AbstractObject<dimensions, T>* object, BasicFeatureGroup<dimensions, Derived, T>* group = nullptr): AbstractBasicFeature<dimensions, T>(object), _group(nullptr) {
if(group) group->add(static_cast<Derived*>(this)); if(group) group->add(static_cast<Derived*>(this));
} }

65
src/SceneGraph/AbstractObject.h

@ -25,7 +25,7 @@
*/ */
/** @file /** @file
* @brief Class Magnum::SceneGraph::AbstractBasicObject, alias Magnum::SceneGraph::AbstractObject2D, Magnum::SceneGraph::AbstractObject3D * @brief Class Magnum::SceneGraph::AbstractObject, alias Magnum::SceneGraph::AbstractBasicObject2D, Magnum::SceneGraph::AbstractBasicObject3D, typedef Magnum::SceneGraph::AbstractObject2D, Magnum::SceneGraph::AbstractObject3D
*/ */
#include <vector> #include <vector>
@ -54,15 +54,16 @@ for(AbstractFeature* feature = o->firstFeature(); feature; feature = feature->ne
} }
@endcode @endcode
@see @ref AbstractObject2D, @ref AbstractObject3D @see @ref AbstractBasicObject2D, @ref AbstractBasicObject3D,
@ref AbstractObject2D, @ref AbstractObject3D
*/ */
template<UnsignedInt dimensions, class T> class MAGNUM_SCENEGRAPH_EXPORT AbstractBasicObject template<UnsignedInt dimensions, class T> class MAGNUM_SCENEGRAPH_EXPORT AbstractObject
#ifndef DOXYGEN_GENERATING_OUTPUT #ifndef DOXYGEN_GENERATING_OUTPUT
: private Containers::LinkedList<AbstractBasicFeature<dimensions, T>> : private Containers::LinkedList<AbstractBasicFeature<dimensions, T>>
#endif #endif
{ {
friend class Containers::LinkedList<AbstractBasicFeature<dimensions, T>>; friend class Containers::LinkedList<AbstractBasicFeature<dimensions, T>>;
friend class Containers::LinkedListItem<AbstractBasicFeature<dimensions, T>, AbstractBasicObject<dimensions, T>>; friend class Containers::LinkedListItem<AbstractBasicFeature<dimensions, T>, AbstractObject<dimensions, T>>;
friend class AbstractBasicFeature<dimensions, T>; friend class AbstractBasicFeature<dimensions, T>;
public: public:
@ -72,8 +73,8 @@ template<UnsignedInt dimensions, class T> class MAGNUM_SCENEGRAPH_EXPORT Abstrac
/** @brief Feature object type */ /** @brief Feature object type */
typedef AbstractBasicFeature<dimensions, T> FeatureType; typedef AbstractBasicFeature<dimensions, T> FeatureType;
explicit AbstractBasicObject(); explicit AbstractObject();
virtual ~AbstractBasicObject(); virtual ~AbstractObject();
/** @brief Whether this object has features */ /** @brief Whether this object has features */
bool hasFeatures() const { bool hasFeatures() const {
@ -104,10 +105,10 @@ template<UnsignedInt dimensions, class T> class MAGNUM_SCENEGRAPH_EXPORT Abstrac
* @brief %Scene * @brief %Scene
* @return %Scene or `nullptr`, if the object is not part of any scene. * @return %Scene or `nullptr`, if the object is not part of any scene.
*/ */
AbstractBasicObject<dimensions, T>* scene() { return doScene(); } AbstractObject<dimensions, T>* scene() { return doScene(); }
/** @overload */ /** @overload */
const AbstractBasicObject<dimensions, T>* scene() const { return doScene(); } const AbstractObject<dimensions, T>* scene() const { return doScene(); }
/** @{ @name Object transformation */ /** @{ @name Object transformation */
@ -138,7 +139,7 @@ template<UnsignedInt dimensions, class T> class MAGNUM_SCENEGRAPH_EXPORT Abstrac
* Object type, use typesafe Object::transformationMatrices() when * Object type, use typesafe Object::transformationMatrices() when
* possible. * possible.
*/ */
std::vector<MatrixType> transformationMatrices(const std::vector<AbstractBasicObject<dimensions, T>*>& objects, const MatrixType& initialTransformationMatrix = MatrixType()) const { std::vector<MatrixType> transformationMatrices(const std::vector<AbstractObject<dimensions, T>*>& objects, const MatrixType& initialTransformationMatrix = MatrixType()) const {
return doTransformationMatrices(objects, initialTransformationMatrix); return doTransformationMatrices(objects, initialTransformationMatrix);
} }
@ -157,7 +158,7 @@ template<UnsignedInt dimensions, class T> class MAGNUM_SCENEGRAPH_EXPORT Abstrac
* @warning This function cannot check if all objects are of the same * @warning This function cannot check if all objects are of the same
* Object type, use typesafe Object::setClean() when possible. * Object type, use typesafe Object::setClean() when possible.
*/ */
static void setClean(const std::vector<AbstractBasicObject<dimensions, T>*>& objects) { static void setClean(const std::vector<AbstractObject<dimensions, T>*>& objects) {
if(objects.empty()) return; if(objects.empty()) return;
objects.front()->doSetClean(objects); objects.front()->doSetClean(objects);
} }
@ -203,32 +204,64 @@ template<UnsignedInt dimensions, class T> class MAGNUM_SCENEGRAPH_EXPORT Abstrac
/*@}*/ /*@}*/
private: private:
virtual AbstractBasicObject<dimensions, T>* doScene() = 0; virtual AbstractObject<dimensions, T>* doScene() = 0;
virtual const AbstractBasicObject<dimensions, T>* doScene() const = 0; virtual const AbstractObject<dimensions, T>* doScene() const = 0;
virtual MatrixType doTransformationMatrix() const = 0; virtual MatrixType doTransformationMatrix() const = 0;
virtual MatrixType doAbsoluteTransformationMatrix() const = 0; virtual MatrixType doAbsoluteTransformationMatrix() const = 0;
virtual std::vector<MatrixType> doTransformationMatrices(const std::vector<AbstractBasicObject<dimensions, T>*>& objects, const MatrixType& initialTransformationMatrix) const = 0; virtual std::vector<MatrixType> doTransformationMatrices(const std::vector<AbstractObject<dimensions, T>*>& objects, const MatrixType& initialTransformationMatrix) const = 0;
virtual bool doIsDirty() const = 0; virtual bool doIsDirty() const = 0;
virtual void doSetDirty() = 0; virtual void doSetDirty() = 0;
virtual void doSetClean() = 0; virtual void doSetClean() = 0;
virtual void doSetClean(const std::vector<AbstractBasicObject<dimensions, T>*>& objects) = 0; virtual void doSetClean(const std::vector<AbstractObject<dimensions, T>*>& objects) = 0;
}; };
#ifndef CORRADE_GCC46_COMPATIBILITY
/**
@brief Base object for two-dimensional scenes
Convenience alternative to <tt>%AbstractObject<2, T></tt>. See AbstractObject
for more information.
@note Not available on GCC < 4.7. Use <tt>%AbstractObject<2, T></tt> instead.
@see @ref AbstractObject2D, @ref AbstractBasicObject3D
*/
template<class T> using AbstractBasicObject2D = AbstractObject<2, T>;
#endif
/** /**
@brief Base object for two-dimensional float scenes @brief Base object for two-dimensional float scenes
@see @ref AbstractObject3D @see @ref AbstractObject3D
*/ */
typedef AbstractBasicObject<2, Float> AbstractObject2D; #ifndef CORRADE_GCC46_COMPATIBILITY
typedef AbstractBasicObject2D<Float> AbstractObject2D;
#else
typedef AbstractObject<2, Float> AbstractObject2D;
#endif
#ifndef CORRADE_GCC46_COMPATIBILITY
/**
@brief Base object for three-dimensional scenes
Convenience alternative to <tt>%AbstractObject<3, T></tt>. See AbstractObject
for more information.
@note Not available on GCC < 4.7. Use <tt>%AbstractObject<3, T></tt> instead.
@see AbstractObject2D
*/
template<class T> using AbstractBasicObject3D = AbstractObject<3, T>;
#endif
/** /**
@brief Base object for three-dimensional float scenes @brief Base object for three-dimensional float scenes
@see @ref AbstractObject2D @see @ref AbstractObject2D
*/ */
typedef AbstractBasicObject<3, Float> AbstractObject3D; #ifndef CORRADE_GCC46_COMPATIBILITY
typedef AbstractBasicObject3D<Float> AbstractObject3D;
#else
typedef AbstractObject<3, Float> AbstractObject3D;
#endif
}} }}

2
src/SceneGraph/Animable.h

@ -154,7 +154,7 @@ template<UnsignedInt dimensions, class T> class MAGNUM_SCENEGRAPH_EXPORT BasicAn
* adds the feature to the object and also to group, if specified. * adds the feature to the object and also to group, if specified.
* @see setDuration(), setState(), setRepeated(), BasicAnimableGroup::add() * @see setDuration(), setState(), setRepeated(), BasicAnimableGroup::add()
*/ */
explicit BasicAnimable(AbstractBasicObject<dimensions, T>* object, BasicAnimableGroup<dimensions, T>* group = nullptr); explicit BasicAnimable(AbstractObject<dimensions, T>* object, BasicAnimableGroup<dimensions, T>* group = nullptr);
~BasicAnimable(); ~BasicAnimable();

2
src/SceneGraph/Animable.hpp

@ -35,7 +35,7 @@
namespace Magnum { namespace SceneGraph { namespace Magnum { namespace SceneGraph {
template<UnsignedInt dimensions, class T> BasicAnimable<dimensions, T>::BasicAnimable(AbstractBasicObject<dimensions, T>* object, BasicAnimableGroup<dimensions, T>* group): AbstractBasicGroupedFeature<dimensions, BasicAnimable<dimensions, T>, T>(object, group), _duration(0.0f), startTime(std::numeric_limits<Float>::infinity()), pauseTime(-std::numeric_limits<Float>::infinity()), previousState(AnimationState::Stopped), currentState(AnimationState::Stopped), _repeated(false), _repeatCount(0), repeats(0) {} template<UnsignedInt dimensions, class T> BasicAnimable<dimensions, T>::BasicAnimable(AbstractObject<dimensions, T>* object, BasicAnimableGroup<dimensions, T>* group): AbstractBasicGroupedFeature<dimensions, BasicAnimable<dimensions, T>, T>(object, group), _duration(0.0f), startTime(std::numeric_limits<Float>::infinity()), pauseTime(-std::numeric_limits<Float>::infinity()), previousState(AnimationState::Stopped), currentState(AnimationState::Stopped), _repeated(false), _repeatCount(0), repeats(0) {}
template<UnsignedInt dimensions, class T> BasicAnimable<dimensions, T>::~BasicAnimable() {} template<UnsignedInt dimensions, class T> BasicAnimable<dimensions, T>::~BasicAnimable() {}

2
src/SceneGraph/Camera2D.h

@ -64,7 +64,7 @@ template<class T> class MAGNUM_SCENEGRAPH_EXPORT BasicCamera2D: public AbstractB
* 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()
*/ */
explicit BasicCamera2D(AbstractBasicObject<2, T>* object); explicit BasicCamera2D(AbstractObject<2, T>* object);
/** /**
* @brief Set projection * @brief Set projection

2
src/SceneGraph/Camera2D.hpp

@ -35,7 +35,7 @@ using namespace std;
namespace Magnum { namespace SceneGraph { namespace Magnum { namespace SceneGraph {
template<class T> BasicCamera2D<T>::BasicCamera2D(AbstractBasicObject<2, T>* object): AbstractBasicCamera<2, T>(object) {} template<class T> BasicCamera2D<T>::BasicCamera2D(AbstractObject<2, T>* object): AbstractBasicCamera<2, T>(object) {}
template<class T> BasicCamera2D<T>* BasicCamera2D<T>::setProjection(const Math::Vector2<T>& size) { template<class T> BasicCamera2D<T>* BasicCamera2D<T>::setProjection(const Math::Vector2<T>& size) {
AbstractBasicCamera<2, T>::rawProjectionMatrix = Math::Matrix3<T>::projection(size); AbstractBasicCamera<2, T>::rawProjectionMatrix = Math::Matrix3<T>::projection(size);

2
src/SceneGraph/Camera3D.h

@ -66,7 +66,7 @@ template<class T> class MAGNUM_SCENEGRAPH_EXPORT BasicCamera3D: public AbstractB
* @brief Constructor * @brief Constructor
* @param object %Object holding this feature * @param object %Object holding this feature
*/ */
explicit BasicCamera3D(AbstractBasicObject<3, T>* object); explicit BasicCamera3D(AbstractObject<3, T>* object);
/** /**
* @brief Set orthographic projection * @brief Set orthographic projection

2
src/SceneGraph/Camera3D.hpp

@ -33,7 +33,7 @@
namespace Magnum { namespace SceneGraph { namespace Magnum { namespace SceneGraph {
template<class T> BasicCamera3D<T>::BasicCamera3D(AbstractBasicObject<3, T>* object): AbstractBasicCamera<3, T>(object), _near(T(0)), _far(T(0)) {} template<class T> BasicCamera3D<T>::BasicCamera3D(AbstractObject<3, T>* object): AbstractBasicCamera<3, T>(object), _near(T(0)), _far(T(0)) {}
template<class T> BasicCamera3D<T>* BasicCamera3D<T>::setOrthographic(const Math::Vector2<T>& size, T near, T far) { template<class T> BasicCamera3D<T>* BasicCamera3D<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 */

2
src/SceneGraph/Drawable.h

@ -126,7 +126,7 @@ template<UnsignedInt dimensions, class T> class BasicDrawable: public AbstractBa
* Adds the feature to the object and also to the group, if specified. * Adds the feature to the object and also to the group, if specified.
* Otherwise you can use BasicDrawableGroup::add(). * Otherwise you can use BasicDrawableGroup::add().
*/ */
explicit BasicDrawable(AbstractBasicObject<dimensions, T>* object, BasicDrawableGroup<dimensions, T>* drawables = nullptr): AbstractBasicGroupedFeature<dimensions, BasicDrawable<dimensions, T>, T>(object, drawables) {} explicit BasicDrawable(AbstractObject<dimensions, T>* object, BasicDrawableGroup<dimensions, T>* drawables = nullptr): AbstractBasicGroupedFeature<dimensions, BasicDrawable<dimensions, T>, T>(object, drawables) {}
/** /**
* @brief Draw the object using given camera * @brief Draw the object using given camera

14
src/SceneGraph/Object.h

@ -88,7 +88,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 MAGNUM_SCENEGRAPH_EXPORT Object: public AbstractBasicObject<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 Containers::LinkedList<Object<Transformation>>, private Containers::LinkedListItem<Object<Transformation>, Object<Transformation>> , private Containers::LinkedList<Object<Transformation>>, private Containers::LinkedListItem<Object<Transformation>, Object<Transformation>>
#endif #endif
@ -129,7 +129,7 @@ template<class Transformation> class MAGNUM_SCENEGRAPH_EXPORT Object: public Abs
* See @ref scenegraph-hierarchy for more information. * See @ref scenegraph-hierarchy for more information.
*/ */
/** @copydoc AbstractBasicObject::scene() */ /** @copydoc AbstractObject::scene() */
Scene<Transformation>* scene(); Scene<Transformation>* scene();
const Scene<Transformation>* scene() const; /**< @overload */ const Scene<Transformation>* scene() const; /**< @overload */
@ -271,13 +271,13 @@ template<class Transformation> class MAGNUM_SCENEGRAPH_EXPORT Object: public Abs
/* `objects` passed by copy intentionally (to avoid copy internally) */ /* `objects` passed by copy intentionally (to avoid copy internally) */
static void setClean(std::vector<Object<Transformation>*> objects); static void setClean(std::vector<Object<Transformation>*> objects);
/** @copydoc AbstractBasicObject::isDirty() */ /** @copydoc AbstractObject::isDirty() */
bool isDirty() const { return !!(flags & Flag::Dirty); } bool isDirty() const { return !!(flags & Flag::Dirty); }
/** @copydoc AbstractBasicObject::setDirty() */ /** @copydoc AbstractObject::setDirty() */
void setDirty(); void setDirty();
/** @copydoc AbstractBasicObject::setClean() */ /** @copydoc AbstractObject::setClean() */
void setClean(); void setClean();
/*@}*/ /*@}*/
@ -298,14 +298,14 @@ template<class Transformation> class MAGNUM_SCENEGRAPH_EXPORT Object: public Abs
return absoluteTransformationMatrix(); return absoluteTransformationMatrix();
} }
std::vector<MatrixType> doTransformationMatrices(const std::vector<AbstractBasicObject<Transformation::Dimensions, typename Transformation::Type>*>& objects, const MatrixType& initialTransformationMatrix) const override final; std::vector<MatrixType> doTransformationMatrices(const std::vector<AbstractObject<Transformation::Dimensions, typename Transformation::Type>*>& objects, const MatrixType& initialTransformationMatrix) const override final;
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; 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;
bool MAGNUM_SCENEGRAPH_LOCAL doIsDirty() const override final { return isDirty(); } bool MAGNUM_SCENEGRAPH_LOCAL doIsDirty() const override final { return isDirty(); }
void MAGNUM_SCENEGRAPH_LOCAL doSetDirty() override final { setDirty(); } void MAGNUM_SCENEGRAPH_LOCAL doSetDirty() override final { setDirty(); }
void MAGNUM_SCENEGRAPH_LOCAL doSetClean() override final { setClean(); } void MAGNUM_SCENEGRAPH_LOCAL doSetClean() override final { setClean(); }
void doSetClean(const std::vector<AbstractBasicObject<Transformation::Dimensions, typename Transformation::Type>*>& objects) override final; void doSetClean(const std::vector<AbstractObject<Transformation::Dimensions, typename Transformation::Type>*>& objects) override final;
void MAGNUM_SCENEGRAPH_LOCAL setClean(const typename Transformation::DataType& absoluteTransformation); void MAGNUM_SCENEGRAPH_LOCAL setClean(const typename Transformation::DataType& absoluteTransformation);

8
src/SceneGraph/Object.hpp

@ -38,8 +38,8 @@
namespace Magnum { namespace SceneGraph { namespace Magnum { namespace SceneGraph {
template<UnsignedInt dimensions, class T> AbstractBasicObject<dimensions, T>::AbstractBasicObject() {} template<UnsignedInt dimensions, class T> AbstractObject<dimensions, T>::AbstractObject() {}
template<UnsignedInt dimensions, class T> AbstractBasicObject<dimensions, T>::~AbstractBasicObject() {} template<UnsignedInt dimensions, class T> AbstractObject<dimensions, T>::~AbstractObject() {}
template<UnsignedInt dimensions, class T> AbstractBasicTransformation<dimensions, T>::AbstractBasicTransformation() {} template<UnsignedInt dimensions, class T> AbstractBasicTransformation<dimensions, T>::AbstractBasicTransformation() {}
@ -160,7 +160,7 @@ template<class Transformation> void Object<Transformation>::setClean() {
} }
} }
template<class Transformation> auto Object<Transformation>::doTransformationMatrices(const std::vector<AbstractBasicObject<Transformation::Dimensions, typename Transformation::Type>*>& objects, const MatrixType& initialTransformationMatrix) const -> std::vector<MatrixType> { template<class Transformation> auto Object<Transformation>::doTransformationMatrices(const std::vector<AbstractObject<Transformation::Dimensions, typename Transformation::Type>*>& objects, const MatrixType& initialTransformationMatrix) const -> std::vector<MatrixType> {
std::vector<Object<Transformation>*> castObjects(objects.size()); std::vector<Object<Transformation>*> castObjects(objects.size());
for(std::size_t i = 0; i != objects.size(); ++i) for(std::size_t i = 0; i != objects.size(); ++i)
/** @todo Ensure this doesn't crash, somehow */ /** @todo Ensure this doesn't crash, somehow */
@ -322,7 +322,7 @@ template<class Transformation> typename Transformation::DataType Object<Transfor
} }
} }
template<class Transformation> void Object<Transformation>::doSetClean(const std::vector<AbstractBasicObject<Transformation::Dimensions, typename Transformation::Type>*>& objects) { template<class Transformation> void Object<Transformation>::doSetClean(const std::vector<AbstractObject<Transformation::Dimensions, typename Transformation::Type>*>& objects) {
std::vector<Object<Transformation>*> castObjects(objects.size()); std::vector<Object<Transformation>*> castObjects(objects.size());
for(std::size_t i = 0; i != objects.size(); ++i) for(std::size_t i = 0; i != objects.size(); ++i)
/** @todo Ensure this doesn't crash, somehow */ /** @todo Ensure this doesn't crash, somehow */

13
src/SceneGraph/SceneGraph.h

@ -58,9 +58,16 @@ template<class Derived> using AbstractGroupedFeature2D = AbstractBasicGroupedFea
template<class Derived> using AbstractGroupedFeature3D = AbstractBasicGroupedFeature<3, Derived, Float>; template<class Derived> using AbstractGroupedFeature3D = AbstractBasicGroupedFeature<3, Derived, Float>;
#endif #endif
template<UnsignedInt dimensions, class> class AbstractBasicObject; template<UnsignedInt, class> class AbstractObject;
typedef AbstractBasicObject<2, Float> AbstractObject2D; #ifndef CORRADE_GCC46_COMPATIBILITY
typedef AbstractBasicObject<3, Float> AbstractObject3D; template<class T> using AbstractBasicObject2D = AbstractObject<2, T>;
template<class T> using AbstractBasicObject3D = AbstractObject<3, T>;
typedef AbstractBasicObject2D<Float> AbstractObject2D;
typedef AbstractBasicObject3D<Float> AbstractObject3D;
#else
typedef AbstractObject<2, Float> AbstractObject2D;
typedef AbstractObject<3, Float> AbstractObject3D;
#endif
enum class TransformationType: UnsignedByte; enum class TransformationType: UnsignedByte;

4
src/SceneGraph/instantiation.cpp

@ -37,8 +37,8 @@
namespace Magnum { namespace SceneGraph { namespace Magnum { namespace SceneGraph {
#ifndef DOXYGEN_GENERATING_OUTPUT #ifndef DOXYGEN_GENERATING_OUTPUT
template class MAGNUM_SCENEGRAPH_EXPORT AbstractBasicObject<2, Float>; template class MAGNUM_SCENEGRAPH_EXPORT AbstractObject<2, Float>;
template class MAGNUM_SCENEGRAPH_EXPORT AbstractBasicObject<3, Float>; template class MAGNUM_SCENEGRAPH_EXPORT AbstractObject<3, Float>;
template class MAGNUM_SCENEGRAPH_EXPORT AbstractBasicTransformation<2, Float>; template class MAGNUM_SCENEGRAPH_EXPORT AbstractBasicTransformation<2, Float>;
template class MAGNUM_SCENEGRAPH_EXPORT AbstractBasicTransformation<3, Float>; template class MAGNUM_SCENEGRAPH_EXPORT AbstractBasicTransformation<3, Float>;

2
src/Shapes/AbstractShape.cpp

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

2
src/Shapes/AbstractShape.h

@ -79,7 +79,7 @@ template<UnsignedInt dimensions> class MAGNUM_SHAPES_EXPORT AbstractShape: publi
* @param object Object holding this feature * @param object Object holding this feature
* @param group Group this shape belongs to * @param group Group this shape belongs to
*/ */
explicit AbstractShape(SceneGraph::AbstractBasicObject<dimensions, Float>* object, ShapeGroup<dimensions>* group = nullptr); explicit AbstractShape(SceneGraph::AbstractObject<dimensions, Float>* object, ShapeGroup<dimensions>* group = nullptr);
/** /**
* @brief Shape group containing this shape * @brief Shape group containing this shape

6
src/Shapes/Shape.h

@ -75,17 +75,17 @@ template<class T> class Shape: public AbstractShape<T::Dimensions> {
* @param shape Shape * @param shape Shape
* @param group Group this shape belongs to * @param group Group this shape belongs to
*/ */
explicit Shape(SceneGraph::AbstractBasicObject<T::Dimensions, Float>* object, const T& shape, ShapeGroup<T::Dimensions>* group = nullptr): AbstractShape<T::Dimensions>(object, group) { explicit Shape(SceneGraph::AbstractObject<T::Dimensions, Float>* object, const T& shape, ShapeGroup<T::Dimensions>* group = nullptr): AbstractShape<T::Dimensions>(object, group) {
Implementation::ShapeHelper<T>::set(*this, shape); Implementation::ShapeHelper<T>::set(*this, shape);
} }
/** @overload */ /** @overload */
explicit Shape(SceneGraph::AbstractBasicObject<T::Dimensions, Float>* object, T&& shape, ShapeGroup<T::Dimensions>* group = nullptr): AbstractShape<T::Dimensions>(object, group) { explicit Shape(SceneGraph::AbstractObject<T::Dimensions, Float>* object, T&& shape, ShapeGroup<T::Dimensions>* group = nullptr): AbstractShape<T::Dimensions>(object, group) {
Implementation::ShapeHelper<T>::set(*this, std::move(shape)); Implementation::ShapeHelper<T>::set(*this, std::move(shape));
} }
/** @overload */ /** @overload */
explicit Shape(SceneGraph::AbstractBasicObject<T::Dimensions, Float>* object, ShapeGroup<T::Dimensions>* group = nullptr): AbstractShape<T::Dimensions>(object, group) {} explicit Shape(SceneGraph::AbstractObject<T::Dimensions, Float>* object, ShapeGroup<T::Dimensions>* group = nullptr): AbstractShape<T::Dimensions>(object, group) {}
/** @brief Shape */ /** @brief Shape */
const T& shape() const { return _shape.shape; } const T& shape() const { return _shape.shape; }

4
src/Shapes/ShapeGroup.cpp

@ -31,11 +31,11 @@ namespace Magnum { namespace Shapes {
template<UnsignedInt dimensions> void ShapeGroup<dimensions>::setClean() { template<UnsignedInt dimensions> void ShapeGroup<dimensions>::setClean() {
/* Clean all objects */ /* Clean all objects */
if(!this->isEmpty()) { if(!this->isEmpty()) {
std::vector<SceneGraph::AbstractBasicObject<dimensions, Float>*> objects(this->size()); std::vector<SceneGraph::AbstractObject<dimensions, Float>*> objects(this->size());
for(std::size_t i = 0; i != this->size(); ++i) for(std::size_t i = 0; i != this->size(); ++i)
objects[i] = (*this)[i]->object(); objects[i] = (*this)[i]->object();
SceneGraph::AbstractBasicObject<dimensions, Float>::setClean(objects); SceneGraph::AbstractObject<dimensions, Float>::setClean(objects);
} }
dirty = false; dirty = false;

Loading…
Cancel
Save