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

Implements a simple lap test. More...

#include <check_lap.hpp>

Inheritance diagram for CheckLap:
Inheritance graph
[legend]

Public Member Functions

 CheckLap (const XMLNode &node, unsigned int index)
 Constructor for a lap line. 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 bool triggeringCheckline () const OVERRIDE
 
- 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 resetAfterKartMove (unsigned int kart_index)
 
virtual void resetAfterRewind (unsigned int kart_index)
 
virtual void changeDebugColor (bool is_active)
 
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...
 
virtual void saveCompleteState (BareNetworkString *bns)
 
virtual void restoreCompleteState (const BareNetworkString &b)
 
void saveIsActive (int kart_id, BareNetworkString *bns)
 
void restoreIsActive (int kart_id, const BareNetworkString &b)
 
int getIndex () const
 

Private Attributes

std::vector< float > m_previous_distance
 Store the previous distance along track. 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 lap test.

A new lap is detected when the distance along the track reduces by a certain amount of time.

Constructor & Destructor Documentation

◆ CheckLap()

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

Constructor for a lap line.

Parameters
check_managerPointer to the check manager, which is needed when resetting e.g. new lap counters.
nodeXML node containing the parameters for this checkline.

Member Function Documentation

◆ isTriggered()

bool CheckLap::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_indexIndex of the kart, can be used to store kart specific additional data.

Implements CheckStructure.

◆ reset()

void CheckLap::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.

Member Data Documentation

◆ m_previous_distance

std::vector<float> CheckLap::m_previous_distance
private

Store the previous distance along track.


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