Collision and Constraint Iterations
- Added constraint and collision iterations and their functionality.
- Added new methods to Engine
Engine:SetConstraintIterations(iterations: number)
Engine:SetCollisionIterations(iterations: number)
- Updated RigidBody:Update() to use constraint iterations.
- Fixed RigidBody.Touched and RigidBody.TouchEnded after adding iterations.
- Fixed MouseConstraint plugin bug - Stop looping through the rigid bodies if we have already found one to attach to the mouse.
Iterations provide accurate calculations for more rigid and smoother physics. Constraint iterations are applied to Constraint:Constrain()
method. Constraint iterations are extremely useful of rod constraints and rope constraints. Constraint iterations do not work on spring constraints.
Collision iterations are used to provide accurate and rigid collision detection and resolution. By default both of these iterations are set to 1. Iterations can be in the range of 1-10 only. Collision iterations can be set only if quadtrees are being used in collision detection.
Keep in mind that the higher the number of iterations the more accurate results. But, having more iterations means you'll have to sacrifice performance. The lesser the number of iterations, the better performance but we'll have to sacrifice on accuracy. So be careful where you use them!
Recommended Iteration Amounts:
Constraint Iterations - 3
Collision Iterations - 4