mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-02-16 21:23:46 +00:00
updated drawmodes and rendering
DebugDraw for recast now caches the results We now have a drawmode dropdown selector drawmode changes come from the gui itself no longer from console values all recast drawmodes are supported with the exception of drawmodes that add abilities like navqueries until the nav tester tool is imlpemented.
This commit is contained in:
parent
30b9502e90
commit
d1771756c2
12 changed files with 548 additions and 53 deletions
|
|
@ -179,7 +179,8 @@ NavMesh::NavMesh()
|
|||
m_chf(0),
|
||||
m_cset(0),
|
||||
m_pmesh(0),
|
||||
m_dmesh(0)
|
||||
m_dmesh(0),
|
||||
m_drawMode(DRAWMODE_NAVMESH)
|
||||
{
|
||||
mTypeMask |= StaticShapeObjectType | MarkerObjectType;
|
||||
mFileName = StringTable->EmptyString();
|
||||
|
|
@ -1526,6 +1527,119 @@ bool NavMesh::testEdgeCover(const Point3F &pos, const VectorF &dir, CoverPointDa
|
|||
|
||||
void NavMesh::renderToDrawer()
|
||||
{
|
||||
mDbgDraw.clearCache();
|
||||
// Recast debug draw
|
||||
NetObject* no = getServerObject();
|
||||
if (no)
|
||||
{
|
||||
NavMesh* n = static_cast<NavMesh*>(no);
|
||||
|
||||
mDbgDraw.depthMask(false);
|
||||
|
||||
if (n->nm && m_drawMode != DRAWMODE_NAVMESH_TRANS)
|
||||
{
|
||||
if (m_drawMode != DRAWMODE_NAVMESH_INVIS)
|
||||
duDebugDrawNavMesh(&mDbgDraw, *n->nm, 0);
|
||||
|
||||
////const F32 texScale = 1.0f / (n->mCellSize * 10.0f); this draw mode is useless for us.
|
||||
////duDebugDrawNavMesh(&mDbgDraw, *n->nm, 0);
|
||||
//if (n->m_geo != NULL)
|
||||
//{
|
||||
// duDebugDrawTriMeshSlope(&mDbgDraw, n->m_geo->getVerts(), n->m_geo->getVertCount(),
|
||||
// n->m_geo->getTris(), n->m_geo->getNormals(), n->m_geo->getTriCount(), n->mWalkableSlope, texScale);
|
||||
//}
|
||||
}
|
||||
|
||||
if (n->nm &&
|
||||
(m_drawMode == DRAWMODE_NAVMESH ||
|
||||
m_drawMode == DRAWMODE_NAVMESH_TRANS ||
|
||||
m_drawMode == DRAWMODE_NAVMESH_BVTREE ||
|
||||
m_drawMode == DRAWMODE_NAVMESH_NODES ||
|
||||
m_drawMode == DRAWMODE_NAVMESH_PORTALS ||
|
||||
m_drawMode == DRAWMODE_NAVMESH_INVIS))
|
||||
{
|
||||
if(m_drawMode == DRAWMODE_NAVMESH_BVTREE)
|
||||
duDebugDrawNavMeshBVTree(&mDbgDraw, *n->nm);
|
||||
if(m_drawMode == DRAWMODE_NAVMESH_PORTALS)
|
||||
duDebugDrawNavMeshPortals(&mDbgDraw, *n->nm);
|
||||
}
|
||||
|
||||
mDbgDraw.depthMask(true);
|
||||
|
||||
for (Tile& tile : n->mTiles)
|
||||
{
|
||||
if (tile.chf && m_drawMode == DRAWMODE_COMPACT)
|
||||
{
|
||||
duDebugDrawCompactHeightfieldSolid(&mDbgDraw, *tile.chf);
|
||||
}
|
||||
|
||||
if (tile.chf && m_drawMode == DRAWMODE_COMPACT_DISTANCE)
|
||||
{
|
||||
duDebugDrawCompactHeightfieldDistance(&mDbgDraw, *tile.chf);
|
||||
}
|
||||
|
||||
if (tile.chf && m_drawMode == DRAWMODE_COMPACT_REGIONS)
|
||||
{
|
||||
duDebugDrawCompactHeightfieldRegions(&mDbgDraw, *tile.chf);
|
||||
}
|
||||
|
||||
if (tile.solid && m_drawMode == DRAWMODE_VOXELS)
|
||||
{
|
||||
duDebugDrawHeightfieldSolid(&mDbgDraw, *tile.solid);
|
||||
}
|
||||
|
||||
if (tile.solid && m_drawMode == DRAWMODE_VOXELS_WALKABLE)
|
||||
{
|
||||
duDebugDrawHeightfieldWalkable(&mDbgDraw, *tile.solid);
|
||||
}
|
||||
|
||||
if (tile.cset && m_drawMode == DRAWMODE_RAW_CONTOURS)
|
||||
{
|
||||
mDbgDraw.depthMask(false);
|
||||
duDebugDrawRawContours(&mDbgDraw, *tile.cset);
|
||||
mDbgDraw.depthMask(true);
|
||||
}
|
||||
|
||||
if (tile.cset && m_drawMode == DRAWMODE_BOTH_CONTOURS)
|
||||
{
|
||||
mDbgDraw.depthMask(false);
|
||||
duDebugDrawRawContours(&mDbgDraw, *tile.cset);
|
||||
duDebugDrawContours(&mDbgDraw, *tile.cset);
|
||||
mDbgDraw.depthMask(true);
|
||||
}
|
||||
|
||||
if (tile.cset && m_drawMode == DRAWMODE_CONTOURS)
|
||||
{
|
||||
mDbgDraw.depthMask(false);
|
||||
duDebugDrawContours(&mDbgDraw, *tile.cset);
|
||||
mDbgDraw.depthMask(true);
|
||||
}
|
||||
|
||||
if (tile.chf && tile.cset && m_drawMode == DRAWMODE_REGION_CONNECTIONS)
|
||||
{
|
||||
duDebugDrawCompactHeightfieldRegions(&mDbgDraw, *tile.chf);
|
||||
|
||||
mDbgDraw.depthMask(false);
|
||||
duDebugDrawRegionConnections(&mDbgDraw, *tile.cset);
|
||||
mDbgDraw.depthMask(true);
|
||||
}
|
||||
|
||||
if (tile.pmesh && m_drawMode == DRAWMODE_POLYMESH)
|
||||
{
|
||||
mDbgDraw.depthMask(false);
|
||||
duDebugDrawPolyMesh(&mDbgDraw, *tile.pmesh);
|
||||
mDbgDraw.depthMask(true);
|
||||
}
|
||||
|
||||
if (tile.dmesh && m_drawMode == DRAWMODE_POLYMESH_DETAIL)
|
||||
{
|
||||
mDbgDraw.depthMask(false);
|
||||
duDebugDrawPolyMeshDetail(&mDbgDraw, *tile.dmesh);
|
||||
mDbgDraw.depthMask(true);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void NavMesh::cleanup()
|
||||
|
|
@ -1570,16 +1684,9 @@ void NavMesh::render(ObjectRenderInst *ri, SceneRenderState *state, BaseMatInsta
|
|||
{
|
||||
NavMesh *n = static_cast<NavMesh*>(no);
|
||||
|
||||
if ((!gEditingMission && n->mAlwaysRender) || (gEditingMission && Con::getBoolVariable("$Nav::Editor::renderMesh", 1)))
|
||||
if ((!gEditingMission && n->mAlwaysRender) || gEditingMission)
|
||||
{
|
||||
if (n->nm)
|
||||
{
|
||||
duDebugDrawNavMesh(&mDbgDraw, *n->nm, 0);
|
||||
if (Con::getBoolVariable("$Nav::Editor::renderPortals"))
|
||||
duDebugDrawNavMeshPortals(&mDbgDraw, *n->nm);
|
||||
if (Con::getBoolVariable("$Nav::Editor::renderBVTree"))
|
||||
duDebugDrawNavMeshBVTree(&mDbgDraw, *n->nm);
|
||||
}
|
||||
mDbgDraw.render(state);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1617,11 +1724,14 @@ void NavMesh::renderLinks(duDebugDraw &dd)
|
|||
|
||||
void NavMesh::renderTileData(duDebugDrawTorque &dd, U32 tile)
|
||||
{
|
||||
if (tile > mTiles.size())
|
||||
return;
|
||||
|
||||
if(nm)
|
||||
{
|
||||
duDebugDrawNavMesh(&dd, *nm, 0);
|
||||
if(m_chf)
|
||||
duDebugDrawCompactHeightfieldSolid(&dd, *m_chf);
|
||||
//duDebugDrawNavMesh(&dd, *nm, 0);
|
||||
if(mTiles[tile].chf)
|
||||
duDebugDrawCompactHeightfieldSolid(&dd, *mTiles[tile].chf);
|
||||
|
||||
duDebugDrawNavMeshPortals(&dd, *nm);
|
||||
|
||||
|
|
@ -1669,6 +1779,7 @@ U32 NavMesh::packUpdate(NetConnection *conn, U32 mask, BitStream *stream)
|
|||
mathWrite(*stream, getTransform());
|
||||
mathWrite(*stream, getScale());
|
||||
stream->writeFlag(mAlwaysRender);
|
||||
stream->write((U32)m_drawMode);
|
||||
|
||||
return retMask;
|
||||
}
|
||||
|
|
@ -1680,8 +1791,10 @@ void NavMesh::unpackUpdate(NetConnection *conn, BitStream *stream)
|
|||
mathRead(*stream, &mObjToWorld);
|
||||
mathRead(*stream, &mObjScale);
|
||||
mAlwaysRender = stream->readFlag();
|
||||
|
||||
setTransform(mObjToWorld);
|
||||
U32 draw;
|
||||
stream->read(&draw);
|
||||
m_drawMode = (DrawMode)draw;
|
||||
|
||||
renderToDrawer();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue