diff options
author | erorcun <erayorcunus@gmail.com> | 2020-06-14 21:59:02 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-14 21:59:02 +0200 |
commit | f64d3ad7de85bfd2f3e9aac4530f1e255b542295 (patch) | |
tree | 8d0c6b4e752fcfaf4d2d0237bed786c2de9e7e84 /src/core/Collision.cpp | |
parent | Merge pull request #625 from aap/miami (diff) | |
parent | Peds, mission switcher & fixes (diff) | |
download | re3-f64d3ad7de85bfd2f3e9aac4530f1e255b542295.tar re3-f64d3ad7de85bfd2f3e9aac4530f1e255b542295.tar.gz re3-f64d3ad7de85bfd2f3e9aac4530f1e255b542295.tar.bz2 re3-f64d3ad7de85bfd2f3e9aac4530f1e255b542295.tar.lz re3-f64d3ad7de85bfd2f3e9aac4530f1e255b542295.tar.xz re3-f64d3ad7de85bfd2f3e9aac4530f1e255b542295.tar.zst re3-f64d3ad7de85bfd2f3e9aac4530f1e255b542295.zip |
Diffstat (limited to 'src/core/Collision.cpp')
-rw-r--r-- | src/core/Collision.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/core/Collision.cpp b/src/core/Collision.cpp index b68214af..77e28a10 100644 --- a/src/core/Collision.cpp +++ b/src/core/Collision.cpp @@ -1801,6 +1801,21 @@ CColSphere::Set(float radius, const CVector ¢er, uint8 surf, uint8 piece) this->piece = piece; } +bool +CColSphere::IntersectRay(CVector const& from, CVector const& dir, CVector &entry, CVector &exit) +{ + CVector distToCenter = from - center; + float distToTouchSqr = distToCenter.MagnitudeSqr() - sq(radius); + float root1, root2; + + if (!CGeneral::SolveQuadratic(1.0f, DotProduct(distToCenter, dir) * 2.f, distToTouchSqr, root1, root2)) + return false; + + entry = from + dir * root1; + exit = from + dir * root2; + return true; +} + void CColBox::Set(const CVector &min, const CVector &max, uint8 surf, uint8 piece) { |