18
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-11-20 16:14:58 +01:00

fix(editor): the ray to the terrain doesn't come up under a chunk through a gap, and starts behind the camera in the top view

Coming down where there's no terrain and finding itself under the ground of the next chunk, the ray gives up and the depth
read back says where the ground is. In the top view it starts 10 km behind the plane of the camera, as far as the view sees,
so the ground higher than the camera is met too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DDcMn1Q7wdYkbxDUWscNHZ
This commit is contained in:
Claude
2026-11-11 11:36:24 +01:00
parent f1f315d629
commit 9a4d5a4688
2 changed files with 20 additions and 6 deletions

View File

@@ -3615,7 +3615,11 @@ bool editor_mode::terrain_cursor(glm::dvec3 &World) const
auto const direction = point(0.5f) - point(0.0f);
if (glm::length(direction) < 1e-9)
return false;
return m_streamer.raycast(GfxRenderer->Camera_Position() + point(0.0f), glm::normalize(direction), 5000.0, World);
// the top view sees from 10 km behind the plane of the camera (the near plane of its projection): the ray starts there,
// so the ground higher than the camera is met too
auto const back{Global.EditorOrtho ? 10000.0 : 0.0};
auto const along{glm::normalize(direction)};
return m_streamer.raycast(GfxRenderer->Camera_Position() + point(0.0f) - along * back, along, 5000.0 + back, World);
}
void editor_mode::fill_terrain_area()