From 633c613da21fd823f3e3ac1cbc0f7bc6a2f8680f Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Tue, 28 Apr 2026 19:40:00 +1000 Subject: [PATCH] ifcviewer: drop unused SidecarHeader reserved field, bump v8 -> v9 The reserved uint32_t was always written as 0 and never inspected on read. Removing it shrinks the header from 16 to 12 bytes; the version bump makes pre-existing sidecars fail the version check cleanly rather than misreading by 4 bytes. Co-Authored-By: Claude Opus 4.7 --- src/ifcviewer/README.md | 6 +++--- src/ifcviewer/SidecarCache.cpp | 7 +++---- src/ifcviewer/SidecarCache.h | 3 ++- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/ifcviewer/README.md b/src/ifcviewer/README.md index 301322851c..4d8290d736 100644 --- a/src/ifcviewer/README.md +++ b/src/ifcviewer/README.md @@ -116,7 +116,7 @@ engine with a Qt6 interface and OpenGL 4.5 rendering. | `InstancedGeometry.h` | Shared structs: `MeshInfo`, `InstanceCpu`, `InstanceGpu`, chunk records | | `BvhAccel.h/cpp` | Median-split BVH builder; operates on instance world-AABBs | | `LodBuilder.h/cpp` | Post-stream decimation of unique meshes via meshoptimizer (`simplifySloppy`) | -| `SidecarCache.h/cpp` | Raw binary `.ifcview` (v8) sidecar read/write | +| `SidecarCache.h/cpp` | Raw binary `.ifcview` (v9) sidecar read/write | | `AppSettings.h/cpp` | Persisted preferences (geometry library, stats overlay, backface culling) | | `SettingsWindow.h/cpp` | Settings dialog | | `CMakeLists.txt` | Build configuration | @@ -293,13 +293,13 @@ while stack not empty: Depth 64 is enough for billions of items on any balanced tree. The stack is on the C++ stack, zero per-frame allocation. -#### Sidecar format (`.ifcview`, v8) +#### Sidecar format (`.ifcview`, v9) Raw memory dump, Blender-`.blend`-style — no serialisation, no parsing. Stores everything needed to skip the `IfcGeom::Iterator` pass: ``` -SidecarHeader (magic "IFVW", version, endian, ...) +SidecarHeader (magic "IFVW", version, endian) uint32_t + uint8_t[] vertex data (12 B/vert quantized; per-mesh basis in MeshInfo) uint32_t + uint32_t[] index data (mesh-local) uint32_t + MeshInfo[] per-unique-mesh metadata (56 B each, incl. LOD1 slice) diff --git a/src/ifcviewer/SidecarCache.cpp b/src/ifcviewer/SidecarCache.cpp index 12077e9c4a..b603dce354 100644 --- a/src/ifcviewer/SidecarCache.cpp +++ b/src/ifcviewer/SidecarCache.cpp @@ -17,9 +17,9 @@ * * ********************************************************************************/ -// v8 layout (all multi-byte fields native-endian; endianness marker in header). +// v9 layout (all multi-byte fields native-endian; endianness marker in header). // -// SidecarHeader (16 bytes) +// SidecarHeader (12 bytes) // // uint32_t num_vertex_bytes // uint8_t[] vertex data (12 B/vertex: pos u16x3 + oct-normal i8x2 + rgba8) @@ -46,7 +46,6 @@ struct SidecarHeader { uint32_t magic; uint32_t version; uint32_t endian; - uint32_t reserved; }; // foo.ifc -> foo.ifcview @@ -87,7 +86,7 @@ bool writeSidecar(const std::string& ifc_path, const SidecarData& data) { FILE* f = fopen(path.c_str(), "wb"); if (!f) return false; - SidecarHeader hdr = { SIDECAR_MAGIC, SIDECAR_VERSION, SIDECAR_ENDIAN, 0 }; + SidecarHeader hdr = { SIDECAR_MAGIC, SIDECAR_VERSION, SIDECAR_ENDIAN }; if (fwrite(&hdr, sizeof(hdr), 1, f) != 1) { fclose(f); return false; } if (!writeVec(f, data.vertices)) { fclose(f); return false; } diff --git a/src/ifcviewer/SidecarCache.h b/src/ifcviewer/SidecarCache.h index 47411e5d5f..95c8a51c38 100644 --- a/src/ifcviewer/SidecarCache.h +++ b/src/ifcviewer/SidecarCache.h @@ -45,7 +45,8 @@ static constexpr uint32_t SIDECAR_MAGIC = 0x49465657; // "IFVW" // on path stem (foo.ifc and foo.ifcdb/ both map to foo.ifcview) so the // same cache serves either source format. Staleness is user-managed // (delete the sidecar to force a rebuild). -static constexpr uint32_t SIDECAR_VERSION = 8; +// v9 = unused `reserved` field dropped from header (16 B -> 12 B). +static constexpr uint32_t SIDECAR_VERSION = 9; static constexpr uint32_t SIDECAR_ENDIAN = 0x01020304; // Fixed-size element record. Strings are stored as (offset, length) pairs