collate_rotation_aware_placements

Function collate_rotation_aware_placements 

Source
pub(crate) fn collate_rotation_aware_placements<M: Borrow<MeshData>>(
    meshes: &[M],
    baked_basis: Option<&Matrix4<f64>>,
) -> FxHashMap<usize, RotatedPlacement>
Expand description

Group instanceable meshes by representation identity (collate_refs) and verify each occurrence’s derived rigid placement against its own baked geometry (issue #3575). Returns a map from a mesh’s index in meshes to the verified placement it should be emitted with; a mesh absent from the map falls back to the pre-#3575 content-hash dedup in parquet_optimized.rs. Verification is all-or-nothing per group: one occurrence over tolerance drops the ENTIRE representation group from the map, not just that occurrence, so a group never ships half-instanced.

Deliberately excludes the RIGID tier (InstanceMeta::canonical_transform set): those groups substitute a congruent-but-not-bit-identical template, so the per-vertex residual check above isn’t meaningful the same way, and this endpoint has no way to signal “close enough, not exact” to a client decoding a lossless-looking mesh table. Only exact-bit groups (the IfcMappedItem / shared-IfcRepresentationMap case the issue reports) are deduplicated this way.

baked_basis is baked_basis_zup for the model these meshes came from, or None when the caller genuinely has no ProcessingResult to read it off (a per-batch streaming writer, a test over synthetic meshes) and the vertices are therefore native.

Generic over Borrow so the streaming route can put an earlier batch’s retained templates in front of the current batch (#5407) as a slice of references, without cloning the batch to build one contiguous slice.