OPC_PlanesTriOverlap.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  2. /**
  3. * Planes-triangle overlap test.
  4. * \param in_clip_mask [in] bitmask for active planes
  5. * \return TRUE if triangle overlap planes
  6. * \warning THIS IS A CONSERVATIVE TEST !! Some triangles will be returned as intersecting, while they're not!
  7. */
  8. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  9. inline_ BOOL PlanesCollider::PlanesTriOverlap(udword in_clip_mask)
  10. {
  11. // Stats
  12. mNbVolumePrimTests++;
  13. const Plane* p = mPlanes;
  14. udword Mask = 1;
  15. while(Mask<=in_clip_mask)
  16. {
  17. if(in_clip_mask & Mask)
  18. {
  19. float d0 = p->Distance(*mVP.Vertex[0]);
  20. float d1 = p->Distance(*mVP.Vertex[1]);
  21. float d2 = p->Distance(*mVP.Vertex[2]);
  22. if(d0>0.0f && d1>0.0f && d2>0.0f) return FALSE;
  23. // if(!(IR(d0)&SIGN_BITMASK) && !(IR(d1)&SIGN_BITMASK) && !(IR(d2)&SIGN_BITMASK)) return FALSE;
  24. }
  25. Mask+=Mask;
  26. p++;
  27. }
  28. /*
  29. for(udword i=0;i<6;i++)
  30. {
  31. float d0 = p[i].Distance(mLeafVerts[0]);
  32. float d1 = p[i].Distance(mLeafVerts[1]);
  33. float d2 = p[i].Distance(mLeafVerts[2]);
  34. if(d0>0.0f && d1>0.0f && d2>0.0f) return false;
  35. }
  36. */
  37. return TRUE;
  38. }