Skip to content

Commit

Permalink
Add option to eliminate dot product in sphere intersection, when the …
Browse files Browse the repository at this point in the history
…ray is known to be normalized
  • Loading branch information
madmann91 committed Aug 19, 2021
1 parent df95019 commit bc3eff9
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion include/bvh/sphere.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,10 @@ struct Sphere {
return BoundingBox<Scalar>(origin - Vector3<Scalar>(radius), origin + Vector3<Scalar>(radius));
}

template <bool AssumeNormalized = false>
std::optional<Intersection> intersect(const Ray<Scalar>& ray) const {
auto oc = ray.origin - origin;
auto a = dot(ray.direction, ray.direction);
auto a = AssumeNormalized ? Scalar(1) : dot(ray.direction, ray.direction);
auto b = 2 * dot(ray.direction, oc);
auto c = dot(oc, oc) - radius * radius;

Expand Down

0 comments on commit bc3eff9

Please sign in to comment.