#ifndef Magnum_Physics_ObjectShape_h #define Magnum_Physics_ObjectShape_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::ObjectShape */ #include "SceneGraph/AbstractGroupedFeature.h" #include "ObjectShapeGroup.h" #include "magnumPhysicsVisibility.h" namespace Magnum { namespace Physics { template class ObjectShapeGroup; template class AbstractShape; /** @brief Object shape Adds shape for collision detection to object. @see ObjectShape2D, ObjectShape3D */ template class PHYSICS_EXPORT ObjectShape: public SceneGraph::AbstractGroupedFeature> { public: /** * @brief Constructor * @param object Object holding this feature * @param group Group this shape belongs to * * Creates empty object shape. * @see setShape() */ ObjectShape(SceneGraph::AbstractObject* object, ObjectShapeGroup* group = nullptr); /** * @brief Destructor * * Deletes associated shape. */ ~ObjectShape(); /** @brief Shape */ inline AbstractShape* shape() { return _shape; } inline const AbstractShape* shape() const { return _shape; } /**< @overload */ /** * @brief Set shape * @return Pointer to self (for method chaining) */ inline ObjectShape* setShape(AbstractShape* shape) { _shape = shape; this->object()->setDirty(); return this; } inline ObjectShapeGroup* group() { return static_cast*>(SceneGraph::AbstractGroupedFeature>::group()); } inline const ObjectShapeGroup* group() const { return static_cast*>(SceneGraph::AbstractGroupedFeature>::group()); } protected: /** Marks also the group as dirty */ void markDirty() override; /** Applies transformation to associated shape. */ void clean(const typename DimensionTraits::MatrixType& absoluteTransformation) override; private: AbstractShape* _shape; }; /** @brief Two-dimensional object shape */ typedef ObjectShape<2> ObjectShape2D; /** @brief Three-dimensional object shape */ typedef ObjectShape<3> ObjectShape3D; }} #endif