pub(crate) const fn hex32(s: &str) -> [u8; 32] {
const fn nibble(c: u8) -> u8 {
match c {
b'0'..=b'9' => c - b'0',
b'a'..=b'f' => c - b'a' + 10,
_ => panic!("not a lower-case hex digit"),
}
}
let b = s.as_bytes();
assert!(b.len() == 64, "a digest is 64 hex digits");
let mut out = [0u8; 32];
let mut i = 0;
while i < 32 {
out[i] = nibble(b[2 * i]) * 16 + nibble(b[2 * i + 1]);
i += 1;
}
out
}
pub const PHYSICS_SEMANTICS_PINS: &[(&str, [u8; 32])] = &[
(
"Xpbd step",
hex32("cf46cd7596ad87225bc7f1e17e1296622b8ed25659d7df968f063f06885a056b"),
),
(
"Xpbd step_n",
hex32("7b962ba6d3dcd404946bcc8c6c423e75d0bdd4dfc8597026eb443c6974016d39"),
),
(
"Xpbd try_step",
hex32("7b962ba6d3dcd404946bcc8c6c423e75d0bdd4dfc8597026eb443c6974016d39"),
),
(
"Xpbd step_parallel",
hex32("7b962ba6d3dcd404946bcc8c6c423e75d0bdd4dfc8597026eb443c6974016d39"),
),
(
"Xpbd try_step_parallel",
hex32("7b962ba6d3dcd404946bcc8c6c423e75d0bdd4dfc8597026eb443c6974016d39"),
),
(
"Xpbd step_with_bridge",
hex32("d73751a75b8b95b567fc4c212638e7fd994e1506e0abbb5af49a662032c0d9fd"),
),
(
"Xpbd substep_with_bridge",
hex32("d73751a75b8b95b567fc4c212638e7fd994e1506e0abbb5af49a662032c0d9fd"),
),
(
"Tgs step",
hex32("cfb9f3e814a4b0a55c96019f1df345eb4aaba233fa5321e021dbcb916ff730fe"),
),
(
"Tgs step_n",
hex32("cfb9f3e814a4b0a55c96019f1df345eb4aaba233fa5321e021dbcb916ff730fe"),
),
(
"Tgs try_step",
hex32("cfb9f3e814a4b0a55c96019f1df345eb4aaba233fa5321e021dbcb916ff730fe"),
),
(
"contacts",
hex32("532dc2852b71eb9da1ca3a62a4f4063f2e1151561744d15852f9fd9dee6b28ad"),
),
(
"distance constraint",
hex32("4c28a6fb32ae076f393c762e590466e9d2e9786a5efacc2c1a114cdc66be5978"),
),
(
"joint",
hex32("7b962ba6d3dcd404946bcc8c6c423e75d0bdd4dfc8597026eb443c6974016d39"),
),
(
"continuous collision",
hex32("afb100a521cc3d308a842b963c1e97112ac2cd824040bb2a65fdb81c846b4d7a"),
),
(
"sleeping",
hex32("2d2fbb89f587cd27872e85f4ed2d856c72bb3f0d62a3d0d5d2f5360260ac7a86"),
),
(
"broadphase Bvh",
hex32("7b962ba6d3dcd404946bcc8c6c423e75d0bdd4dfc8597026eb443c6974016d39"),
),
(
"broadphase DynamicTree",
hex32("7b962ba6d3dcd404946bcc8c6c423e75d0bdd4dfc8597026eb443c6974016d39"),
),
(
"broadphase Hybrid",
hex32("7b962ba6d3dcd404946bcc8c6c423e75d0bdd4dfc8597026eb443c6974016d39"),
),
(
"participant",
hex32("3de49332adc74a203ca1c416e3bc162bc432aa692ff5b61a58f5aa13c14bd684"),
),
(
"cloth",
hex32("ba4fd85c6e390518ef3326802fb3a29498e1994245901e8636cdad9c0ae1d556"),
),
(
"physics2d",
hex32("9bf77c1406346913dd64841bddcb1e53c458259dd9314250ba33cc75a4216536"),
),
(
"step_parallel shared-body order",
hex32("412bed1309a8709f63637bbe6b1a796a249594c880f024f2b814834089ef16ca"),
),
(
"installed bridge",
hex32("d73751a75b8b95b567fc4c212638e7fd994e1506e0abbb5af49a662032c0d9fd"),
),
("alice-det-math", alice_det_math::SEMANTICS_ID),
];
pub const PHYSICS_SEMANTICS_BY_DET_MATH: &[([u8; 32], [u8; 32])] = &[
(
hex32("135c407d4249c1c200e4d1be79a12e848ce5c355fc3a918da965849e697ef000"),
hex32("cd9aa3b89257fc8b3e5d6714362ce4e52d4ff142baf30de2f80324e44bdd3469"),
),
(
hex32("85e0884623b154a3b2b264374907b6cbac09307ca3f9a08339e48c567d3cb315"),
hex32("79ca52976f404dfb453908970ebe45f584970ff9344a56a06aae3fc9c3c38108"),
),
];
pub const PHYSICS_SEMANTICS_ID: [u8; 32] = semantics_id_for(&alice_det_math::SEMANTICS_ID);
#[must_use]
pub const fn semantics_id_for(det_math: &[u8; 32]) -> [u8; 32] {
let mut i = 0;
while i < PHYSICS_SEMANTICS_BY_DET_MATH.len() {
if same32(&PHYSICS_SEMANTICS_BY_DET_MATH[i].0, det_math) {
return PHYSICS_SEMANTICS_BY_DET_MATH[i].1;
}
i += 1;
}
panic!("alice-det-math SEMANTICS_ID has no row in PHYSICS_SEMANTICS_BY_DET_MATH: add its fold");
}
const fn same32(a: &[u8; 32], b: &[u8; 32]) -> bool {
let mut i = 0;
while i < 32 {
if a[i] != b[i] {
return false;
}
i += 1;
}
true
}
pub const PREVIOUS_PHYSICS_SEMANTICS_IDS: &[[u8; 32]] = &[hex32(
"cd9aa3b89257fc8b3e5d6714362ce4e52d4ff142baf30de2f80324e44bdd3469",
)];