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

This class implements a check sphere that is used to change the ambient light if a kart is inside this sphere. More...

#include <check_cylinder.hpp>

Inheritance diagram for CheckCylinder:
Inheritance graph
[legend]

Public Member Functions

 CheckCylinder (const XMLNode &node, std::function< void(int)> triggering_function)
 
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. More...
 
bool isInside (int index) const
 Returns if kart indx is currently inside of the sphere. More...
 
float getDistance2ForKart (int index) const
 Returns the squared distance of kart index from the enter of this sphere. More...
 
float getRadius2 () const
 Returns the square of the radius of this sphere. More...
 
- 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...
 
virtual void reset (const Track &track)
 Initialises the 'previous positions' of all karts with the start position defined for this track. 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 bool triggeringCheckline () const
 
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

Vec3 m_center_point
 Center of the sphere. More...
 
float m_radius2
 Squared radius of the cylinder. More...
 
float m_height
 
std::vector< bool > m_is_inside
 A flag for each kart to indicate if it's inside of the sphere. More...
 
std::vector< float > m_distance2
 Stores the distance of each kart from the center of this sphere. More...
 
std::function< void(int)> m_triggering_function
 Function to call when triggered. 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

This class implements a check sphere that is used to change the ambient light if a kart is inside this sphere.

Besides a normal radius this sphere also has a 2nd 'inner' radius: player karts inside the inner radius will have the full new ambient light, karts outside the default light, and karts in between will mix the light dependent on distance.

Member Function Documentation

◆ getDistance2ForKart()

float CheckCylinder::getDistance2ForKart ( int  index) const
inline

Returns the squared distance of kart index from the enter of this sphere.

◆ getRadius2()

float CheckCylinder::getRadius2 ( ) const
inline

Returns the square of the radius of this sphere.

◆ isInside()

bool CheckCylinder::isInside ( int  index) const
inline

Returns if kart indx is currently inside of the sphere.

◆ isTriggered()

bool CheckCylinder::isTriggered ( const Vec3 old_pos,
const Vec3 new_pos,
int  kart_id 
)
virtual

True if going from old_pos to new_pos enters or leaves this cylinder.

This function is called from update (of the checkline structure). It also updates the flag about which karts are inside

Parameters
old_posPosition in previous frame.
new_posPosition in current frame.
kart_idIndex of the kart, can be used to store kart specific additional data.

Implements CheckStructure.

Member Data Documentation

◆ m_center_point

Vec3 CheckCylinder::m_center_point
private

Center of the sphere.

◆ m_distance2

std::vector<float> CheckCylinder::m_distance2
private

Stores the distance of each kart from the center of this sphere.

This saves some computations.

◆ m_is_inside

std::vector<bool> CheckCylinder::m_is_inside
private

A flag for each kart to indicate if it's inside of the sphere.

◆ m_radius2

float CheckCylinder::m_radius2
private

Squared radius of the cylinder.

◆ m_triggering_function

std::function<void(int)> CheckCylinder::m_triggering_function
private

Function to call when triggered.


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