From 25b611a8d3f8adc27e65c19f7abc874caf0099f4 Mon Sep 17 00:00:00 2001 From: hikerstk Date: Mon, 29 Nov 2010 05:26:45 +0000 Subject: [PATCH] Adjust color of check lines according to state: active ones are light red, inactive ones white-grey. git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@6765 178a84e3-b1eb-0310-8ba1-8eac791a3b58 --- src/tracks/check_line.cpp | 19 +++++++++++++++++++ src/tracks/check_line.hpp | 1 + src/tracks/check_structure.cpp | 9 ++++++++- src/tracks/check_structure.hpp | 2 ++ 4 files changed, 30 insertions(+), 1 deletion(-) diff --git a/src/tracks/check_line.cpp b/src/tracks/check_line.cpp index 1b1e578b0..8e71bb569 100644 --- a/src/tracks/check_line.cpp +++ b/src/tracks/check_line.cpp @@ -21,6 +21,8 @@ #include +#include "irrlicht.h" + #include "io/xml_node.hpp" #include "modes/world.hpp" #include "race/race_manager.hpp" @@ -46,6 +48,7 @@ CheckLine::CheckLine(CheckManager *check_manager, const XMLNode &node, { video::SMaterial material; material.setFlag(video::EMF_BACK_FACE_CULLING, false); + material.setFlag(video::EMF_LIGHTING, false); material.MaterialType = video::EMT_TRANSPARENT_ADD_COLOR; scene::IMesh *mesh = irr_driver->createQuadMesh(&material, /*create mesh*/true); @@ -101,6 +104,22 @@ void CheckLine::reset(const Track &track) } } // reset +// ---------------------------------------------------------------------------- +void CheckLine::changeDebugColor(bool is_active) +{ + assert(m_debug_node); + + scene::IMesh *mesh = m_debug_node->getMesh(); + scene::IMeshBuffer *buffer = mesh->getMeshBuffer(0); + irr::video::S3DVertex* vertices + = (video::S3DVertex*)buffer->getVertices(); + for(unsigned int i=0; i<4; i++) + { + vertices[i].Color = is_active ? video::SColor(0, 255, 0, 0) + : video::SColor(0, 128, 128, 128); + } +} // changeDebugColor + // ---------------------------------------------------------------------------- /** True if going from old_pos to new_pos crosses this checkline. This function * is called from update (of the checkline structure). diff --git a/src/tracks/check_line.hpp b/src/tracks/check_line.hpp index 3bde7e104..3026398e7 100644 --- a/src/tracks/check_line.hpp +++ b/src/tracks/check_line.hpp @@ -69,6 +69,7 @@ public: virtual ~CheckLine(); virtual bool isTriggered(const Vec3 &old_pos, const Vec3 &new_pos, int indx); virtual void reset(const Track &track); + virtual void changeDebugColor(bool is_active); /** Returns the actual line data for this checkpoint. */ const core::line2df &getLine2D() const {return m_line;} }; // CheckLine diff --git a/src/tracks/check_structure.cpp b/src/tracks/check_structure.cpp index c8ce78857..26cabf6e3 100644 --- a/src/tracks/check_structure.cpp +++ b/src/tracks/check_structure.cpp @@ -121,6 +121,10 @@ void CheckStructure::changeStatus(const std::vector indices, int kart_index, ChangeState change_state) { + bool update_debug_colors = + UserConfigParams::m_check_debug && + kart_index==World::getWorld()->getPlayerKart(0)->getWorldKartId(); + for(unsigned int i=0; i indices, } cs->m_is_active[kart_index] = !cs->m_is_active[kart_index]; } // switch - + if(update_debug_colors) + { + cs->changeDebugColor(cs->m_is_active[kart_index]); + } } // for i