Skip to content
Snippets Groups Projects
Commit 08b57b88 authored by Lukas Werner's avatar Lukas Werner
Browse files

Added transform to BF method to Ray class

parent 053de11f
No related merge requests found
......@@ -45,6 +45,7 @@ inline bool intersects(const AABB& aabb, const Ray& ray, real_t& t, real_t paddi
inline bool intersects(const SphereID sphere, const Ray& ray, real_t& t, Vec3& n);
inline bool intersects(const PlaneID plane, const Ray& ray, real_t& t, Vec3& n);
inline bool intersects(const BoxID box, const Ray& ray, real_t& t, Vec3& n);
inline bool intersects(const CapsuleID capsule, const Ray& ray, real_t& t, Vec3& n);
struct IntersectsFunctor
{
......@@ -122,7 +123,7 @@ inline bool intersects(const PlaneID plane, const Ray& ray, real_t& t, Vec3& n)
}
inline bool intersects(const BoxID box, const Ray& ray, real_t& t, Vec3& n) {
Ray transformedRay(box->pointFromWFtoBF(ray.getOrigin()), box->vectorFromWFtoBF(ray.getDirection()));
Ray transformedRay = ray.transformedToBF(box);
const Vec3& lengths = box->getLengths();
const Vec3 lengthsHalved = lengths/real_t(2);
......
......@@ -117,6 +117,14 @@ public:
sign_[1] = int8_c(inv_direction_[1] < 0);
sign_[2] = int8_c(inv_direction_[2] < 0);
}
/*!\brief Transforms the ray to the body frame.
*
* \return Ray transformed to the body frame.
*/
Ray transformedToBF(const BodyID body) const {
return Ray(body->pointFromWFtoBF(getOrigin()), body->vectorFromWFtoBF(getDirection()));
}
//@}
};
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment