Reference

class Application

Public Functions

Application()
~Application()
void setName(const char *name)
template<std::derived_from<Scene> S, class ...Args>
inline void registerScene(const char *name, Args&&... args)
void run()
inline Scene *scene()
inline const Scene *scene() const
void close()
bool isKeyPressed(Keyboard::Key key) const
inline Renderer *renderer()

Private Functions

void changeScene(std::shared_ptr<Scene> next)
void doGui(float dt)
void show() const

Private Members

std::shared_ptr<Scene> scene_ = nullptr
std::unique_ptr<Renderer> renderer_ = nullptr
GLFWwindow *window_ = nullptr
std::unordered_map<const char*, std::shared_ptr<Scene>> scenes_ = {}

Private Static Functions

static void frameBufferResizeCallback(GLFWwindow *window, int w, int h)
static void windowResizeCallback(GLFWwindow *window, int w, int h)
static void keypressCallback(GLFWwindow *window, int key, int scancode, int action, int modifiers)
static void mouseMoveCallback(GLFWwindow *window, double x, double y)
static void mousePressCallback(GLFWwindow *window, int button, int action, int mods)
static void mouseScrollCallback(GLFWwindow *window, double x, double y)
struct Bias

Public Functions

template<ConstraintFunction F>
inline void operator()(F f)

Public Members

const Proxies &proxies
MatrixRowManipulator<Value> manip = {}
Uint32 i = 0
class Block

Public Functions

inline Block(std::size_t size)
Block(const Block&) = delete
Block(Block&&) = delete
inline ~Block()
template<class T>
T *allocate(std::size_t n)
template<class T>
bool deallocate(T *p, std::size_t n) noexcept
inline bool isEmpty() const noexcept

Private Types

typedef std::uint8_t Byte

Private Members

std::list<FreeBlock> freeList_ = {}
Byte *data_ = nullptr
std::size_t sz
class Bodies

Public Types

typedef Vector<float, n> Dominance

Public Functions

inline Bodies(std::initializer_list<Body*> bodies, std::optional<Dominance> dominances = std::nullopt)
inline Body const *const *begin() const
inline Body const *const *end() const
inline Body *const *begin()
inline Body *const *end()
inline Body *operator[](Uint32 index)
inline const Body *operator[](Uint32 index) const
inline Uint32 size() const
inline bool isBodyStructural(const Body *body) const
inline bool operator==(const Bodies &other) const
inline bool operator!=(const Bodies &other) const

Public Static Functions

static inline Bodies singleBody(Body *body)

Public Static Attributes

static constexpr Uint32 n = 2

Private Functions

inline void startSolve(Position *ps, Velocity *vs)
inline void endSolve()
inline bool hasProxies() const
inline Proxies &getProxies()

Private Members

std::array<Body*, n> bodies_
Proxies proxies_ = {}
InvMasses invMasses_

Friends

friend class Island
friend class Constraint
class Body : public simu::PhysicsObject

Subclassed by simu::VisibleBody

Public Types

typedef PhysicsObject::PhysicsAlloc Alloc

Public Functions

inline Body(const BodyDescriptor &descriptor)

Constructs a Body.

Body(const Body &other) = delete
Body(Body &&other) = delete
inline ~Body() override
Collider *addCollider(const ColliderDescriptor &descriptor)
void removeCollider(Collider *collider)
inline void applyForce(Vec2 force, float dt, Vec2 whereFromCentroid = Vec2{0, 0})

Applies a force for some time on an object.

whereFromCentroid does not need to lie inside the Body’s world space geometry.

inline void applyImpulse(Vec2 impulse, Vec2 whereFromCentroid = Vec2{0, 0})

Applies an impulse on an object.

whereFromCentroid does not need to lie inside the Body’s world space geometry.

inline Vec2 velocity() const

The Body’s current linear velocity.

inline float angularVelocity() const

The Body’s current angular velocity in radians/s.

inline void setVelocity(Vec2 velocity)

Change the Body’s linear velocity to velocity.

inline void setAngularVelocity(float angularVelocity)

Change the Body’s angularVelocity to angularVelocity in radians/s.

inline Vec2 position() const

The Body’s world space position.

This is an offset of the Body’s local space geometry

inline float orientation() const

The Body’s world space orientation in radians.

The orientation rotates the Body’s local space geometry around its centroid

inline auto colliders() const

Returns a read only reference to the Body’s Colliders.

inline Transform toWorldSpace() const

Transformation matrix to convert from the Body’s local space to world space.

inline Transform toLocalSpace() const

Transformation matrix to convert from world space to the Body’s local space.

inline Vec2 centroid() const
inline Vec2 localCentroid() const
inline float invMass() const
inline float invInertia() const
inline float mass() const
inline float inertia() const
inline bool isStructural() const

Whether the body is structural or not according to its dominance.

bool interactsAsStructural() const

true if the body is structural in all of its constraints and has no velocity

This is mostly used internally.

inline float dominance() const

The Body’s dominance.

inline bool isAsleep() const
inline void wake()
inline auto constraints()

Returns an iterable view of Constraint*.

ie: for (Constraint* c : body.constraints())

inline auto constraints() const

Returns an iterable view of const Constraint*.

ie: for (const Constraint* c : body.constraints())

inline auto contacts()
inline auto contacts() const

Private Functions

inline virtual void setAllocator(const PhysicsAlloc &alloc) override
inline void update()
inline bool isImmobile(float velocityTreshold, float angularVelocityTreshold) const
inline void updateTimeImmobile(float dt, float velocityTreshold, float angularVelocityTreshold)
inline bool canSleep(float minTimeImmobile) const
inline void sleep()

Private Members

Position position_
Velocity velocity_ = {}
Colliders colliders_
float dominance_
bool isAsleep_ = false
float timeImmobile_ = 0.f
std::vector<Constraint*, ReboundTo<Alloc, Constraint*>> constraints_
std::vector<ContactConstraint*, ReboundTo<Alloc, ContactConstraint*>> contacts_
Int32 proxyIndex = NO_INDEX
World *world_ = nullptr

Private Static Attributes

static constexpr Int32 NO_INDEX = -1

Friends

friend class Island
friend class SolverProxy
friend class World
friend class Bodies
struct BodyDescriptor
#include <Body.hpp>

Describes a Body for construction.

Public Members

Vec2 position = {}

The initial position of the Body. This is a translation of the local-space geometry.

float orientation = {}

The initial orientation of the Body. This is a rotation around the body’s local space origin.

float dominance = 1.f

dominance scales the inverse mass of the Body when interacting in constraints.

A dominance of 0 means that the body has infinite mass and is considered structural. Ie when constrained with another body, only the other bodies will be acted upon.

A structural Body is not affected by any ForceField. Otherwise, ForceFields should not take dominance into account.

This parameter can be overriden for specific Constraints when passing Bodies.

See also

Bodies

class BoundingBox
#include <BoundingBox.hpp>

An axis-aligned bounding box defined by a minimum and maximum point.

If minimum == maximum, then the box is a single point.

The bounding box is invalid if any coordinates of minimum are greater than their maximum counterpart.

An invalid bounding box overlaps nothing and is ignored when combining boxes.

Public Functions

inline BoundingBox()

Creates an invalid bounding box.

BoundingBox(Vec2 min, Vec2 max)

Creates a bounding box from the specified min and max points.

template<VertexIterator2D It>
BoundingBox(It begin, It end)

Creates a bounding box that contains all the vertices.

template<Geometry T>
BoundingBox(const T &geoemtry)

Creates a bounding box that contains all the vertices of the geometry.

inline bool isValid() const

true if the bounding box covers a valid area,

See also

BoundingBox

inline Vec2 min() const

The minimum coordinate.

inline Vec2 max() const

The maximum coordinate.

inline Vec2 center() const

The center of the box.

bool overlaps(const BoundingBox &other) const

true if this overlaps other, if the borders touch, the boxes overlap. If this or other is invalid, they never overlap.

bool contains(const BoundingBox &other) const
BoundingBox combined(const BoundingBox &other) const

Returns a bounding box that covers this and other.

inline bool operator==(const BoundingBox &other) const

true if both boxes are invalid or they have the same min and max coordinates.

inline bool operator!=(const BoundingBox &other) const

Public Static Functions

static BoundingBox scaled(BoundingBox original, float ratio)

Private Members

Vec2 min_
Vec2 max_
class BoxSpawner : public simu::Tool

Public Functions

inline BoxSpawner(Scene &scene)
virtual void doGui() override
inline virtual const char *getName() const override
virtual bool onMousePress(Mouse::Input input) override
inline virtual bool onMouseMove(Vec2) override
inline virtual bool onKeypress(Keyboard::Input) override
inline virtual bool onMouseScroll(Vec2) override
Body *makeBox(Vec2 pos, std::optional<Vec2> dims = std::nullopt)

Public Members

float orientation = 0.f
float dominance = 1.f
Vec2 dims = {2.f, 2.f}
float density = 1.f
float friction = 0.5f
float bounciness = 0.f
Rgba color = {225, 150, 240, 255}

Public Static Attributes

static constexpr char name[] = "Box Spawner"

Private Members

Scene &scene_
class Camera

Public Functions

Camera()
float zoom() const
void setZoom(float ratio)
inline void zoomIn()
inline void zoomOut()
Vec2 center() const
void pan(Vec2 offset)
void panTo(Vec2 center)
Mat3 transform() const
Mat3 invTransform() const
inline float pixelSize() const
inline void setPixelSize(float size)
Vec2 viewDimensions() const
void setViewDimensions(Vec2 dimensions)
void setDimensionsFromScreenCoordinates(Vec2 pixelDimensions)

Private Members

Vec2 center_ = {}
Vec2 viewDimensions_ = {2, 2}
float zoom_ = 1.f
float pixelSize_ = 1.f / 10.f
class Collider
#include <Collider.hpp>

Represents geometry that moves.

The Collider holds a local space Polygon and a set of transformed vertices that defines the geometry in world space.

All of its geometry is always positively oriented.

The local space geometry will be recentered to have its centroid at origin

Public Types

typedef FreeListAllocator<Vec2> Alloc

Public Functions

inline Collider(const ColliderDescriptor &descr, Body *body, const Alloc &alloc)

Creates a Collider from a local space polygon and an initial transform.

inline Body *body()
inline const Body *body() const
inline const Material &material() const
inline MassProperties properties() const
inline void replaceAlloc(const Alloc &alloc)
inline BoundingBox boundingBox() const

The world space bounding box of the Collider.

inline auto begin()

Iterators for the transformed geometry (world space vertices)

inline auto begin() const
inline auto end()
inline auto end() const
inline auto vertexView() const
inline void update(const Transform &transform)

Changes the transform of the Collider applied to the local space geometry.

Private Members

std::vector<Vec2, Alloc> local_
std::vector<Vec2, Alloc> transformed_
BoundingBox boundingBox_
Material material_
Body *body_
ColliderTree::iterator treeLocation_

Friends

friend class World
struct ColliderDescriptor

Public Members

Polygon polygon

The Geometry for the Collider. This is put as-is in the Body’s local space.

Does not need to be centered on origin.

Material material = {}

The Material of the Collider. Affects how it interacts with other bodies.

class Colliders

Public Types

typedef Collider::Alloc Alloc

Public Functions

Colliders() = default
inline auto begin() const
inline auto end() const
inline bool isEmpty() const
inline void replaceAlloc(const Alloc &alloc)
inline const MassProperties &properties() const
inline Collider *add(const ColliderDescriptor &descr, Body *owner)
inline void remove(Collider *collider)
inline void update(const Transform &transform)

Private Types

typedef std::list<Collider, ReboundTo<Alloc, Collider>> ColliderList

Private Members

ColliderList colliders_ = {}
MassProperties properties_ = {}

Friends

friend class Body
class ColliderTree : public simu::RTree<Collider*, FreeListAllocator<Collider*>>

Private Types

typedef RTree<Collider*, FreeListAllocator<Collider*>> Base
struct CombinableProperty

A property that can be combined according to some Mode.

Some values are typically given for a system (collision restitution and friction coefficients), this class allows defining them per object and then combining them to obtain a value for the system.

Conception taken from https://docs.unity3d.com/Manual/class-PhysicMaterial.html

Public Types

enum Mode

The Mode defines how the property is combined.

When the Mode of two CombinableProperty is different, the one with the highest value (priority) is taken.

Values:

enumerator average
enumerator minimum
enumerator multiply
enumerator maximum

Public Functions

inline explicit CombinableProperty(float value, Mode mode = average)
inline CombinableProperty(CombinableProperty first, CombinableProperty second)

Public Members

Mode mode
float value

Public Static Functions

static inline float combine(Mode mode, float first, float second)
template<class T, class U, simu::Uint32 m, simu::Uint32 n>
struct common_type<simu::Matrix<T, m, n>, simu::Matrix<U, m, n>>

Public Types

typedef simu::Matrix<typename std::common_type<T, U>::type, m, n> type
class Constraint : public simu::PhysicsObject

Call sequence pseudo-code:

let S be the set of active constraints;
foreach constraint c:
    if c.isActive():
        S <- S U c;

foreach constraint c in S:
    c.initSolve();

foreach constraint c in S:
    c.warmstart();

for i in range(world.nVelocityIterations)
    foreach constraint c in S:
        c.solveVelocities();

for i in range(world.nPositionIterations)
    foreach constraint c:
        c.solvePositions();

Subclassed by simu::ConstraintImplementation< TranslationMotorFunction >, simu::ConstraintImplementation< HingeConstraintFunction >, simu::ConstraintImplementation< DistanceConstraintFunction, LimitsSolver< DistanceConstraintFunction > >, simu::ConstraintImplementation< RotationConstraintFunction >, simu::ConstraintImplementation< MouseConstraintFunction >, simu::ConstraintImplementation< RotationMotorFunction >, simu::ConstraintImplementation< WeldConstraintFunction >, simu::ConstraintImplementation< F, S >, simu::ContactConstraint

