template<UnsignedInt dimensions>
Magnum::Shapes::Composition class

Composition of shapes.

Result of logical operations on shapes. See Collision detection for brief introduction.

Public types

enum (anonymous): UnsignedInt { Dimensions = dimensions }
enum class Type { Point, Line, LineSegment, Sphere, InvertedSphere, Cylinder, Capsule, AxisAlignedBox, Box, Plane }
Shape type.

Constructors, destructors, conversion operators

Composition() explicit
Default constructor.
template<class T>
Composition(CompositionOperation operation, T&& a) explicit
Unary operation constructor.
template<class T, class U>
Composition(CompositionOperation operation, T&& a, U&& b) explicit
Binary operation constructor.
Composition(const Composition<dimensions>& other)
Copy constructor.
Composition(Composition<dimensions>&& other)
Move constructor.

Public functions

auto operator=(const Composition<dimensions>& other) -> Composition<dimensions>&
Assigment operator.
auto operator=(Composition<dimensions>&& other) -> Composition<dimensions>&
Move assignment operator.
auto transformed(const MatrixTypeFor<dimensions, Float>& matrix) const -> Composition<dimensions>
Transformed shape.
auto size() const -> std::size_t
Count of shapes in the hierarchy.
auto type(std::size_t i) const -> Type
Type of shape at given position.
template<class T>
auto get(std::size_t i) const -> const T&
Shape at given position.
template<class T>
auto operator%(const T& other) const -> bool
Collision with another shape.

Enum documentation

template<UnsignedInt dimensions>
enum Magnum::Shapes::Composition<dimensions>::(anonymous): UnsignedInt

Enumerators
Dimensions

Dimension count

template<UnsignedInt dimensions>
enum class Magnum::Shapes::Composition<dimensions>::Type

Shape type.

Enumerators
Point

Point

Line

Line

LineSegment

Line segment

Sphere

Sphere

InvertedSphere

Inverted sphere

Cylinder

Cylinder

Capsule

Capsule

AxisAlignedBox

Axis aligned box

Box

Box

Plane

Plane (3D only)

Function documentation

template<UnsignedInt dimensions>
Magnum::Shapes::Composition<dimensions>::Composition() explicit

Default constructor.

Creates empty composition.

template<UnsignedInt dimensions> template<class T>
Magnum::Shapes::Composition<dimensions>::Composition(CompositionOperation operation, T&& a) explicit

Unary operation constructor.

Parameters
operation Unary operation
a Operand

template<UnsignedInt dimensions> template<class T, class U>
Magnum::Shapes::Composition<dimensions>::Composition(CompositionOperation operation, T&& a, U&& b) explicit

Binary operation constructor.

Parameters
operation Binary operation
a Left operand
b Right operand

template<UnsignedInt dimensions> template<UnsignedInt dimensions>
Debug& operator<<(Debug& debug, typename Composition<dimensions>::Type value)

Debug output operator.

template<UnsignedInt dimensions> template<UnsignedInt dimensions, class T>
bool operator%(const T& a, const Composition<dimensions>& b)

Collision occurence of shape with Composition.

template<UnsignedInt dimensions> template<class T>
Composition<T::Dimensions> operator!(T a)

Logical NOT of shape.

template<UnsignedInt dimensions> template<class T>
Composition<T::Dimensions> operator&&(T a, T b)

Logical AND of two shapes.

Short-circuit evaluation is used here, so this operation can be used for providing simplified shape version, because collision with b is computed only if a collides. See Providing simplified version of shape for better performance for an example.

template<UnsignedInt dimensions> template<class T>
Composition<T::Dimensions> operator||(T a, T b)

Logical OR of two shapes.

Short-circuit evaluation is used, so if collision with a is detected, collision with b is not computed.