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()); }