Better pointInPoly

This commit is contained in:
Benau 2016-01-04 16:10:38 +08:00
parent 87df259f48
commit 405d31ecfc
2 changed files with 5 additions and 5 deletions

View File

@ -138,11 +138,7 @@ void BattleGraph::findItemsOnGraphNodes()
for (unsigned int j = 0; j < this->getNumNodes(); ++j) for (unsigned int j = 0; j < this->getNumNodes(); ++j)
{ {
if (NavMesh::get()->getNavPoly(j).pointInPoly(xyz)) if (NavMesh::get()->getNavPoly(j).pointInPoly(xyz))
{ polygon = j;
float dist = xyz.getY() - NavMesh::get()->getCenterOfPoly(j).getY();
if (fabsf(dist) < 1.0f )
polygon = j;
}
} }
if (polygon != BattleGraph::UNKNOWN_POLY) if (polygon != BattleGraph::UNKNOWN_POLY)

View File

@ -70,6 +70,10 @@ bool NavPoly::pointInPoly(const Vec3& p) const
return false; return false;
} }
// Check for vertical distance too
const float dist = p.getY() - m_center.getY();
if (fabsf(dist) > 1.0f )
return false;
return true; return true;
} }