Public Functions

inline Constraint(const Bodies &bodies, bool disablesContacts)
~Constraint() override = default
virtual bool isActive(const Proxies &proxies) = 0
virtual void initSolve(const Proxies &proxies) = 0
virtual void warmstart(Proxies &proxies, float dt) = 0
virtual void solveVelocities(Proxies &proxies, float dt) = 0
virtual void solvePositions(Proxies &proxies) = 0
inline Bodies &bodies()
inline const Bodies &bodies() const
inline bool disablesContacts() const

Protected Functions

inline virtual bool shouldDie() const override

Offers an alternative death condition than this->kill().

Subclasses should always consider if Base::shouldDie() is true.

Example: a Constraint that is broken if the force it applies exceeds a treshold can implement this death condition in shouldDie.

Private Functions

inline Proxies &proxies()

Private Members

Bodies bodies_
bool disablesContacts_
template<ConstraintFunction... Fs>
class ConstraintFunctions

Public Types

typedef Vector<float, dimension> Value
typedef Matrix<float, dimension, 6> Jacobian

Public Functions

inline ConstraintFunctions(const Fs&... constraints)
inline Value eval(const Proxies &proxies) const
inline Jacobian jacobian(const Proxies &proxies) const
inline Value clampLambda(const Value &lambda, float dt) const
inline Value clampPositionLambda(const Value &lambda) const
inline Value bias(const Proxies &proxies) const

Public Members

std::tuple<Fs...> constraints

Public Static Attributes

static constexpr Uint32 nBodies = details::NProxies<Fs...>::value
static constexpr Uint32 dimension = details::Dimension<Fs...>::value
template<ConstraintFunction F, ConstraintSolver S = EqualitySolver<F>>
class ConstraintImplementation : public simu::Constraint

Public Types

typedef F::Value Value
typedef S Solver

Public Functions

inline ConstraintImplementation(const Bodies &bodies, const F &f, bool disableContacts)
inline virtual bool isActive(const Proxies &proxies) override
inline virtual void initSolve(const Proxies &proxies) override
inline virtual void warmstart(Proxies &proxies, float dt) override
inline virtual void solveVelocities(Proxies &proxies, float dt) override
inline virtual void solvePositions(Proxies &proxies) override

Protected Attributes

F f
S solver
template<ConstraintFunction F_>
class ConstraintSolverBase

Public Types

typedef F_ F
typedef F::Value Value
typedef F::Jacobian Jacobian
typedef Proxies::State State
typedef Proxies::VelocityVec VelocityVec
typedef Proxies::Impulse Impulse
typedef Matrix<float, dimension, dimension> KMatrix

Public Functions

inline ConstraintSolverBase(Bodies, const F&)
inline Value &restitution()
inline const Value &restitution() const
inline Value &damping()
inline const Value &damping() const
inline void initBase()
inline void warmstartDefault(Proxies &proxies, const F &f, float dt)
inline KMatrix computeEffectiveMass(const Proxies &proxies, const F &f, bool addDamping)
inline Value computeRhs(const Proxies &proxies, const F &f, float dt, bool addDamping) const
inline void updateLambda(Proxies &proxies, const F &f, float dt, Value dLambda)
inline Jacobian getJacobian() const
inline Value getAccumulatedLambda() const
inline Value getPreviousLambda() const
inline void setLambdaHint(Value lambda)

Public Static Functions

static inline Impulse impulse(const Jacobian &J, const Value &lambda)

Public Static Attributes

static constexpr Uint32 nBodies = F::nBodies
static constexpr Uint32 dimension = F::dimension

Private Members

Value lambda_ = {}
Value previousLambda_ = {}
Jacobian J_ = {}
Value restitution_ = {}
Value damping_ = {}
class ContactConstraint : public simu::Constraint

Subclassed by simu::VisibleContactConstraint

Public Functions

inline ContactConstraint(Collider &first, Collider &second)
inline const std::array<const Collider*, 2> &colliders() const
inline ContactInfo contactInfo() const
inline virtual void preStep() override

Called at the start of World::step, after dead objects are removed.

Subclasses should always call Base::preStep().

This is called for Body, Constraint and then for ForceField.

inline virtual bool isActive(const Proxies &proxies) final override
inline virtual void initSolve(const Proxies &proxies) final override
inline virtual void warmstart(Proxies &proxies, float) final override
inline virtual void solveVelocities(Proxies &proxies, float) final override
inline virtual void solvePositions(Proxies &proxies) final override

Public Members

float invNormalK11_
LcpSolver<float> normalKSolver_

Public Static Attributes

static constexpr float sinkTolerance = 3.f

Private Types

typedef Proxies::State State
typedef Proxies::Impulse Impulse
typedef Matrix<float, 2, 6> Jacobian
typedef Matrix<float, 1, 6> JacobianRow
typedef std::array<JacobianRow, 2> JacobianRows

Private Functions

inline void updateContacts()
inline void computeKs(const Proxies &proxies, bool computeFrictionK)
inline void computeBounce(const Proxies &proxies)
inline void computeJacobians(const Proxies &proxies, bool computeFriction)
inline Matrix<float, 1, 6> normalJacobian(Uint32 contact) const
inline std::array<Vec2, 2> relativePosition() const

Private Members

ContactManifold manifold_
ContactManifold::FrameManifold frame_
JacobianRows Jf
Jacobian Jn
Vec2 invTangentKs_
union simu::ContactConstraint::[anonymous] [anonymous]
Vec2 tangentLambda_ = {}
Vec2 previousTangentLambda_ = {}
Vec2 normalLambda_ = {}
Vec2 previousNormalLambda_ = {}
Vec2 bounce_ = {}
float restitutionCoeff_
float frictionCoeff_

Private Static Attributes

static constexpr Uint32 inc = 0
static constexpr Uint32 ref = 1
static constexpr float restitutionTreshold = 1.f
static constexpr float posCorrectionFactor = 0.2f
static constexpr float maxCorrection = 0.2f
struct ContactInfo

Public Members

std::array<Vec2, 2> refContacts
std::array<Vec2, 2> incContacts
Uint32 nContacts
Vec2 normal
class ContactManifold

Public Types

typedef std::array<Transform, 2> Transforms

Public Functions

inline ContactManifold(const Collider &first, const Collider &second)
inline const std::array<const Collider*, 2> &colliders() const
inline void update()
inline FrameManifold frameManifold(const Bodies &bodies) const
inline FrameManifold frameManifold(const Proxies &proxies) const
inline Uint32 nContacts() const
inline Uint32 referenceIndex() const
inline Uint32 incidentIndex() const
inline void setMinimumPenetration(float minPen)
inline float minimumPenetration() const

Private Types

typedef Edges<Collider>::Edge Edge

Private Functions

inline FrameManifold frameManifold(Transforms Ts) const
inline std::array<std::array<Vertex, 2>, 2> contacts(const Transforms &Ts) const

contacts()[referenceIndex()][1] -> second contact point of the reference body

inline Vec2 contactNormal(const Transforms &Ts) const
inline Vec2 contactTangent(const Transforms &Ts) const
inline std::array<Edge, 2> computeContactEdges(Vec2 mtv)
inline void computeContacts(std::array<Edge, 2> contactEdges)

Private Members

std::array<const Collider*, 2> colliders_
std::array<std::array<Vertex, 2>, 2> contacts_ = {}
Uint32 nContacts_ = 0
Vec2 contactNormal_ = {}
float minPen_
Uint32 referenceIndex_ = 0

Private Static Functions

static inline Edge computeContactEdge(const Collider &collider, Vec2 direction)
struct ContactStatus

Public Members

UniquePtr<ContactConstraint> existingContact = nullptr
bool hit = false
struct DerefContact

Public Functions

inline ContactConstraint &operator()(typename ContactList::value_type &s) const
inline const ContactConstraint &operator()(const typename ContactList::value_type &s) const
template<ConstraintFunction... Fs>
struct Dimension : public std::integral_constant<Uint32, 0>
template<ConstraintFunction F, ConstraintFunction... Fs>
struct Dimension<F, Fs...> : public std::integral_constant<Uint32, F::dimension + Dimension<Fs...>::value>
class DistanceConstraint : public simu::ConstraintImplementation<DistanceConstraintFunction, LimitsSolver<DistanceConstraintFunction>>

Subclassed by simu::VisibleDistanceConstraint

Public Functions

inline DistanceConstraint(const Bodies &bodies, std::array<Vec2, 2> fixedPoints, bool disableContacts = true)
inline DistanceConstraint(const Bodies &bodies, std::array<Vec2, 2> fixedPoints, float distance, bool disableContacts = true)
inline DistanceConstraint(const Bodies &bodies, std::array<Vec2, 2> fixedPoints, std::optional<float> minDistance, std::optional<float> maxDistance, bool disableContacts = true)
class DistanceConstraintFunction : public simu::EqualityConstraintFunctionBase<2, 1>

Public Types

typedef EqualityConstraintFunctionBase<2, 1> Base

Public Functions

inline DistanceConstraintFunction(const Bodies &bodies, std::array<Vec2, 2> fixedPoints)
inline Value eval(const Proxies &proxies) const
inline Value bias(const Proxies&) const
inline Jacobian jacobian(const Proxies &proxies) const
inline std::array<Vec2, 2> localFixedPoints() const

Public Static Functions

static inline float distanceSquared(std::array<Vec2, 2> worldPoints)

Private Functions

inline std::array<Vec2, 2> worldSpaceFixedPoints(const Proxies &proxies) const

Private Members

std::array<Vec2, 2> localFixedPoints_
struct Domain

Public Members

DomainType type
BoundingBox region
struct DoubleDereference
#include <View.hpp>

Dereferences the element one more time.

Propagates const, suppose a sequence of int*const * then a simple dereference returns int*const & and doubleDereference returns const int&

Public Functions

template<class Value>
inline auto &operator()(Value &v) const
template<class Value>
inline const auto &operator()(const Value &v) const
class Edge

Public Functions

inline Edge(It from, It to)
inline Vec2 from() const
inline Vec2 to() const
inline It fromIt() const
inline It toIt() const
inline Vec2 direction() const
inline Vec2 normal() const
inline Vec2 normalizedNormal() const
inline float distanceSquaredToPoint(Vec2 point) const
inline float distanceSquaredToOrigin() const
inline bool isOutside(Vec2 p) const
inline bool isInside(Vec2 p) const
inline Vertex clipInside(const Edge &other) const
bool operator==(const Edge &other) const = default
bool operator!=(const Edge &other) const = default

Private Members

friend Edges
It from_
It to_

Friends

friend class Iterator
template<Geometry T>
class Edges

Public Functions

inline Edges(const T &geometry)
inline Iterator begin() const
inline Iterator end() const
inline Iterator next(Iterator edge) const
inline Iterator previous(Iterator edge) const

Private Types

typedef IteratorOf<const T> It

Private Members

const T &geometry_
template<Uint32 nBodies_, Uint32 dimension_>
class EqualityConstraintFunctionBase

Public Types

typedef Vector<float, dimension> Value
typedef Matrix<float, dimension, 6> Jacobian

Public Functions

EqualityConstraintFunctionBase() = default
inline Value clampLambda(Value lambda, float) const
inline Value clampPositionLambda(Value lambda) const

Public Static Attributes

static constexpr Uint32 nBodies = nBodies_
static constexpr Uint32 dimension = dimension_
template<ConstraintFunction F>
class EqualitySolver : public simu::ConstraintSolverBase<F>

Public Types

typedef ConstraintSolverBase<F> Base
typedef Base::Value Value
typedef Base::Jacobian Jacobian
typedef Base::State State
typedef Base::KMatrix KMatrix
typedef Solver<float, Base::dimension> KSolver

Public Functions

inline EqualitySolver(const Bodies &bodies, const F &f)
inline void initSolve(const Proxies &proxies, const F &f)
inline void warmstart(Proxies &proxies, const F &f, float dt)
inline void solveVelocity(Proxies &proxies, const F &f, float dt)
inline void solvePosition(Proxies &proxies, const F &f)

Public Static Attributes

static constexpr Uint32 nBodies = F::nBodies
static constexpr Uint32 dimension = F::dimension

Private Members

KSolver solver_
struct Eval

Public Functions

template<ConstraintFunction F>
inline void operator()(F f)

Public Members

const Proxies &proxies
MatrixRowManipulator<Value> manip = {}
Uint32 i = 0
class Event

Subclassed by simu::Keyboard, simu::Mouse

Public Types

enum class Action

Values:

enumerator release
enumerator press
enumerator repeat
class Exception : public std::exception

Public Functions

inline Exception(const std::string &msg)
inline char const *what() const noexcept override

Private Members

std::string msg_
class ForceField : public simu::PhysicsObject

Subclassed by simu::Gravity, simu::LinearField

Public Types

enum class DomainType

Values:

enumerator global
enumerator region

Public Functions

inline ForceField(Domain domain)
~ForceField() override = default
inline Domain domain() const
virtual void apply(Collider &collider, float dt) const = 0

Public Static Functions

static inline Domain global()
static inline Domain region(Vec2 min, Vec2 max)

Protected Attributes

Domain domain_
struct FrameManifold

Public Members

Uint32 nContacts
std::array<std::array<Vertex, 2>, 2> contacts
Vec2 normal
Vec2 tangent
struct FreeBlock

Public Functions

inline FreeBlock(Byte *start, Byte *end)
inline std::size_t size() const noexcept

Public Members

Byte *start
Byte *end
template<class T, std::size_t blockSize = 32 * 1024>
class FreeListAllocator

