However, this function seems to cause a crash in the system (nothing in the log file) when it exits. Also, there's two lines of code that seem to be outdated in the MOC code...
Code: Select all
pentity->getParentNode()->getWorldPosition(),
pentity->getParentNode()->getWorldOrientation(),
Edit:
Here's the full code of the getHeight function... mebbe I'm missing something stupid
Code: Select all
float ogreEngine::getHeight(Vector3 start)
{
float closeHit = -1;
start.y += PATHING_CUTOFF;
rayTest = Ray(start, Vector3::NEGATIVE_UNIT_Y);
raySceneQuery->setRay(rayTest);
RaySceneQueryResult &result = raySceneQuery->execute();
for (u_int i = 0; i < result.size(); i++)
{
if (result[i].worldFragment)
return result[i].worldFragment->singleIntersection.y;
else if (result[i].movable )
{
Ogre::Entity* entity = static_cast<Ogre::Entity*>(result[i].movable);
if (entity->getParentNode())
{
size_t vertex_count = 0;
size_t index_count = 0;
Ogre::Vector3 *vertices = NULL;
unsigned long *indices = NULL;
collision->GetMeshInformation(entity->getMesh(), vertex_count, vertices, index_count, indices,
entity->getParentNode()->_getDerivedPosition(),
entity->getParentNode()->_getDerivedOrientation(),
entity->getParentNode()->_getDerivedScale());
if (vertices)
{
for (int i = 0; i < static_cast<int>(index_count); i += 3)
{
std::pair<bool, Ogre::Real> hit = Ogre::Math::intersects(rayTest, vertices[indices[i]], vertices[indices[i+1]], vertices[indices[i+2]], true, false);
if (hit.first)
{
if ((closeHit < 0.0f) || (hit.second < closeHit))
{
closeHit = hit.second;
}
}
}
delete[] vertices;
delete[] indices;
return rayTest.getPoint(closeHit).y;
}
}
}
}
return -1000;
}