ToyMaker Game Engine 0.0.2
ToyMaker is a game engine developed and maintained by Zoheb Shujauddin.
Loading...
Searching...
No Matches
Physics properties, maths, contraints, etc.

Files

file  ToyMaker_Main/include/toymaker/engine/physics/system.hpp
 File containing ToyMaker's implementation of XPBD, extended position based dynamics.

Classes

class  ToyMaker::PhysicsSystem
 The physics system, an ECS system that tracks and updates the state of each physics object in the scene according to its properties. More...
struct  ToyMaker::PhysicsState
 Component representing the physics state of the body it's attached to at some particular point in time. More...
class  ToyMaker::BaseConstraint
 Base class for constraints. More...

Enumerations

enum  ToyMaker::PhysicsState::Mode : Traits { ToyMaker::PhysicsState::MODE_DYNAMIC =0x0 , ToyMaker::PhysicsState::MODE_KINEMATIC =0x1 , ToyMaker::PhysicsState::MODE_STATIC =0x2 }
 Defines how the object this component is attached to responds to physics updates. More...
enum  ToyMaker::PhysicsState::CollisionResponse : Traits { ToyMaker::PhysicsState::COLLISION_SEPARATE =0x4 , ToyMaker::PhysicsState::COLLISION_SIGNAL =0x8 }
 Defines how the object this component is attached to responds to collisions. More...

Functions

float ToyMaker::computeGeneralizedInverseMassPositional (const ObjectBounds &object, const PhysicsState &physics, const glm::vec3 &correctionPoint, const glm::vec3 &correctionGradient)
 Computes the generalized inverse mass used for positional corrections applied by constraints.
float ToyMaker::computeGeneralizedInverseMassRotational (const ObjectBounds &object, const PhysicsState &physics, const glm::vec3 &correctionRotational)
 Computes the generalized inverse mass used by constraints to apply strictly rotational corrections.
glm::mat3 ToyMaker::computeInertiaRotationalWorld (const glm::vec3 &rotationalInertiaLocal, const glm::quat &orientation)
 Returns an objects rotation tensor in the global frame given its tensor in the local frame according to its current orientation.
ObjectBounds ToyMaker::applyImpulseObject (ObjectBounds object, const PhysicsState &physics, const glm::vec3 &impulsePositional, const glm::vec3 &impulsePoint)
 Returns object bounds in state it would be post application of a positional impulse.
ObjectBounds ToyMaker::applyImpulseObject (ObjectBounds object, const PhysicsState &physics, const glm::vec3 &impulseRotational)
 Returns object bounds in state it would be post application of a rotational impulse.
PhysicsState ToyMaker::applyImpulsePhysics (const ObjectBounds &object, PhysicsState physics, const glm::vec3 &impulsePositional, const glm::vec3 &impulsePoint)
 Returns new physics state after application of global impulse.
PhysicsState ToyMaker::applyImpulsePhysics (const ObjectBounds &object, PhysicsState physics, const glm::vec3 &impulseRotational)
 Returns new physics state after application of global angular impulse.

Detailed Description

Enumeration Type Documentation

◆ CollisionResponse

Defines how the object this component is attached to responds to collisions.

Enumerator
COLLISION_SEPARATE 

Whether this object should be separated from the object it collides with.

COLLISION_SIGNAL 

Whether this object's collision events should be reported (via signal).

◆ Mode

Defines how the object this component is attached to responds to physics updates.

Enumerator
MODE_DYNAMIC 

Trait indicating that this object responds to external forces, including those set externally, or generated by constraints, and so on.

MODE_KINEMATIC 

Trait indicating that this object will undergo position and orientation updates according to its translational and rotational velocity, but won't respond to any forces.

In effect, this object will act as though it is of infinite mass.

MODE_STATIC 

Trait indicating that this object won't undergo any physics system updates whatsoever.

Function Documentation

◆ computeGeneralizedInverseMassPositional()

float ToyMaker::computeGeneralizedInverseMassPositional ( const ObjectBounds & object,
const PhysicsState & physics,
const glm::vec3 & correctionPoint,
const glm::vec3 & correctionGradient )

Computes the generalized inverse mass used for positional corrections applied by constraints.

Parameters
objectThe bounds indicating the current position and orientation of the object in world space
inverseMass1 divided by the mass of the object.
inverseRotationalInertiaThe inverse of the rotational inertia of this object in its local frame
correctionPointLocation of the point of application of the correction
correctionGradientThe direction of the greatest increase in error with respect to the desired object state in terms of its position.

◆ computeGeneralizedInverseMassRotational()

float ToyMaker::computeGeneralizedInverseMassRotational ( const ObjectBounds & object,
const PhysicsState & physics,
const glm::vec3 & correctionRotational )

Computes the generalized inverse mass used by constraints to apply strictly rotational corrections.

Parameters
inverseMass1 divided by the mass of the object.
inverseRotationalInertiaThe inverse of the rotational inertia of the object in its local frame.
correctionThe vector representing the desired rotational correction, usually a product of an impulse vector and its offset from the object's center-of-mass. Moving along its direction increases the magnitude of the correction required