Public Types

typedef T value_type
typedef value_type *pointer
typedef std::size_t size_type
typedef std::true_type propagate_on_container_copy_assignment
typedef std::true_type propagate_on_container_move_assignment
typedef std::true_type propagate_on_container_swap

Public Functions

FreeListAllocator()
FreeListAllocator(const FreeListAllocator &other) noexcept
FreeListAllocator &operator=(const FreeListAllocator &other) noexcept
template<class U>
FreeListAllocator(const FreeListAllocator<U, blockSize> &other) noexcept
inline FreeListAllocator select_on_container_copy_construction() const noexcept
pointer allocate(size_type n)
void deallocate(pointer p, size_type n) noexcept
template<class U>
bool operator==(const FreeListAllocator<U, blockSize> &other) const noexcept
template<class U>
bool operator!=(const FreeListAllocator<U, blockSize> &other) const noexcept
template<class U>
FreeListAllocator(const FreeListAllocator<U, sz> &other) noexcept
template<class U>
bool operator==(const FreeListAllocator<U, sz> &other) const noexcept
template<class U>
bool operator!=(const FreeListAllocator<U, sz> &other) const noexcept

Private Members

std::shared_ptr<std::list<Block>> blocks_

Friends

friend class FreeListAllocator
struct GeometricProperties
#include <Geometry.hpp>

Compute properties of some non self-intersecting Geometry.

Convex, concave and geometry containing holes are all valid input. The hole(s) should be of opposite Orientation and attached to a vertex of the outer (solid) perimeter.

if area == 0, then the geometry isDegenerate (collinear) and the properties are undefined but no exception is raised

If vertices are negatively oriented, then the area is negative. Centroid and momentOfArea are unaffected.

Assuming constant density p, then mass = p * |area| inertia = p * momentOfArea

Public Functions

GeometricProperties() = default
template<Geometry T>
GeometricProperties(const T &geometry) noexcept

Public Members

Vec2 centroid = {}
float area = 0.f
float momentOfArea = 0.f
bool isDegenerate = false
template<Geometry T = simu::Polygon>
class Gjk
#include <Gjk.hpp>

Determines if two collidable are in collision as well as the separation/penetration vector between them.

The boolean GJK algorithm is used upon construction and results are saved. If areColliding(), then calling penetration() uses the EPA algorithm (results are not saved)

If the the underlying Geometry of the Collidables is concave or has holes, only their convex hulls are considered.

Warning

changing first or second between construction and calls to any method is undefined.

Public Functions

Gjk(const T &first, const T &second, Vec2 initialDir = Vec2::i())
inline bool areColliding() const
Vec2 separation()

Minimum translation vector such that areColliding() would be true.

It is the vector of the closest feature of first to the closest feature of second

If areColliding(), returns a null vector.

In order to make first and second only touch, both are equivalent:

Vec2 penetration() const

Minimum translation vector such that first and second are only touching.

It is the vector of the penetration of second into first

If not areColliding(), returns a null vector.

In order to make first and second only touch, both are equivalent:

Private Functions

Vec2 furthestVertexInDirection(const Vec2 &direction) const

Private Members

const T &first_
const T &second_
priv::Simplex simplex_
bool done_ = false
bool areColliding_ = false
class Grabber : public simu::Tool

Public Functions

inline Grabber(Scene &scene)
inline virtual void doGui() override
inline virtual const char *getName() const override
virtual bool onMousePress(Mouse::Input input) override
virtual bool onMouseMove(Vec2 pos) override
inline virtual bool onKeypress(Keyboard::Input) override
inline virtual bool onMouseScroll(Vec2) override

Public Static Attributes

static constexpr char name[] = "Grabber"

Private Functions

VisibleMouseConstraint *makeMouseConstraint(Body *b, Vec2 pos)

Private Members

VisibleMouseConstraint *mc_ = nullptr
Scene &scene_
class Gravity : public simu::ForceField

Public Functions

inline explicit Gravity(Vec2 acceleration = Vec2{0, -9.81f})
inline virtual void apply(Collider &collider, float dt) const override

Private Members

Vec2 acceleration_
template<>
struct hash<std::array<simu::Collider*, 2>>

Public Functions

inline size_t operator()(const std::array<simu::Collider*, 2> &colliders) const
class HingeConstraint : public simu::ConstraintImplementation<HingeConstraintFunction>

Public Functions

inline HingeConstraint(const Bodies &bodies, Vec2 worldSpaceSharedPoint, bool disableContacts = true)
class HingeConstraintFunction : public simu::EqualityConstraintFunctionBase<2, 2>

Public Types

typedef EqualityConstraintFunctionBase<2, 2> Base

Public Functions

inline HingeConstraintFunction(const Bodies &bodies, Vec2 worldSpaceSharedPoint)
inline Value eval(const Proxies &proxies) const
inline Value bias(const Proxies&) const
inline Jacobian jacobian(const Proxies &proxies) const

Private Functions

inline std::array<Vec2, nBodies> worldSpacePoints(const Proxies &proxies) const

Private Members

std::array<Vec2, nBodies> localSpaceSharedPoint_
template<Uint32 nBodies_, Uint32 dimension_>
class InequalityConstraintFunctionBase

Public Types

typedef Vector<float, dimension> Value
typedef Matrix<float, dimension, 6> Jacobian

Public Functions

InequalityConstraintFunctionBase() = default
inline Value clampLambda(Value lambda, float) const
inline Value clampPositionLambda(Value lambda) const

Public Static Attributes

static constexpr Uint32 nBodies = nBodies_
static constexpr Uint32 dimension = dimension_
template<ConstraintFunction F>
class InequalitySolver : public simu::ConstraintSolverBase<F>

Public Types

typedef ConstraintSolverBase<F> Base
typedef Base::Value Value
typedef Base::Jacobian Jacobian
typedef Base::State State
typedef Base::KMatrix KMatrix
typedef Solver<float, Base::dimension> KSolver

Public Functions

inline InequalitySolver(const Bodies &bodies, const F &f)
inline void initSolve(const Proxies &proxies, const F &f)
inline void warmstart(Proxies &proxies, const F &f, float dt)
inline void solveVelocity(Proxies &proxies, const F &f, float dt)
inline void solvePosition(Proxies &proxies, const F &f)

Public Static Attributes

static constexpr Uint32 nBodies = F::nBodies
static constexpr Uint32 dimension = F::dimension

Private Members

KMatrix effectiveMass_
struct Input

Public Members

Action action
Modifier modifier
Key key

Public Static Functions

static inline Input fromGlfw(int key, int action, int mods)
struct Input

Public Members

Vec2 pos
Button button
Action action
Keyboard::Modifier modifiers

Public Static Functions

static inline Input fromGlfw(Vec2 pos, int button, int action, int mods)
template<class T>
class Interval
#include <Interval.hpp>

Interval or range of values.

The min and max of the interval are always included. if min > max, then the interval is degenerate and contains nothing. if min == max, the interval contains a single value.

Public Functions

inline Interval(T min, T max)
inline auto contains(T value) const

Returns bool for most types. Returns a ComparisonMatrix if T is a Matrix type.

inline auto overlaps(const Interval &other) const

Private Members

T min_
T max_
template<class T>
Interval<T> approx(T value, T epsilon)

defines an interval for the approximation: value +/- epsilon

struct InvMasses

Public Members

float m0
float I0
float m1
float I1
template<class F>
struct IsCallable : public std::is_invocable_r<R, F, A...>
template<class F>
struct IsCallableStrictReturn : public std::integral_constant<bool, std::is_same_v<std::invoke_result_t<F, A...>, R> && std::is_invocable_r_v<R, F, A...>>
class Island

Public Types

typedef PhysicsObject::PhysicsAlloc Alloc

Public Functions

inline Island(const Alloc &alloc)
Island(const Island&) = delete
Island(Island&&) = delete
inline void init(Body *root)
inline void clear()
inline bool hasConstraints()
inline bool isAwake() const
inline auto bodies()
inline auto constraints()
inline auto contacts()
inline void refreshProxies()
inline void applyVelocityConstraints(Uint32 nIter, bool warmstartEnabled, float dt)
inline void integrateBodies(float dt)
inline void applyPositionConstraints(Uint32 nIter)
inline void endSolve()

Private Functions

inline bool addBody(Body *body)
template<class T, class C>
inline bool addConstraint(T *constraint, C &container)

Private Members

std::vector<Body*, ReboundTo<Alloc, Body*>> bodies_
std::vector<Constraint*, ReboundTo<Alloc, Constraint*>> constraints_
std::vector<ContactConstraint*, ReboundTo<Alloc, ContactConstraint*>> contacts_
std::vector<Position, ReboundTo<Alloc, Position>> positions_
std::vector<Velocity, ReboundTo<Alloc, Velocity>> velocities_
bool isAwake_ = false
template<std::forward_iterator Iter, std::invocable<decltype(*std::declval<Iter>())> Deref>
class Iterator

Public Types

typedef std::remove_reference_t<DerefReturn> value_type
typedef std::iterator_traits<Iter>::difference_type difference_type
typedef value_type &reference
typedef value_type *pointer
typedef std::forward_iterator_tag iterator_category

Public Functions

Iterator() = default
inline Iterator(Iter it, Deref deref)
inline reference operator*() const
inline pointer operator->() const
inline Iterator &operator++()
inline Iterator operator++(int)
inline bool operator==(const Iterator &other) const
inline bool operator!=(const Iterator &other) const

Private Members

Iter it_
Deref deref_
class Iterator

Public Types

typedef const Edge value_type
typedef std::ptrdiff_t difference_type
typedef const Edge *pointer
typedef const Edge &reference
typedef std::input_iterator_tag iterator_category

Public Functions

inline Iterator(Edge e)
inline Iterator &operator++()
inline Iterator operator++(int)
inline bool operator==(const Iterator &other) const
inline bool operator!=(const Iterator &other) const
inline const Edge &operator*() const
inline const Edge *operator->() const

Private Members

Edge e_
template<bool isConst>
class Iterator

Public Types

typedef std::ptrdiff_t difference_type
typedef std::conditional_t<isConst, const RTree::value_type, RTree::value_type> value_type
typedef std::conditional_t<isConst, RTree::const_pointer, RTree::pointer> pointer
typedef std::conditional_t<isConst, RTree::const_reference, RTree::reference> reference
typedef std::forward_iterator_tag iterator_category

Public Functions

inline Iterator(NodePtr n = nullptr)
template<bool otherIsConst> inline  requires (isConst||!otherIsConst) Iterator(const Iterator< otherIsConst > &other)
inline BoundingBox bounds() const
inline Iterator &operator++()
inline Iterator operator++(int)
template<bool otherIsConst>
inline bool operator==(const Iterator<otherIsConst> &other) const
template<bool otherIsConst>
inline bool operator!=(const Iterator<otherIsConst> &other) const
inline reference operator*() const
inline pointer operator->() const

Private Types

typedef std::conditional_t<isConst, const Node*, Node*> NodePtr

Private Functions

inline void goLeft()

Private Members

friend Iterator<!isConst >
friend RTree
NodePtr node

Private Static Functions

static inline Iterator leftmost(NodePtr n)
struct JacobianBuilder

Public Functions

template<ConstraintFunction F>
inline void operator()(F f)

Public Members

const Proxies &proxies
MatrixRowManipulator<Jacobian> manip = {}
Uint32 i = 0
class Keyboard : public simu::Event

Public Types

enum Modifier

Values:

enumerator shift
enumerator control
enumerator alt
enumerator super
enumerator capsLock
enumerator numLock
enum class Key

Values:

enumerator unknown
enumerator space
enumerator apostrophe
enumerator comma
enumerator minus
enumerator period
enumerator slash
enumerator key0
enumerator key1
enumerator key2
enumerator key3
enumerator key4
enumerator key5
enumerator key6
enumerator key7
enumerator key8
enumerator key9
enumerator semicolon
enumerator equal
enumerator A
enumerator B
enumerator C
enumerator D
enumerator E
enumerator F
enumerator G
enumerator H
enumerator I
enumerator J
enumerator K
enumerator L
enumerator M
enumerator N
enumerator O
enumerator P
enumerator Q
enumerator R
enumerator S
enumerator T
enumerator U
enumerator V
enumerator W
enumerator X
enumerator Y
enumerator Z
enumerator leftBracket
enumerator backslash
enumerator rightBracket
enumerator graveAccent
enumerator world1
enumerator world2
enumerator escape
enumerator enter
enumerator tab
enumerator backspace
enumerator insert
enumerator del
enumerator right
enumerator left
enumerator down
enumerator up
enumerator pageUp
enumerator pageDown
enumerator home
enumerator end
enumerator capsLock
enumerator scrollLock
enumerator numLock
enumerator printScreen
enumerator pause
enumerator F1
enumerator F2
enumerator F3
enumerator F4
enumerator F5
enumerator F6
enumerator F7
enumerator F8
enumerator F9
enumerator F10
enumerator F11
enumerator F12
enumerator F13
enumerator F14
enumerator F15
enumerator F16
enumerator F17
enumerator F18
enumerator F19
enumerator F20
enumerator F21
enumerator F22
enumerator F23
enumerator F24
enumerator F25
enumerator keypad0
enumerator keypad1
enumerator keypad2
enumerator keypad3
enumerator keypad4
enumerator keypad5
enumerator keypad6
enumerator keypad7
enumerator keypad8
enumerator keypad9
enumerator keypadDecimal
enumerator keypadDivide
enumerator keypadMultiply
enumerator keypadSubstract
enumerator keypadAdd
enumerator keypadEnter
enumerator keypadEqual
enumerator leftShift
enumerator leftControl
enumerator leftAlt
enumerator leftSuper
enumerator rightShift
enumerator rightControl
enumerator rightAlt
enumerator rightSuper
enumerator menu

