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

Collision data.

Contains information about collision between objects A and B, described by contact position, separation normal and separation distance.

If the collision occured, contact position is on object B surface, separation normal is normalized vector in which direction should object A be moved to separate the bodies, separation distance is positive and describes minimal movement of object A in direction of separation normal after which the contact position will no longer be colliding with object A.

If the collision not occured, contact position and separation normal is undefined (i.e., not normalized) and separation distance is negative or zero.

Constructors, destructors, conversion operators

Collision()
Default constructor.
Collision(const VectorTypeFor<dimensions, Float>& position, const VectorTypeFor<dimensions, Float>& separationNormal, Float separationDistance) explicit noexcept
Constructor.
operator bool() const
Whether the collision happened.

Public functions

auto position() const -> VectorTypeFor<dimensions, Float>
Collision position.
auto separationNormal() const -> VectorTypeFor<dimensions, Float>
Separation normal.
auto separationDistance() const -> Float
Separation distance.
auto flipped() const -> Collision<dimensions>
Flipped collision.

Function documentation

template<UnsignedInt dimensions>
Magnum::Shapes::Collision<dimensions>::Collision()

Default constructor.

Sets position, normal and separation distance to zero, as if no collision happened.

template<UnsignedInt dimensions>
Magnum::Shapes::Collision<dimensions>::Collision(const VectorTypeFor<dimensions, Float>& position, const VectorTypeFor<dimensions, Float>& separationNormal, Float separationDistance) explicit noexcept

Constructor.

If separation distance is positive, the separation normal is expected to be normalized.

template<UnsignedInt dimensions>
Magnum::Shapes::Collision<dimensions>::operator bool() const

Whether the collision happened.

Negative or zero separation distance means that no collision happened.

template<UnsignedInt dimensions>
VectorTypeFor<dimensions, Float> Magnum::Shapes::Collision<dimensions>::separationNormal() const

Separation normal.

template<UnsignedInt dimensions>
Float Magnum::Shapes::Collision<dimensions>::separationDistance() const

Separation distance.

template<UnsignedInt dimensions>
Collision<dimensions> Magnum::Shapes::Collision<dimensions>::flipped() const

Flipped collision.

Returns new collision object as if the collision occured between flipped pair of objects, i.e. with flipped separation normal and contact position on surface of object A.