Merge pull request #7531 from ZappoMan/optimizeDepthReticle

only do depth reticle depth check when the reticle is visible
This commit is contained in:
Brad Davis 2016-04-01 13:06:44 -07:00
commit cd548744f6

View file

@ -112,7 +112,7 @@ function autoHideReticle() {
function checkReticleDepth() { function checkReticleDepth() {
var now = Date.now(); var now = Date.now();
var timeSinceLastDepthCheck = now - lastDepthCheckTime; var timeSinceLastDepthCheck = now - lastDepthCheckTime;
if (timeSinceLastDepthCheck > TIME_BETWEEN_DEPTH_CHECKS) { if (timeSinceLastDepthCheck > TIME_BETWEEN_DEPTH_CHECKS && Reticle.visible) {
var newDesiredDepth = desiredDepth; var newDesiredDepth = desiredDepth;
lastDepthCheckTime = now; lastDepthCheckTime = now;
var reticlePosition = Reticle.position; var reticlePosition = Reticle.position;
@ -160,7 +160,6 @@ function moveToDesiredDepth() {
} else { } else {
newDepth = Reticle.depth + distanceToAdjustThisCycle; newDepth = Reticle.depth + distanceToAdjustThisCycle;
} }
Reticle.setDepth(newDepth); Reticle.setDepth(newDepth);
} }
} }