raycast resturns hit normal.

This commit is contained in:
Mikko Mononen
2009-12-21 10:48:27 +00:00
parent 021880fe92
commit 5daf3f8157
9 changed files with 400 additions and 176 deletions

View File

@@ -182,19 +182,15 @@ void Sample_TileMesh::toolRecalc()
m_straightPath[0] = m_spos[0];
m_straightPath[1] = m_spos[1];
m_straightPath[2] = m_spos[2];
m_npolys = m_navMesh->raycast(m_startRef, m_spos, m_epos, t, m_polys, MAX_POLYS);
vcopy(m_hitPos, m_epos);
m_npolys = m_navMesh->raycast(m_startRef, m_spos, m_epos, t, m_hitNormal, m_polys, MAX_POLYS);
if (m_npolys && t < 1)
{
m_straightPath[3] = m_spos[0] + (m_epos[0] - m_spos[0]) * t;
m_straightPath[4] = m_spos[1] + (m_epos[1] - m_spos[1]) * t;
m_straightPath[5] = m_spos[2] + (m_epos[2] - m_spos[2]) * t;
}
else
{
m_straightPath[3] = m_epos[0];
m_straightPath[4] = m_epos[1];
m_straightPath[5] = m_epos[2];
m_hitPos[0] = m_spos[0] + (m_epos[0] - m_spos[0]) * t;
m_hitPos[1] = m_spos[1] + (m_epos[1] - m_spos[1]) * t;
m_hitPos[2] = m_spos[2] + (m_epos[2] - m_spos[2]) * t;
}
vcopy(&m_straightPath[3], m_hitPos);
}
}
else if (m_toolMode == TOOLMODE_DISTANCE_TO_WALL)
@@ -471,6 +467,12 @@ void Sample_TileMesh::handleRender()
glVertex3f(m_straightPath[i*3], m_straightPath[i*3+1]+0.4f, m_straightPath[i*3+2]);
glEnd();
glPointSize(1.0f);
glColor4ub(255,255,255,128);
glBegin(GL_LINES);
glVertex3f(m_hitPos[0], m_hitPos[1] + 0.4f, m_hitPos[2]);
glVertex3f(m_hitPos[0] + m_hitNormal[0]*m_agentRadius, m_hitPos[1] + 0.4f + m_hitNormal[1]*m_agentRadius, m_hitPos[2] + m_hitNormal[2]*m_agentRadius);
glEnd();
}
}
else if (m_toolMode == TOOLMODE_DISTANCE_TO_WALL)