IntersectionTestHelpers.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #pragma once
  9. #include <AzCore/Math/Vector3.h>
  10. namespace UnitTest::IntersectTest
  11. {
  12. // Implementation of the Moller Trumbore ray/triangle intersection algorithm.
  13. // ( https://en.wikipedia.org/wiki/M%C3%B6ller%E2%80%93Trumbore_intersection_algorithm )
  14. // This is used for cross-verifying that our current ray/triangle intersection logic produces consistent results with other
  15. // ray/triangle intersection algorithms and to provide comparative timing benchmarks between different algorithms.
  16. // One-sided version of the algorithm, using counter-clockwise triangle winding.
  17. bool MollerTrumboreIntersectSegmentTriangleCCW(
  18. const AZ::Vector3& p, const AZ::Vector3& q,
  19. const AZ::Vector3& a, const AZ::Vector3& b, const AZ::Vector3& c,
  20. AZ::Vector3& triNormal, float& t);
  21. // Two-sided version of the algorithm
  22. bool MollerTrumboreIntersectSegmentTriangle(
  23. const AZ::Vector3& p, const AZ::Vector3& q,
  24. const AZ::Vector3& a, const AZ::Vector3& b, const AZ::Vector3& c,
  25. AZ::Vector3& triNormal, float& t);
  26. // Implementation of the Arenberg ray/triangle intersection algorithm.
  27. // ( http://graphics.stanford.edu/pub/Graphics/RTNews/html/rtnews5b.html )
  28. // This is used for cross-verifying that our current ray/triangle intersection logic produces consistent results with other
  29. // ray/triangle intersection algorithms and to provide comparative timing benchmarks between different algorithms.
  30. // One-sided version of the algorithm, using counter-clockwise triangle winding.
  31. bool ArenbergIntersectSegmentTriangleCCW(
  32. const AZ::Vector3& p, const AZ::Vector3& q,
  33. const AZ::Vector3& a, const AZ::Vector3& b, const AZ::Vector3& c,
  34. AZ::Vector3& triNormal, float& t);
  35. // Two-sided version of the algorithm
  36. bool ArenbergIntersectSegmentTriangle(
  37. const AZ::Vector3& p, const AZ::Vector3& q,
  38. const AZ::Vector3& a, const AZ::Vector3& b, const AZ::Vector3& c,
  39. AZ::Vector3& triNormal, float& t);
  40. } // namespace UnitTest