22 #ifndef __ND_INTERSECTION_H__
23 #define __ND_INTERSECTION_H__
25 #include "ndCoreStdafx.h"
43 D_CORE_API ndFloat32 ndRayCastSphere (
const ndVector& p0,
const ndVector& p1,
const ndVector& origin, ndFloat32 radius);
50 ndInt32 mask = val.GetSignMask() & 0x07;
51 return (mask == 0x07);
56 ndVector val(ndVector::m_negOne & ((p0 >= q0) & (p1 <= q1)));
57 ndInt32 mask = val.GetSignMask() & 0x07;
58 return (mask == 0x07);
64 return (p0.m_x != q0.m_x) || (p0.m_y != q0.m_y) || (p0.m_z != q0.m_z) || (p1.m_x != q1.m_x) || (p1.m_y != q1.m_y) || (p1.m_z != q1.m_z);
67 inline void ndMovingAABB (
ndVector& p0,
ndVector& p1,
const ndVector& veloc,
const ndVector& omega, ndFloat32 timestep, ndFloat32 maxRadius, ndFloat32 minRadius)
69 ndVector linearStep (veloc.Scale (timestep));
72 ndAssert (omega.m_w == ndFloat32 (0.0f));
73 ndFloat32 maxAngle = ndMin (ndSqrt (omega.DotProduct(omega).GetScalar() * timestep * timestep), ndFloat32 (45.0f * ndDegreeToRad));
75 ndFloat32 angularTravel = (maxRadius - minRadius) * maxAngle;
76 ndVector angularStep (angularTravel, angularTravel, angularTravel, ndFloat32 (0.0f));
82 p0 = r0.GetMin (q0) & ndVector::m_triplexMask;
83 p1 = r1.GetMax (q1) & ndVector::m_triplexMask;
99 inline ndFloat32 ndBoxDistanceToOrigin2 (
const ndVector& minBox,
const ndVector& maxBox)
101 ndAssert(maxBox.m_x >= minBox.m_x);
102 ndAssert(maxBox.m_y >= minBox.m_y);
103 ndAssert(maxBox.m_z >= minBox.m_z);
104 const ndVector mask (((minBox * maxBox) > ndVector::m_zero) & ndVector::m_triplexMask);
105 const ndVector dist (maxBox.Abs().GetMin (minBox.Abs()) & mask);
106 return dist.DotProduct(dist).GetScalar();