SuperTuxKart
check_line.hpp
1 //
2 // SuperTuxKart - a fun racing game with go-kart
3 // Copyright (C) 2009-2015 Joerg Henrichs
4 //
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 3
8 // of the License, or (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 
19 #ifndef HEADER_CHECK_LINE_HPP
20 #define HEADER_CHECK_LINE_HPP
21 
22 #include <ISceneNode.h>
23 #include <line2d.h>
24 #include <vector2d.h>
25 #include <memory>
26 using namespace irr;
27 
28 #include "tracks/check_structure.hpp"
29 #include "utils/cpp2011.hpp"
30 
31 class XMLNode;
32 class CheckManager;
33 
34 namespace SP
35 {
36  class SPDynamicDrawCall;
37 }
38 
50 class CheckLine : public CheckStructure
51 {
52 private:
54  core::line2df m_line;
55 
60 
62  float m_min_height;
63 
67  Vec3 m_left_point, m_right_point;
68 
72  std::vector<bool> m_previous_sign;
73 
75  std::shared_ptr<SP::SPDynamicDrawCall> m_debug_dy_dc;
76 
79  static const int m_under_min_height = 1;
80 
83  static const int m_over_min_height = 4;
84 
85 public:
86  CheckLine(const XMLNode &node, unsigned int index);
87  virtual ~CheckLine();
88  virtual bool isTriggered(const Vec3 &old_pos, const Vec3 &new_pos,
89  int indx) OVERRIDE;
90  virtual void reset(const Track &track) OVERRIDE;
91  virtual void resetAfterKartMove(unsigned int kart_index) OVERRIDE;
92  virtual void resetAfterRewind(unsigned int kart_index) OVERRIDE
93  { resetAfterKartMove(kart_index); }
94  virtual void changeDebugColor(bool is_active) OVERRIDE;
95  virtual bool triggeringCheckline() const OVERRIDE { return true; }
96  // ------------------------------------------------------------------------
98  const core::line2df &getLine2D() const {return m_line;}
99  // ------------------------------------------------------------------------
103  void setIgnoreHeight(bool b) { m_ignore_height = b; }
104  // ------------------------------------------------------------------------
105  virtual void saveCompleteState(BareNetworkString* bns) OVERRIDE;
106  // ------------------------------------------------------------------------
107  virtual void restoreCompleteState(const BareNetworkString& b) OVERRIDE;
108  // ------------------------------------------------------------------------
109  const Vec3 &getLeftPoint() const { return m_left_point; }
110  // ------------------------------------------------------------------------
111  const Vec3 &getRightPoint() const { return m_right_point; }
112 
113 }; // CheckLine
114 
115 #endif
116 
A wrapper around bullets btVector3 to include conventient conversion functions (e....
Definition: vec3.hpp:34
std::shared_ptr< SP::SPDynamicDrawCall > m_debug_dy_dc
Used to display debug information about checklines.
Definition: check_line.hpp:75
std::vector< bool > m_previous_sign
Stores the sign (i.e.
Definition: check_line.hpp:72
float m_min_height
The minimum height of the checkline.
Definition: check_line.hpp:62
bool m_ignore_height
True if this line should ignore the height test.
Definition: check_line.hpp:59
const core::line2df & getLine2D() const
Returns the actual line data for this checkpoint.
Definition: check_line.hpp:98
void setIgnoreHeight(bool b)
Sets if this check line should not do a height test for testing if a line is crossed.
Definition: check_line.hpp:103
Implements a simple checkline.
Definition: check_line.hpp:50
Controls all checks structures of a track.
Definition: check_manager.hpp:39
Describes a chain of 8-bit unsigned integers.
Definition: network_string.hpp:52
utility class used to parse XML files
Definition: xml_node.hpp:47
Vec3 m_left_point
The actual (or estimated) left and right end points in 3d.
Definition: check_line.hpp:67
core::line2df m_line
The line that is tested for being crossed.
Definition: check_line.hpp:54
Virtual base class for a check structure.
Definition: check_structure.hpp:51
Definition: track.hpp:96