Skip to main content

compose_trs_to_mat4

Function compose_trs_to_mat4 

pub fn compose_trs_to_mat4(batch: &TrsBatchSoa, out: &mut [Mat4])
Expand description

Composes out[i] = T · R · S for every entity in batch, the same column-major affine matrix Mat4::from_translation(t) * Mat4::from_quat(q) * Mat4::from_scale(s) produces — eight entities per [f32x8] tile, scalar for the ragged tail.

The quaternion is taken as-is (not renormalised), matching Mat4::from_quat. The last matrix row is written as the exact affine constant [0, 0, 0, 1].

Performance caveat (measured): because the output is array-of-structs Mat4, each lane is transposed back out individually, and that scatter dominates the relatively cheap quaternion expansion — so for AoS Mat4 output this kernel is slower than compose_trs_to_mat4_scalar. The explicit-SIMD win materialises only when the data stays field-SoA resident across the loop (see normalize_quat_batch, which is in-place SoA and does win). Use this kernel only inside a pipeline whose result also stays SoA, not for a one-off SoA→AoS transpose.

§Panics

Panics if out.len() != batch.len().