Public Static Functions

static bool isPressed(Key key)
struct LambdaClamper

Public Functions

template<ConstraintFunction F>
inline void operator()(F f)

Public Members

MatrixRowManipulator<Value> manip
float dt
Uint32 i = 0
template<class T>
class LcpSolver

Public Functions

inline LcpSolver(const Matrix<T, 2, 2> &A)
template<class U>
inline Vector<Promoted<T, U>, 2> solve(const Vector<U, 2> &b) const
inline Matrix<T, 2, 2> original() const
inline bool isValid() const

Private Members

Solver<T, 2> solver
float invA11
float invA22
template<ConstraintFunction F>
class LimitsSolver : public simu::ConstraintSolverBase<F>

Adds upper and lower limits to a constraint.

Given a constraint of the form C(s): f(s) - a = 0 where f(s) is a function depending on the state of the bodies and a is a constant,

defines the constraints: lower limit: CL(s): C(s) - L >= 0 (f(s) >= a + L) upper limit: CU(s): -C(s) + U >= 0 (f(s) <= a + H) with L and U constant offsets from a, L <= U.

If L == U, then the equality constraint CE(s): f(s) - a - L = 0 is applied

This is not typically used with constraints of more than one dimension.

Public Types

typedef ConstraintSolverBase<F> Base
typedef Base::Value Value
typedef Base::Jacobian Jacobian
typedef Base::State State
typedef Base::KMatrix KMatrix
typedef Solver<float, Base::dimension> KSolver

Public Functions

inline LimitsSolver(Bodies bodies, const F &f)
inline void setLowerLimit(std::optional<Value> L)
inline void setUpperLimit(std::optional<Value> U)
inline bool isActive(const Proxies &proxies, const F &f) const
inline void initSolve(const Proxies &proxies, const F &f)
inline void warmstart(Proxies &proxies, const F &f, float dt)
inline void solveVelocity(Proxies &proxies, const F &f, float dt)
inline void solvePosition(Proxies &proxies, const F &f)

Public Members

KMatrix effectiveMass_
KSolver solver_

Public Static Attributes

static constexpr Uint32 nBodies = F::nBodies
static constexpr Uint32 dimension = F::dimension

Private Types

enum class Func

Values:

enumerator lower
enumerator upper
enumerator equality
enumerator off

Private Functions

inline void assertLimits() const
inline Func nextFunc(const Proxies &proxies, const F &f) const
inline Value rhs(const Proxies &proxies, const F &f, float dt)

Private Members

Func func_ = Func::off
std::optional<Value> L_ = std::nullopt
std::optional<Value> U_ = std::nullopt
union simu::LimitsSolver::[anonymous] [anonymous]
bool canWarmstart_ = false
class LinearField : public simu::ForceField

Public Functions

inline explicit LinearField(Vec2 force, const Domain &domain = ForceField::global())
inline virtual void apply(Collider &collider, float dt) const override

Private Members

Vec2 force_
struct LineBarycentric

Barycentric coordinates of Q for the line A -> B.

closestPoint is the point on A->B closest to Q

The following equation holds if u and v are both greater than 0: closestPoint = u*A + v*B;

coordinates are normalized, they are such that u+v = 1

Public Functions

inline LineBarycentric(Vec2 A, Vec2 B, Vec2 Q)

Public Members

Vec2 closestPoint
float u
float v
class Mass
#include <Body.hpp>

Mass properties of a Body.

The mass and inertia are always strictly positive for a Body.

Public Functions

Mass() = default
inline Mass(float mass, float inertia)
inline Mass(const GeometricProperties &properties, float density)
inline float invMass() const
inline float invInertia() const
inline float mass() const
inline float inertia() const

Private Members

float invMass_ = {}
float invInertia_ = {}
struct MassProperties

Public Functions

MassProperties() = default
template<Geometry G>
inline MassProperties(const G &geometry, float density)

Public Members

float m = 0.f
float I = 0.f
Vec2 centroid = Vec2{}

Friends

inline friend MassProperties operator+(const MassProperties &lhs, const MassProperties &rhs)
struct Material
#include <Material.hpp>

Defines the material of a Collider.

Public Members

float density = 1.f

The weight per unit of area, must be greater than 0.

CombinableProperty bounciness = {0.f, CombinableProperty::average}

How much the body will bounce when colliding with another.

The value should be in [0, 1]. A value of 0 means the object does not bounce at all (all energy is lost) A value of 1 means the object fully bounces (no energy is lost)

behavior is undefined if e <= -1

This value is combined to obtain a coefficient of restitution: https://en.wikipedia.org/wiki/Coefficient_of_restitution

CombinableProperty friction = {0.f, CombinableProperty::average}

How much the body resists to sliding against another.

The value will typically be in [0, 1]. A value of 0 implies a very slippery object (ice)

This value is combined to obtain a coefficient of friction: https://simple.wikipedia.org/wiki/Coefficient_of_friction

CombinableProperty penetration = {0.005f, CombinableProperty::average}

How much penetration the body tolerates during collisions.

This value should be small enough that there is no visible overlapping, while being big enough relative to a Body’s geometry to compute correct ContactManifolds.

It is also used to determine if a ContactManifold is still valid. if the contact points between two bodies are closer than penetration, the contact is considered valid.

This means that the Body

’s geometry’s vertices should have a distance of more

than twice the

Material’s penetration between them.

template<class T, Uint32 m, Uint32 n>
struct Matrix : public simu::MatrixData<T, m, n>, public simu::SpecialConstructors<T, m, n>
#include <Matrix.hpp>

Matrix class for small matrices.

Most operations are provided as global functions

See also

Operations

Public Functions

Matrix() = default
template<class U>
inline explicit Matrix(const Matrix<U, m, n> &other)
inline explicit Matrix(const MatrixData<T, m, n> &data)
inline explicit Matrix(const std::initializer_list<T> &init)
inline Vector<Vector<T, n>, m> asRows() const
inline Vector<Vector<T, m>, n> asCols() const
inline Matrix operator+() const
inline Matrix operator-() const
template<class U>
inline Matrix &operator+=(const Matrix<U, m, n> &other)
template<class U>
inline Matrix &operator-=(const Matrix<U, m, n> &other)
template<class U>
inline Matrix &operator*=(U scalar)
template<class U>
inline Matrix &operator/=(U scalar)
template<class U>
Matrix<T, m, n> fromRows(const std::initializer_list<Vector<U, n>> &rows)
template<class U>
Matrix<T, m, n> fromRows(const Vector<Vector<U, n>, m> &rows)
template<class U>
Matrix<T, m, n> fromCols(const std::initializer_list<Vector<U, m>> &cols)
template<class U>
Matrix<T, m, n> fromCols(const Vector<Vector<U, m>, n> &cols)
template<class U>
Matrix<T, m, n> &operator+=(const Matrix<U, m, n> &other)
template<class U>
Matrix<T, m, n> &operator-=(const Matrix<U, m, n> &other)
template<class U>
Matrix<T, m, n> &operator*=(U scalar)
template<class U>
Matrix<T, m, n> &operator/=(U scalar)

Public Static Functions

static inline Matrix filled(T val)
template<class U>
static inline Matrix fromRows(const std::initializer_list<Vector<U, n>> &rows)
template<class U>
static inline Matrix fromRows(const Vector<Vector<U, n>, m> &rows)
template<class U>
static inline Matrix fromCols(const std::initializer_list<Vector<U, m>> &cols)
template<class U>
static inline Matrix fromCols(const Vector<Vector<U, m>, n> &cols)
template<class T, Uint32 mRows_, Uint32 nCols_>
struct MatrixData
#include <Matrix.hpp>

Matrix data, stored row-major.

Two methods for random access are provided, For matrices, mat(i, j) is recommended For vectors, vec[i] is recommended

Direct access to the data member is allowed, but for matrices it is preferable to use operator() to avoid errors

Subclassed by simu::Matrix< float, dimension >, simu::Matrix< float, 3, 3 >, simu::Matrix< Uint8, 4 >, simu::Matrix< float, 2 >, simu::Matrix< float, 2, 6 >

Public Types

typedef T value_type
typedef T *iterator
typedef const T *const_iterator

Public Functions

MatrixData() = default
template<class U>
inline explicit MatrixData(const MatrixData<U, mRows_, nCols_> &other)
inline T &operator()(Uint32 row, Uint32 col)
inline const T &operator()(Uint32 row, Uint32 col) const
inline T &operator[](Uint32 index)
inline const T &operator[](Uint32 index) const
inline iterator begin()
inline iterator end()
inline const_iterator begin() const
inline const_iterator end() const
template<class U>
MatrixData(const MatrixData<U, m, n> &other)

Public Members

T data[mRows * nCols]

Public Static Functions

static inline constexpr Uint32 size()

Public Static Attributes

static constexpr Uint32 mRows = mRows_
static constexpr Uint32 nCols = nCols_
template<class MatrixT>
class MatrixRowManipulator

Public Functions

inline MatrixRowManipulator()
inline MatrixRowManipulator(const MatrixT &m)
inline operator MatrixT()
template<class SubMatrixT>
inline void assign(Uint32 begin, const SubMatrixT &subMat)
template<Uint32 dim>
inline auto extract(Uint32 begin)

Private Types

typedef MatrixRows::value_type Row

Private Members

decltype(std::declval< MatrixT >().asRows()) typedef MatrixRows
MatrixRows rows_
template<Uint32 dimension_>
class MotorFunctionBase

Public Types

typedef Vector<float, dimension> Value
typedef Matrix<float, dimension, 6> Jacobian

Public Functions

inline MotorFunctionBase(float maxVelocity, float maxForce)
inline Value eval(const Proxies&) const
inline Value bias(const Proxies&) const
inline Value clampLambda(Value lambda, float dt) const
inline Value clampPositionLambda(Value) const
inline float throttle() const
inline void throttle(float throttle)
inline Value direction() const
inline void direction(Value direction)

Public Static Attributes

static constexpr Uint32 nBodies = 1
static constexpr Uint32 dimension = dimension_

Private Members

float throttle_ = 1.f
Value direction_ = {}
float maxVelocity_
float maxForce_
class Mouse : public simu::Event

Public Types

enum class Button

Values:

enumerator button1
enumerator button2
enumerator button3
enumerator button4
enumerator button5
enumerator button6
enumerator button7
enumerator button8
enumerator left
enumerator right
enumerator middle
class MouseConstraint : public simu::ConstraintImplementation<MouseConstraintFunction>

Subclassed by simu::VisibleMouseConstraint

Public Functions

inline MouseConstraint(Body *body, Vec2 pos)
inline Vec2 bodyPos() const
inline Vec2 mousePos() const
inline void updateMousePos(Vec2 pos)
inline virtual void solvePositions(Proxies&) override
class MouseConstraintFunction : public simu::EqualityConstraintFunctionBase<1, 2>

Public Types

typedef EqualityConstraintFunctionBase<1, 2> Base

Public Functions

inline MouseConstraintFunction(Body *body, Vec2 pos)
inline Value eval(const Proxies &proxy) const
inline Value bias(const Proxies&) const
inline Jacobian jacobian(const Proxies &proxy) const
inline Vec2 mousePos() const
inline Vec2 localBodyPos() const
inline void updateMousePos(Vec2 pos)

Private Functions

inline Vec2 worldBodyPos(const Proxies &proxy) const

Private Members

Vec2 mousePos_
Vec2 localBodyPos_
struct Node

Public Functions

inline Node(const BoundingBox &bounds, pointer value = nullptr)
inline bool isRoot() const
inline bool isLeaf() const
inline bool isLeft() const
inline bool isRight() const
inline void setLeft(Node *node)
inline void setRight(Node *node)
inline void replaceChild(Node *child, Node *newChild)
inline void replaceBy(Node *replacement)
inline Node *&childHandle(Node *child)
inline Node *&otherChildHandle(Node *child)
inline Node *&handle()
inline Node *&sibling()

Public Members

Node *parent = nullptr
Node *left = nullptr
Node *right = nullptr
BoundingBox bounds
pointer data = nullptr
class NoTool : public simu::Tool

Public Functions

NoTool() = default
inline virtual void doGui() override
inline virtual const char *getName() const override
inline virtual bool onKeypress(Keyboard::Input) override
inline virtual bool onMousePress(Mouse::Input) override
inline virtual bool onMouseMove(Vec2) override
inline virtual bool onMouseScroll(Vec2) override

Public Static Attributes

static constexpr char name[] = "No Tool"
template<ConstraintFunction... Fs>
struct NProxies : public std::integral_constant<Uint32, 0>
template<ConstraintFunction F>
struct NProxies<F> : public std::integral_constant<Uint32, F::nBodies>
template<ConstraintFunction F1, ConstraintFunction F2, ConstraintFunction... Fs>
struct NProxies<F1, F2, Fs...> : public simu::details::NProxies<F1>
class OpenGlRenderer : public simu::Renderer

Public Functions

OpenGlRenderer()
~OpenGlRenderer() override
virtual void drawPolygon(Vec2 center, Poly vertices, Rgba color) override
virtual void flush() override
virtual void fillScreen(Rgba color) override
virtual void setViewport(Vec2i lowerLeft, Vec2i dim) override

Private Types

typedef Vector<float, 4> FloatRgba

Private Members

std::vector<Vertex, typename Alloc::rebind<Vertex>::other> vertices_ = {}
std::vector<Uint16, typename Alloc::rebind<Uint16>::other> indices_ = {}
unsigned int programId_
unsigned int cameraTransformBinding_
unsigned int vao_
unsigned int vbo_
unsigned int ebo_

Private Static Attributes

static const std::size_t maxVertices_ = 1024
static const char *const vertexShaderSrc_
static const char *const fragmentShaderSrc_
class OverlapList

