Skip to content

Commit

Permalink
changed Sleeping constants to be public (module level)
Browse files Browse the repository at this point in the history
  • Loading branch information
liabru committed Jun 21, 2014
1 parent 0ae2d02 commit 7eadea9
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/core/Sleeping.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ var Sleeping = {};

(function() {

var _motionWakeThreshold = 0.18,
_motionSleepThreshold = 0.08,
_minBias = 0.9;
Sleeping._motionWakeThreshold = 0.18,
Sleeping._motionSleepThreshold = 0.08,
Sleeping._minBias = 0.9;

/**
* Puts bodies to sleep or wakes them up depending on their motion.
Expand All @@ -36,9 +36,9 @@ var Sleeping = {};
maxMotion = Math.max(body.motion, motion);

// biased average motion estimation between frames
body.motion = _minBias * minMotion + (1 - _minBias) * maxMotion;
body.motion = Sleeping._minBias * minMotion + (1 - Sleeping._minBias) * maxMotion;

if (body.sleepThreshold > 0 && body.motion < _motionSleepThreshold * timeFactor) {
if (body.sleepThreshold > 0 && body.motion < Sleeping._motionSleepThreshold * timeFactor) {
body.sleepCounter += 1;

if (body.sleepCounter >= body.sleepThreshold)
Expand Down Expand Up @@ -78,7 +78,7 @@ var Sleeping = {};
var sleepingBody = (bodyA.isSleeping && !bodyA.isStatic) ? bodyA : bodyB,
movingBody = sleepingBody === bodyA ? bodyB : bodyA;

if (!sleepingBody.isStatic && movingBody.motion > _motionWakeThreshold * timeFactor) {
if (!sleepingBody.isStatic && movingBody.motion > Sleeping._motionWakeThreshold * timeFactor) {
Sleeping.set(sleepingBody, false);
}
}
Expand Down

0 comments on commit 7eadea9

Please sign in to comment.