template<class T>
Magnum::Shapes::Shape class

Object shape.

Adds shape for collision detection to object. Each Shape is part of some ShapeGroup, which essentially maintains a set of objects which can collide with each other. See Collision detection for brief introduction.

The shape contains original shape with relative transformation under shape() and also caches a shape with absolute transformation under transformedShape(), which can be used for collision detection. To conveniently use collision detection among many objects, you need to add the shape to ShapeGroup, which then provides collision detection for given group of shapes using either collides(), collision() or ShapeGroup::firstCollision(). You can also use ShapeGroup::add() and ShapeGroup::remove() later to manage e.g. collision islands.

Shapes::ShapeGroup3D shapes;

Object3D object;
auto shape = new Shapes::Shape<Shapes::Sphere3D>(object, {{}, 0.75f}, &shapes);

Shapes::AbstractShape3D* firstCollision = shapes.firstCollision(shape);

Base classes

template<UnsignedInt dimensions>
class AbstractShape deprecated
Base class for object shapes.

Constructors, destructors, conversion operators

Shape(SceneGraph::AbstractObject<T::Dimensions, Float>& object, const T& shape, ShapeGroup<T::Dimensions>* group = nullptr) explicit
Constructor.
Shape(SceneGraph::AbstractObject<T::Dimensions, Float>& object, T&& shape, ShapeGroup<T::Dimensions>* group = nullptr) explicit
Shape(SceneGraph::AbstractObject<T::Dimensions, Float>& object, ShapeGroup<T::Dimensions>* group = nullptr) explicit

Public functions

auto shape() const -> const T&
Shape.
auto setShape(const T& shape) -> Shape<T>&
Set shape.
auto transformedShape() -> const T&
Transformed shape.

Protected functions

void clean(const MatrixTypeFor<T::Dimensions, Float>& absoluteTransformationMatrix) override

Function documentation

template<class T>
Magnum::Shapes::Shape<T>::Shape(SceneGraph::AbstractObject<T::Dimensions, Float>& object, const T& shape, ShapeGroup<T::Dimensions>* group = nullptr) explicit

Constructor.

Parameters
object Object holding this feature
shape Shape
group Group this shape belongs to

template<class T>
Magnum::Shapes::Shape<T>::Shape(SceneGraph::AbstractObject<T::Dimensions, Float>& object, T&& shape, ShapeGroup<T::Dimensions>* group = nullptr) explicit

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<class T>
Magnum::Shapes::Shape<T>::Shape(SceneGraph::AbstractObject<T::Dimensions, Float>& object, ShapeGroup<T::Dimensions>* group = nullptr) explicit

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<class T>
Shape<T>& Magnum::Shapes::Shape<T>::setShape(const T& shape)

Set shape.

Returns Reference to self (for method chaining)

Marks the feature as dirty.

template<class T>
const T& Magnum::Shapes::Shape<T>::transformedShape()

Transformed shape.

Cleans the feature before returning the shape.

template<class T>
void Magnum::Shapes::Shape<T>::clean(const MatrixTypeFor<T::Dimensions, Float>& absoluteTransformationMatrix) override protected

Applies transformation to associated shape.