diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2022-01-10 02:07:53 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2022-01-10 02:07:53 +0000 |
commit | 94f0e426bc8f298aec90fd0d4fcf6f823f8c399c (patch) | |
tree | c1be0231cab6f9680aa8c3f9e0acf531d8debb89 /ui | |
parent | Tweak ray tracer calls to account for scale (diff) | |
download | ilt-94f0e426bc8f298aec90fd0d4fcf6f823f8c399c.tar.bz2 ilt-94f0e426bc8f298aec90fd0d4fcf6f823f8c399c.tar.xz ilt-94f0e426bc8f298aec90fd0d4fcf6f823f8c399c.zip |
Ray Trace cursor clicks to terrain surface
Diffstat (limited to 'ui')
-rw-r--r-- | ui/gameMainWindow.cpp | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/ui/gameMainWindow.cpp b/ui/gameMainWindow.cpp index d53db4b..1724927 100644 --- a/ui/gameMainWindow.cpp +++ b/ui/gameMainWindow.cpp @@ -70,16 +70,11 @@ public: const auto & ref = *selected.base()->get(); clicked = typeid(ref).name(); } + else if (const auto pos = gameState->geoData->intersectRay(ray)) { + clicked = streamed_string(*pos); + } else { - try { - const auto dist = camera->pos.z / -ray.direction.z; - const auto pos = !camera->pos + (!ray.direction * dist); - - clicked = streamed_string(gameState->geoData->positionAt(pos)); - } - catch (std::range_error &) { - clicked.clear(); - } + clicked.clear(); } } } |