Made the hilbert spiral order a little more pleasant.
This commit is contained in:
parent
15cd261026
commit
167d70b8df
|
@ -19,7 +19,7 @@ use crate::{
|
|||
ray::Ray,
|
||||
scene::{Scene, SceneLightSample},
|
||||
scramble::owen4,
|
||||
space_fill::{hilbert, morton},
|
||||
space_fill::{hilbert_spiral, morton},
|
||||
timer::Timer,
|
||||
tracer::Tracer,
|
||||
};
|
||||
|
@ -128,16 +128,15 @@ impl<'a> Renderer<'a> {
|
|||
let pow2 = upper_power_of_two(larger);
|
||||
let buffer = hilbert_count; // For hilbert spiral.
|
||||
(
|
||||
(bucket_count_x / 2, bucket_count_y / 2),
|
||||
(bucket_count_x as i32 / 2 - 1, bucket_count_y as i32 / 2 - 1),
|
||||
(pow2 + buffer) * (pow2 + buffer),
|
||||
)
|
||||
};
|
||||
for hilbert_spiral_i in 0..bucket_n {
|
||||
let (bx, by) =
|
||||
crate::space_fill::hilbert_spiral::decode(hilbert_spiral_i, hilbert_count);
|
||||
let (bx, by) = hilbert_spiral::decode(hilbert_spiral_i, hilbert_count);
|
||||
|
||||
let bx = middle_bucket.0 as i32 + bx;
|
||||
let by = middle_bucket.1 as i32 + by;
|
||||
let bx = middle_bucket.0 + bx;
|
||||
let by = middle_bucket.1 + by;
|
||||
if bx < 0 || by < 0 {
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -148,10 +148,10 @@ pub mod hilbert_spiral {
|
|||
let (hx, hy) = super::hilbert::decode(hilbert_i, hilbert_size);
|
||||
let a = hilbert_size - 1;
|
||||
match section {
|
||||
0 => (hx, a - hy),
|
||||
1 => (a - hy, hx),
|
||||
2 => (a - hx, hy),
|
||||
3 => (hy, a - hx),
|
||||
0 => (hy, hx),
|
||||
1 => (a - hx, a - hy),
|
||||
2 => (a - hy, a - hx),
|
||||
3 => (hx, hy),
|
||||
_ => unreachable!(),
|
||||
}
|
||||
};
|
||||
|
@ -179,10 +179,10 @@ pub mod hilbert_spiral {
|
|||
let d = -(size as i32 / 2) + 1 + arm_n as i32;
|
||||
|
||||
match arm {
|
||||
0 => (d, -radius, 0),
|
||||
1 => (radius, d, if arm_n == (size - 2) { 2 } else { 1 }),
|
||||
2 => (-d, radius, 2),
|
||||
3 => (-radius, -d, 3),
|
||||
0 => (radius, d, 0),
|
||||
1 => (-d, radius, if arm_n == (size - 2) { 2 } else { 1 }),
|
||||
2 => (-radius, -d, 2),
|
||||
3 => (d, -radius, 3),
|
||||
_ => unreachable!(),
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user