From dc464727205906a6ff64ee27fb21fff4cfb9e0aa Mon Sep 17 00:00:00 2001 From: liabru Date: Fri, 2 Sep 2022 17:59:15 +0100 Subject: [PATCH] rename internal Common._timeUnit to Common._baseDelta --- src/body/Body.js | 2 +- src/collision/Resolver.js | 4 ++-- src/constraint/Constraint.js | 2 +- src/core/Common.js | 2 +- src/core/Engine.js | 2 +- src/core/Sleeping.js | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/body/Body.js b/src/body/Body.js index 9e991df..e2e07ce 100644 --- a/src/body/Body.js +++ b/src/body/Body.js @@ -759,7 +759,7 @@ var Axes = require('../geometry/Axes'); correction = Body._timeCorrection ? deltaTime / (body.deltaTime || deltaTime) : 1; // from the previous step - var frictionAir = 1 - body.frictionAir * (deltaTime / Common._timeUnit), + var frictionAir = 1 - body.frictionAir * (deltaTime / Common._baseDelta), velocityPrevX = (body.position.x - body.positionPrev.x) * correction, velocityPrevY = (body.position.y - body.positionPrev.y) * correction; diff --git a/src/collision/Resolver.js b/src/collision/Resolver.js index d1be837..9fd7d39 100644 --- a/src/collision/Resolver.js +++ b/src/collision/Resolver.js @@ -62,7 +62,7 @@ var Bounds = require('../geometry/Bounds'); contactShare, positionImpulse, positionDampen = Resolver._positionDampen * (damping || 1), - slopDampen = Common.clamp(delta / Common._timeUnit, 0, 1), + slopDampen = Common.clamp(delta / Common._baseDelta, 0, 1), pairsLength = pairs.length; // find impulses required to resolve penetration @@ -226,7 +226,7 @@ var Bounds = require('../geometry/Bounds'); * @param {number} delta */ Resolver.solveVelocity = function(pairs, delta) { - var timeScale = delta / Common._timeUnit, + var timeScale = delta / Common._baseDelta, timeScaleSquared = timeScale * timeScale, timeScaleCubed = timeScaleSquared * timeScale, restingThresh = -Resolver._restingThresh * timeScale, diff --git a/src/constraint/Constraint.js b/src/constraint/Constraint.js index e6e6948..4c7f6a0 100644 --- a/src/constraint/Constraint.js +++ b/src/constraint/Constraint.js @@ -113,7 +113,7 @@ var Common = require('../core/Common'); * @param {number} delta */ Constraint.solveAll = function(constraints, delta) { - var timeScale = Common.clamp(delta / Common._timeUnit, 0, 1); + var timeScale = Common.clamp(delta / Common._baseDelta, 0, 1); // Solve fixed constraints first. for (var i = 0; i < constraints.length; i += 1) { diff --git a/src/core/Common.js b/src/core/Common.js index 0738e86..face05e 100644 --- a/src/core/Common.js +++ b/src/core/Common.js @@ -10,7 +10,7 @@ module.exports = Common; (function() { - Common._timeUnit = 1000 / 60; + Common._baseDelta = 1000 / 60; Common._nextId = 0; Common._seed = 0; Common._nowStartTime = +(new Date()); diff --git a/src/core/Engine.js b/src/core/Engine.js index cb4fa13..7330822 100644 --- a/src/core/Engine.js +++ b/src/core/Engine.js @@ -88,7 +88,7 @@ var Body = require('../body/Body'); timestamp = timing.timestamp, i; - delta = typeof delta !== 'undefined' ? delta : Common._timeUnit; + delta = typeof delta !== 'undefined' ? delta : Common._baseDelta; delta *= timing.timeScale; // increment timestamp diff --git a/src/core/Sleeping.js b/src/core/Sleeping.js index 17d10bc..fc7fe16 100644 --- a/src/core/Sleeping.js +++ b/src/core/Sleeping.js @@ -25,7 +25,7 @@ var Common = require('./Common'); * @param {number} delta */ Sleeping.update = function(bodies, delta) { - var timeScale = delta / Common._timeUnit, + var timeScale = delta / Common._baseDelta, motionSleepThreshold = Sleeping._motionSleepThreshold; // update bodies sleeping status