Skip to content

Commit

Permalink
Merge pull request #16 from eloj/test-avx-builder
Browse files Browse the repository at this point in the history
Test the AVX builder too.
  • Loading branch information
jbikker authored Nov 9, 2024
2 parents 18accc1 + 9df38a4 commit 5eaf18c
Showing 1 changed file with 22 additions and 8 deletions.
30 changes: 22 additions & 8 deletions tiny_bvh_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,31 @@ int main()
v2.z = z + 0.1f * uniform_rand();
}

// build a BVH over the scene
tinybvh::BVH bvh;
bvh.Build( (tinybvh::bvhvec4*)triangles, TRIANGLE_COUNT );

// from here: play with the BVH!
tinybvh::bvhvec3 O( 0.5f, 0.5f, -1 );
tinybvh::bvhvec3 D( 0.1f, 0, 2 );
tinybvh::Ray ray( O, D );
int steps = bvh.Intersect( ray );
printf( "nearest intersection: %f (found in %i traversal steps).\n", ray.hit.t, steps );

// build a BVH over the scene
{
tinybvh::BVH bvh;
bvh.Build( (tinybvh::bvhvec4*)triangles, TRIANGLE_COUNT );

// from here: play with the BVH!
int steps = bvh.Intersect( ray );
printf( "std: nearest intersection: %f (found in %i traversal steps).\n", ray.hit.t, steps );
}

#if defined(BVH_USEAVX)
// Same thing, using the AVX builder.
{
tinybvh::BVH bvh;
bvh.BuildAVX( (tinybvh::bvhvec4*)triangles, TRIANGLE_COUNT );

int steps = bvh.Intersect( ray );
printf( "avx: nearest intersection: %f (found in %i traversal steps).\n", ray.hit.t, steps );
}
#endif

// all done.
return 0;
}
}

0 comments on commit 5eaf18c

Please sign in to comment.