From ee732676656aff282e16f15a99df3921f219eea7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Fri, 25 Jan 2013 18:00:42 +0100 Subject: [PATCH] Physics: convenience overload for ObjectShape::setShape(). Will allow for more convenient usage of e.g. ShapeGroup operators: Physics::ObjectShape3D* shape; shape->setShape(Physics::Sphere3D({}, 0.75f) || Physics::AxisAlignedBox3D({}, {3.0f, 1.5f, 2.0f})); --- src/Physics/ObjectShape.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/Physics/ObjectShape.h b/src/Physics/ObjectShape.h index 259ee93ef..23e0d69a3 100644 --- a/src/Physics/ObjectShape.h +++ b/src/Physics/ObjectShape.h @@ -65,6 +65,25 @@ template class MAGNUM_PHYSICS_EXPORT ObjectShape: publi return this; } + /** + * @brief Set shape + * @return Pointer to self (for method chaining) + * + * Convenience overload for setShape(AbstractShape*), allowing you to + * use e.g. ShapeGroup operators: + * @code + * Physics::ObjectShape3D* shape; + * shape->setShape(Physics::Sphere3D({}, 0.75f) || Physics::AxisAlignedBox3D({}, {3.0f, 1.5f, 2.0f})); + * @endcode + */ + #ifdef DOXYGEN_GENERATING_OUTPUT + template inline ObjectShape* setShape(T&& shape) { + #else + template inline typename std::enable_if, T>::value, ObjectShape*>::type setShape(T&& shape) { + #endif + return setShape(new T(std::move(shape))); + } + inline ObjectShapeGroup* group() { return static_cast*>(SceneGraph::AbstractGroupedFeature>::group()); }