Skip to content

Commit

Permalink
Update everything
Browse files Browse the repository at this point in the history
  • Loading branch information
svenstaro committed Jul 5, 2018
1 parent fb667e7 commit 259eccd
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 17 deletions.
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ license = "MIT"
[dependencies]
approx = "0.2"
nalgebra = "0.15.3"
rand = "0.3.14"
log = "0.3.7"
rand = "0.5"
log = "0.4"

[dev-dependencies]
quickcheck = "0.4.1"
quickcheck = "0.6"
obj-rs = "0.4"

[profile.release]
Expand Down
9 changes: 2 additions & 7 deletions src/bvh/optimization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -327,19 +327,14 @@ impl BVH {
*self.nodes[node_index].child_l_aabb_mut() = child_l_aabb;
*self.nodes[node_index].child_r_aabb_mut() = child_r_aabb;

/// Returns true randomly, with a chance given by the parameter.
fn chance(chance: f32) -> bool {
let mut rng = thread_rng();
rng.next_f32() < chance
}

// Only execute the following block, if `node_index` does not reference the root node.
if node_index != 0 {
// Even with no rotation being useful for this node, a parent node's rotation
// could be beneficial, so queue the parent *sometimes*. For reference see:
// https://github.com/jeske/SimpleScene/blob/master/SimpleScene/Util/ssBVH/ssBVH_Node.cs#L307
// TODO Evaluate whether this is a smart thing to do.
if chance(0.01f32) {
let mut rng = thread_rng();
if rng.gen_bool(0.01) {
Some(OptimizationIndex::Refit(parent_index))
} else {
// Otherwise, we still have to fix the parent's AABBs
Expand Down
12 changes: 6 additions & 6 deletions src/ray.rs
Original file line number Diff line number Diff line change
Expand Up @@ -485,8 +485,8 @@ mod tests {
#[bench]
/// Benchmark for the optimized intersection algorithm.
fn bench_intersects_aabb(b: &mut ::test::Bencher) {
let seed = [0];
let mut rng = StdRng::from_seed(&seed);
let seed = [0; 32];
let mut rng = StdRng::from_seed(seed);

b.iter(|| {
let one_thousand = ::test::black_box(1000);
Expand All @@ -500,8 +500,8 @@ mod tests {
#[bench]
/// Benchmark for the naive intersection algorithm.
fn bench_intersects_aabb_naive(b: &mut ::test::Bencher) {
let seed = [0];
let mut rng = StdRng::from_seed(&seed);
let seed = [0; 32];
let mut rng = StdRng::from_seed(seed);

b.iter(|| {
let one_thousand = ::test::black_box(1000);
Expand All @@ -515,8 +515,8 @@ mod tests {
#[bench]
/// Benchmark for the branchless intersection algorithm.
fn bench_intersects_aabb_branchless(b: &mut ::test::Bencher) {
let seed = [0];
let mut rng = StdRng::from_seed(&seed);
let seed = [0; 32];
let mut rng = StdRng::from_seed(seed);

b.iter(|| {
let one_thousand = ::test::black_box(1000);
Expand Down
6 changes: 5 additions & 1 deletion src/testbase.rs
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,11 @@ pub fn randomly_transform_scene(
seed: &mut u64,
) -> HashSet<usize> {
let mut indices: Vec<usize> = (0..triangles.len()).collect();
let mut rng: StdRng = SeedableRng::from_seed([*seed as usize].as_ref());
let mut seed_array = [0u8; 32];
for i in 0..seed_array.len() {
seed_array[i] = seed.to_bytes()[i % 8];
}
let mut rng: StdRng = SeedableRng::from_seed(seed_array);
rng.shuffle(&mut indices);
indices.truncate(amount);

Expand Down

0 comments on commit 259eccd

Please sign in to comment.