SuperTuxKart
Loading...
Searching...
No Matches
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 <triangle3d.h>
23#include <memory>
24
25using namespace irr;
26
27#include "tracks/check_structure.hpp"
28#include "utils/cpp2011.hpp"
29
30class XMLNode;
31class CheckManager;
32
33namespace SP
34{
35 class SPDynamicDrawCall;
36}
37
50{
51private:
56
60 Vec3 m_left_point, m_right_point;
61
65 std::vector<bool> m_previous_sign;
66
68 std::shared_ptr<SP::SPDynamicDrawCall> m_debug_dy_dc;
69
71 irr::core::triangle3df m_check_plane[4];
72public:
73 CheckLine(const XMLNode &node, unsigned int index);
74 virtual ~CheckLine();
75 virtual bool isTriggered(const Vec3 &old_pos, const Vec3 &new_pos,
76 int indx) OVERRIDE;
77 virtual void reset(const Track &track) OVERRIDE;
78 virtual void resetAfterKartMove(unsigned int kart_index) OVERRIDE;
79 virtual void resetAfterRewind(unsigned int kart_index) OVERRIDE
80 { resetAfterKartMove(kart_index); }
81 virtual void changeDebugColor(bool is_active) OVERRIDE;
82 virtual bool triggeringCheckline() const OVERRIDE { return true; }
83 // ------------------------------------------------------------------------
87 void setIgnoreHeight(bool b) { m_ignore_height = b; }
88 // ------------------------------------------------------------------------
89 virtual void saveCompleteState(BareNetworkString* bns) OVERRIDE;
90 // ------------------------------------------------------------------------
91 virtual void restoreCompleteState(const BareNetworkString& b) OVERRIDE;
92 // ------------------------------------------------------------------------
93 const Vec3 &getLeftPoint() const { return m_left_point; }
94 // ------------------------------------------------------------------------
95 const Vec3 &getRightPoint() const { return m_right_point; }
96 // ------------------------------------------------------------------------
97 virtual CheckStructure* clone() OVERRIDE
98 {
99 CheckLine* cl = new CheckLine(*this);
100 // Drop unneeded stuff
101 cl->m_debug_dy_dc = nullptr;
102 return cl;
103 }
104}; // CheckLine
105
106#endif
107
Describes a chain of 8-bit unsigned integers.
Definition: network_string.hpp:53
Implements a simple checkline.
Definition: check_line.hpp:50
virtual CheckStructure * clone() OVERRIDE
Clone to child process for server usage (atm no sound or scripting).
Definition: check_line.hpp:97
std::vector< bool > m_previous_sign
Stores the sign (i.e.
Definition: check_line.hpp:65
std::shared_ptr< SP::SPDynamicDrawCall > m_debug_dy_dc
Used to display debug information about checklines.
Definition: check_line.hpp:68
virtual void reset(const Track &track) OVERRIDE
Initialises the 'previous positions' of all karts with the start position defined for this track.
Definition: check_line.cpp:157
Vec3 m_left_point
The actual (or estimated) left and right end points in 3d.
Definition: check_line.hpp:60
virtual bool isTriggered(const Vec3 &old_pos, const Vec3 &new_pos, int indx) OVERRIDE
True if going from old_pos to new_pos crosses this checkline.
Definition: check_line.cpp:200
bool m_ignore_height
True if this line should ignore the height test.
Definition: check_line.hpp:55
irr::core::triangle3df m_check_plane[4]
The planes that are tested for being crossed.
Definition: check_line.hpp:71
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:87
Controls all checks structures of a track.
Definition: check_manager.hpp:40
Virtual base class for a check structure.
Definition: check_structure.hpp:52
Definition: track.hpp:114
A wrapper around bullets btVector3 to include conventient conversion functions (e....
Definition: vec3.hpp:35
utility class used to parse XML files
Definition: xml_node.hpp:48