aboutsummaryrefslogtreecommitdiff
path: root/src/common/Collision/DynamicTree.cpp
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2018-01-28 11:37:20 +0100
committerShauren <shauren.trinity@gmail.com>2018-03-25 19:28:36 +0300
commit91be2332e249147ce3169c46a7da77f0f8c2211d (patch)
treeeab9e0ab76ae523f7a843fe1c2300eba17f53af2 /src/common/Collision/DynamicTree.cpp
parent1e62b53c66829dc9820117e17bfb44cb2652f814 (diff)
Core/Entities: Phasing rewrite
* Optimized phase visibility checking * Handle all phase flags Closes #16758 Closes #21119
Diffstat (limited to 'src/common/Collision/DynamicTree.cpp')
-rw-r--r--src/common/Collision/DynamicTree.cpp22
1 files changed, 11 insertions, 11 deletions
diff --git a/src/common/Collision/DynamicTree.cpp b/src/common/Collision/DynamicTree.cpp
index 0e6c80d15ca..2fa66ab3adb 100644
--- a/src/common/Collision/DynamicTree.cpp
+++ b/src/common/Collision/DynamicTree.cpp
@@ -146,11 +146,11 @@ void DynamicMapTree::update(uint32 t_diff)
struct DynamicTreeIntersectionCallback
{
- DynamicTreeIntersectionCallback(std::set<uint32> const& phases) : _didHit(false), _phases(phases) { }
+ DynamicTreeIntersectionCallback(PhaseShift const& phaseShift) : _didHit(false), _phaseShift(phaseShift) { }
bool operator()(G3D::Ray const& r, GameObjectModel const& obj, float& distance)
{
- _didHit = obj.intersectRay(r, distance, true, _phases);
+ _didHit = obj.intersectRay(r, distance, true, _phaseShift);
return _didHit;
}
@@ -158,20 +158,20 @@ struct DynamicTreeIntersectionCallback
private:
bool _didHit;
- std::set<uint32> _phases;
+ PhaseShift const& _phaseShift;
};
-bool DynamicMapTree::getIntersectionTime(std::set<uint32> const& phases, G3D::Ray const& ray, G3D::Vector3 const& endPos, float& maxDist) const
+bool DynamicMapTree::getIntersectionTime(G3D::Ray const& ray, G3D::Vector3 const& endPos, PhaseShift const& phaseShift, float& maxDist) const
{
float distance = maxDist;
- DynamicTreeIntersectionCallback callback(phases);
+ DynamicTreeIntersectionCallback callback(phaseShift);
impl->intersectRay(ray, callback, distance, endPos);
if (callback.didHit())
maxDist = distance;
return callback.didHit();
}
-bool DynamicMapTree::getObjectHitPos(std::set<uint32> const& phases, G3D::Vector3 const& startPos, G3D::Vector3 const& endPos, G3D::Vector3& resultHitPos, float modifyDist) const
+bool DynamicMapTree::getObjectHitPos(G3D::Vector3 const& startPos, G3D::Vector3 const& endPos, G3D::Vector3& resultHitPos, float modifyDist, PhaseShift const& phaseShift) const
{
bool result = false;
float maxDist = (endPos - startPos).magnitude();
@@ -186,7 +186,7 @@ bool DynamicMapTree::getObjectHitPos(std::set<uint32> const& phases, G3D::Vector
G3D::Vector3 dir = (endPos - startPos)/maxDist; // direction with length of 1
G3D::Ray ray(startPos, dir);
float dist = maxDist;
- if (getIntersectionTime(phases, ray, endPos, dist))
+ if (getIntersectionTime(ray, endPos, phaseShift, dist))
{
resultHitPos = startPos + dir * dist;
if (modifyDist < 0)
@@ -209,7 +209,7 @@ bool DynamicMapTree::getObjectHitPos(std::set<uint32> const& phases, G3D::Vector
return result;
}
-bool DynamicMapTree::isInLineOfSight(G3D::Vector3 const& startPos, G3D::Vector3 const& endPos, std::set<uint32> const& phases) const
+bool DynamicMapTree::isInLineOfSight(G3D::Vector3 const& startPos, G3D::Vector3 const& endPos, PhaseShift const& phaseShift) const
{
float maxDist = (endPos - startPos).magnitude();
@@ -217,17 +217,17 @@ bool DynamicMapTree::isInLineOfSight(G3D::Vector3 const& startPos, G3D::Vector3
return true;
G3D::Ray r(startPos, (endPos - startPos) / maxDist);
- DynamicTreeIntersectionCallback callback(phases);
+ DynamicTreeIntersectionCallback callback(phaseShift);
impl->intersectRay(r, callback, maxDist, endPos);
return !callback.didHit();
}
-float DynamicMapTree::getHeight(float x, float y, float z, float maxSearchDist, std::set<uint32> const& phases) const
+float DynamicMapTree::getHeight(float x, float y, float z, float maxSearchDist, PhaseShift const& phaseShift) const
{
G3D::Vector3 v(x, y, z + 0.5f);
G3D::Ray r(v, G3D::Vector3(0, 0, -1));
- DynamicTreeIntersectionCallback callback(phases);
+ DynamicTreeIntersectionCallback callback(phaseShift);
impl->intersectZAllignedRay(r, callback, maxSearchDist);
if (callback.didHit())