From 203f225562114a0e227ba021b481857901e6f08f Mon Sep 17 00:00:00 2001 From: vangel76 Date: Sun, 15 Nov 2026 23:32:37 +0100 Subject: [PATCH] DDS: stop the principal-axis iteration once the axis is a fixed point A power-iteration step that gives back the same axis bit for bit gives it back on every later step, so stopping there keeps the output. Kept only if the timings show a gain. --- crates/dds/src/bc.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/crates/dds/src/bc.rs b/crates/dds/src/bc.rs index 1641a9e56..12bf15179 100644 --- a/crates/dds/src/bc.rs +++ b/crates/dds/src/bc.rs @@ -235,7 +235,14 @@ fn principal_endpoints(colours: &[[f32; 3]]) -> ([f32; 3], [f32; 3]) { if !len.is_normal() { break; } - axis = next.map(|v| v / len); + let normalised = next.map(|v| v / len); + // A step that returns the same axis, bit for bit, returns it on every later step too: + // stopping there gives the very axis the remaining steps would. Kept only if timing + // shows the comparison pays for itself. + if normalised.map(f32::to_bits) == axis.map(f32::to_bits) { + break; + } + axis = normalised; } axis };