Browse Source

SceneGraph: ability to access parent from AbstractObject.

Didn't do any tests because there's nothing for AbstractObject anyway
(it's on my TODO list, though).
pull/187/head^2
Vladimír Vondruš 10 years ago
parent
commit
832289f7c3
  1. 9
      src/Magnum/SceneGraph/AbstractObject.h
  2. 3
      src/Magnum/SceneGraph/Object.h
  3. 8
      src/Magnum/SceneGraph/Object.hpp

9
src/Magnum/SceneGraph/AbstractObject.h

@ -170,6 +170,12 @@ template<UnsignedInt dimensions, class T> class AbstractObject
/** @overload */
const AbstractObject<dimensions, T>* scene() const { return doScene(); }
/** @brief Parent object or `nullptr`, if this is root object */
AbstractObject<dimensions, T>* parent() { return doParent(); }
/** @overload */
const AbstractObject<dimensions, T>* parent() const { return doParent(); }
/** @{ @name Object transformation */
/**
@ -269,6 +275,9 @@ template<UnsignedInt dimensions, class T> class AbstractObject
virtual AbstractObject<dimensions, T>* doScene() = 0;
virtual const AbstractObject<dimensions, T>* doScene() const = 0;
virtual AbstractObject<dimensions, T>* doParent() = 0;
virtual const AbstractObject<dimensions, T>* doParent() const = 0;
virtual MatrixType doTransformationMatrix() const = 0;
virtual MatrixType doAbsoluteTransformationMatrix() const = 0;
virtual std::vector<MatrixType> doTransformationMatrices(const std::vector<std::reference_wrapper<AbstractObject<dimensions, T>>>& objects, const MatrixType& initialTransformationMatrix) const = 0;

3
src/Magnum/SceneGraph/Object.h

@ -363,6 +363,9 @@ template<class Transformation> class Object: public AbstractObject<Transformatio
Object<Transformation>* doScene() override final;
const Object<Transformation>* doScene() const override final;
Object<Transformation>* doParent() override final;
const Object<Transformation>* doParent() const override final;
MatrixType MAGNUM_SCENEGRAPH_LOCAL doTransformationMatrix() const override final {
return transformationMatrix();
}

8
src/Magnum/SceneGraph/Object.hpp

@ -69,6 +69,14 @@ template<class Transformation> const Object<Transformation>* Object<Transformati
return scene();
}
template<class Transformation> Object<Transformation>* Object<Transformation>::doParent() {
return parent();
}
template<class Transformation> const Object<Transformation>* Object<Transformation>::doParent() const {
return parent();
}
template<class Transformation> Object<Transformation>& Object<Transformation>::setParent(Object<Transformation>* parent) {
/* Skip if parent is already parent or this is scene (which cannot have parent) */
/** @todo Assert for setting parent to scene */

Loading…
Cancel
Save