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

Method TraceRaySlow

core/aabbtree.cpp:650–694  ·  view source on GitHub ↗

bool AABBTree::TraceRay(const Vec3& start, const Vector3& dir, float& outT, Vector3* outNormal) const { outT = FLT_MAX; TraceRecursive(0, start, dir, outT, outNormal); return (outT != FLT_MAX); } void AABBTree::TraceRecursive(uint32_t n, const Vec3& start, const Vector3& dir, float& outT, Vector3* outNormal) const { const Node& node = m_nodes[n]; if (node.m_numFaces == 0)

Source from the content-addressed store, hash-verified

648}
649*/
650bool AABBTree::TraceRaySlow(const Vec3& start, const Vector3& dir, float& outT, float& outU, float& outV, float& outW, float& faceSign, uint32_t& faceIndex) const
651{
652 const uint32_t numFaces = GetNumFaces();
653
654 float minT, minU, minV, minW, minS;
655 minT = minU = minV = minW = minS = FLT_MAX;
656
657 Vector3 minNormal(0.0f, 1.0f, 0.0f);
658
659 Vector3 n(0.0f, 1.0f, 0.0f);
660 float t, u, v, w, s;
661 bool hit = false;
662 uint32_t minIndex = 0;
663
664 for (uint32_t i=0; i < numFaces; ++i)
665 {
666 const Vec3& a = m_vertices[m_indices[i*3+0]];
667 const Vec3& b = m_vertices[m_indices[i*3+1]];
668 const Vec3& c = m_vertices[m_indices[i*3+2]];
669
670 if (IntersectRayTriTwoSided(start, dir, a, b, c, t, u, v, w, s))
671 {
672 if (t < minT)
673 {
674 minT = t;
675 minU = u;
676 minV = v;
677 minW = w;
678 minS = s;
679 minNormal = n;
680 minIndex = i;
681 hit = true;
682 }
683 }
684 }
685
686 outT = minT;
687 outU = minU;
688 outV = minV;
689 outW = minW;
690 faceSign = minS;
691 faceIndex = minIndex;
692
693 return hit;
694}
695
696void AABBTree::DebugDraw()
697{

Callers

nothing calls this directly

Calls 1

IntersectRayTriTwoSidedFunction · 0.85

Tested by

no test coverage detected