Public Types

typedef ReboundTo<Allocator, Node*> Alloc

Public Functions

inline OverlapList(const Alloc &alloc = Alloc{})
inline OverlapList(const ViewType<iterator*> &iterators, const Alloc &alloc = Alloc{})
inline OverlapList(const OverlapList &other)
OverlapList(OverlapList &&other) = default
inline void addOverlapping(Node *node)
inline void sortOverlapping(const BoundingBox &box)
inline auto overlapping()
inline auto overlapping() const
inline void setMiddle(std::size_t middle)
inline std::size_t middle() const

Private Members

std::vector<Node*, Alloc> nodes_ = {}
std::size_t middle_ = {}
template<class ...Args>
struct Pack
class PhysicsObject
#include <PhysicsObject.hpp>

Base class of physics objects.

The lifetime of physics objects is managed by World. Instead of explicitly removing them from the world, objects must specify themselves when they should be removed.

Objects will be removed if they are killed with PhysicsObject::kill() or when some condition is satisfied in the virtual PhysicsObject::shouldDie() method.

The actual removal will be done at the beginning of World::step(). Since some objects may want to remove themselves once some other object dies, no object is truly removed until PhysicsObject::isDead() is called on all objects of the world. This means that objects can query other objects in their shouldDie() method without worrying about accessing released memory. The shouldDie() method can also be used to update references to dying objects (which is why it is not const).

Some objects may want to spawn objects when they are created and kill them when they are destroyed, this can be done with PhysicsObject::onConstruction(world) and PhysicsObject::onDestruction(world). Again, onDestruction will be called for all objects that will be destroyed before any object is truly removed and their memory released.

Subclassed by simu::Body, simu::Constraint, simu::ForceField

Public Types

typedef FreeListAllocator<PhysicsObject> PhysicsAlloc

Public Functions

virtual ~PhysicsObject() = default
inline bool isDead() const
inline void kill()

Protected Functions

inline virtual void setAllocator(const PhysicsAlloc&)
inline virtual void onConstruction(World&)

Called when a World creates this object.

Subclasses should always call Base::onConstruction

inline virtual void onDestruction(World&)

Called when a World destroys this object.

Subclasses should always call Base::onDestruction

See also

onKill

inline virtual void onKill()

Called when this object is requested to die (by a call to kill())

Subclasses should always call Base::onKill

This is different from onDestruction since this object is not destroyed immediately after this call. It will be destroyed the next time World::step is called on the World owning this object.

This method should be used to kill other objects linked to this one. For example a composed Body may create other objects with onConstruction, keep a reference to them and kill them when it is killed with onKill.

inline virtual bool shouldDie() const

Offers an alternative death condition than this->kill().

Subclasses should always consider if Base::shouldDie() is true.

Example: a Constraint that is broken if the force it applies exceeds a treshold can implement this death condition in shouldDie.

inline virtual void preStep()

Called at the start of World::step, after dead objects are removed.

Subclasses should always call Base::preStep().

This is called for Body, Constraint and then for ForceField.

inline virtual void postStep()

Called at the end of World::step.

Subclasses should always call Base::postStep().

This is called for Body, Constraint and then for ForceField.

Protected Attributes

friend World

Private Members

bool killed_ = false
class Polygon
#include <Polygon.hpp>

A polygon has at least 3 vertices in a positive Orientation.

Polygons are allowed to be concave and have holes as long as they do not self-intersect, in which case behavior is undefined.

The vertices are reordered to be positively oriented. The GeometricProperties are modified to reflect this change.

Polygons are not allowed to modify their vertices after construction.

Warning

no special measures are taken if properties indicate that the geometry isDegenerate.

Public Functions

inline Polygon(const std::initializer_list<Vertex> &vertices)
template<VertexIterator2D It>
Polygon(It begin, It end)
inline GeometricProperties properties() const
inline Vertices::const_iterator begin() const
inline Vertices::const_iterator end() const
inline auto vertexView() const

Public Static Functions

static inline Polygon box(Vec2 dim, Vec2 center = Vec2{})

Private Members

GeometricProperties properties_
Vertices vertices_
struct Polytope

Public Types

typedef Edges<Vertices>::Edge Edge

Public Functions

inline Polytope(const Simplex &simplex)
inline bool addVertex(const Edge &where, Vertex v)

Public Members

Vertices vertices = {}
class Position

Public Functions

inline Position(Vec2 position, float orientation, Vec2 localCentroid)
inline Vec2 position() const
inline float orientation() const
inline Vec2 centroid() const
inline Vec2 localCentroid() const
inline void advance(Vec2 dPos, float dTheta)
inline Transform toWorldSpace() const
inline Transform toLocalSpace() const
inline void setLocalCentroid(Vec2 c)

Private Members

Translation pos_
Rotation orientation_
Translation localCentroid_
struct PosLambdaClamper

Public Functions

template<ConstraintFunction F>
inline void operator()(F f)

Public Members

MatrixRowManipulator<Value> manip
Uint32 i = 0
struct Profiler

Public Functions

Profiler() = default
inline void reset()

Public Members

TimeEntry treeUpdateAndCollision = {}
TimeEntry narrowPhaseCollision = {}
Uint32 treeHeight = {}
TimeEntry islandConstruction = {}
TimeEntry solveVelocities = {}
TimeEntry solvePositions = {}
class Proxies

Public Types

typedef Vector<float, 3 * n> State
typedef State VelocityVec
typedef State Impulse
typedef Matrix<float, 3 * n, 3 * n> Mass
typedef Vector<float, 3 * n> MassVec
typedef Vector<float, n> Dominance

Public Functions

Proxies() = default
inline Proxies(const SolverProxy &p0, const SolverProxy &p1, const InvMasses &masses)
inline SolverProxy const *begin() const
inline SolverProxy const *end() const
inline SolverProxy *begin()
inline SolverProxy *end()
inline SolverProxy &operator[](Uint32 index)
inline const SolverProxy &operator[](Uint32 index) const
inline void applyImpulse(const Impulse &impulse)
inline void applyPositionCorrection(const State &correction)
inline VelocityVec velocity() const
inline const InvMasses &invMasses() const
inline MassVec invMassVec() const
inline Mass inverseMass() const

Public Static Attributes

static constexpr Uint32 n = 2

Private Members

std::array<SolverProxy, 2> proxies_
InvMasses invMasses_
class Random

Public Static Functions

template<class Dist>
static inline auto generate(Dist &dist)
template<class Dist, class ...Args>
static inline auto generate(Args&&... args)
template<std::integral T>
static inline T uniform(T min, T max)
requires (sizeof(T) > 1)
template<std::floating_point T>
static inline T uniform(T min, T max)

Private Static Attributes

static std::mt19937_64 engine_
template<class U>
struct rebind

Public Types

typedef FreeListAllocator<U, blockSize> other
class RecycleBin

Public Types

typedef ReboundTo<Allocator, Node*> Alloc

Public Functions

inline RecycleBin(RTree &tree, Alloc alloc)
inline ~RecycleBin()
inline void recycleSubTree(Node *subRoot)
inline void recycle(Node *node)
inline Node *getNode()

Private Members

std::vector<Node*, Alloc> bin_
RTree &tree_
class Renderer

Subclassed by simu::OpenGlRenderer

Public Types

enum class Contour

Values:

enumerator outside
enumerator inside
enumerator over
enum class LineTip

Values:

enumerator square
enumerator triangle
enumerator rounded
typedef ViewType<const Vec2*> Poly

Public Functions

inline Renderer()
virtual ~Renderer() = default
virtual void drawPolygon(Vec2 center, Poly vertices, Rgba color) = 0
virtual void flush() = 0
virtual void fillScreen(Rgba color) = 0
virtual void setViewport(Vec2i lowerLeft, Vec2i dim) = 0
void setCameraTransform(const Mat3 &cameraTransform)
const Mat3 &cameraTransform() const
void drawContouredPolygon(Vec2 center, Poly vertices, Rgba fillColor, Rgba contourColor, float contourWidth, Contour contour = Contour::outside)
void drawTriangle(Vec2 A, Vec2 B, Vec2 C, Rgba color)
inline float getLineWidth() const
inline void setLineWidth(float width)
void drawLine(Vec2 A, Vec2 B, Rgba color, LineTip tip = LineTip::square)
inline float getPointRadius() const
inline void setPointRadius(float radius)
inline Uint32 getPointPrecision() const
inline void setPointPrecision(Uint32 precision)
void drawPoint(Vec2 P, Rgba color)

Protected Types

typedef FreeListAllocator<Vec2> Alloc

Protected Attributes

Alloc alloc

Private Types

typedef std::vector<Vec2, Alloc> Vertices

Private Functions

void updatePointOffsets(float radius, Uint32 precision)

Private Members

Vertices v_
Vertices pointOffsets_
Mat3 cameraTransform_
float lineWidth_ = 1.f
float pointRadius_ = 1.f
class Rotation

Public Functions

inline explicit Rotation(float theta)
inline explicit operator Mat3() const
inline Rotation inverse() const
inline float theta() const
inline void set(float theta)
inline Vec2 operator*(const Vec2 &v) const
inline Rotation &operator*=(const Rotation &other)
inline Rotation operator*(const Rotation &other) const

Private Functions

inline Rotation(float theta, float c, float s)

Private Members

float theta_
float cosine
float sine
class RotationConstraint : public simu::ConstraintImplementation<RotationConstraintFunction>

Public Functions

inline RotationConstraint(const Bodies &bodies, bool disableContacts = true)
class RotationConstraintFunction : public simu::EqualityConstraintFunctionBase<2, 1>

Public Types

typedef EqualityConstraintFunctionBase<2, 1> Base

Public Functions

inline RotationConstraintFunction(const Bodies &bodies)
inline Value eval(const Proxies &proxies) const
inline Value bias(const Proxies&) const
inline Jacobian jacobian(const Proxies&) const

Private Members

Value initialAngle_
class RotationMotor : public simu::ConstraintImplementation<RotationMotorFunction>

Public Types

typedef RotationMotorFunction F
typedef ConstraintImplementation<F> Base

Public Functions

inline RotationMotor(const Bodies &bodies, Specs specs)
inline float throttle() const
inline void throttle(float throttle)
inline Value direction() const
inline void direction(Value direction)
class RotationMotorFunction : public simu::MotorFunctionBase<1>

Public Types

typedef MotorFunctionBase<1> Base

Public Functions

inline RotationMotorFunction(float maxAngularVelocity, float maxTorque)
inline Jacobian jacobian(const Proxies&) const
template<class T, class Allocator = std::allocator<T>>
class RTree

Public Types

typedef T value_type
typedef T *pointer
typedef const T *const_pointer
typedef T &reference
typedef const T &const_reference
typedef Iterator<false> iterator
typedef Iterator<true> const_iterator

Public Functions

inline RTree(const Allocator &alloc = Allocator{})
inline ~RTree()
RTree(const RTree &other) = delete
RTree &operator=(const RTree &other) = delete
inline RTree(RTree &&other) noexcept
inline RTree &operator=(RTree &&other) noexcept
template<Callable<void(iterator)> F>
inline void forEachIn(BoundingBox box, const F &func)
template<Callable<void(iterator)> F>
inline void forEachAt(Vec2 point, const F &func)
template<Callable<void(iterator)> F>
inline void forEachOverlapping(iterator it, const F &func)
template<Callable<void(iterator, iterator)> F>
inline void forEachOverlapping(const ViewType<iterator*> &iterators, const F &func)
template<Callable<BoundingBox(iterator)> Update, Callable<void(iterator, iterator)> OnCollision>
inline void updateAndCollide(const Update &update, const OnCollision &onCollision)
inline iterator begin()
inline iterator end()
inline const_iterator begin() const
inline const_iterator end() const
inline iterator insert(BoundingBox bounds, const_reference val)
template<class ...Args>
inline iterator emplace(BoundingBox bounds, Args&&... args)
inline iterator erase(iterator it)
inline iterator update(iterator it, BoundingBox newBounds)
inline void clear()
inline bool isEmpty() const
inline std::size_t size() const
inline BoundingBox bounds() const
inline BoundingBox bounds(const_iterator it) const
inline Uint32 height() const

Private Types

typedef std::allocator_traits<Allocator> AllocTraits
typedef AllocTraits::template rebind_alloc<Node> NodeAllocator
typedef AllocTraits::template rebind_traits<Node> NodeAllocTraits

Private Functions

inline Node *makeNode(const BoundingBox &bounds = BoundingBox{})
template<class ...Args>
inline Node *makeLeaf(const BoundingBox &bounds, Args&&... args)
inline void deleteNode(Node *node)
inline void swapNodes(Node *first, Node *second)
inline void checkRotations(Node *grandParent)
inline void checkRotation(Node *upper, Node *lower)
inline void refit(Node *node)
inline void addLeafTo(Node *node, Node *leaf)
inline float area(BoundingBox bounds)
inline BoundingBox bounds(Node *node)
inline iterator insert(Node *node)
inline Node *extract(Node *node)
inline void erase(Node *node)
inline Uint32 height(const Node *subRoot) const
inline std::size_t size(Node *node) const
template<class F>
inline void forEachIn(const BoundingBox &box, const F &func, Node *node)
template<class F>
inline void forEachOverlapping(Node *node, const F &func)
template<class F>
inline void forEachOverlapping(Node *subRoot, OverlapList &list, const F &func)
template<class OnCollision>
inline Node *updateAndCollide(ViewType<Node**> nodes, OverlapList collisions, const OnCollision &onCollision, RecycleBin &bin)
inline void update(Node *node, BoundingBox newBounds)

Private Members

Allocator alloc_
NodeAllocator nodeAlloc_ = {alloc_}
Node *root_
class Scene

