Solver

Solver is the discrete solver algorithm that calculates the movement of the physics world. It uses a modified predictive-corrective semi-implicit Euler implementation. Because this is a local iterative solver, there may be divergence issues at higher timeSteps and convergence can be tuned with the iterationPerFrame.

Constructor

new Solver(timeStep, iterationPerFrame, constraintIteration, particles, constraints, walls)

Instantiates new Solver

Parameters:
NameTypeDescription
timeStepNumber

the change in time per frame (smaller is more accurate)

iterationPerFrameNumber

the amount of time the solver is called per frame (not substepping, timeStep remains constant)

constraintIterationNumber

the amount of times the constraints are solved per frame

particlesSpatialHashGrid

SpatialHashGrid of particles

constraintsArray.<Constraint>

list of constraints

wallsArray.<Wall>

list of walls

Methods

nextFrame()

Computes next frame or "world-state"

solve()

Solves one iteration of the current physics world

update()

Optional function that can be defined to exhibit certain behavior in the solve loop.

updateSolverParticles()

Update the particle positions in the SpatialHashGrid