svenstaro / bvh

A fast BVH using SAH in rust
https://docs.rs/bvh
MIT License
227 stars 38 forks source link

Port from nalgebra to glam #63

Closed mdesmedt closed 3 years ago

mdesmedt commented 3 years ago

Ported the use of math types to glam. Mostly very straightforward. It was 99% search & replace. Tests and benchmarks pass.

I've opted to type alias glam::Vec3 directly in lib.rs for visibility and simplicity. So now we have bvh::Point3 and bvh::Vector3 which are used everywhere.

Changes of interest: lib.rs for the above type aliases aabb.relative_eq (no longer using approx, because it's not implemented on Vec3) ray.sign (split out the Vector3 into 3 variables)

Resolves #38

codecov-commenter commented 3 years ago

Codecov Report

Merging #63 (a6e9087) into master (4785cc5) will increase coverage by 0.07%. The diff coverage is 97.67%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #63      +/-   ##
==========================================
+ Coverage   79.84%   79.92%   +0.07%     
==========================================
  Files           9        9              
  Lines        1523     1529       +6     
==========================================
+ Hits         1216     1222       +6     
  Misses        307      307              
Impacted Files Coverage Δ
src/axis.rs 42.10% <ø> (ø)
src/bvh/bvh_impl.rs 61.99% <ø> (ø)
src/bvh/iter.rs 87.23% <ø> (ø)
src/bvh/optimization.rs 85.68% <ø> (ø)
src/flat_bvh.rs 63.63% <ø> (ø)
src/aabb.rs 93.08% <93.33%> (+0.17%) :arrow_up:
src/ray.rs 93.02% <100.00%> (+0.10%) :arrow_up:
src/testbase.rs 89.06% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 4785cc5...a6e9087. Read the comment docs.

mdesmedt commented 3 years ago

Hmm. Note: Besides the straightforward port, we should investigate whether to use the aligned Vec3A instead of Vec3 for potentially better SIMD code generation. I'll take a look.

mdesmedt commented 3 years ago

Here are benchmark results with Vec3A. Building seems to be slightly faster overall, intersection (presumably due to 25% increased memory traffic of loading points) slightly slower. This might change if intersection was SIMD-ified, but changing from Vec3 to Vec3A is just the type alias in lib.rs so we can always do it later. Let's just use Vec3 for now. https://gist.github.com/mdesmedt/b13f076a8385615015b13c0c1c9674bd