Public Functions

inline Scene()
virtual ~Scene() = default
inline bool isInit() const
inline void reset()
inline void setPlaySpeed(float speed)
inline float playSpeed() const
inline void resume()
inline void pause()
inline bool isPaused() const
inline void step(float dt)
inline Camera &camera()
inline const Camera &camera() const
inline Application *app()
inline const Application *app() const
inline World &world()
inline const World &world() const

Protected Functions

inline Renderer *getRenderer() const
virtual void init(Renderer &renderer) = 0
inline virtual void doGui()
inline virtual void onClear()
inline virtual void preStep(float)
inline virtual void postStep(float)
virtual void moveCamera(float dt)
virtual bool onKeypress(Keyboard::Input input)
inline virtual bool onMousePress(Mouse::Input)
inline virtual bool onMouseMove(Vec2)
virtual bool onMouseScroll(Vec2 scroll)
template<std::derived_from<Tool> T, class ...Args>
inline T *registerTool(Args&&... args)
inline void registerAllTools()
template<std::derived_from<Tool> T>
inline T *useTool()
inline Tool *useTool(const std::string &name)
inline Tool *currentTool() const

Private Functions

void init(Application *app)
void keypress(Keyboard::Input input)
void mousePress(Mouse::Input input)
void mouseMove(Vec2 newPos)
void mouseScroll(Vec2 scroll)

Private Members

friend Application
World world_ = {}
Camera camera_ = {}
Tool *tool_ = nullptr
std::list<std::unique_ptr<Tool>> tools_ = {}
Renderer *renderer_ = nullptr
Application *app_ = nullptr
float playSpeed_ = 1.f
bool isPaused_ = false
bool isInit_ = false
class ScopedTimer
struct Settings

Public Members

Uint32 nVelocityIterations = 8

Number of velocity solver iterations.

Uint32 nPositionIterations = 2

Number of position solver iterations.

bool enableWarmstarting = true

Enable constraints to guess impulse based on previous step.

bool enableSleeping = false
float inactivitySleepDelay = 1.f
float velocitySleepThreshold = 1e-3f
float angularVelocitySleepThreshold = 1e-3f
template<class Signature>
struct SignatureDecomposition
template<class R, class ...A>
struct SignatureDecomposition<R(A...)>

Public Types

typedef R Return
typedef Pack<A...> Args
struct Simplex

Public Functions

inline Simplex(Vec2 initialSearchDir = Vec2::i())
inline void pushPoint(Vertex v)
inline Vec2 nextDirection() const
inline bool hasPoint(Vertex v) const
inline bool containsOrigin() const

Public Members

std::array<Vertex, 3> pointStack = {}
std::array<Vec2, 3> normals = {}
Vec2 initialSearchDir_
Uint32 nIterations = 0

Private Members

mutable bool keepBottomPoint_ = false
template<class T, Uint32 n>
class Solver

Public Functions

inline Solver(const Matrix<T, n, n> &A)
template<class U>
inline Vector<Promoted<T, U>, n> solve(const Vector<U, n> &b) const
inline Matrix<T, n, n> original() const
inline bool isValid() const

Private Members

Matrix<T, n, n> QT_
Matrix<T, n, n> R_
bool isValid_ = true
template<class T>
class Solver<T, 2>

Public Functions

inline Solver(const Matrix<T, 2, 2> &A)
template<class U>
inline Vector<Promoted<T, U>, 2> solve(const Vector<U, 2> &b) const
inline Matrix<T, 2, 2> original() const
inline bool isValid() const

Private Members

Matrix<T, 2, 2> A_
T invDet_
bool isValid_

Friends

friend class LcpSolver
class SolverProxy

Public Functions

SolverProxy() = default
inline SolverProxy(Position *p, Velocity *v)
inline void advancePos(Vec2 dPos, float dTheta)
inline void incrementVel(Vec2 dv, float dw)
inline void setVelocity(Vec2 velocity, float angularVelocity)
inline Vec2 position() const
inline float orientation() const
inline Vec2 velocity() const
inline float angularVelocity() const
inline Vec2 centroid() const
inline Transform toWorldSpace() const

Private Members

Position *position_ = nullptr
Velocity *velocity_ = nullptr

Friends

friend class Bodies
friend class Proxies
template<class T, Uint32 m, Uint32 n, bool isSquare = (m == n)>
struct SpecialConstructors

Subclassed by simu::Matrix< float, dimension >, simu::Matrix< T, n, n >, simu::Matrix< T, 2, 2 >, simu::Matrix< float, 3, 3 >, simu::Matrix< Uint8, 4 >, simu::Matrix< float, 2 >, simu::Matrix< float, 2, 6 >, simu::Matrix< T, m, n >

template<class T, Uint32 dim>
struct SpecialConstructors<T, dim, 1, false>

Public Static Functions

static inline Vector<T, dim> i()
static inline Vector<T, dim> j()
static inline Vector<T, dim> k()
static inline Vector<T, dim> w()
template<class T, Uint32 dim>
struct SpecialConstructors<T, dim, dim, true>

Public Static Functions

static inline Matrix<T, dim, dim> identity()
static inline Matrix<T, dim, dim> diagonal(const Vector<T, dim> &elements)
class Specs

Public Functions

inline float maxAngularVelocity() const
inline float maxTorque(const Bodies &body) const

Public Static Functions

static inline Specs fromTorque(float maxAngularVelocity, float maxTorque)
static inline Specs fromAccel(float maxAngularVelocity, float maxAngularAccel, std::optional<float> targetInertia = std::nullopt)
static inline Specs fromTargetForce(float maxAngularVelocity, float radius, float targetForceAtCentroid)

Private Members

float maxAngularVelocity_ = {}
std::optional<float> maxAccel_ = {}
std::optional<float> maxTorque_ = {}
class Specs

Public Functions

inline float maxVelocity() const
inline float maxForce(const Bodies &body) const

Public Static Functions

static inline Specs fromForce(float maxVelocity, float maxForce)
static inline Specs fromAccel(float maxVelocity, float maxAccel, std::optional<float> targetMass = std::nullopt)

Private Members

float maxVelocity_ = {}
std::optional<float> maxAccel_ = {}
std::optional<float> maxForce_ = {}
class TimeEntry

Public Types

typedef std::chrono::steady_clock Clock
typedef Clock::time_point TimePoint
typedef Clock::duration Duration
typedef std::chrono::duration<double> Seconds

Public Functions

TimeEntry() = default
inline double last() const
inline double average() const
inline double max() const
inline Int64 nMeasures() const
inline ScopedTimer time()
inline void startPartial()
inline ScopedTimer timePartial()
inline void commitPartial()

Private Functions

inline void addMeasure(Seconds seconds)

Private Members

Seconds last_ = {0.0}
Seconds average_ = {0.0}
Seconds max_ = {0.0}
Int64 nMeasures_ = 0
class Tool

Subclassed by simu::BoxSpawner, simu::Grabber, simu::NoTool

Public Functions

Tool() = default
virtual ~Tool() = default
virtual void doGui() = 0
inline virtual const char *getName() const
virtual bool onKeypress(Keyboard::Input input) = 0
virtual bool onMousePress(Mouse::Input input) = 0
virtual bool onMouseMove(Vec2 newPos) = 0
virtual bool onMouseScroll(Vec2 scroll) = 0
class Transform

Public Functions

inline explicit Transform()
inline Transform(Rotation r, Translation t)
inline explicit operator Mat3() const
inline Transform inverse() const
inline const Rotation &rotation() const

The rotation part of this transform.

inline Rotation &rotation()
inline const Translation &translation() const

The translation part of this transform.

inline Translation &translation()
inline Vec2 operator*(const Vec2 &v) const

Public Static Functions

static inline Transform identity()

No-op transformation.

static inline Rotation rotation(float theta)

Rotates a 2D vector by theta radians around the origin {0, 0}.

static inline Translation translation(Vec2 offset)

Translate a 2D vector by offset.

static inline Transform transformAround(float theta, Vec2 offset, Vec2 transformOrigin)

Rotates around transformOrigin by theta radians and then translates by offset.

Private Members

Rotation r_
Translation t_
class Translation

Public Functions

inline explicit Translation(Vec2 offset)
inline explicit operator Mat3() const
inline Translation inverse() const
inline Vec2 offset() const
inline void set(Vec2 offset)
inline Vec2 operator*(const Vec2 &v) const
inline Translation operator*=(const Translation &other)
inline Translation operator*(const Translation &other) const

Private Members

Vec2 offset_
class TranslationMotor : public simu::ConstraintImplementation<TranslationMotorFunction>

Public Types

typedef TranslationMotorFunction F
typedef ConstraintImplementation<F> Base

Public Functions

inline TranslationMotor(const Bodies &bodies, Specs specs)
inline float throttle() const
inline void throttle(float throttle)
inline Value direction() const
inline void direction(Value direction)
class TranslationMotorFunction : public simu::MotorFunctionBase<2>

Public Types

typedef MotorFunctionBase<2> Base

Public Functions

inline TranslationMotorFunction(float maxVelocity, float maxForce)
inline Jacobian jacobian(const Proxies&) const
struct TriangleBarycentric

Barycentric coordinates of Q for the triangle ABC.

ABC can be given in any winding order.

closestPoint will be on vertices or edges if Q is outside ABC, else closestPoint = Q.

Warning

coordinates are not normalized, they are such that u+v+w = abs(area(ABC))

Public Functions

TriangleBarycentric(Vec2 A, Vec2 B, Vec2 C, Vec2 Q)

Public Members

LineBarycentric AB
LineBarycentric BC
LineBarycentric CA
Vec2 closestPoint
float u
float v
float w
class Velocity

Public Functions

Velocity() = default
inline Velocity(Vec2 linear, float angular)
inline Vec2 linear() const
inline void setLinear(Vec2 v)
inline float angular() const
inline void setAngular(float w)
inline void set(Vec2 v, float w)
inline void increment(Vec2 dLinear, float dAngular)

Private Members

Vec2 linear_
float angular_
struct Vertex

Public Functions

inline Vertex(Vec2 pos, Rgba color)

Public Members

Vec2 pos
Rgba color
class Visible

Subclassed by simu::VisibleBody, simu::VisibleContactConstraint, simu::VisibleDistanceConstraint, simu::VisibleMouseConstraint

Public Functions

inline Visible(Renderer *renderer)
virtual ~Visible() = default
inline void draw()

Protected Functions

virtual void draw(Renderer &renderer) = 0

Private Members

Renderer *renderer_
class VisibleBody : public simu::Body, public simu::Visible

Public Functions

inline VisibleBody(BodyDescriptor descr, Rgba color, Renderer *renderer)

Protected Functions

inline virtual void postStep() override

Called at the end of World::step.

Subclasses should always call Base::postStep().

This is called for Body, Constraint and then for ForceField.

inline virtual void draw(Renderer &renderer) override

Private Members

Rgba color_
class VisibleContactConstraint : public simu::ContactConstraint, public simu::Visible

Public Functions

inline VisibleContactConstraint(Collider &first, Collider &second, Renderer *renderer)

Protected Functions

inline virtual void postStep() override

Called at the end of World::step.

Subclasses should always call Base::postStep().

This is called for Body, Constraint and then for ForceField.

inline virtual void draw(Renderer &renderer) override
class VisibleDistanceConstraint : public simu::DistanceConstraint, public simu::Visible

Public Functions

inline VisibleDistanceConstraint(const Bodies &bodies, std::array<Vec2, 2> fixedPoints, Renderer *renderer, bool disableContacts = true)
inline VisibleDistanceConstraint(const Bodies &bodies, std::array<Vec2, 2> fixedPoints, float distance, Renderer *renderer, bool disableContacts = true)
inline VisibleDistanceConstraint(const Bodies &bodies, std::array<Vec2, 2> fixedPoints, std::optional<float> minDistance, std::optional<float> maxDistance, Renderer *renderer, bool disableContacts = true)

Protected Functions

inline virtual void postStep() override

Called at the end of World::step.

Subclasses should always call Base::postStep().

This is called for Body, Constraint and then for ForceField.

inline virtual void draw(Renderer &renderer) override
class VisibleMouseConstraint : public simu::MouseConstraint, public simu::Visible

Public Functions

inline VisibleMouseConstraint(Body *b, Vec2 pos, Renderer *renderer)

Protected Functions

inline virtual void postStep() override

Called at the end of World::step.

Subclasses should always call Base::postStep().

This is called for Body, Constraint and then for ForceField.

inline virtual void draw(Renderer &renderer) override
class WeldConstraint : public simu::ConstraintImplementation<WeldConstraintFunction>

Public Functions

inline WeldConstraint(const Bodies &bodies, bool disableContacts = true)

Private Static Functions

static inline Vec2 centroidMidPoint(const Bodies &bodies)
static inline F makeWeldFunction(const Bodies &bodies)
class World
#include <World.hpp>

The World class makes the ForceField, Body and Constraint classes interact.

Collisions are detected discretely, and the corresponding constraints are managed by the world.

The World owns all objects that are put into it. For object lifetime management, see PhysicsObject.

Public Types

typedef PhysicsObject::PhysicsAlloc Alloc
typedef ReboundTo<Alloc, UniquePtr<ContactConstraint>> ContactAlloc
std::function< UniquePtr< ContactConstraint >Collider &, Collider &, const ContactAlloc &)> ContactFactory

Public Functions

World(ContactFactory makeContact = defaultContactFactory)

Construct an empty world.

World(const World &other) = delete
World(World &&other) = delete
inline void clear()
inline void setContactFactory(ContactFactory makeContact)
inline auto bodies()

Gives a view over the Bodies in the world.

ie for ( [const] Body& body : world.bodies())

inline auto bodies() const
inline auto forceFields()

