DubiousEngine  0.2.0
Simple Game Engine
Dubious::Physics::Constraint_solver Class Reference

Constraint Solver... solves constraints. More...

#include <Constraint_solver.h>

Public Member Functions

 Constraint_solver (float time_step, float beta, float cor, float slop)
 Constructor. More...
 
 Constraint_solver (const Constraint_solver &)=delete
 
Constraint_solveroperator= (const Constraint_solver &)=delete
 
void warm_start (Physics_object &a, Physics_object &b, const Contact_manifold &contact_manifold)
 Re-apply forces from previous time step. More...
 
void solve (Physics_object &a, Physics_object &b, Contact_manifold &contact_manifold)
 The heart of constraint solving. More...
 

Detailed Description

Constraint Solver... solves constraints.

This class is based entirely on the Sequential Impulse technique described by Erin Catto http://box2d.org/ And as pre-digested and explained by Ming-Lun "Allen" Chou http://allenchou.net/game-physics-series/

Constructor & Destructor Documentation

Dubious::Physics::Constraint_solver::Constraint_solver ( float  time_step,
float  beta,
float  cor,
float  slop 
)
Dubious::Physics::Constraint_solver::Constraint_solver ( const Constraint_solver )
delete

Member Function Documentation

Constraint_solver& Dubious::Physics::Constraint_solver::operator= ( const Constraint_solver )
delete
void Dubious::Physics::Constraint_solver::solve ( Physics_object a,
Physics_object b,
Contact_manifold contact_manifold 
)

The heart of constraint solving.

Given two objects that are known to be colliding, and up to 4 points that are in the contact manifold. Figures out all of the forces at each point.

Parameters
a- [in,out] The first object in the colliding pair. Its velocities will be updated.
b- [in,out] The second object in the colliding pair. Its velocities will be updated.
contact_manifold- [in,out] Up to 4 points that define the collision. Its forces will be updated
void Dubious::Physics::Constraint_solver::warm_start ( Physics_object a,
Physics_object b,
const Contact_manifold contact_manifold 
)

Re-apply forces from previous time step.

See the discussion by Allen Chou on his web page. The general idea is that often the previous time step's forces are mostly pertinent to the current time step. For exmaple a bunch of blocks at rest all have the same gravity every time step. So this just re-applies the same force. Allen Chou says he actually applies a fraction of the previous force, so this should probably be updated at some point. But in my current tests it gets good results

Parameters
a- [in,out] The first object in the colliding pair. Its velocities will be updated.
b- [in,out] The second object in the colliding pair. Its velocities will be updated.
contact_manifold- [in] Up to 4 points that define the collision

The documentation for this class was generated from the following files: