forked from 1b-agent/opencadstudio-upstream
Revert: stop honoring BlockRecord.is_loaded for xref skip decision
Empirically the DWG \"loaded\" bit doesn't track AutoCAD's XREF Manager \"Loaded\"/\"Unloaded\" state reliably: - File A: manager \"Loaded\", on-disk is_loaded = Some(true) - File B: manager \"Loaded\", on-disk is_loaded = Some(false) Same UI state, opposite bit values, so we were incorrectly skipping xrefs the user wants loaded. Drop the `is_loaded == Some(false)` skip and auto-resolve every xref again. The OOM problem this was meant to mitigate is now addressed by the frustum culler, so loading more xrefs no longer threatens the GPU budget. The `BlockRecord::is_loaded` field + acadrust patch stay in place so we can revisit once we identify the actual on-disk representation of XREF→Unload (likely an XREF dependency record or ACAD_XREF_PANEL_DATA xrecord). Co-Authored-By: Claude Opus 4.7 <[email protected]>
This commit is contained in:
1 parent
8d5ecdef51
commit
0996b75bdd
1 file changed
+12
-15
+12
-15
@@ -34,28 +34,25 @@ pub struct XrefInfo {
|
||||
///
|
||||
/// Returns a list of [`XrefInfo`] describing each xref block found.
|
||||
pub fn resolve_xrefs(doc: &mut CadDocument, base_dir: &Path) -> Vec<XrefInfo> {
|
||||
// Collect xref blocks: (name, raw_path, block_record_handle, is_loaded)
|
||||
// is_loaded == Some(false) means the host DWG marked this xref Unloaded
|
||||
// via XREF→Unload; respect that and skip reading the external file.
|
||||
let xref_entries: Vec<(String, String, Handle, Option<bool>)> = doc
|
||||
// Collect xref blocks: (name, raw_path, block_record_handle)
|
||||
//
|
||||
// Note: `BlockRecord::is_loaded` (the DWG R2000+ "loaded" bit) turned out
|
||||
// to be unreliable as a signal of AutoCAD's Unload state — different
|
||||
// files with xrefs the manager calls "Loaded" carry both `Some(true)`
|
||||
// and `Some(false)` on disk. Until we identify the actual on-disk
|
||||
// representation of XREF→Unload (likely in an XREF dependency record
|
||||
// or ACAD_XREF_PANEL_DATA xrecord), we auto-resolve every xref and
|
||||
// rely on frustum culling to keep the GPU bounded.
|
||||
let xref_entries: Vec<(String, String, Handle)> = doc
|
||||
.block_records
|
||||
.iter()
|
||||
.filter(|br| (br.flags.is_xref || br.flags.is_xref_overlay) && !br.xref_path.is_empty())
|
||||
.map(|br| (br.name.clone(), br.xref_path.clone(), br.handle, br.is_loaded))
|
||||
.map(|br| (br.name.clone(), br.xref_path.clone(), br.handle))
|
||||
.collect();
|
||||
|
||||
let mut result = Vec::new();
|
||||
|
||||
for (block_name, raw_path, br_handle, is_loaded) in xref_entries {
|
||||
if is_loaded == Some(false) {
|
||||
result.push(XrefInfo {
|
||||
name: block_name,
|
||||
path: raw_path,
|
||||
status: XrefStatus::Unloaded,
|
||||
});
|
||||
continue;
|
||||
}
|
||||
|
||||
for (block_name, raw_path, br_handle) in xref_entries {
|
||||
let resolved = resolve_path(&raw_path, base_dir);
|
||||
|
||||
let status = match &resolved {
|
||||
|
||||
Reference in new issue
Block a user