From 36fcdfb85ef46119b81308e3279903f3b0804285 Mon Sep 17 00:00:00 2001 From: Jiri Pokorny Date: Sat, 7 Dec 2024 01:28:04 +0100 Subject: [PATCH] Fixed saturation current depth --- projects/scuba-physics/src/lib/AlgorithmContext.ts | 5 ++--- projects/scuba-physics/src/lib/BuhlmannAlgorithm.ts | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/projects/scuba-physics/src/lib/AlgorithmContext.ts b/projects/scuba-physics/src/lib/AlgorithmContext.ts index 7f73dc87..c1948234 100644 --- a/projects/scuba-physics/src/lib/AlgorithmContext.ts +++ b/projects/scuba-physics/src/lib/AlgorithmContext.ts @@ -136,13 +136,12 @@ export class AlgorithmContext { return newGas; } - public addSaturation(): void { + public addSaturation(currentDepth: number): void { if (!FeatureFlags.Instance.collectSaturation) { return; } - // TODO Fix current depth at the moment, not the currentDepth at end of last segment - const ambientPressure = this.depthConverter.toBar(this.currentDepth); + const ambientPressure = this.depthConverter.toBar(currentDepth); const currentOverPressures = this.tissues.saturationRatio(ambientPressure, this.depthConverter.surfacePressure, 1); this.saturationRatios.push(currentOverPressures); } diff --git a/projects/scuba-physics/src/lib/BuhlmannAlgorithm.ts b/projects/scuba-physics/src/lib/BuhlmannAlgorithm.ts index b8ca1f84..3aaa9ab5 100644 --- a/projects/scuba-physics/src/lib/BuhlmannAlgorithm.ts +++ b/projects/scuba-physics/src/lib/BuhlmannAlgorithm.ts @@ -342,7 +342,7 @@ export class BuhlmannAlgorithm { context.tissues.load(loadSegment, segment.gas); context.runTime += segment.duration; context.addCeiling(); - context.addSaturation(); + context.addSaturation(segment.averageDepth); } /**