void RecastMapRenderer::Render()
{
	if (!m_RecastMap->GetGeometry() || !m_RecastMap->GetGeometry()->getMesh())
		return;
	// ========================================== setup
	glDepthFunc(GL_LESS);
	glDepthMask(GL_TRUE);
	DebugDrawGL dd;
	const float texScale = 1.0f / (RECAST_CELL_SIZE * 10.0f);
	duDebugDrawTriMeshSlope(&dd, 
		m_RecastMap->GetGeometry()->getMesh()->getVerts(), 
		m_RecastMap->GetGeometry()->getMesh()->getVertCount(),
		m_RecastMap->GetGeometry()->getMesh()->getTris(), 
		m_RecastMap->GetGeometry()->getMesh()->getNormals(), 
		m_RecastMap->GetGeometry()->getMesh()->getTriCount(),
		RECAST_AGENT_MAX_SLOPE, 
		texScale);
	
	DrawAgents(&dd);
	
	glDepthMask(GL_FALSE);
	// Draw bounds
	const float* bmin = m_RecastMap->GetGeometry()->getMeshBoundsMin();
	const float* bmax = m_RecastMap->GetGeometry()->getMeshBoundsMax();
	duDebugDrawBoxWire(&dd, bmin[0],bmin[1],bmin[2], bmax[0],bmax[1],bmax[2], duRGBA(255,255,255,128), 1.0f);
	
	// Tiling grid.
	int gw = 0, gh = 0;
	rcCalcGridSize(bmin, bmax, RECAST_CELL_SIZE, &gw, &gh);
	const int tw = (gw + RECAST_TILE_SIZE - 1) / RECAST_TILE_SIZE;
	const int th = (gh + RECAST_TILE_SIZE - 1) / RECAST_TILE_SIZE;
	const float s = RECAST_TILE_SIZE*RECAST_CELL_SIZE;
	duDebugDrawGridXZ(&dd, bmin[0],bmin[1],bmin[2], tw,th, s, duRGBA(0,0,0,64), 1.0f);

	if(m_RecastMap->GetMesh() && m_RecastMap->GetQuery())
	{
		duDebugDrawNavMesh(&dd, *(m_RecastMap->GetMesh()), 
			DU_DRAWNAVMESH_COLOR_TILES|DU_DRAWNAVMESH_CLOSEDLIST|DU_DRAWNAVMESH_OFFMESHCONS);
		duDebugDrawNavMeshPolysWithFlags(&dd, *(m_RecastMap->GetMesh()), POLY_ABILITY_DISABLED, duRGBA(0,0,0,128));
	}
	if (m_RecastMap->GetTileCache())
		//DrawTiles(&dd, m_RecastMap->GetTileCache());
	
	if (m_RecastMap->GetTileCache())
		DrawObstacles(&dd, m_RecastMap->GetTileCache());

	if (m_RecastMap->GetGeometry())
		DrawConvexVolumes(&dd, m_RecastMap->GetGeometry());
}
void Sample_TileMesh::handleRender()
{
	if (!m_geom || !m_geom->getMesh())
		return;
	
	const float texScale = 1.0f / (m_cellSize * 10.0f);
	
	// Draw mesh
	if (m_drawMode != DRAWMODE_NAVMESH_TRANS)
	{
		// Draw mesh
		duDebugDrawTriMeshSlope(&m_dd, m_geom->getMesh()->getVerts(), m_geom->getMesh()->getVertCount(),
								m_geom->getMesh()->getTris(), m_geom->getMesh()->getNormals(), m_geom->getMesh()->getTriCount(),
								m_agentMaxSlope, texScale);
		m_geom->drawOffMeshConnections(&m_dd);
	}
		
	glDepthMask(GL_FALSE);
	
	// Draw bounds
	const float* bmin = m_geom->getNavMeshBoundsMin();
	const float* bmax = m_geom->getNavMeshBoundsMax();
	duDebugDrawBoxWire(&m_dd, bmin[0],bmin[1],bmin[2], bmax[0],bmax[1],bmax[2], duRGBA(255,255,255,128), 1.0f);
	
	// Tiling grid.
	int gw = 0, gh = 0;
	rcCalcGridSize(bmin, bmax, m_cellSize, &gw, &gh);
	const int tw = (gw + (int)m_tileSize-1) / (int)m_tileSize;
	const int th = (gh + (int)m_tileSize-1) / (int)m_tileSize;
	const float s = m_tileSize*m_cellSize;
	duDebugDrawGridXZ(&m_dd, bmin[0],bmin[1],bmin[2], tw,th, s, duRGBA(0,0,0,64), 1.0f);
	
	// Draw active tile
	duDebugDrawBoxWire(&m_dd, m_lastBuiltTileBmin[0],m_lastBuiltTileBmin[1],m_lastBuiltTileBmin[2],
					   m_lastBuiltTileBmax[0],m_lastBuiltTileBmax[1],m_lastBuiltTileBmax[2], m_tileCol, 1.0f);
		
	if (m_navMesh && m_navQuery &&
		(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_INVIS)
			duDebugDrawNavMeshWithClosedList(&m_dd, *m_navMesh, *m_navQuery, m_navMeshDrawFlags);
		if (m_drawMode == DRAWMODE_NAVMESH_BVTREE)
			duDebugDrawNavMeshBVTree(&m_dd, *m_navMesh);
		if (m_drawMode == DRAWMODE_NAVMESH_PORTALS)
			duDebugDrawNavMeshPortals(&m_dd, *m_navMesh);
		if (m_drawMode == DRAWMODE_NAVMESH_NODES)
			duDebugDrawNavMeshNodes(&m_dd, *m_navQuery);
		duDebugDrawNavMeshPolysWithFlags(&m_dd, *m_navMesh, SAMPLE_POLYFLAGS_DISABLED, duRGBA(0,0,0,128));
	}
	
	
	glDepthMask(GL_TRUE);
	
	if (m_chf && m_drawMode == DRAWMODE_COMPACT)
		duDebugDrawCompactHeightfieldSolid(&m_dd, *m_chf);
	
	if (m_chf && m_drawMode == DRAWMODE_COMPACT_DISTANCE)
		duDebugDrawCompactHeightfieldDistance(&m_dd, *m_chf);
	if (m_chf && m_drawMode == DRAWMODE_COMPACT_REGIONS)
		duDebugDrawCompactHeightfieldRegions(&m_dd, *m_chf);
	if (m_solid && m_drawMode == DRAWMODE_VOXELS)
	{
		glEnable(GL_FOG);
		duDebugDrawHeightfieldSolid(&m_dd, *m_solid);
		glDisable(GL_FOG);
	}
	if (m_solid && m_drawMode == DRAWMODE_VOXELS_WALKABLE)
	{
		glEnable(GL_FOG);
		duDebugDrawHeightfieldWalkable(&m_dd, *m_solid);
		glDisable(GL_FOG);
	}
	
	if (m_cset && m_drawMode == DRAWMODE_RAW_CONTOURS)
	{
		glDepthMask(GL_FALSE);
		duDebugDrawRawContours(&m_dd, *m_cset);
		glDepthMask(GL_TRUE);
	}
	
	if (m_cset && m_drawMode == DRAWMODE_BOTH_CONTOURS)
	{
		glDepthMask(GL_FALSE);
		duDebugDrawRawContours(&m_dd, *m_cset, 0.5f);
		duDebugDrawContours(&m_dd, *m_cset);
		glDepthMask(GL_TRUE);
	}
	if (m_cset && m_drawMode == DRAWMODE_CONTOURS)
	{
		glDepthMask(GL_FALSE);
		duDebugDrawContours(&m_dd, *m_cset);
		glDepthMask(GL_TRUE);
	}
	if (m_chf && m_cset && m_drawMode == DRAWMODE_REGION_CONNECTIONS)
	{
		duDebugDrawCompactHeightfieldRegions(&m_dd, *m_chf);
		
		glDepthMask(GL_FALSE);
		duDebugDrawRegionConnections(&m_dd, *m_cset);
		glDepthMask(GL_TRUE);
	}
	if (m_pmesh && m_drawMode == DRAWMODE_POLYMESH)
	{
		glDepthMask(GL_FALSE);
		duDebugDrawPolyMesh(&m_dd, *m_pmesh);
		glDepthMask(GL_TRUE);
	}
	if (m_dmesh && m_drawMode == DRAWMODE_POLYMESH_DETAIL)
	{
		glDepthMask(GL_FALSE);
		duDebugDrawPolyMeshDetail(&m_dd, *m_dmesh);
		glDepthMask(GL_TRUE);
	}
		
	m_geom->drawConvexVolumes(&m_dd);
	
	if (m_tool)
		m_tool->handleRender();
	renderToolStates();

	glDepthMask(GL_TRUE);
}
void Sample_TempObstacles::handleRender()
{
    if (!m_geom || !m_geom->getMesh())
        return;

    DebugDrawGL dd;

    const float texScale = 1.0f / (m_cellSize * 10.0f);

    // Draw mesh
    if (m_drawMode != DRAWMODE_NAVMESH_TRANS)
    {
        // Draw mesh
        duDebugDrawTriMeshSlope(&dd, m_geom->getMesh()->getVerts(), m_geom->getMesh()->getVertCount(),
                                m_geom->getMesh()->getTris(), m_geom->getMesh()->getNormals(), m_geom->getMesh()->getTriCount(),
                                m_agentMaxSlope, texScale);
        m_geom->drawOffMeshConnections(&dd);
    }

    if (m_tileCache && m_drawMode == DRAWMODE_CACHE_BOUNDS)
        drawTiles(&dd, m_tileCache);

    if (m_tileCache)
        drawObstacles(&dd, m_tileCache);


    glDepthMask(GL_FALSE);

    // Draw bounds
    const float* bmin = m_geom->getNavMeshBoundsMin();
    const float* bmax = m_geom->getNavMeshBoundsMax();
    duDebugDrawBoxWire(&dd, bmin[0],bmin[1],bmin[2], bmax[0],bmax[1],bmax[2], duRGBA(255,255,255,128), 1.0f);

    // Tiling grid.
    int gw = 0, gh = 0;
    rcCalcGridSize(bmin, bmax, m_cellSize, &gw, &gh);
    const int tw = (gw + (int)m_tileSize-1) / (int)m_tileSize;
    const int th = (gh + (int)m_tileSize-1) / (int)m_tileSize;
    const float s = m_tileSize*m_cellSize;
    duDebugDrawGridXZ(&dd, bmin[0],bmin[1],bmin[2], tw,th, s, duRGBA(0,0,0,64), 1.0f);

    if (m_navMesh && m_navQuery &&
            (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_INVIS)
            duDebugDrawNavMeshWithClosedList(&dd, *m_navMesh, *m_navQuery, m_navMeshDrawFlags/*|DU_DRAWNAVMESH_COLOR_TILES*/);
        if (m_drawMode == DRAWMODE_NAVMESH_BVTREE)
            duDebugDrawNavMeshBVTree(&dd, *m_navMesh);
        if (m_drawMode == DRAWMODE_NAVMESH_PORTALS)
            duDebugDrawNavMeshPortals(&dd, *m_navMesh);
        if (m_drawMode == DRAWMODE_NAVMESH_NODES)
            duDebugDrawNavMeshNodes(&dd, *m_navQuery);
        duDebugDrawNavMeshPolysWithFlags(&dd, *m_navMesh, SAMPLE_POLYFLAGS_DISABLED, duRGBA(0,0,0,128));
    }


    glDepthMask(GL_TRUE);

    m_geom->drawConvexVolumes(&dd);

    if (m_tool)
        m_tool->handleRender();
    renderToolStates();

    glDepthMask(GL_TRUE);
}
void CMaNGOS_Map::handleRender()
{
    if (m_MapInfos->IsEmpty())
        return;

    DebugDrawGL dd;
    
    // Draw mesh
    const float texScale = 1.0f / (m_cellSize * 10.0f);

    for (MeshObjectsMap::const_iterator itr = m_MapInfos->GetGeomsMap()->begin(); itr != m_MapInfos->GetGeomsMap()->end(); itr++)
    {
        if (m_drawMode != DRAWMODE_NAVMESH_TRANS)
        {
            MeshInfos const* mmi = itr->second->GetMap();
            MeshInfos const* vmi = itr->second->GetVMap();

            if (m_DrawMapMesh && mmi)
            {

                MeshDetails const* mmd = mmi->GetSolidMesh();
                MeshDetails const* mlmi = mmi->GetLiquidMesh();
                if (mmd)
                {
                    duDebugDrawTriMeshSlope(&dd, mmd->Verts(), mmd->VertCount(), mmd->Tris(), mmd->Normals(), mmd->TrisCount(),
                        m_agentMaxSlope, texScale);
                }
                if (mlmi)
                    duDebugDrawLiquidTriMesh(&dd, mlmi->Verts(), mlmi->VertCount(), mlmi->Tris(), mlmi->Normals(), mlmi->TrisCount(), texScale);
            }

            if (m_DrawVMapMesh && vmi)
            {
                MeshDetails const* vmd = vmi->GetSolidMesh();
                MeshDetails const* vlmi = vmi->GetLiquidMesh();
                if (vmd)
                {
                    duDebugDrawTriMeshSlope(&dd, vmd->Verts(), vmd->VertCount(), vmd->Tris(), vmd->Normals(), vmd->TrisCount(),
                        m_agentMaxSlope, texScale);
                }
                if (vlmi)
                    duDebugDrawLiquidTriMesh(&dd, vlmi->Verts(), vlmi->VertCount(), vlmi->Tris(), vlmi->Normals(), vlmi->TrisCount(), texScale);
            }
        }
    }

    glDepthMask(GL_FALSE);
    
    // Draw bounds
    const float* bmin;
    const float* bmax;
    GetGeomBounds(bmin, bmax);
    duDebugDrawBoxWire(&dd, bmin[0], bmin[1], bmin[2], bmax[0], bmax[1], bmax[2], duRGBA(255, 255, 255, 128), 2.0f);

    // Tiles grid
    duDebugDrawGridXZ(&dd, m_GridBMin[0], m_GridBMin[1], m_GridBMin[2], 3, 3, BLOCK_SIZE, duRGBA(255, 0, 0, 128), 2.0f);

    // Draw active tile
    if (m_SelectedTile)
    {
        duDebugDrawBoxWire(&dd, m_SelectedTile->bMin[0], m_SelectedTile->bMin[1], m_SelectedTile->bMin[2],
            m_SelectedTile->bMax[0], m_SelectedTile->bMax[1], m_SelectedTile->bMax[2], m_tileCol, 2.0f);
    }

    if (m_navMesh && m_navQuery &&
        (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_INVIS)
            duDebugDrawNavMeshWithClosedList(&dd, *m_navMesh, *m_navQuery, m_navMeshDrawFlags);
        if (m_drawMode == DRAWMODE_NAVMESH_BVTREE)
            duDebugDrawNavMeshBVTree(&dd, *m_navMesh);
        if (m_drawMode == DRAWMODE_NAVMESH_PORTALS)
            duDebugDrawNavMeshPortals(&dd, *m_navMesh);
        if (m_drawMode == DRAWMODE_NAVMESH_NODES)
            duDebugDrawNavMeshNodes(&dd, *m_navQuery);
        duDebugDrawNavMeshPolysWithFlags(&dd, *m_navMesh, SAMPLE_POLYFLAGS_DISABLED, duRGBA(0, 0, 0, 128));
    }


    glDepthMask(GL_TRUE);

    /*if (m_chf && m_drawMode == DRAWMODE_COMPACT)
        duDebugDrawCompactHeightfieldSolid(&dd, *m_chf);

    if (m_chf && m_drawMode == DRAWMODE_COMPACT_DISTANCE)
        duDebugDrawCompactHeightfieldDistance(&dd, *m_chf);
    if (m_chf && m_drawMode == DRAWMODE_COMPACT_REGIONS)
        duDebugDrawCompactHeightfieldRegions(&dd, *m_chf);
    if (m_solid && m_drawMode == DRAWMODE_VOXELS)
    {
        glEnable(GL_FOG);
        duDebugDrawHeightfieldSolid(&dd, *m_solid);
        glDisable(GL_FOG);
    }
    if (m_solid && m_drawMode == DRAWMODE_VOXELS_WALKABLE)
    {
        glEnable(GL_FOG);
        duDebugDrawHeightfieldWalkable(&dd, *m_solid);
        glDisable(GL_FOG);
    }

    if (m_cset && m_drawMode == DRAWMODE_RAW_CONTOURS)
    {
        glDepthMask(GL_FALSE);
        duDebugDrawRawContours(&dd, *m_cset);
        glDepthMask(GL_TRUE);
    }

    if (m_cset && m_drawMode == DRAWMODE_BOTH_CONTOURS)
    {
        glDepthMask(GL_FALSE);
        duDebugDrawRawContours(&dd, *m_cset, 0.5f);
        duDebugDrawContours(&dd, *m_cset);
        glDepthMask(GL_TRUE);
    }
    if (m_cset && m_drawMode == DRAWMODE_CONTOURS)
    {
        glDepthMask(GL_FALSE);
        duDebugDrawContours(&dd, *m_cset);
        glDepthMask(GL_TRUE);
    }
    if (m_chf && m_cset && m_drawMode == DRAWMODE_REGION_CONNECTIONS)
    {
        duDebugDrawCompactHeightfieldRegions(&dd, *m_chf);

        glDepthMask(GL_FALSE);
        duDebugDrawRegionConnections(&dd, *m_cset);
        glDepthMask(GL_TRUE);
    }
    if (m_pmesh && m_drawMode == DRAWMODE_POLYMESH)
    {
        glDepthMask(GL_FALSE);
        duDebugDrawPolyMesh(&dd, *m_pmesh);
        glDepthMask(GL_TRUE);
    }
    if (m_dmesh && m_drawMode == DRAWMODE_POLYMESH_DETAIL)
    {
        glDepthMask(GL_FALSE);
        duDebugDrawPolyMeshDetail(&dd, *m_dmesh);
        glDepthMask(GL_TRUE);
    }*/

    //m_geom->drawConvexVolumes(&dd);

    if (m_tool)
        m_tool->handleRender();
    renderToolStates();

    glDepthMask(GL_TRUE);
}
void Sample_Debug::handleRender()
{
	if (!m_geom || !m_geom->getMesh())
		return;
	
	DebugDrawGL dd;
	
	glEnable(GL_FOG);
	glDepthMask(GL_TRUE);
	
	if (m_drawMode == DRAWMODE_MESH)
	{
		// Draw mesh
		duDebugDrawTriMeshSlope(&dd, m_geom->getMesh()->getVerts(), m_geom->getMesh()->getVertCount(),
								m_geom->getMesh()->getTris(), m_geom->getMesh()->getNormals(), m_geom->getMesh()->getTriCount(),
								m_agentMaxSlope);
		m_geom->drawOffMeshConnections(&dd);
	}
	else if (m_drawMode != DRAWMODE_NAVMESH_TRANS)
	{
		// Draw mesh
		duDebugDrawTriMesh(&dd, m_geom->getMesh()->getVerts(), m_geom->getMesh()->getVertCount(),
						   m_geom->getMesh()->getTris(), m_geom->getMesh()->getNormals(), m_geom->getMesh()->getTriCount(), 0);
		m_geom->drawOffMeshConnections(&dd);
	}
	
	glDisable(GL_FOG);
	glDepthMask(GL_FALSE);
	
	// Draw bounds
	const float* bmin = m_geom->getMeshBoundsMin();
	const float* bmax = m_geom->getMeshBoundsMax();
	duDebugDrawBoxWire(&dd, bmin[0],bmin[1],bmin[2], bmax[0],bmax[1],bmax[2], duRGBA(255,255,255,128), 1.0f);
	
	// Tiling grid.
	int gw = 0, gh = 0;
	rcCalcGridSize(bmin, bmax, m_cellSize, &gw, &gh);
	const int tw = (gw + (int)m_tileSize-1) / (int)m_tileSize;
	const int th = (gh + (int)m_tileSize-1) / (int)m_tileSize;
	duDebugDrawGridXZ(&dd, bmin[0],bmin[1],bmin[2], tw,th, m_tileSize, duRGBA(0,0,0,64), 1.0f);
	
	if (m_navMesh &&
		(m_drawMode == DRAWMODE_NAVMESH ||
		 m_drawMode == DRAWMODE_NAVMESH_TRANS ||
		 m_drawMode == DRAWMODE_NAVMESH_BVTREE ||
		 m_drawMode == DRAWMODE_NAVMESH_INVIS))
	{
		if (m_drawMode != DRAWMODE_NAVMESH_INVIS)
			duDebugDrawNavMesh(&dd, *m_navMesh, m_navMeshDrawFlags);
		if (m_drawMode == DRAWMODE_NAVMESH_BVTREE)
			duDebugDrawNavMeshBVTree(&dd, *m_navMesh);
	}
	
	glDepthMask(GL_TRUE);
	
    if (m_drawMode == DRAWMODE_COMPACT)
		for (int i = 0; i < m_chfCount; ++i)
            if(i == m_tile)
			duDebugDrawCompactHeightfieldSolid(&dd, m_chf[i]);

	if (m_drawMode == DRAWMODE_COMPACT_DISTANCE)
		for (int i = 0; i < m_chfCount; ++i)
            if(i == m_tile)
			duDebugDrawCompactHeightfieldDistance(&dd, m_chf[i]);

	if (m_drawMode == DRAWMODE_COMPACT_REGIONS)
		for (int i = 0; i < m_chfCount; ++i)
            if(i == m_tile)
			duDebugDrawCompactHeightfieldRegions(&dd, m_chf[i]);
	
	if (m_drawMode == DRAWMODE_VOXELS)
	{
		glEnable(GL_FOG);
		for (int i = 0; i < m_hfCount; ++i)
            if(i == m_tile)
			duDebugDrawHeightfieldSolid(&dd, m_hf[i]);
		glDisable(GL_FOG);
	}

	if (m_drawMode == DRAWMODE_VOXELS_WALKABLE)
	{
		glEnable(GL_FOG);
		for (int i = 0; i < m_hfCount; ++i)
            if(i == m_tile)
			duDebugDrawHeightfieldWalkable(&dd, m_hf[i]);
		glDisable(GL_FOG);
	}

	if (m_drawMode == DRAWMODE_RAW_CONTOURS)
	{
		glDepthMask(GL_FALSE);
		for (int i = 0; i < m_csetCount; ++i)
            if(i == m_tile)
			duDebugDrawRawContours(&dd, m_cset[i]);
		glDepthMask(GL_TRUE);
	}

	if (m_drawMode == DRAWMODE_BOTH_CONTOURS)
	{
		glDepthMask(GL_FALSE);
		for (int i = 0; i < m_csetCount; ++i)
            if(i == m_tile)
		{
			duDebugDrawRawContours(&dd, m_cset[i], 0.5f);
			duDebugDrawContours(&dd, m_cset[i]);
		}
		glDepthMask(GL_TRUE);
	}

	if (m_drawMode == DRAWMODE_CONTOURS)
	{
		glDepthMask(GL_FALSE);
		for (int i = 0; i < m_csetCount; ++i)
            if(i == m_tile)
			duDebugDrawContours(&dd, m_cset[i]);
		glDepthMask(GL_TRUE);
	}

	if (m_drawMode == DRAWMODE_REGION_CONNECTIONS)
	{
		for (int i = 0; i < m_chfCount; ++i)
            if(i == m_tile)
			duDebugDrawCompactHeightfieldRegions(&dd, m_chf[i]);
		
		glDepthMask(GL_FALSE);
		for (int i = 0; i < m_csetCount; ++i)
            if(i == m_tile)
			duDebugDrawRegionConnections(&dd, m_cset[i]);
		glDepthMask(GL_TRUE);
	}

	if (/*m_pmesh &&*/ m_drawMode == DRAWMODE_POLYMESH)
	{
		glDepthMask(GL_FALSE);
        for(int i = 0; i < m_pmeshCount; ++i)
            if(i == m_tile)
		    duDebugDrawPolyMesh(&dd, m_pmesh[i]);
		glDepthMask(GL_TRUE);
	}
	if (/*m_dmesh &&*/ m_drawMode == DRAWMODE_POLYMESH_DETAIL)
	{
		glDepthMask(GL_FALSE);
        for(int i = 0; i < m_dmeshCount; ++i)
            if(i == m_tile)
		    duDebugDrawPolyMeshDetail(&dd, m_dmesh[i]);
		glDepthMask(GL_TRUE);
	}
	
	m_geom->drawConvexVolumes(&dd);

	if (m_tool)
		m_tool->handleRender();

	glDepthMask(GL_TRUE);
}