Skip to main content

box3d_rust/hull/
identity.rs

1//! Hull identity: content hash and byte-wise compare.
2//!
3//! The verstable `b3HullMap` is deferred — only the hash/compare primitives used by
4//! identity and serialization are ported here.
5
6use super::types::HullData;
7
8/// Spread the baked 32-bit content hash across 64 bits. (b3HashHullData)
9pub fn hash_hull_data(hull: &HullData) -> u64 {
10    (hull.hash as u64).wrapping_mul(0x9E3779B97F4A7C15)
11}
12
13/// Compare two hulls by C contiguous-blob equality. (b3CompareHullData)
14pub fn compare_hull_data(hull1: &HullData, hull2: &HullData) -> bool {
15    if core::ptr::eq(hull1, hull2) {
16        return true;
17    }
18    if hull1.byte_count != hull2.byte_count {
19        return false;
20    }
21    hull1.to_bytes() == hull2.to_bytes()
22}