5#include "MRPch/MRBindingMacros.h"
25struct RayOrigin<float>
27 MR_BIND_IGNORE Simd4::F
p;
28 RayOrigin(
const Vector3f & ro ) :
p( Simd4::make( ro.x, ro.y, ro.z, 0 ) ) { }
36template <
typename T =
float>
39 assert( box.
valid() );
42 if constexpr ( std::is_same_v<T, float> )
44 using namespace Simd4;
46 static_assert(
sizeof( Box3f ) == 6 *
sizeof( float ) );
47 const float *
const c = &box.
min.x;
48 const F l = mul( sub( loadu( c ), rayOrigin.p ), prec.
invDir );
49 const F r = mul( sub( shiftDown( loadu( c + 2 ) ), rayOrigin.p ), prec.
invDir );
51 t0 = max3( minFast( l, r ), t0 );
52 t1 = min3( maxFast( l, r ), t1 );
58 const Vector3i& sign = prec.
sign;
61 t1 = std::min( (box[sign.x].x - rayOrigin.p.x) * prec.
invDir.x, t1 );
62 t0 = std::max( (box[1 - sign.x].x - rayOrigin.p.x) * prec.
invDir.x, t0 );
65 t1 = std::min( (box[sign.y].y - rayOrigin.p.y) * prec.
invDir.y, t1 );
66 t0 = std::max( (box[1 - sign.y].y - rayOrigin.p.y) * prec.
invDir.y, t0 );
69 t1 = std::min( (box[sign.z].z - rayOrigin.p.z) * prec.
invDir.z, t1 );
70 t0 = std::max( (box[1 - sign.z].z - rayOrigin.p.z) * prec.
invDir.z, t0 );
76template <
typename T =
float>
Box< Vector3< T > > Box3
Definition MRMeshFwd.h:422
Line< Vector3< T > > Line3
Definition MRMeshFwd.h:340
bool rayBoxIntersect(const Box3< T > &box, const RayOrigin< T > &rayOrigin, T &t0, T &t1, const IntersectionPrecomputes< T > &prec)
Definition MRRayBoxIntersection.h:37
Only strictly necessary for the bindings (to make MR::MeshIntersectionResult a complete type).
Definition MRCameraOrientationPlugin.h:8
V min
Definition MRBox.h:44
bool valid() const
true if the box contains at least one point
Definition MRBox.h:75
Definition MRIntersectionPrecomputes.h:114
Vector3i sign
stores signs of direction vector;
Definition MRIntersectionPrecomputes.h:124
Vector3< T > invDir
{1 / dir}
Definition MRIntersectionPrecomputes.h:116
Definition MRRayBoxIntersection.h:17
RayOrigin(const Vector3< T > &ro)
Definition MRRayBoxIntersection.h:20
Vector3< T > p
This is hidden to match the specialization below.
Definition MRRayBoxIntersection.h:19
Definition MRVector3.h:33