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 <noreply@anthropic.com>
This commit is contained in:
Dion Moult
2026-04-28 19:40:00 +10:00
parent 8282f691e8
commit 633c613da2
3 changed files with 8 additions and 8 deletions
+3 -3
View File
@@ -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)
+3 -4
View File
@@ -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; }
+2 -1
View File
@@ -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