mirror of
https://github.com/GTAmodding/re3.git
synced 2025-07-10 03:54:10 +00:00
Make collision code placement more like original (+ small fixes)
# Conflicts: # premake5.lua # src/CMakeLists.txt # src/collision/Collision.cpp # src/core/Collision.h
This commit is contained in:
parent
26c6908d25
commit
9bb8ebaa10
26 changed files with 953 additions and 873 deletions
27
src/collision/ColSphere.cpp
Normal file
27
src/collision/ColSphere.cpp
Normal file
|
@ -0,0 +1,27 @@
|
|||
#include "common.h"
|
||||
#include "ColSphere.h"
|
||||
#include "General.h"
|
||||
|
||||
void
|
||||
CColSphere::Set(float radius, const CVector ¢er, uint8 surf, uint8 piece)
|
||||
{
|
||||
this->radius = radius;
|
||||
this->center = center;
|
||||
this->surface = surf;
|
||||
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;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue