fix: honor GRIDUNIT X/Y spacing and LIMITS option in grid display

The viewport grid ignored the configured spacing and forced square grids: compute_grid_step hardcoded a 1.0 base, a single shared step drove both line families (including the tangent derivative used for gap measurement), and the display always clipped to LIMITS despite the beyond-Limits option.

Grid spacing now scales per-axis from GRIDUNIT via compute_grid_steps (adaptive 5x growth, fixed passthrough), GridParams carries step_x/step_y, snap tolerances follow the visible steps, and the LIMITS clip is skipped when beyond-Limits is set. Also fixes a per-axis overflow fallback that returned the X base for Y. Spacing state (X/Y, adaptive, beyond-Limits) is stored on the app and persisted to UserSettings at defaults; dialog wiring follows separately.
This commit is contained in:
Karim Jerbi committed 2026-09-17 13:52:37 +01:00
1 parent bb29b987c2
commit 05f462f294
7 files changed
+246 -73

No files matched your search

+11
View File
@@ -542,6 +542,13 @@ pub(super) struct OpenCADStudio {
snap_angle_deg: f32,
/// Show grid lines in the viewport (F7).
show_grid: bool,
/// GRIDUNIT X/Y display spacing backing the DSettings grid-resize inputs.
pub grid_spacing_x: f32,
pub grid_spacing_y: f32,
/// Adaptive grid: scale GRIDUNIT up by 5x steps to stay readable.
pub grid_adaptive: bool,
/// Display the grid beyond LIMITS (infinite) instead of clipping to them.
pub grid_beyond_limits: bool,
/// Dynamic input overlay (F12): show coordinate tooltip near cursor.
dyn_input: bool,
/// Currently visible page in the application Options dialog.
@@ -3806,6 +3813,10 @@ impl OpenCADStudio {
iso_plane: settings::IsoPlane::Left,
snap_angle_deg: 0.0,
show_grid: false,
grid_spacing_x: 10.0,
grid_spacing_y: 10.0,
grid_adaptive: true,
grid_beyond_limits: true,
dyn_input: true,
options_tab: crate::ui::window::options::OptionsTab::General,
spacemouse: {