Core/Entities: Phase Rework (main commit)

This commit is contained in:
Ovahlord
2018-03-08 17:33:27 +01:00
parent 4a268b3fd3
commit e44bb5f387
79 changed files with 1738 additions and 851 deletions

View File

@@ -142,11 +142,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, VMAP::ModelIgnoreFlags::Nothing);
_didHit = obj.intersectRay(r, distance, true, _phaseShift, VMAP::ModelIgnoreFlags::Nothing);
return _didHit;
}
@@ -154,20 +154,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();
@@ -182,7 +182,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)
@@ -205,7 +205,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();
@@ -213,17 +213,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())