SuperTuxKart
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
RubberBall Class Reference
Inheritance diagram for RubberBall:
Inheritance graph
[legend]

Public Member Functions

 RubberBall (AbstractKart *kart)
 
virtual ~RubberBall ()
 Destructor, removes any playing sfx.
 
virtual bool updateAndDelete (int ticks) OVERRIDE
 Updates the rubber ball. More...
 
virtual bool hit (AbstractKart *kart, PhysicalObject *obj=NULL) OVERRIDE
 Callback from the physics in case that a kart or object is hit. More...
 
virtual void setAnimation (AbstractKartAnimation *animation) OVERRIDE
 
virtual BareNetworkStringsaveState (std::vector< std::string > *ru) OVERRIDE
 This object does not create an explosion, all affects on karts are handled by this hit() function. More...
 
virtual void restoreState (BareNetworkString *buffer, int count) OVERRIDE
 Called when a state needs to be replayed. More...
 
virtual void onFireFlyable () OVERRIDE
 Call when the item is (re-)fired (during rewind if needed) by projectile_manager. More...
 
- Public Member Functions inherited from Flyable
 Flyable (AbstractKart *kart, PowerupManager::PowerupType type, float mass=1.0f)
 
void updateGraphics (float dt) OVERRIDE
 Called once per rendered frame. More...
 
virtual HitEffectgetHitEffect () const
 Returns the hit effect object to use when this objects hits something. More...
 
