Browse Source

SceneGraph: remove constructor signature requirements in addChild().

It now calls setParent() afterwards instead of requiring the last
constructor parameter to be a parent pointer.
pull/461/head
Vladimír Vondruš 6 years ago
parent
commit
cec77c0a80
  1. 6
      doc/changelog.dox
  2. 7
      src/Magnum/SceneGraph/Object.h

6
doc/changelog.dox

@ -137,6 +137,12 @@ See also:
@ref Corrade::Containers::ArrayView are now removed. This should have a
significant positive effect on compile times of code using the @ref GL,
@ref Audio, @ref Trade and @ref Text librariess
- @ref SceneGraph::Object:addChild() no longer requires the type constructor
to have the last parameter a parent object object pointer, as that was
quite limiting. Instead it's calling @ref SceneGraph::Object::setParent()
afterwards. This can cause compilation breakages in case the type
constructor has the parent parameter non-optional, pass the parent
explicitly in that case.
@section changelog-2020-06 2020.06

7
src/Magnum/SceneGraph/Object.h

@ -195,10 +195,13 @@ template<class Transformation> class Object: public AbstractObject<Transformatio
* @brief Add a child
*
* Calling `object.addChild<MyObject>(args...)` is equivalent to
* `new MyObject{args..., &object}`.
* `new MyObject{args...}` followed by an appropriate @ref setParent()
* call.
*/
template<class T, class ...Args> T& addChild(Args&&... args) {
return *(new T{std::forward<Args>(args)..., this});
T* child = new T{std::forward<Args>(args)...};
child->setParent(this);
return *child;
}
/**

Loading…
Cancel
Save