Gives a view over the ForceFields in the world.

ie for ( [const] ForceField& force : world.forceFields())

inline auto forceFields() const
inline auto constraints()

Gives a view over the Constraints in the world.

ie for ( [const] Constraint& constraint : world.constraints())

inline auto constraints() const
inline auto contacts()

Gives a view over the ContactConstraints in the world.

ie for ( [const] ContactConstraint& contact : world.contacts())

inline auto contacts() const
template<std::derived_from<Body> T, class ...Args>
inline T *makeBody(Args&&... args)

Construct a Body and puts it in the world.

inline Body *makeBody(const BodyDescriptor &descr)
template<std::derived_from<Constraint> T, class ...Args>
inline T *makeConstraint(Args&&... args)

Construct a Constraint and puts it in the world.

template<std::derived_from<ForceField> T, class ...Args>
inline T *makeForceField(Args&&... args)

Construct a ForceField and puts it in the world.

void step(float dt)

Makes the world progress in time.

ForceFields are applied to non-structural bodies, contacts are updated, killed objects are removed, constraints are enforce and bodies are moved.

inline void updateSettings(const Settings &settings)

Updates the world’s settings.

inline const Settings &settings() const

Read the world’s settings.

template<Callable<void(Body*)> F>
inline void forEachIn(BoundingBox box, const F &func)
template<Callable<void(Body*)> F>
inline void forEachAt(Vec2 point, const F &func)
inline Profiler &profiler()
inline const Profiler &profiler() const

Public Static Attributes

static ContactFactory defaultContactFactory

Private Types

typedef ReboundTo<Alloc, UniquePtr<Body>> BodyAlloc
typedef ReboundTo<Alloc, UniquePtr<Constraint>> ConstraintAlloc
typedef ReboundTo<Alloc, UniquePtr<ForceField>> ForceFieldAlloc
typedef std::list<UniquePtr<Constraint>, ConstraintAlloc> ConstraintList
typedef std::list<UniquePtr<ForceField>, ForceFieldAlloc> ForceFieldList
typedef std::unordered_map<std::array<simu::Collider*, 2>, ContactStatus, std::hash<std::array<simu::Collider*, 2>>, std::equal_to<std::array<simu::Collider*, 2>>, ReboundTo<Alloc, std::pair<const std::array<simu::Collider*, 2>, ContactStatus>>> ContactList
typedef std::list<UniquePtr<Body>, BodyAlloc> BodyList

Private Functions

inline void addCollider(Collider *collider)
void removeCollider(Collider *collider)
UniquePtr<ContactConstraint> makeContactConstraint(Collider &first, Collider &second)
template<std::derived_from<PhysicsObject> T, class A, class ...Args>
inline UniquePtr<T> makeObject(A &alloc, Args&&... args)
void applyForces(float dt)
void cleanup()
void updateBodies(float dt)
inline ContactList::iterator inContacts(const std::array<simu::Collider*, 2> &colliders)

Private Members

friend Body
Alloc miscAlloc_ = {}
BodyAlloc bAlloc_ = {miscAlloc_}
ConstraintAlloc cAlloc_ = {bAlloc_}
ForceFieldAlloc fAlloc_ = {miscAlloc_}
ConstraintList constraints_ = {cAlloc_}
ForceFieldList forces_ = {fAlloc_}
ContactList contacts_ = {miscAlloc_}
ColliderTree colliderTree_ = {bAlloc_}
BodyList bodies_ = {bAlloc_}
Settings settings_
Profiler profiler_
ContactFactory makeContactConstraint_
namespace details

Functions

template<typename T>
inline void hash_combine(std::size_t &seed, const T &val)
template<typename T>
inline void hash_val(std::size_t &seed, const T &val)
template<typename T, typename ...Types>
inline void hash_val(std::size_t &seed, const T &val, const Types&... args)
template<typename ...Types>
inline std::size_t hash_val(const Types&... args)
namespace simu

Typedefs

typedef Vector<Uint8, 4> Rgba
typedef std::int8_t Int8
typedef std::uint8_t Uint8
typedef std::int16_t Int16
typedef std::uint16_t Uint16
typedef std::int32_t Int32
typedef std::uint32_t Uint32
typedef std::int64_t Int64
typedef std::uint64_t Uint64
typedef Vec2 Vertex
typedef std::vector<Vertex> Vertices
template<class T>
using IteratorOf = decltype(std::declval<T>().begin())

The iterator type returned by T::begin()

template<class T, Uint32 dim>
using Vector = Matrix<T, dim, 1>

Vector class.

Vectors are always column vectors, use transpose(vec) to obtain a row vector when needed.

template<class T, class U>
using Promoted = typename std::common_type<T, U>::type
typedef Vector<float, 2> Vec2
typedef Vector<float, 3> Vec3
typedef Vector<float, 4> Vec4
typedef Vector<Int32, 2> Vec2i
typedef Vector<Int32, 3> Vec3i
typedef Vector<Int32, 4> Vec4i
typedef Matrix<float, 2, 2> Mat2
typedef Matrix<float, 3, 3> Mat3
typedef Matrix<float, 4, 4> Mat4
typedef Matrix<Int32, 2, 2> Mat2i
typedef Matrix<Int32, 3, 3> Mat3i
typedef Matrix<Int32, 4, 4> Mat4i
template<Uint32 m, Uint32 n>
using ComparisonMatrix = MatrixData<bool, m, n>

Comparison Matrix returned by comparisons of matrices.

This is not convertible to bool, use the functions all() and any() to evaluate to a bool.

All matrix comparisons are done element-wise.

element-wise boolean operators are also provided for ComparisonMatrix

typedef ConstraintFunctions<HingeConstraintFunction, RotationConstraintFunction> WeldConstraintFunction
typedef TimeEntry::ScopedTimer ScopedTimer
template<class Alloc, class T>
using ReboundTo = typename std::allocator_traits<Alloc>::template rebind_alloc<T>
typedef std::function<void(void*)> Deleter
template<class T>
using UniquePtr = std::unique_ptr<T, Deleter>
template<class Iter>
using ViewType = decltype(simu::makeView(std::declval<Iter>(), std::declval<Iter>()))

Enums

enum class Orientation

Orientation or winding order of a chain of vertices.

Values:

enumerator positive
enumerator collinear
enumerator negative

Functions

template<Geometry T>
Edges<T> edgesOf(const T &geometry)
Orientation orientation(Vertex v0, Vertex v1, Vertex v2, float epsilon = simu::EPSILON)

Find the Orientation of 3 vertices.

epsilon is used to approximate collinearity

template<Geometry T>
Vertex furthestVertexInDirection(const T &geometry, Vec2 direction)
template<class T, class U, Uint32 m, Uint32 n>
inline Matrix<Promoted<T, U>, m, n> operator+(const Matrix<T, m, n> &lhs, const Matrix<U, m, n> &rhs)
template<class T, class U, Uint32 m, Uint32 n>
inline Matrix<Promoted<T, U>, m, n> operator-(const Matrix<T, m, n> &lhs, const Matrix<U, m, n> &rhs)
template<class T, class U, Uint32 m, Uint32 n>
inline Matrix<Promoted<T, U>, m, n> operator*(U scalar, const Matrix<T, m, n> &mat)
template<class T, class U, Uint32 m, Uint32 n>
inline Matrix<Promoted<T, U>, m, n> operator*(const Matrix<T, m, n> &mat, U scalar)
template<class T, class U, Uint32 m, Uint32 n>
inline Matrix<Promoted<T, U>, m, n> operator/(const Matrix<T, m, n> &mat, U scalar)
template<class T, class U, Uint32 mLeft, Uint32 nLeft, Uint32 nRight>
inline Matrix<Promoted<T, U>, mLeft, nRight> operator*(const Matrix<T, mLeft, nLeft> &lhs, const Matrix<U, nLeft, nRight> &rhs)
template<class T, Uint32 m, Uint32 n>
inline Matrix<T, n, m> transpose(const Matrix<T, m, n> &original)
template<class T, class U, Uint32 n>
inline Vector<Promoted<T, U>, n> solve(const Matrix<T, n, n> &A, const Vector<U, n> &b)

Return x such that Ax = b.

template<class T, Uint32 n>
inline Matrix<T, n, n> invert(const Matrix<T, n, n> &mat)
template<class T, Uint32 n, std::invocable<Vector<T, n>, Uint32> Proj>
inline Vector<T, n> solveInequalities(const Matrix<T, n, n> &A, Vector<T, n> b, Proj proj, Vector<T, n> initialGuess = Vector<T, n>{}, float epsilon = simu::EPSILON)

Return x such that Ax >= b with bounds on x.

proj must project x onto its valid bounds (ie clamp its values). With the following signature: T proj(const Vector<T, n>& x, Uint32 index) where x[index] must be clamped and returned.

when the absolute change of components of x drops below epsilon, iteration terminates.

Uses projected Gauss-Seidel to solve the MLCP, See A. Enzenhofer’s master thesis (McGill): Numerical Solutions of MLCP

proj must project x onto its valid bounds (ie clamp its values).

when the absolute change of components of x drops below epsilon, iteration terminates.

Uses projected Gauss-Seidel to solve the MLCP, See A. Enzenhofer’s master thesis (McGill): Numerical Solutions of MLCP

template<class T>
inline Vector<T, 2> solveLcp(const Matrix<T, 2, 2> &A, const Vector<T, 2> &b)

Solves the LCP Ax >= b with x >= 0.

This gives Ax - b = w with the residuals w >= 0, the complementarity condition is dot(x, w) = 0 (xi = 0 or wi = 0 for each index i)

Uses total enumeration, taken from box2d’s contact solver. If no value is returned, the LCP had no solution.

template<class T, class U, Uint32 dim>
inline Vector<Promoted<T, U>, dim> elementWiseMul(const Vector<T, dim> &lhs, const Vector<U, dim> &rhs)
template<class T, class U, Uint32 dim>
inline Promoted<T, U> dot(const Vector<T, dim> &lhs, const Vector<U, dim> &rhs)
template<class T, class U>
inline Vector<Promoted<T, U>, 3> cross(const Vector<T, 3> &lhs, const Vector<U, 3> &rhs)
template<class T, class U>
inline Promoted<T, U> cross(const Vector<T, 2> &lhs, const Vector<U, 2> &rhs)
template<class T, Uint32 dim>
inline T normSquared(const Vector<T, dim> &v)
template<class T, Uint32 dim>
inline T norm(const Vector<T, dim> &v)
template<class T, Uint32 dim>
inline Vector<T, dim> normalized(const Vector<T, dim> &v)
template<class T, class U, Uint32 dim>
inline Vector<Promoted<T, U>, dim> projection(const Vector<T, dim> &ofThis, const Vector<U, dim> &onThat)
template<class T>
inline Vector<T, 2> perp(const Vector<T, 2> &v, bool clockwise = false)

rotates v by 90 degrees

If clockwise is false, then this is (k x v) If clockwise is true, then this is (v x k)

template<class T, class U, Uint32 m, Uint32 n>
inline ComparisonMatrix<m, n> operator==(const Matrix<T, m, n> &lhs, const Matrix<U, m, n> &rhs)
template<class T, class U, Uint32 m, Uint32 n>
inline ComparisonMatrix<m, n> operator!=(const Matrix<T, m, n> &lhs, const Matrix<U, m, n> &rhs)
template<class T, class U, Uint32 m, Uint32 n>
inline ComparisonMatrix<m, n> operator<(const Matrix<T, m, n> &lhs, const Matrix<U, m, n> &rhs)
template<class T, class U, Uint32 m, Uint32 n>
inline ComparisonMatrix<m, n> operator<=(const Matrix<T, m, n> &lhs, const Matrix<U, m, n> &rhs)
template<class T, class U, Uint32 m, Uint32 n>
inline ComparisonMatrix<m, n> operator>(const Matrix<T, m, n> &lhs, const Matrix<U, m, n> &rhs)
template<class T, class U, Uint32 m, Uint32 n>
inline ComparisonMatrix<m, n> operator>=(const Matrix<T, m, n> &lhs, const Matrix<U, m, n> &rhs)
template<Uint32 m, Uint32 n>
inline bool all(const ComparisonMatrix<m, n> &comp)

true if all elements are true

template<Uint32 m, Uint32 n>
inline bool any(const ComparisonMatrix<m, n> &comp)

true if any element is true

template<Uint32 m, Uint32 n>
inline ComparisonMatrix<m, n> operator&&(const ComparisonMatrix<m, n> &lhs, const ComparisonMatrix<m, n> &rhs)
template<Uint32 m, Uint32 n>
inline ComparisonMatrix<m, n> operator||(const ComparisonMatrix<m, n> &lhs, const ComparisonMatrix<m, n> &rhs)
template<Uint32 m, Uint32 n>
inline ComparisonMatrix<m, n> operator!(const ComparisonMatrix<m, n> &unary)
template<BodyRange T, class Alloc>
void solveIslands(const T &bodies, const Alloc &alloc, World::Settings s, float dt, Profiler &profiler)
inline Transform operator*(const Rotation &r, const Translation &t)
inline Transform operator*(const Translation &t, const Rotation &r)
inline Transform operator*(const Transform &T, const Translation &t)
inline Transform operator*(const Transform &T, const Rotation &r)
inline Transform operator*(const Translation &t, const Transform &T)
inline Transform operator*(const Rotation &r, const Transform &T)
inline Transform operator*(const Transform &T1, const Transform &T2)
inline Vec2 operator*(const Mat3 &T, Vec2 v)
template<class T>
inline T clamp(T val, T min, T max)
template<class T>
inline T squared(const T &x)
template<std::bidirectional_iterator Iter, Callable<bool(Iter)> GoesLeft>
Iter booleanSort(Iter begin, Iter end, GoesLeft goesLeft)
bool isNan(float val)
template<class T, class Alloc, class ...Args, std::enable_if_t<!std::is_array_v<T>, bool> = true>
UniquePtr<T> makeUnique(const Alloc &alloc, Args&&... args)
template<class T, class Alloc, class ...Args, std::enable_if_t<std::is_array_v<T> && std::extent_v<T> == 0, bool> = true>
UniquePtr<T> makeUnique(const Alloc &alloc, std::size_t size)
template<class Container, class A>
void replaceAllocator(Container &c, const A &alloc)
template<std::forward_iterator Iter, class Deref>
auto makeView(Iter begin, Iter end, Deref deref)