bool isOwnerImmunity (const AbstractKart *kart_hit) const
 Returns true if the item hit the kart who shot it (to avoid that an item that's too close to the shooter hits the shooter). More...
 
void explode (AbstractKart *kart, PhysicalObject *obj=NULL, bool secondary_hits=true)
 Creates the explosion physical effect, i.e. More...
 
unsigned int getOwnerId ()
 
bool hasAnimation () const
 Returns if this flyable has an animation playing (e.g. More...
 
void setAdjustUpVelocity (bool f)
 If true the up velocity of the flyable will be adjust so that the flyable stays at a height close to the average height. More...
 
void setPositionOffset (const Vec3 &o)
 Sets the offset to be used when determining the terrain under the flyable. More...
 
virtual void hitTrack ()
 Called when this flyable hits the track. More...
 
bool hasHit ()
 Enables/disables adjusting ov velocity depending on height above terrain. More...
 
void setHasHit ()
 Indicates that something was hit and that this object must be removed. More...
 
void reset () OVERRIDE
 Resets this flyable. More...
 
PowerupManager::PowerupType getType () const
 Returns the type of flyable. More...
 
AbstractKartgetOwner () const
 Returns the owner's kart.
 
void setDoTerrainInfo (bool d)
 Sets wether Flyable should update TerrainInfo as part of its update call, or if the inheriting object will update TerrainInfo itself (or perhaps not at all if it is not needed). More...
 
const Vec3getExtend () const
 Returns the size (extend) of the mesh. More...
 
void addForRewind (const std::string &uid)
 
virtual void undoEvent (BareNetworkString *buffer) OVERRIDE
 Called when an event needs to be undone. More...
 
virtual void rewindToEvent (BareNetworkString *buffer) OVERRIDE
 Called when an event needs to be replayed. More...
 
virtual void undoState (BareNetworkString *buffer) OVERRIDE
 Undo the effects of the given state, but do not rewind to that state (which is done by rewindTo). More...
 
virtual void saveTransform () OVERRIDE
 Called before a rewind. More...
 
virtual void computeError () OVERRIDE
 Called when a rewind is finished, and is used to compute the error caused by the rewind (which is then visually smoothed over time). More...
 
bool hasServerState () const
 
virtual void onDeleteFlyable ()
 
void setCreatedTicks (int ticks)
 
- Public Member Functions inherited from Moveable
scene::ISceneNode * getNode () const
 Returns the scene node of this moveable. More...
 
void setNode (scene::ISceneNode *n)
 Sets the mesh for this model. More...
 
virtual const btVector3 & getVelocity () const
 
const btVector3 & getVelocityLC () const
 
virtual void setVelocity (const btVector3 &v)
 
const Vec3getXYZ () const
 
float getHeading () const
 Returns the heading between -pi and pi. More...
 
float getPitch () const
 Returns the pitch of the kart, restricted to between -pi/2 and pi/2. More...
 
float getRoll () const
 Returns the roll of the kart between -pi and pi. More...
 
const btQuaternion getRotation () const
 
virtual void flyUp ()
 Enter flying mode.
 
virtual void flyDown ()
 
virtual void stopFlying ()
 
virtual void setXYZ (const Vec3 &a)
 Sets the XYZ coordinates of the moveable. More...
 
void setRotation (const btMatrix3x3 &m)
 Sets the rotation of the physical body this moveable. More...
 
void setRotation (const btQuaternion &q)
 Sets the rotation of the physical body this moveable. More...
 
virtual void update (int ticks)
 Updates the current position and rotation from the corresponding physics body, and then calls updateGraphics to position the model correctly. More...
 
btRigidBody * getBody () const
 
void createBody (float mass, btTransform &trans, btCollisionShape *shape, float restitution)
 Creates the bullet rigid body for this moveable. More...
 
const btTransform & getTrans () const
 
void setTrans (const btTransform &t)
 Places this moveable at a certain location and stores this transform in this Moveable, so that it can be accessed easily. More...
 
void updatePosition ()
 Updates the current position and rotation. More...
 
void prepareSmoothing ()
 
void checkSmoothing ()
 
const btTransform & getSmoothedTrans () const
 
const Vec3getSmoothedXYZ () const
 
virtual const std::string & getIdent () const
 
- Public Member Functions inherited from SmoothNetworkBody
 SmoothNetworkBody (bool enable=false)
 
void reset ()
 
void setEnable (bool val)
 
bool isEnabled () const
 
void setSmoothRotation (bool val)
 
void setAdjustVerticalOffset (bool val)
 
void prepareSmoothing (const btTransform &current_transform, const Vec3 &current_velocity)
 
void checkSmoothing (const btTransform &current_transform, const Vec3 &current_velocity)
 Adds a new error between graphical and physical position/rotation. More...
 
void updateSmoothedGraphics (const btTransform &current_transform, const Vec3 &current_velocity, float dt)
 
void setSmoothedTransform (const btTransform &t)
 
const btTransform & getSmoothedTrans () const
 
const Vec3getSmoothedXYZ () const
 
void setMinAdjustLength (float val)
 
void setMaxAdjustLength (float val)
 
void setMinAdjustSpeed (float val)
 
void setMaxAdjustTime (float val)
 
void setAdjustLengthThreshold (float val)
 
- Public Member Functions inherited from TerrainInfo
 TerrainInfo ()
 Constructor to initialise terrain data.
 
 TerrainInfo (const Vec3 &pos)
 Constructor to initialise terrain data at a given position. More...
 
bool getSurfaceInfo (const Vec3 &from, Vec3 *position, const Material **m)
 Does a raycast upwards from the given position If the raycast indicated that the kart is 'under something' (i.e. More...
 
virtual void update (const btMatrix3x3 &rotation, const Vec3 &from)
 Update the terrain information based on the latest position. More...
 
virtual void update (const Vec3 &from)
 Update the terrain information based on the latest position. More...
 
virtual void update (const Vec3 &from, const Vec3 &towards)
 Update the terrain information based on the latest position. More...
 
virtual void update (const btMatrix3x3 &rotation)
 Simple wrapper with no offset. More...
 
float getHoT () const
 Returns the height of the terrain. More...
 
const MaterialgetMaterial () const
 Returns the current material the kart is on. More...
 
const MaterialgetLastMaterial () const
 Returns the previous material the kart was one (which might be the same as getMaterial() ). More...
 
const Vec3getNormal () const
 Returns the normal of the terrain the kart is on. More...
 
float getTerrainPitch (float heading) const
 Returns the pitch of the terrain depending on the heading. More...
 
const btVector3 & getHitPoint () const
 Returns the hit point of the raycast. More...
 
const Vec3getOrigin () const
 
- Public Member Functions inherited from Rewinder
 Rewinder (const std::string &ui="")
 
virtual std::function< void()> getLocalStateRestoreFunction ()
 
const std::string & getUniqueIdentity () const
 
bool rewinderAdd ()
 Add this object to the list of all rewindable objects in the rewind manager.
 
template<typename T >
std::shared_ptr< T > getShared ()
 
- Public Member Functions inherited from TrackSector
 TrackSector ()
 Initialises the object, and sets the current graph node to be undefined.
 
void reset ()
 
void rescue ()
 Sets current and last valid graph node to the rescue location.
 
void update (const Vec3 &xyz, bool ignore_vertical=false)
 Updates the current graph node index, and the track coordinates for the specified point. More...
 
float getRelativeDistanceToCenter () const
 Returns the relative distance of the corresponding kart from the center, i.e. More...
 
float getDistanceFromStart (bool account_for_checklines, bool strict=false) const
 Returns how far the the object is from the start line. More...
 
float getDistanceToCenter () const
 Returns the distance to the centre driveline. More...
 
int getCurrentGraphNode () const
 Returns the current graph node. More...
 
bool isOnRoad () const
 Returns if this object is on the road (driveline). More...
 
void setLastTriggeredCheckline (int i)
 
int getLastTriggeredCheckline () const
 
int getLastValidGraphNode () const
 
void saveState (BareNetworkString *buffer) const
 Only basket ball is used for rewind for TrackSector so save the minimum.
 
void rewindTo (BareNetworkString *buffer)
 
void saveCompleteState (BareNetworkString *bns)
 Save completely for spectating in linear race.
 
void restoreCompleteState (const BareNetworkString &b)
 

Static Public Member Functions

static void init (const XMLNode &node, scene::IMesh *rubberball)
 Initialises this object with data from the power.xml file (this is a static function). More...
 
- Static Public Member Functions inherited from Flyable
static void init (const XMLNode &node, scene::IMesh *model, PowerupManager::PowerupType type)
 Initialises the static members of this class for a certain type with default values and with settings from powerup.xml. More...
 

Private Member Functions

void computeTarget ()
 Determines the first kart that is still in the race.
 
void updateDistanceToTarget ()
 Determines the distance to the target kart. More...
 
unsigned int getSuccessorToHitTarget (unsigned int node_index, float *f=NULL)
 Determines the successor of a graph node. More...
 
void getNextControlPoint ()
 Determines the next control points to aim at. More...
 
float updateHeight ()
 Updates the height of the rubber ball, and if necessary also adjusts the maximum height of the ball depending on distance from the target. More...
 
void interpolate (Vec3 *next_xyz, int ticks)
 Uses Hermite splines (Catmull-Rom) to interpolate the position of the ball between the control points. More...
 
void moveTowardsTarget (Vec3 *next_xyz, int ticks)
 Moves the rubber ball in a straight line towards the target. More...
 
void updateWeightedSpeed (int ticks)
 Calculates the current speed of the basket ball. More...
 
void initializeControlPoints (const Vec3 &xyz)
 Sets up the control points for the interpolation. More...
 
float getTunnelHeight (const Vec3 &next_xyz, const float vertical_offset) const
 When the ball is in a tunnel, this will return the tunnel height. More...
 
bool checkTunneling ()
 Checks if the line from the previous ball position to the new position hits something, which indicates that the ball is tunneling through. More...
 
void removePingSFX ()
 

Private Attributes

int m_id
 Used in case of flyable debugging so that each output line gets a unique number for each ball. More...
 
const AbstractKartm_target
 A pointer to the target kart. More...
 
int m_last_aimed_graph_node
 The last graph node who's coordinates are stored in m_control_points[3]. More...
 
Vec3 m_control_points [4]
 Keep the last two, current, and next aiming points for interpolation. More...
 
Vec3 m_previous_xyz
 Saves the previous location of the ball. More...
 
float m_previous_height
 To simplify code this stores the previous height above terrain used. More...
 
float m_length_cp_1_2
 Estimated length of the spline between the control points 1 and 2. More...
 
float m_length_cp_2_3
 Estimated length of the spline between the control points 2 and 3. More...
 
float m_t
 The parameter for the spline, m_t in [0,1]. More...
 
float m_t_increase
 How much m_t must increase per second in order to maintain a constant speed, i.e. More...
 
float m_interval
 How long it takes from one bounce of the ball to the next. More...
 
float m_distance_to_target
 Distance to target. More...
 
float m_height_timer
 This timer is used to determine the height depending on the time. More...
 
float m_current_max_height
 The current maximum height of the ball. More...
 
int16_t m_delete_ticks
 If the ball overtakes its target or starts to aim at the kart which originally shot the rubber ball, after a certain amount of time the ball will be deleted. More...
 
uint8_t m_tunnel_count
 This variable counts how often a ball tunneled (in consecutive frames). More...
 
bool m_fast_ping
 This flag is set if the target is within the fast ping distance. More...
 
bool m_aiming_at_target
 Once the ball is close enough, it will aim for the kart. More...
 
SFXBasem_ping_sfx
 A 'ping' sound effect to be played when the ball hits the ground. More...
 
bool m_restoring_state
 

Static Private Attributes

static int m_next_id = 0
 A class variable which stores the next id number to use. More...
 
static float m_st_interval
 A class variable to store the default interval size. More...
 
static float m_st_squash_duration
 A class variable to store the default squash duration. More...
 
static float m_st_squash_slowdown
 A class variable to store the default squash slowdown. More...
 
static float m_st_target_distance
 If the ball is closer than this distance to the target, it will start to aim directly at the target (and not interpolate anymore). More...
 
static float m_st_max_height_difference
 In somce track, e.g. More...
 
static float m_st_fast_ping_distance
 Distance between ball and target at which the ball will start to bounce faster (which makes more 'ping' sfx for the driver to hear it coming closer, but also higher probability to hit the target and not fly over it). More...
 
static float m_st_target_max_angle
 The maximum angle the ball can change per second when being close to the taregt. More...
 
static float m_st_min_interpolation_distance
 Each control point chosen must be at least this far away from the previous one. More...
 
static int16_t m_st_delete_ticks
 If the ball overtakes its target or starts to aim at the kart which originally shot the rubber ball, after this amount of time the ball will be deleted. More...
 
static float m_st_min_speed_offset
 If the ball is closer to its target than min_offset_distance, the speed in addition to the difficulty's default max speed. More...
 
static float m_st_max_speed_offset
 If the ball is farther to its target than max_offset_distance, the speed in addition to the difficulty's default max speed. More...
 
static float m_st_min_offset_distance
 The distance to target under which the ball is the slowest.
 
static float m_st_max_offset_distance
 The distance to target over which the ball is the fastest.
 
static float m_st_early_target_factor
 This factor is used to influence how much the rubber ball should aim at its target early. More...
 

Additional Inherited Members

- Protected Member Functions inherited from Flyable
void getClosestKart (const AbstractKart **minKart, float *minDistSquared, Vec3 *minDelta, const AbstractKart *inFrontOf=NULL, const bool backwards=false) const
 Returns information on what is the closest kart and at what distance it is. More...
 
void getLinearKartItemIntersection (const Vec3 &origin, const AbstractKart *target_kart, float item_XY_velocity, float gravity, float forw_offset, float *fire_angle, float *up_velocity)
 Returns information on the parameters needed to hit a target kart moving at constant velocity and direction for a given speed in the XZ-plane. More...
 
void createPhysics (float y_offset, const Vec3 &velocity, btCollisionShape *shape, float restitution, const btVector3 &gravity=btVector3(0.0f, 0.0f, 0.0f), const bool rotates=false, const bool turn_around=false, const btTransform *customDirection=NULL)
 init bullet for moving objects like projectiles More...
 
void moveToInfinity (bool set_moveable_trans=true)
 It's called when undoing the creation or destruction of flyables, so that it will not affected the current game, and it will be deleted in computeError. More...
 
void removePhysics ()
 
- Protected Member Functions inherited from Moveable
void updateSmoothedGraphics (float dt)
 
virtual void updateGraphics (const Vec3 &off_xyz=Vec3(0.0f, 0.0f, 0.0f), const btQuaternion &off_rotation=btQuaternion(0.0f, 0.0f, 0.0f, 1.0f))
 Updates the graphics model. More...
 
- Protected Member Functions inherited from Rewinder
void setUniqueIdentity (const std::string &uid)
 
- Protected Attributes inherited from Flyable
AbstractKartm_owner
 Kart which shot this flyable. More...
 
PowerupManager::PowerupType m_type
 Type of the powerup. More...
 
btCollisionShape * m_shape
 Collision shape of this Flyable. More...
 
float m_max_height
 Maximum height above terrain. More...
 
float m_min_height
 Minimum height above terrain. More...
 
float m_average_height
 Average of average of m_{min,ax}_height. More...
 
float m_force_updown
 Force pushing the Flyable up. More...
 
float m_speed
 Speed of this Flyable. More...
 
const float m_mass
 Mass of this Flyable. More...
 
Vec3 m_extend
 Size of this flyable. More...
 
uint16_t m_ticks_since_thrown
 Time since thrown. More...
 
bool m_has_server_state
 
bool m_owner_has_temporary_immunity
 If set to true, the kart that throwns this flyable can't collide with it for a short time. More...
 
bool m_deleted_once
 
int m_last_deleted_ticks
 
int m_max_lifespan
 Set to something > -1 if this flyable should auto-destrcut after that may ticks. More...
 
int m_created_ticks
 
- Protected Attributes inherited from Moveable
btTransform m_transform
 The bullet transform of this rigid body. More...
 
UserPointer m_user_pointer
 
scene::ISceneNode * m_node
 
std::unique_ptr< btRigidBody > m_body
 
std::unique_ptr< KartMotionStatem_motion_state
 
- Static Protected Attributes inherited from Flyable
static float m_st_speed [PowerupManager::POWERUP_MAX]
 Speed of the projectile. More...
 
static scene::IMesh * m_st_model [PowerupManager::POWERUP_MAX]
 The mesh of this Flyable. More...
 
static float m_st_min_height [PowerupManager::POWERUP_MAX]
 Minimum height above track. More...
 
static float m_st_max_height [PowerupManager::POWERUP_MAX]
 Max height above track. More...
 
static float m_st_force_updown [PowerupManager::POWERUP_MAX]
 Force pushing up/down. More...
 
static Vec3 m_st_extend [PowerupManager::POWERUP_MAX]
 Size of the model. More...
 

Member Function Documentation

◆ checkTunneling()

bool RubberBall::checkTunneling ( )
private

Checks if the line from the previous ball position to the new position hits something, which indicates that the ball is tunneling through.

If this happens, the ball position is adjusted so that it is just before the hit point. If tunneling happens four frames in a row the ball is considered stuck and explodes (e.g. the ball might try to tunnel through a wall to get to a 'close' target. In this case the ball would not move much anymore and be stuck).

Returns
True if the ball tunneled often enough to be removed.

◆ getNextControlPoint()

void RubberBall::getNextControlPoint ( )
private

Determines the next control points to aim at.

The control points must not be too close to each other (since otherwise the interpolation is still not smooth enough), so keep on picking graph nodes till the distance between the currently aimed at graph node and the next one is above a certain threshold. It uses getSuccessorToHitTarget to determine which graph node to select.

◆ getSuccessorToHitTarget()

unsigned int RubberBall::getSuccessorToHitTarget ( unsigned int  node_index,
float *  dist = NULL 
)
private

Determines the successor of a graph node.

For now always a successor on the main driveline is returned, but a more sophisticated implementation might check if the target kart is on a shortcut, and select the path so that it will get to the target even in this case.

Parameters
node_indexThe node for which the successor is searched.
distIf not NULL a pointer to a float. The distance between node_index and the selected successor is added to this float.
Returns
The node index of a successor node.

◆ getTunnelHeight()

float RubberBall::getTunnelHeight ( const Vec3 next_xyz,
const float  vertical_offset 
) const
private

When the ball is in a tunnel, this will return the tunnel height.

NOTE: When this function is called next_xyz is usually the interpolated point on the track and not the ball's current location. Look at updateAndDelete().

Parameters
vertical_offsetA vertical offset which is added to the current position in order to avoid hitting the track when doing a raycast up.
Returns
The distance to the terrain element found by raycast in the up direction. If no terrain found, it returns 99990

◆ hit()

bool RubberBall::hit ( AbstractKart kart,
PhysicalObject object = NULL 
)
virtual

Callback from the physics in case that a kart or object is hit.

The rubber ball will only be removed if it hits it target, all other karts it might hit earlier will only be flattened. \params kart The kart hit (NULL if no kart was hit). \params object The object that was hit (NULL if none).

Returns
True if

Reimplemented from Flyable.

◆ init()

void RubberBall::init ( const XMLNode node,
scene::IMesh *  rubberball 
)
static

Initialises this object with data from the power.xml file (this is a static function).

Parameters
nodeXML Node
rubberballThe rubber ball mesh

◆ initializeControlPoints()

void RubberBall::initializeControlPoints ( const Vec3 xyz)
private

Sets up the control points for the interpolation.

The parameter contains the coordinates of the first control points (i.e. a control point that influences the direction the ball is flying only, not the actual coordinates - see details about Catmull-Rom splines). This function will then set the 2nd control point to be the current coordinates of the ball, and find two more appropriate control points for a smooth movement.

Parameters
xyzCoordinates of the first control points.

◆ interpolate()

void RubberBall::interpolate ( Vec3 next_xyz,
int  ticks 
)
private

Uses Hermite splines (Catmull-Rom) to interpolate the position of the ball between the control points.

If the next point would be outside of the spline between control_points[1] and [2], a new control point is added.

Parameters
next_xyzReturns the new position.
Thetime step size.

◆ moveTowardsTarget()

void RubberBall::moveTowardsTarget ( Vec3 next_xyz,
int  ticks 
)
private

Moves the rubber ball in a straight line towards the target.

This is used once the rubber ball is close to its target. It restricts the angle by which the rubber ball can change its direction per frame.

Parameters
next_xyzThe position the ball should move to.
ticksNumber of physics steps - should be 1.

◆ onFireFlyable()

void RubberBall::onFireFlyable ( )
virtual

Call when the item is (re-)fired (during rewind if needed) by projectile_manager.

Reimplemented from Flyable.

◆ restoreState()

void RubberBall::restoreState ( BareNetworkString buffer,
int  count 
)
virtual

Called when a state needs to be replayed.

This is called during rewind, i.e. when going forward in time again, and only for confirmed states.

Reimplemented from Flyable.

◆ saveState()

BareNetworkString * RubberBall::saveState ( std::vector< std::string > *  ru)
virtual

This object does not create an explosion, all affects on karts are handled by this hit() function.

Reimplemented from Flyable.

◆ updateAndDelete()

bool RubberBall::updateAndDelete ( int  ticks)
virtual

Updates the rubber ball.

Parameters
dtTime step size.
Returns
True if the rubber ball should be removed.

Reimplemented from Flyable.

◆ updateDistanceToTarget()

void RubberBall::updateDistanceToTarget ( )
private

Determines the distance to the target kart.

If the target is close, the rubber ball will switch from following the quad graph structure to directly aim at the target.

◆ updateHeight()

float RubberBall::updateHeight ( )
private

Updates the height of the rubber ball, and if necessary also adjusts the maximum height of the ball depending on distance from the target.

The height is decreased when the ball is getting closer to the target so it hops faster and faster. This function modifies m_current_max_height.

Returns
Returns the new height of the ball.

◆ updateWeightedSpeed()

void RubberBall::updateWeightedSpeed ( int  ticks)
private

Calculates the current speed of the basket ball.

The base basket ball speed is the target's normal max speed. Then an offset is applied. If closer than m_st_min_offset_distance ; it is m_st_min_speed_offset If farther than m_st_max_offset_distance ; it is m_st_max_speed_offset Else, it is a weighted average. It takes up to 5 seconds to fully change its speed (to avoid sudden big speed changes when the distance change suddenly at ball throwing, because of paths, shortcuts, etc.) If there is no target, it will keep its current speed

Member Data Documentation

◆ m_aiming_at_target

bool RubberBall::m_aiming_at_target
private

Once the ball is close enough, it will aim for the kart.

If the kart should be able to then increase the distance to the ball, the ball will be removed and the kart escapes. This boolean is used to keep track of the state of this ball.

◆ m_control_points

Vec3 RubberBall::m_control_points[4]
private

Keep the last two, current, and next aiming points for interpolation.

◆ m_current_max_height

float RubberBall::m_current_max_height
private

The current maximum height of the ball.

This value will be reduced if the ball gets closer to the target.

◆ m_delete_ticks

int16_t RubberBall::m_delete_ticks
private

If the ball overtakes its target or starts to aim at the kart which originally shot the rubber ball, after a certain amount of time the ball will be deleted.

This timer tracks this time. If it is < 0 it indicates that the ball is targeting another kart atm.

◆ m_distance_to_target

float RubberBall::m_distance_to_target
private

Distance to target.

This is measured in terms of 'distance along track', but also takes the 3d distance and height difference into account (in case that the target is on a different part of the track)

◆ m_fast_ping

bool RubberBall::m_fast_ping
private

This flag is set if the target is within the fast ping distance.

It will cause the rubber ball to decrese the jump height and intervall.

◆ m_height_timer

float RubberBall::m_height_timer
private

This timer is used to determine the height depending on the time.

It is always between 0 and m_interval.

◆ m_id

int RubberBall::m_id
private

Used in case of flyable debugging so that each output line gets a unique number for each ball.

◆ m_interval

float RubberBall::m_interval
private

How long it takes from one bounce of the ball to the next.

◆ m_last_aimed_graph_node

int RubberBall::m_last_aimed_graph_node
private

The last graph node who's coordinates are stored in m_control_points[3].

◆ m_length_cp_1_2

float RubberBall::m_length_cp_1_2
private

Estimated length of the spline between the control points 1 and 2.

◆ m_length_cp_2_3

float RubberBall::m_length_cp_2_3
private

Estimated length of the spline between the control points 2 and 3.

◆ m_next_id

int RubberBall::m_next_id = 0
staticprivate

A class variable which stores the next id number to use.

◆ m_ping_sfx

SFXBase* RubberBall::m_ping_sfx
private

A 'ping' sound effect to be played when the ball hits the ground.

◆ m_previous_height

float RubberBall::m_previous_height
private

To simplify code this stores the previous height above terrain used.

◆ m_previous_xyz

Vec3 RubberBall::m_previous_xyz
private

Saves the previous location of the ball.

This is needed if a ball should lose it target, and has to reinitialise the control points for the interpolation.

◆ m_st_delete_ticks

int16_t RubberBall::m_st_delete_ticks
staticprivate

If the ball overtakes its target or starts to aim at the kart which originally shot the rubber ball, after this amount of time the ball will be deleted.

◆ m_st_early_target_factor

float RubberBall::m_st_early_target_factor
staticprivate

This factor is used to influence how much the rubber ball should aim at its target early.

It used the 'distance to center of track' of its target, and adjusts the interpolation control points to be more or less at the same (relative) distance from center. If the factor is 1, the rubber ball will aim to be at the same relative distance, if the factor is 0, the rubber ball will aim directly at the driveline points. A factor of 1 usually means that by the time the ball starts aiming directly at the target it is (nearly) on the same 'line', meaning it only has to go straight. On the other hand in a tunnel this might result in the ball being too far to the side, increasing the likelihood of the ball tunneling through (which can happen when the ball switches to aim-at-target mode, in a tight curve, so that the direct line to the target goes through a wall.

◆ m_st_fast_ping_distance

float RubberBall::m_st_fast_ping_distance
staticprivate

Distance between ball and target at which the ball will start to bounce faster (which makes more 'ping' sfx for the driver to hear it coming closer, but also higher probability to hit the target and not fly over it).

◆ m_st_interval

float RubberBall::m_st_interval
staticprivate

A class variable to store the default interval size.

◆ m_st_max_height_difference

float RubberBall::m_st_max_height_difference
staticprivate

In somce track, e.g.

subsea track, it is possible that the karts are on different parts of the track (different shortcuts), but still close to each other - because one of the parts is just on top of the other part. Therefore use the height as additional criteria to determine if a ball is close to its target.

◆ m_st_max_speed_offset

float RubberBall::m_st_max_speed_offset
staticprivate

If the ball is farther to its target than max_offset_distance, the speed in addition to the difficulty's default max speed.

◆ m_st_min_interpolation_distance

float RubberBall::m_st_min_interpolation_distance
staticprivate

Each control point chosen must be at least this far away from the previous one.

This gives smooth 'overall' interpolation even if the quads should be close to each other.

◆ m_st_min_speed_offset

float RubberBall::m_st_min_speed_offset
staticprivate

If the ball is closer to its target than min_offset_distance, the speed in addition to the difficulty's default max speed.

◆ m_st_squash_duration

float RubberBall::m_st_squash_duration
staticprivate

A class variable to store the default squash duration.

◆ m_st_squash_slowdown

float RubberBall::m_st_squash_slowdown
staticprivate

A class variable to store the default squash slowdown.

◆ m_st_target_distance

float RubberBall::m_st_target_distance
staticprivate

If the ball is closer than this distance to the target, it will start to aim directly at the target (and not interpolate anymore).

◆ m_st_target_max_angle

float RubberBall::m_st_target_max_angle
staticprivate

The maximum angle the ball can change per second when being close to the taregt.

If the target angle is small, it makes it much harder to hit the target, giving it some chances to escape.

◆ m_t

float RubberBall::m_t
private

The parameter for the spline, m_t in [0,1].

This is not directly related to the time, since depending on the distance between the two control points different increments must be used for m_t. For example, if the distance is 10 m, and assuming a speed of 10 m/s for the ball, then each second must add '1' to m_t. If the distance on the other hand is 200 m, then 10/200 = 1/20 per second must be added (so that it takes 20 seconds to move from 0 to 1).

◆ m_t_increase

float RubberBall::m_t_increase
private

How much m_t must increase per second in order to maintain a constant speed, i.e.

the speed of the ball divided by the distance between the control points. See m_t for more details.

◆ m_target

const AbstractKart* RubberBall::m_target
private

A pointer to the target kart.

◆ m_tunnel_count

uint8_t RubberBall::m_tunnel_count
private

This variable counts how often a ball tunneled (in consecutive frames).

If a ball tunnels a certain number of times, it is considered stuck and will be removed.


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