17
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-10-29 08:07:29 +01:00

Put the editor viewport into a top-down orthographic plan view

Opening the Plan tool now switches the whole colour pass to an orthographic
projection and pins the camera looking straight down, so the plan is drawn
against the loaded scenery rather than in a window of its own. Closing the
tool hands the camera's orientation back; leaving the editor clears the view
outright. The wheel changes how much ground fits on screen instead of moving
the camera, which with no perspective would change nothing but the clipping.

Both configured backends follow: the experimental renderer swaps the pass
projection (and fits its shadow cascades to it), the modern GL renderer uses
its existing ortho helpers. Everything reading the pass projection - the
mouse ray, the frustum test - picks the change up on its own.

The experimental renderer also publishes its colour pass camera now, which
it previously left at the interface defaults, so overlays can place world
points on screen.
This commit is contained in:
maj00r
2026-07-31 19:15:17 +02:00
committed by maj00r
parent 4bef28cf94
commit db49039b9d
8 changed files with 109 additions and 12 deletions

View File

@@ -1591,7 +1591,19 @@ void opengl33_renderer::setup_pass(viewport_config &Viewport, renderpass_config
auto const zfar = ( Zfar > 1.f ? Zfar : Config.draw_range * Zfar );
auto const znear = ( Znear > 1.f ? Znear : Znear > 0.f ? Znear * zfar : 0.1f * Global.ZoomFactor);
camera.projection() = perspective_projection(Viewport.projection, znear, zfar, frustumtest_proj);
// the editor's top-down plan view drops the perspective, so distances read the same wherever
// they sit on screen; the off-axis virtual screen above has no meaning then
if (Global.editor_ortho && Viewport.main && Viewport.proj_type == viewport_config::normal)
{
auto const halfheight = Global.editor_ortho_extent;
auto const halfwidth = halfheight * std::max(1.f, (float)Global.window_size.x) / std::max(1.f, (float)Global.window_size.y);
camera.projection() = ortho_projection(-halfwidth, halfwidth, -halfheight, halfheight, znear, zfar);
frustumtest_proj = ortho_frustumtest_projection(-halfwidth, halfwidth, -halfheight, halfheight, znear, zfar);
}
else
{
camera.projection() = perspective_projection(Viewport.projection, znear, zfar, frustumtest_proj);
}
break;
}
case rendermode::shadows: