forked from 1b-agent/opencadstudio-upstream
feat(scene): fall back to header EXTMIN/EXTMAX for fit-all
When a fresh document hasn't tessellated yet (no wire AABB cache, no per-entity key vertices found), compute_model_space_extents() returned None, so ZOOM EXTENTS / auto_fit_viewport had to wait for the next pass before they could fit. Use the header's saved model_space_extents_min/max as a last-resort answer so the very first ZOOM EXTENTS / fit-all after open lands on the drawing immediately. LIMMIN/LIMMAX and INSBASE remain read-only metadata for now — they need a bounded-grid mode (LIMMIN/LIMMAX) and a "save as block" anchor (INSBASE) before they map onto a visible behaviour. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
1 parent
2d795e64ed
commit
65920959d4
1 file changed
+21
-3
+21
-3
@@ -1696,10 +1696,28 @@ impl Scene {
|
||||
}
|
||||
}
|
||||
if any {
|
||||
Some((min, max))
|
||||
} else {
|
||||
None
|
||||
return Some((min, max));
|
||||
}
|
||||
// Last-resort: the header's saved EXTMIN/EXTMAX. AutoCAD writes these
|
||||
// on save so opening a file gives ZOOM EXTENTS a useful answer before
|
||||
// the wire cache is built.
|
||||
const SANE_EXTENT: f64 = 1.0e16;
|
||||
let h = &self.document.header;
|
||||
let hmin = h.model_space_extents_min;
|
||||
let hmax = h.model_space_extents_max;
|
||||
if hmin.x < hmax.x
|
||||
&& hmin.y < hmax.y
|
||||
&& hmin.x.abs() < SANE_EXTENT
|
||||
&& hmax.x.abs() < SANE_EXTENT
|
||||
&& hmin.y.abs() < SANE_EXTENT
|
||||
&& hmax.y.abs() < SANE_EXTENT
|
||||
{
|
||||
return Some((
|
||||
glam::Vec3::new(hmin.x as f32, hmin.y as f32, hmin.z as f32),
|
||||
glam::Vec3::new(hmax.x as f32, hmax.y as f32, hmax.z as f32),
|
||||
));
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
/// Set a newly created viewport's `view_target` and `view_height` so that
|
||||
|
||||
Reference in new issue
Block a user