From 04f42212ba67ec7d8160bf4a19c0b1283aec69bc Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Mon, 11 Dec 2023 20:49:52 +0000 Subject: Fix clamping to seafloor and add specific test --- gfx/gl/camera.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'gfx/gl/camera.cpp') diff --git a/gfx/gl/camera.cpp b/gfx/gl/camera.cpp index a0d76ab..ff4c91e 100644 --- a/gfx/gl/camera.cpp +++ b/gfx/gl/camera.cpp @@ -41,9 +41,9 @@ Camera::extentsAtDist(const GlobalDistance dist) const const auto clampToSeaFloor = [this, dist](GlobalPosition3D target) -> GlobalPosition4D { target += position; if (target.z < -1500) { - const auto diff = (target - position); - const auto something = (-1500 - position.z) / diff.z; - return {position + diff * something, dist}; + const auto diff = target - position; + const auto limit = -1500 - position.z; + return {position + (limit * diff) / diff.z, (limit * dist) / diff.z}; } return {target, dist}; }; -- cgit v1.2.3