MCPcopy Create free account
hub / github.com/NVIDIAGameWorks/FleX / IntersectLineTri

Function IntersectLineTri

core/maths.h:1232–1250  ·  view source on GitHub ↗

intersects a line (through points p and q, against a triangle a, b, c - mostly taken from Real Time Collision Detection - p186

Source from the content-addressed store, hash-verified

1230
1231// intersects a line (through points p and q, against a triangle a, b, c - mostly taken from Real Time Collision Detection - p186
1232CUDA_CALLABLE inline bool IntersectLineTri(const Vec3& p, const Vec3& q, const Vec3& a, const Vec3& b, const Vec3& c)//, float& t, float& u, float& v, float& w, Vec3* normal, float expand)
1233{
1234 const Vec3 pq = q-p;
1235 const Vec3 pa = a-p;
1236 const Vec3 pb = b-p;
1237 const Vec3 pc = c-p;
1238
1239 Vec3 m = Cross(pq, pc);
1240 float u = Dot(pb, m);
1241 if (u< 0.0f) return false;
1242
1243 float v = -Dot(pa, m);
1244 if (v < 0.0f) return false;
1245
1246 float w = ScalarTriple(pq, pb, pa);
1247 if (w < 0.0f) return false;
1248
1249 return true;
1250}
1251
1252CUDA_CALLABLE inline Vec3 ClosestPointToAABB(const Vec3& p, const Vec3& lower, const Vec3& upper)
1253{

Callers

nothing calls this directly

Calls 3

ScalarTripleFunction · 0.85
CrossFunction · 0.70
DotFunction · 0.70

Tested by

no test coverage detected