Skip to content

Commit 574221d

Browse files
committed
A new property was added to Matter.World, correction which is used in the Engine.update call and allows you to adjust the time being passed to the simulation. The default value is 1 to remain consistent with previous releases.
1 parent 7f78178 commit 574221d

2 files changed

Lines changed: 25 additions & 3 deletions

File tree

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,22 @@
22

33
## Version 3.3.1 - Tetsuo - In Development
44

5+
### New Features
6+
7+
* A new property was added to Matter.World, `correction` which is used in the Engine.update call and allows you to adjust the time
8+
being passed to the simulation. The default value is 1 to remain consistent with previous releases.
9+
10+
511
### Bug Fixes
612

713
* In the WebGL Render Texture the tint of the texture was always set to 0xffffff and therefore the alpha values were ignored. The tint is now calculated using the alpha value. Fix #3385 (thanks @ger1995)
814

915
### Updates
1016

17+
18+
19+
20+
1121
## Version 3.3.0 - Tetsuo - 22nd March 2018
1222

1323
A special mention must go to @orblazer for their outstanding assistance in helping to complete the JSDoc data-types, callbacks and type defs across the API.

src/physics/matter-js/World.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,20 @@ var World = new Class({
118118
*/
119119
this.enabled = GetValue(config, 'enabled', true);
120120

121+
/**
122+
* The correction argument is an optional Number that specifies the time correction factor to apply to the update.
123+
* This can help improve the accuracy of the simulation in cases where delta is changing between updates.
124+
* The value of correction is defined as delta / lastDelta, i.e. the percentage change of delta over the last step.
125+
* Therefore the value is always 1 (no correction) when delta constant (or when no correction is desired, which is the default).
126+
* See the paper on Time Corrected Verlet for more information.
127+
*
128+
* @name Phaser.Physics.Matter.World#correction
129+
* @type {number}
130+
* @default 1
131+
* @since 3.3.1
132+
*/
133+
this.correction = GetValue(config, 'correction', 1);
134+
121135
/**
122136
* [description]
123137
*
@@ -592,9 +606,7 @@ var World = new Class({
592606
{
593607
if (this.enabled)
594608
{
595-
var correction = 1;
596-
597-
Engine.update(this.engine, delta, correction);
609+
Engine.update(this.engine, delta, this.correction);
598610
}
599611
},
600612

0 commit comments

Comments
 (0)