SuperTuxKart
Public Member Functions | Private Attributes | Static Private Attributes | List of all members
CheckLine Class Reference

Implements a simple checkline. More...

#include <check_line.hpp>

Inheritance diagram for CheckLine:
Inheritance graph
[legend]

Public Member Functions

 CheckLine (const XMLNode &node, unsigned int index)
 Constructor for a checkline. More...
 
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. More...
 
virtual void reset (const Track &track) OVERRIDE
 Initialises the 'previous positions' of all karts with the start position defined for this track. More...
 
virtual void resetAfterKartMove (unsigned int kart_index) OVERRIDE
 
virtual void resetAfterRewind (unsigned int kart_index) OVERRIDE
 
virtual void changeDebugColor (bool is_active) OVERRIDE
 
virtual bool triggeringCheckline () const OVERRIDE
 
const core::line2df & getLine2D () const
 Returns the actual line data for this checkpoint. More...
 
void setIgnoreHeight (bool b)
 Sets if this check line should not do a height test for testing if a line is crossed. More...
 
virtual void saveCompleteState (BareNetworkString *bns) OVERRIDE
 
virtual void restoreCompleteState (const BareNetworkString &b) OVERRIDE
 
const Vec3getLeftPoint () const
 
const Vec3getRightPoint () const
 
- Public Member Functions inherited from CheckStructure
 CheckStructure (const XMLNode &node, unsigned int index)
 
virtual void update (float dt)
 Updates all check structures. More...
 
virtual void trigger (unsigned int kart_index)
 Is called when this check structure is triggered. More...
 
CheckType getType () const
 Returns the type of this check structure. More...
 
void addSuccessor (unsigned int i)
 Adds the index of a successor check structure which will get triggered by this check structure. More...
 
void saveIsActive (int kart_id, BareNetworkString *bns)
 
void restoreIsActive (int kart_id, const BareNetworkString &b)
 
int getIndex () const
 

Private Attributes

core::line2df m_line
 The line that is tested for being crossed. More...
 
bool m_ignore_height
 True if this line should ignore the height test. More...
 
float m_min_height
 The minimum height of the checkline. More...
 
Vec3 m_left_point
 The actual (or estimated) left and right end points in 3d. More...
 
Vec3 m_right_point
 
std::vector< bool > m_previous_sign
 Stores the sign (i.e. More...
 
std::shared_ptr< SP::SPDynamicDrawCallm_debug_dy_dc
 Used to display debug information about checklines. More...
 

Static Private Attributes

static const int m_under_min_height = 1
 How much a kart is allowed to be under the minimum height of a quad and still considered to be able to cross it. More...
 
static const int m_over_min_height = 4
 How much a kart is allowed to be over the minimum height of a quad and still considered to be able to cross it. More...
 

Additional Inherited Members

- Public Types inherited from CheckStructure
enum  CheckType {
  CT_NEW_LAP, CT_ACTIVATE, CT_TOGGLE, CT_CANNON,
  CT_GOAL, CT_AMBIENT_SPHERE, CT_TRIGGER
}
 Different types of check structures: ACTIVATE: Activates another check structure (independent of the state that check structure is in) TOGGLE: Switches (inverts) the state of another check structure. More...
 
- Protected Member Functions inherited from CheckStructure
 CheckStructure (unsigned index)
 For CheckTrigger or CheckCylinder.
 
- Protected Attributes inherited from CheckStructure
AlignedArray< Vec3m_previous_position
 Stores the previous position of all karts. More...
 
std::vector< bool > m_is_active
 Stores if this check structure is active (for a given kart). More...
 
bool m_active_at_reset
 True if this check structure should be activated at a reset. More...
 
unsigned int m_index
 Stores the index of this check structure. More...
 

Detailed Description

Implements a simple checkline.

It's a finite line with 2 endpoints in 2d and a minimum height (i.e. the minimum Y coordinate of the two points). If a kart crosses the line (in the projection on the 2d plane) and has an appropriate height, the checkline will be triggered. This allows for very easy checking of checklines, and should be sufficient for most check structure.

Constructor & Destructor Documentation

◆ CheckLine()

CheckLine::CheckLine ( const XMLNode node,
unsigned int  index 
)

Constructor for a checkline.

Parameters
nodeXML node containing the parameters for this checkline.
indexIndex of this check structure in the check manager.

Member Function Documentation

◆ getLine2D()

const core::line2df& CheckLine::getLine2D ( ) const
inline

Returns the actual line data for this checkpoint.

◆ isTriggered()

bool CheckLine::isTriggered ( const Vec3 old_pos,
const Vec3 new_pos,
int  kart_index 
)
virtual

True if going from old_pos to new_pos crosses this checkline.

This function is called from update (of the checkline structure).

Parameters
old_posPosition in previous frame.
new_posPosition in current frame.
kart_indxIndex of the kart, can be used to store kart specific additional data. If set to a negative number it will be ignored (used for e.g. soccer ball, and basket ball).

Implements CheckStructure.

◆ reset()

void CheckLine::reset ( const Track track)
virtual

Initialises the 'previous positions' of all karts with the start position defined for this track.

Parameters
trackThe track object defining the start positions.

Reimplemented from CheckStructure.

◆ setIgnoreHeight()

void CheckLine::setIgnoreHeight ( bool  b)
inline

Sets if this check line should not do a height test for testing if a line is crossed.

Used for basket calls in cannon (the ball can be too heigh to otherwise trigger he cannon).

Member Data Documentation

◆ m_debug_dy_dc

std::shared_ptr<SP::SPDynamicDrawCall> CheckLine::m_debug_dy_dc
private

Used to display debug information about checklines.

◆ m_ignore_height

bool CheckLine::m_ignore_height
private

True if this line should ignore the height test.

This is required e.g. for basketball cannons, since the ball can be too height to otherwise trigger the cannon.

◆ m_left_point

Vec3 CheckLine::m_left_point
private

The actual (or estimated) left and right end points in 3d.

This is used by the cannon. If the xml file stores only the min_height, those points are set from the 2d points and the min height.

◆ m_line

core::line2df CheckLine::m_line
private

The line that is tested for being crossed.

◆ m_min_height

float CheckLine::m_min_height
private

The minimum height of the checkline.

◆ m_over_min_height

const int CheckLine::m_over_min_height = 4
staticprivate

How much a kart is allowed to be over the minimum height of a quad and still considered to be able to cross it.

◆ m_previous_sign

std::vector<bool> CheckLine::m_previous_sign
private

Stores the sign (i.e.

side) of the previous line to save some computations. True if the value is >=0, i.e. the point is on or to the right of the line.

◆ m_under_min_height

const int CheckLine::m_under_min_height = 1
staticprivate

How much a kart is allowed to be under the minimum height of a quad and still considered to be able to cross it.


The documentation for this class was generated from the following files: