diff options
author | joschiwald <joschiwald.trinity@gmail.com> | 2017-05-05 20:48:08 +0200 |
---|---|---|
committer | joschiwald <joschiwald.trinity@gmail.com> | 2017-05-05 21:22:58 +0200 |
commit | 036f67c0c144954827733cad0c5881eba1bd88e7 (patch) | |
tree | 6ebf1797fd5e27ed67049010af18ecb72aea21db /src/common/Collision/Models/GameObjectModel.cpp | |
parent | c1cc0e9949a73e1cbb2640032d5d038cca051954 (diff) |
Core/Collision: Replaced phasemask with proper phases in GameObject collision calculation
Diffstat (limited to 'src/common/Collision/Models/GameObjectModel.cpp')
-rw-r--r-- | src/common/Collision/Models/GameObjectModel.cpp | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/common/Collision/Models/GameObjectModel.cpp b/src/common/Collision/Models/GameObjectModel.cpp index b111b0de301..f3e5d9f6e64 100644 --- a/src/common/Collision/Models/GameObjectModel.cpp +++ b/src/common/Collision/Models/GameObjectModel.cpp @@ -115,7 +115,6 @@ bool GameObjectModel::initialize(std::unique_ptr<GameObjectModelOwnerBase> model name = it->second.name; iPos = modelOwner->GetPosition(); - phasemask = modelOwner->GetPhaseMask(); iScale = modelOwner->GetScale(); iInvScale = 1.f / iScale; @@ -153,9 +152,12 @@ GameObjectModel* GameObjectModel::Create(std::unique_ptr<GameObjectModelOwnerBas return mdl; } -bool GameObjectModel::intersectRay(const G3D::Ray& ray, float& MaxDist, bool StopAtFirstHit, uint32 ph_mask) const +bool GameObjectModel::intersectRay(G3D::Ray const& ray, float& maxDist, bool stopAtFirstHit, std::set<uint32> const& phases) const { - if (!(phasemask & ph_mask) || !owner->IsSpawned()) + if (!isCollisionEnabled() || !owner->IsSpawned()) + return false; + + if (!owner->IsInPhase(phases)) return false; float time = ray.intersectionTime(iBound); @@ -165,12 +167,12 @@ bool GameObjectModel::intersectRay(const G3D::Ray& ray, float& MaxDist, bool Sto // child bounds are defined in object space: Vector3 p = iInvRot * (ray.origin() - iPos) * iInvScale; Ray modRay(p, iInvRot * ray.direction()); - float distance = MaxDist * iInvScale; - bool hit = iModel->IntersectRay(modRay, distance, StopAtFirstHit); + float distance = maxDist * iInvScale; + bool hit = iModel->IntersectRay(modRay, distance, stopAtFirstHit); if (hit) { distance *= iScale; - MaxDist = distance; + maxDist = distance; } return hit; } |