summaryrefslogtreecommitdiff
path: root/gfx
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2023-12-11 20:49:52 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2023-12-11 20:49:52 +0000
commit04f42212ba67ec7d8160bf4a19c0b1283aec69bc (patch)
treedf623be62e89a80a9ea75f069b331b625be890a6 /gfx
parentInteger camera (diff)
downloadilt-04f42212ba67ec7d8160bf4a19c0b1283aec69bc.tar.bz2
ilt-04f42212ba67ec7d8160bf4a19c0b1283aec69bc.tar.xz
ilt-04f42212ba67ec7d8160bf4a19c0b1283aec69bc.zip
Fix clamping to seafloor and add specific test
Diffstat (limited to 'gfx')
-rw-r--r--gfx/gl/camera.cpp6
1 files changed, 3 insertions, 3 deletions
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};
};