SuperTuxKart
Loading...
Searching...
No Matches
check_cylinder.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_CYLINDER_HPP
20#define HEADER_CHECK_CYLINDER_HPP
21
22#include "tracks/check_structure.hpp"
23#include <functional>
24
25class XMLNode;
26class CheckManager;
27class TriggerItemListener;
28
38{
39private:
43 float m_radius2;
44 float m_height;
46 std::vector<bool> m_is_inside;
49 std::vector<float> m_distance2;
51 std::function<void(int)> m_triggering_function;
52public:
53 CheckCylinder(const XMLNode &node,
54 std::function<void(int)> triggering_function);
55 virtual ~CheckCylinder() {};
56 virtual bool isTriggered(const Vec3 &old_pos, const Vec3 &new_pos,
57 int kart_id);
58 // ------------------------------------------------------------------------
60 bool isInside(int index) const { return m_is_inside[index]; }
61 // -------------------------------------------------------------------------
64 float getDistance2ForKart(int index) const { return m_distance2[index];}
65 // -------------------------------------------------------------------------
67 float getRadius2() const { return m_radius2; }
68 // ------------------------------------------------------------------------
70 {
71 CheckCylinder* cc = new CheckCylinder(*this);
72 // Drop unneeded stuff ( trigger function is not supported in server,
73 // no scripting atm)
74 cc->m_triggering_function = nullptr;
75 return cc;
76 }
77}; // CheckCylinder
78
79#endif
80
This class implements a check sphere that is used to change the ambient light if a kart is inside thi...
Definition: check_cylinder.hpp:38
virtual CheckStructure * clone()
Clone to child process for server usage (atm no sound or scripting).
Definition: check_cylinder.hpp:69
std::vector< bool > m_is_inside
A flag for each kart to indicate if it's inside of the sphere.
Definition: check_cylinder.hpp:46
std::function< void(int)> m_triggering_function
Function to call when triggered.
Definition: check_cylinder.hpp:51
float m_radius2
Squared radius of the cylinder.
Definition: check_cylinder.hpp:43
virtual bool isTriggered(const Vec3 &old_pos, const Vec3 &new_pos, int kart_id)
True if going from old_pos to new_pos enters or leaves this cylinder.
Definition: check_cylinder.cpp:58
bool isInside(int index) const
Returns if kart indx is currently inside of the sphere.
Definition: check_cylinder.hpp:60
float getDistance2ForKart(int index) const
Returns the squared distance of kart index from the enter of this sphere.
Definition: check_cylinder.hpp:64
std::vector< float > m_distance2
Stores the distance of each kart from the center of this sphere.
Definition: check_cylinder.hpp:49
Vec3 m_center_point
Center of the sphere.
Definition: check_cylinder.hpp:41
float getRadius2() const
Returns the square of the radius of this sphere.
Definition: check_cylinder.hpp:67
Controls all checks structures of a track.
Definition: check_manager.hpp:40
Virtual base class for a check structure.
Definition: check_structure.hpp:52
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