Creates a view of [begin, end) and applies Deref(*Iter) to every dereferenced element.

Deref must return a reference, ie it should not create new objects.

template<std::forward_iterator Iter>
auto makeView(Iter begin, Iter end)
template<Range R, class Deref>
auto makeView(R &range, Deref deref)

Creates a view of the range and applies Deref to every dereferenced element.

template<Range R>
auto makeView(R &range)

Variables

constexpr float EPSILON = 1e-6f
template<class T, Uint32 dim> concept VertexIterator  = requires(T it) {{ *it } -> std::convertible_to<Vector<float, dim>>;} && std::forward_iterator<T>

Any iterator that dereferences to a vector of dimension dim.

template<class T> concept VertexIterator2D   = VertexIterator<T, 2>

Any iterator that dereferences to a Vertex.

template<class T> concept Geometry  = requires(T geo){{ geo.begin() } -> VertexIterator2D;{ geo.end() }   -> VertexIterator2D;}

Any type that allows iterating over vertices.

template<class F> concept ConstraintFunction  = requires(F                 f,typename F::Value lambda,constProxies&    proxies,float             dt) {requires F::nBodies == 1 || F::nBodies == 2;typename F::Value;requires std::is_same_v<typename F::Value,Vector<float, F::dimension>>;typename F::Jacobian;requires std::is_same_v<typename F::Jacobian,Matrix<float, F::dimension, 6>>;{ f.eval(proxies) } -> std::same_as<typename F::Value>;{ f.bias(proxies) } -> std::same_as<typename F::Value>;{ f.jacobian(proxies) } -> std::same_as<typename F::Jacobian>;{ f.clampLambda(lambda, dt) } -> std::same_as<typename F::Value>;{ f.clampPositionLambda(lambda) } -> std::same_as<typename F::Value>;}
template<class S> concept ConstraintSolver  = requires(S              s,Proxies&       proxies,constProxies& cProxies,typename S::F  f,float          dt) {typename S::F;requires ConstraintFunction<typename S::F>;requires std::derived_from<S,ConstraintSolverBase<typename S::F>>;requires std::constructible_from<S,Bodies, typename S::F>;{ s.initSolve(cProxies, f) };{ s.warmstart(proxies, f, dt) };{ s.solveVelocity(proxies, f, dt) };{ s.solvePosition(proxies, f) };}
template<class T> concept BodyRange  = Range<T> && requires(T t) {{ *t.begin() } -> std::convertible_to<Body&>;}
template<class F, class Signature> concept Callable   = details::SignatureDecomposition<Signature>::template IsCallable<F>::value
template<class F, class Signature> concept StrictCallable   = details::SignatureDecomposition<Signature>::template IsCallableStrictReturn<F>::value
template<class R> concept Range   = std::ranges::range<R>
namespace details

Functions

template<class Tuple, class Func, Uint32 i = 0> requires constexpr std::invocable< Func, std::tuple_element_t< i, Tuple > & > void forEach (Tuple &tuple, Func &func)
template<class Tuple, class Func, Uint32 i = 0> requires constexpr std::invocable< Func, const std::tuple_element_t< i, Tuple > & > void forEach (const Tuple &tuple, Func &func)
namespace TransformView
namespace priv
namespace std

Unnamed Group

template<class T, simu::Uint32 m, simu::Uint32 n>
inline simu::Matrix<T, m, n> abs(const simu::Matrix<T, m, n> &mat)
template<class T, simu::Uint32 m, simu::Uint32 n>
inline simu::Matrix<T, m, n> round(const simu::Matrix<T, m, n> &mat)
template<class T, simu::Uint32 m, simu::Uint32 n>
inline simu::Matrix<T, m, n> min(const simu::Matrix<T, m, n> &lhs, const simu::Matrix<T, m, n> &rhs)
template<class T, simu::Uint32 m, simu::Uint32 n>
inline simu::Matrix<T, m, n> max(const simu::Matrix<T, m, n> &lhs, const simu::Matrix<T, m, n> &rhs)

Functions

template<class T, simu::Uint32 m, simu::Uint32 n>
bool isfinite(const simu::Matrix<T, m, n> &mat)
file app.hpp
#include “Simu/physics.hpp
#include “Simu/app/Application.hpp
file Application.hpp
#include “Simu/physics.hpp
#include “Simu/app/Scene.hpp
#include “Simu/app/Event.hpp
file Camera.hpp
#include “Simu/config.hpp
file Event.hpp
#include “Simu/config.hpp
#include “Simu/math/Matrix.hpp
file MouseConstraint.hpp
file Renderer.hpp
#include <vector>
#include “Simu/config.hpp
#include “Simu/math/Geometry.hpp
#include “Simu/utility/View.hpp
#include “Simu/utility/Memory.hpp
file Scene.hpp
#include “Simu/config.hpp
#include “Simu/physics.hpp
#include “Simu/utility/View.hpp
#include “Simu/app/Renderer.hpp
#include “Simu/app/Camera.hpp
#include “Simu/app/Event.hpp
#include “Simu/app/Tool.hpp
file Tool.hpp
#include “Simu/app/Event.hpp
file VisiblePhysics.hpp
#include “Simu/physics.hpp
#include “Simu/app/Renderer.hpp
file config.hpp
#include <cstdint>
#include <exception>
#include <sstream>

Defines

SIMU_API

Define DLL export/import macro.

SIMU_PROFILE
SIMU_ASSERT(cond, msg)
file math.hpp
#include “math/Matrix.hpp
#include “math/Interval.hpp
#include “math/Geometry.hpp
#include “math/Polygon.hpp
#include “math/Gjk.hpp
file BarycentricCoordinates.hpp
#include “Simu/math/Matrix.hpp
#include “Simu/utility/Algo.hpp
file Edges.hpp
#include “Simu/utility/Algo.hpp
#include “Simu/math/Geometry.hpp
file Geometry.hpp
#include <concepts>
#include <vector>
#include “Simu/math/Matrix.hpp
#include “Simu/math/Interval.hpp
file Geometry.inl.hpp
#include “Simu/math/Geometry.hpp
#include “Simu/math/Edges.hpp
file Gjk.hpp
#include <array>
#include “Simu/math/Polygon.hpp
#include “Gjk.inl.hpp
file Gjk.inl.hpp
#include “Simu/math/Gjk.hpp
file Interval.hpp
#include “Simu/config.hpp
#include <cmath>
file Matrix.hpp
#include <initializer_list>
#include <type_traits>
#include <cmath>
#include <optional>
#include “Simu/config.hpp
#include “Simu/math/Matrix.inl.hpp
file Matrix.inl.hpp
#include “Simu/math/Matrix.hpp
file Polygon.hpp
#include <algorithm>
#include “Simu/config.hpp
#include “Simu/math/Matrix.hpp
#include “Simu/math/Geometry.hpp
#include “Simu/utility/View.hpp
file Polygon.inl.hpp
#include “Simu/math/Polygon.hpp
file Random.hpp
#include <random>
#include <concepts>
#include “Simu/config.hpp
file physics.hpp
#include “Simu/math.hpp
#include “Simu/physics/World.hpp
#include “Simu/physics/Motors.hpp
file Bodies.hpp
#include <cmath>
#include <array>
#include <optional>
#include <ranges>
#include “Simu/config.hpp
#include “Simu/physics/Body.hpp
file Bodies.inl.hpp
#include “Simu/physics/Bodies.hpp
#include “Simu/physics/Body.hpp
file Body.hpp
#include <type_traits>
#include “Simu/config.hpp
#include “Simu/math/Matrix.hpp
#include “Simu/utility/View.hpp
file BodyTree.hpp
#include “Simu/config.hpp
#include “Simu/physics/RTree.hpp
#include “Simu/utility/Memory.hpp
file BoundingBox.hpp
#include “Simu/config.hpp
#include “Simu/math/Matrix.hpp
#include “Simu/math/Geometry.hpp
file Collider.hpp
#include <list>
#include “Simu/config.hpp
#include “Simu/math/Polygon.hpp
file CombinableProperty.hpp
#include “Simu/config.hpp
file Constraint.hpp
#include <memory>
#include “Simu/math/Gjk.hpp
#include “Simu/physics/Body.hpp
file Constraint.inl.hpp
#include “Simu/physics/World.hpp
file ConstraintFunction.hpp
#include “Simu/config.hpp
#include “Simu/physics/Body.hpp
#include “Simu/physics/Bodies.hpp
file ConstraintInterfaces.hpp
#include “Simu/utility/View.hpp
#include “Simu/math/Matrix.hpp
#include “Simu/physics/Bodies.hpp
file ConstraintSolver.hpp
#include <iostream>
#include “Simu/config.hpp
#include “Simu/math/Matrix.hpp
file ContactManifold.hpp
#include <algorithm>
#include <array>
#include “Simu/math/Gjk.hpp
#include “Simu/physics/Bodies.hpp
file DistanceConstraint.hpp
file ForceField.hpp
#include “Simu/config.hpp
#include “Simu/physics/Body.hpp
file Island.hpp
#include <set>
#include “Simu/physics/Body.hpp
file Material.hpp
#include “Simu/config.hpp
file Motors.hpp
#include “Simu/config.hpp
file PhysicsObject.hpp
#include “Simu/config.hpp
#include “Simu/utility/Memory.hpp
file Profiler.hpp
#include <chrono>
#include “Simu/config.hpp

Defines

SIMU_PROFILE_ENTRY(timeEntry)
SIMU_PROFILE_START_PARTIAL_ENTRY(timeEntry)
SIMU_PROFILE_PARTIAL_ENTRY(timeEntry)
SIMU_PROFILE_COMMIT_PARTIAL_ENTRY(timeEntry)
SIMU_PROFILE_TREE_HEIGHT(profiler, tree)
file RTree.hpp
#include <queue>
#include <utility>
#include “Simu/config.hpp
#include “Simu/utility/View.hpp
#include “Simu/utility/Algo.hpp
#include “Simu/utility/Memory.hpp
file RTree.inl.hpp
#include “Simu/physics/RTree.hpp
file Transform.hpp
#include <cmath>
#include <numbers>
#include “Simu/config.hpp
#include “Simu/math/Matrix.hpp
file World.hpp
#include “Simu/config.hpp
#include “Simu/utility/View.hpp
#include “Simu/utility/Memory.hpp
#include “Simu/physics/Body.hpp
#include “Simu/physics/Bodies.hpp
#include <list>
#include <unordered_map>
file Algo.hpp
file Callable.hpp
#include <functional>
#include “Simu/config.hpp
file FloatingPointExceptions.hpp
#include <float.h>
#include <fenv.h>
file Memory.hpp
#include <cstdlib>
#include <cstddef>
#include <memory>
#include <functional>
#include <list>
#include “Simu/config.hpp
file View.hpp
#include <ranges>

Defines

SIMU_HAS_STD_VIEW
file View.inl.hpp
#include “Simu/utility/View.hpp
group math

Math classes and related algorithms for Simu.

group BarycentricCoordinates

Barycentric coordinates allows finding the closest point on a line or triangle from a point Q.

For an intuitive explanation, see Erin Catto’s GDC conference, slides available at https://box2d.org/files/ErinCatto_GJK_GDC2010.pdf

group Geometry

Typedefs

typedef Vec2 Vertex
typedef std::vector<Vertex> Vertices
template<class T>
using IteratorOf = decltype(std::declval<T>().begin())

The iterator type returned by T::begin()

Enums

enum class Orientation

Orientation or winding order of a chain of vertices.

Values:

enumerator positive
enumerator collinear
enumerator negative

Variables

template<class T, Uint32 dim> concept VertexIterator  = requires(T it) {{ *it } -> std::convertible_to<Vector<float, dim>>;} && std::forward_iterator<T>

Any iterator that dereferences to a vector of dimension dim.

template<class T> concept VertexIterator2D   = VertexIterator<T, 2>

Any iterator that dereferences to a Vertex.

template<class T> concept Geometry  = requires(T geo){{ geo.begin() } -> VertexIterator2D;{ geo.end() }   -> VertexIterator2D;}

Any type that allows iterating over vertices.

group LinearAlgebra

Typedefs

template<class T, Uint32 dim>
using Vector = Matrix<T, dim, 1>

Vector class.

Vectors are always column vectors, use transpose(vec) to obtain a row vector when needed.

group operations

Typedefs

template<class T, class U>
using Promoted = typename std::common_type<T, U>::type
group comparison

Typedefs

template<Uint32 m, Uint32 n>
using ComparisonMatrix = MatrixData<bool, m, n>

Comparison Matrix returned by comparisons of matrices.

This is not convertible to bool, use the functions all() and any() to evaluate to a bool.

All matrix comparisons are done element-wise.

element-wise boolean operators are also provided for ComparisonMatrix

dir /home/runner/work/Simu/Simu/include/Simu/app
dir /home/runner/work/Simu/Simu/include
dir /home/runner/work/Simu/Simu/include/Simu/math
dir /home/runner/work/Simu/Simu/include/Simu/physics
dir /home/runner/work/Simu/Simu/include/Simu
dir /home/runner/work/Simu/Simu/include/Simu/utility