|
@@ -108,8 +108,8 @@ fn to_grid(p: &Point3f, bounds: &Bounds3f, grid_res: &[i32; 3], pi: &mut Point3i
|
108
|
108
|
in_bounds
|
109
|
109
|
}
|
110
|
110
|
|
111
|
|
-fn hash(p: &Point3i, hash_size: usize) -> usize {
|
112
|
|
- (((p.x * 73856093) ^ (p.y * 19349663) ^ (p.z * 83492791)) % hash_size as i32) as usize
|
|
111
|
+fn hash(p: &Point3i, hash_size: i32) -> usize {
|
|
112
|
+ (((p.x * 73856093) ^ (p.y * 19349663) ^ (p.z * 83492791)) as u32 % hash_size as u32) as usize
|
113
|
113
|
}
|
114
|
114
|
|
115
|
115
|
/// **Main function** to **render** a scene multi-threaded (using all
|
|
@@ -382,7 +382,7 @@ pub fn render_sppm(
|
382
|
382
|
for y in p_min.y..p_max.y {
|
383
|
383
|
for x in p_min.x..p_max.x {
|
384
|
384
|
// add visible point to grid cell $(x, y, z)$
|
385
|
|
- let h: usize = hash(&Point3i { x: x, y: y, z: z }, hash_size);
|
|
385
|
+ let h: usize = hash(&Point3i { x: x, y: y, z: z }, hash_size as i32);
|
386
|
386
|
let mut node_arc: Arc<SPPMPixelListNode> =
|
387
|
387
|
Arc::new(SPPMPixelListNode::default());
|
388
|
388
|
let pixel_clone: Arc<SPPMPixel> = pixel.clone();
|
|
@@ -471,8 +471,9 @@ pub fn render_sppm(
|
471
|
471
|
&grid_res,
|
472
|
472
|
&mut photon_grid_index,
|
473
|
473
|
) {
|
474
|
|
- let h: usize = hash(&photon_grid_index, hash_size);
|
|
474
|
+ let h: usize = hash(&photon_grid_index, hash_size as i32);
|
475
|
475
|
// add photon contribution to visible points in _grid[h]_
|
|
476
|
+ assert!(h < hash_size, "hash({:?}, {:?})", photon_grid_index, hash_size);
|
476
|
477
|
if let Some(root) = grid[h].get() {
|
477
|
478
|
let mut node: &SPPMPixelListNode = root;
|
478
|
479
|
loop {
|