From 262eb40dfed47d1002dc7ad1790764fb20fcaf3d Mon Sep 17 00:00:00 2001 From: Benau Date: Sun, 4 Sep 2016 14:33:23 +0800 Subject: [PATCH] Allow showing yellow (2d) / green (3d) quads in track debug --- src/tracks/battle_graph.cpp | 1 - src/tracks/graph_structure.cpp | 12 +++++------- src/tracks/graph_structure.hpp | 7 +++++-- src/tracks/quad_graph.cpp | 14 ++++++++++++++ src/tracks/quad_graph.hpp | 3 +-- 5 files changed, 25 insertions(+), 12 deletions(-) diff --git a/src/tracks/battle_graph.cpp b/src/tracks/battle_graph.cpp index 300b38e8c..e6ebcc2ab 100644 --- a/src/tracks/battle_graph.cpp +++ b/src/tracks/battle_graph.cpp @@ -1,4 +1,3 @@ - // // SuperTuxKart - a fun racing game with go-kart // Copyright (C) 2009-2015 Joerg Henrichs diff --git a/src/tracks/graph_structure.cpp b/src/tracks/graph_structure.cpp index bb006e489..e6fd0cd71 100644 --- a/src/tracks/graph_structure.cpp +++ b/src/tracks/graph_structure.cpp @@ -78,15 +78,11 @@ void GraphStructure::createDebugMesh() createMesh(/*show_invisible*/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(); for (unsigned int i = 0; i < m_mesh_buffer->getVertexCount(); i++) { - // Swap the colours from red to blue and back - c.setRed ((i%2) ? 255 : 0); - c.setBlue((i%2) ? 0 : 255); - v[i].Color = c; + // Swap the alpha and back + v[i].Color.setAlpha((i%2) ? 64 : 255); } m_node = irr_driver->addMesh(m_mesh, "track-debug-mesh"); #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 set3DVerticesOfGraph(count, new_v+4*i, (different_color ? (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 // (note, afaik with opengl we could use quads directly, but the code diff --git a/src/tracks/graph_structure.hpp b/src/tracks/graph_structure.hpp index d66f156c5..e6f159e4c 100644 --- a/src/tracks/graph_structure.hpp +++ b/src/tracks/graph_structure.hpp @@ -46,11 +46,14 @@ class GraphStructure : public NoCopy { 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 { COLOR_BLUE, - COLOR_RED + COLOR_GREEN, + COLOR_RED, + COLOR_YELLOW }; void cleanupDebugMesh(); diff --git a/src/tracks/quad_graph.cpp b/src/tracks/quad_graph.cpp index e0467e570..f8d3c86ca 100644 --- a/src/tracks/quad_graph.cpp +++ b/src/tracks/quad_graph.cpp @@ -908,3 +908,17 @@ float QuadGraph::getDistanceFromStart(int j) const { return m_all_nodes[j]->getDistanceFromStart(); } // getDistanceFromStart + +//----------------------------------------------------------------------------- +const bool QuadGraph::differentNodeColor(int n, NodeColor* c) const +{ + if (UserConfigParams::m_track_debug) + { + if (dynamic_cast(m_all_nodes[n]) != NULL) + *c = COLOR_GREEN; + else + *c = COLOR_YELLOW; + return true; + } + return false; +} // differentNodeColor diff --git a/src/tracks/quad_graph.hpp b/src/tracks/quad_graph.hpp index eaa3634f7..a5ead4155 100644 --- a/src/tracks/quad_graph.hpp +++ b/src/tracks/quad_graph.hpp @@ -92,8 +92,7 @@ private: virtual const bool hasLapLine() const { return true; } // ------------------------------------------------------------------------ - virtual const bool differentNodeColor(int n, NodeColor* c) const - { return false; } + virtual const bool differentNodeColor(int n, NodeColor* c) const; public: static const int UNKNOWN_SECTOR;