mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-18 00:05:08 +00:00
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.
This commit is contained in:
1 parent
e22ccf3511
commit
203f225562
1 file changed
+8
-1
@@ -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
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user