#ifndef Magnum_Physics_ShapedObject_h #define Magnum_Physics_ShapedObject_h /* Copyright © 2010, 2011, 2012 Vladimír Vondruš This file is part of Magnum. Magnum is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 3 only, as published by the Free Software Foundation. Magnum is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 3 for more details. */ /** @file * @brief Class Magnum::Physics::ShapedObject */ #include "SceneGraph/Object.h" #include "magnumPhysicsVisibility.h" namespace Magnum { namespace Physics { template class ShapedObjectGroup; template class AbstractShape; /** @brief Object with assigned shape @see ShapedObject2D, ShapedObject3D */ template class PHYSICS_EXPORT ShapedObject: public SceneGraph::AbstractObject::ObjectType { public: /** * @brief Constructor * @param group Group this shaped object belongs to * @param parent Parent object * * Creates object with no shape. * @see setShape() */ ShapedObject(ShapedObjectGroup* group, typename SceneGraph::AbstractObject::ObjectType* parent = nullptr); /** * @brief Destructor * * Deletes associated shape. */ ~ShapedObject(); /** @brief Object shape */ inline AbstractShape* shape() { return _shape; } inline const AbstractShape* shape() const { return _shape; } /**< @overload */ /** * @brief Set object shape * @return Pointer to self (for method chaining) */ inline ShapedObject* setShape(AbstractShape* shape) { _shape = shape; setDirty(); return this; } /** * @copybrief SceneGraph::AbstractObject::setDirty() * * Marks shaped object group as dirty. */ void setDirty(); protected: /** * @copybrief SceneGraph::AbstractObject::clean() * * Applies transformation to associated shape. */ void clean(const typename DimensionTraits::MatrixType& absoluteTransformation); private: ShapedObjectGroup* group; AbstractShape* _shape; }; /** @brief Two-dimensional shaped object */ typedef ShapedObject<2> ShapedObject2D; /** @brief Three-dimensional shaped object */ typedef ShapedObject<3> ShapedObject3D; }} #endif