diff options
| author | Kim Kulling <kim.kulling@googlemail.com> | 2023-04-16 18:20:14 +0200 |
|---|---|---|
| committer | Kim Kulling <kim.kulling@googlemail.com> | 2023-04-16 18:20:14 +0200 |
| commit | 5d841ec9a5889f910fe0ed906056616babefe6cf (patch) | |
| tree | 496f0103462fa58ce14ec097da422f2b3cd9db42 /code/Geometry/GeometryUtils.cpp | |
| parent | 7e5a178637ff4dbac91e55937035af0434d86bb0 (diff) | |
Refactoring: Cleanup post-processing steps.
Diffstat (limited to 'code/Geometry/GeometryUtils.cpp')
| -rw-r--r-- | code/Geometry/GeometryUtils.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/code/Geometry/GeometryUtils.cpp b/code/Geometry/GeometryUtils.cpp index ab735aa6e..92a3aa853 100644 --- a/code/Geometry/GeometryUtils.cpp +++ b/code/Geometry/GeometryUtils.cpp @@ -76,4 +76,17 @@ ai_real GeometryUtils::calculateAreaOfTriangle( const aiFace& face, aiMesh* mesh return area; } +// ------------------------------------------------------------------------------------------------ +// Check whether a ray intersects a plane and find the intersection point +bool GeometryUtils::PlaneIntersect(const aiRay& ray, const aiVector3D& planePos, + const aiVector3D& planeNormal, aiVector3D& pos) { + const ai_real b = planeNormal * (planePos - ray.pos); + ai_real h = ray.dir * planeNormal; + if ((h < 10e-5 && h > -10e-5) || (h = b/h) < 0) + return false; + + pos = ray.pos + (ray.dir * h); + return true; +} + } // namespace Assimp |
