Allow showing yellow (2d) / green (3d) quads in track debug

This commit is contained in:
Benau 2016-09-04 14:33:23 +08:00
parent 9d41f4b429
commit 262eb40dfe
5 changed files with 25 additions and 12 deletions

View File

@ -1,4 +1,3 @@
// //
// SuperTuxKart - a fun racing game with go-kart // SuperTuxKart - a fun racing game with go-kart
// Copyright (C) 2009-2015 Joerg Henrichs // Copyright (C) 2009-2015 Joerg Henrichs

View File

@ -78,15 +78,11 @@ void GraphStructure::createDebugMesh()
createMesh(/*show_invisible*/true, createMesh(/*show_invisible*/true,
/*enable_transparency*/true); /*enable_transparency*/true);
// Now colour the quads red/blue/red ...
video::SColor c( 128, 255, 0, 0);
video::S3DVertex *v = (video::S3DVertex*)m_mesh_buffer->getVertices(); video::S3DVertex *v = (video::S3DVertex*)m_mesh_buffer->getVertices();
for (unsigned int i = 0; i < m_mesh_buffer->getVertexCount(); i++) for (unsigned int i = 0; i < m_mesh_buffer->getVertexCount(); i++)
{ {
// Swap the colours from red to blue and back // Swap the alpha and back
c.setRed ((i%2) ? 255 : 0); v[i].Color.setAlpha((i%2) ? 64 : 255);
c.setBlue((i%2) ? 0 : 255);
v[i].Color = c;
} }
m_node = irr_driver->addMesh(m_mesh, "track-debug-mesh"); m_node = irr_driver->addMesh(m_mesh, "track-debug-mesh");
#ifdef DEBUG #ifdef DEBUG
@ -154,7 +150,9 @@ void GraphStructure::createMesh(bool show_invisible,
// Transfer the 4 points of the current quad to the list of vertices // Transfer the 4 points of the current quad to the list of vertices
set3DVerticesOfGraph(count, new_v+4*i, (different_color ? set3DVerticesOfGraph(count, new_v+4*i, (different_color ?
(nc == COLOR_RED ? video::SColor(255, 255, 0, 0) : (nc == COLOR_RED ? video::SColor(255, 255, 0, 0) :
video::SColor(255, 0, 0, 255)) : c)); nc == COLOR_GREEN ? video::SColor(255, 0, 255, 0) :
nc == COLOR_BLUE ? video::SColor(255, 0, 0, 255) :
video::SColor(255, 255, 255, 0)) : c));
// Set up the indices for the triangles // Set up the indices for the triangles
// (note, afaik with opengl we could use quads directly, but the code // (note, afaik with opengl we could use quads directly, but the code

View File

@ -46,11 +46,14 @@ class GraphStructure : public NoCopy
{ {
protected: protected:
/** Used by soccer field with navmesh to draw goal line. */ /** Used by soccer field with navmesh to draw goal line,
* or to determine 2d/3d nodes in driveline graph. */
enum NodeColor enum NodeColor
{ {
COLOR_BLUE, COLOR_BLUE,
COLOR_RED COLOR_GREEN,
COLOR_RED,
COLOR_YELLOW
}; };
void cleanupDebugMesh(); void cleanupDebugMesh();

View File

@ -908,3 +908,17 @@ float QuadGraph::getDistanceFromStart(int j) const
{ {
return m_all_nodes[j]->getDistanceFromStart(); return m_all_nodes[j]->getDistanceFromStart();
} // getDistanceFromStart } // getDistanceFromStart
//-----------------------------------------------------------------------------
const bool QuadGraph::differentNodeColor(int n, NodeColor* c) const
{
if (UserConfigParams::m_track_debug)
{
if (dynamic_cast<Node3D*>(m_all_nodes[n]) != NULL)
*c = COLOR_GREEN;
else
*c = COLOR_YELLOW;
return true;
}
return false;
} // differentNodeColor

View File

@ -92,8 +92,7 @@ private:
virtual const bool hasLapLine() const virtual const bool hasLapLine() const
{ return true; } { return true; }
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
virtual const bool differentNodeColor(int n, NodeColor* c) const virtual const bool differentNodeColor(int n, NodeColor* c) const;
{ return false; }
public: public:
static const int UNKNOWN_SECTOR; static const int UNKNOWN_SECTOR;