SuperTuxKart
Loading...
Searching...
No Matches
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.
 
virtual bool hit (AbstractKart *kart, PhysicalObject *obj=NULL) OVERRIDE
 Callback from the physics in case that a kart or object is hit.
 
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.
 
virtual void restoreState (BareNetworkString *buffer, int count) OVERRIDE
 Called when a state needs to be replayed.
 
virtual void onFireFlyable () OVERRIDE
 Call when the item is (re-)fired (during rewind if needed) by projectile_manager.
 
- 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.
 
virtual bool updateAndDelete (int ticks)
 Updates this flyable.
 
virtual void setAnimation (AbstractKartAnimation *animation)
 
virtual HitEffectgetHitEffect () const
 Returns the hit effect object to use when this objects hits something.
 
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).
 
virtual bool hit (AbstractKart *kart, PhysicalObject *obj=NULL)
 Callback from the physics in case that a kart or physical object is hit.
 
void explode (AbstractKart *kart, PhysicalObject *obj=NULL, bool secondary_hits=true)
 Creates the explosion physical effect, i.e.
 
unsigned int getOwnerId ()
 
bool hasAnimation () const
 Returns if this flyable has an animation playing (e.g.
 
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.
 
void setPositionOffset (const Vec3 &o)
 Sets the offset to be used when determining the terrain under the flyable.
 
virtual void hitTrack ()
 Called when this flyable hits the track.
 
bool hasHit ()
 Enables/disables adjusting ov velocity depending on height above terrain.
 
void setHasHit ()
 Indicates that something was hit and that this object must be removed.
 
void reset () OVERRIDE
 Resets this flyable.
 
PowerupManager::PowerupType getType () const
 Returns the type of flyable.
 
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).
 
const Vec3getExtend () const
 Returns the size (extend) of the mesh.
 
void addForRewind (const std::string &uid)
 
virtual void undoEvent (BareNetworkString *buffer) OVERRIDE
 Called when an event needs to be undone.
 
virtual void rewindToEvent (BareNetworkString *buffer) OVERRIDE
 Called when an event needs to be replayed.
 
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).
 
virtual void saveTransform () OVERRIDE
 Called before a rewind.
 
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).
 
virtual BareNetworkStringsaveState (std::vector< std::string > *ru) OVERRIDE
 Provides a copy of the state of the object in one memory buffer.
 
virtual void restoreState (BareNetworkString *buffer, int count) OVERRIDE
 Called when a state needs to be replayed.
 
bool hasServerState () const
 
virtual void onFireFlyable ()
 Call when the item is (re-)fired (during rewind if needed) by projectile_manager.
 
virtual void onDeleteFlyable ()
 
void setCreatedTicks (int ticks)
 
- Public Member Functions inherited from Moveable
scene::ISceneNode * getNode () const
 Returns the scene node of this moveable.
 
void setNode (scene::ISceneNode *n)
 Sets the mesh for this model.
 
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.
 
float getPitch () const
 Returns the pitch of the kart, restricted to between -pi/2 and pi/2.
 
float getRoll () const
 Returns the roll of the kart between -pi and pi.
 
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.
 
void setRotation (const btMatrix3x3 &m)
 Sets the rotation of the physical body this moveable.
 
void setRotation (const btQuaternion &q)
 Sets the rotation of the physical body this moveable.
 
virtual void reset ()
 The reset position must be set before calling reset.
 
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.
 
btRigidBody * getBody () const
 
void createBody (float mass, btTransform &trans, btCollisionShape *shape, float restitution)
 Creates the bullet rigid body for this moveable.
 
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.
 
void updatePosition ()
 Updates the current position and rotation.
 
virtual void updateGraphics (float dt)=0
 Called once per rendered frame.
 
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.
 
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.
 
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.
 
virtual void update (const btMatrix3x3 &rotation, const Vec3 &from)
 Update the terrain information based on the latest position.
 
virtual void update (const Vec3 &from)
 Update the terrain information based on the latest position.
 
virtual void update (const Vec3 &from, const Vec3 &towards)
 Update the terrain information based on the latest position.
 
virtual void update (const btMatrix3x3 &rotation)
 Simple wrapper with no offset.
 
float getHoT () const
 Returns the height of the terrain.
 
const MaterialgetMaterial () const
 Returns the current material the kart is on.
 
const MaterialgetLastMaterial () const
 Returns the previous material the kart was one (which might be the same as getMaterial() ).
 
const Vec3getNormal () const
 Returns the normal of the terrain the kart is on.
 
float getTerrainPitch (float heading) const
 Returns the pitch of the terrain depending on the heading.
 
const btVector3 & getHitPoint () const
 Returns the hit point of the raycast.
 
const Vec3getOrigin () const
 
- Public Member Functions inherited from Rewinder
 Rewinder (const std::string &ui="")
 
virtual void saveTransform ()=0
 Called before a rewind.
 
virtual void computeError ()=0
 Called when a rewind is finished, and is used to compute the error caused by the rewind (which is then visually smoothed over time).
 
virtual BareNetworkStringsaveState (std::vector< std::string > *ru)=0
 Provides a copy of the state of the object in one memory buffer.
 
virtual void undoEvent (BareNetworkString *buffer)=0
 Called when an event needs to be undone.
 
virtual void rewindToEvent (BareNetworkString *buffer)=0
 Called when an event needs to be replayed.
 
virtual void restoreState (BareNetworkString *buffer, int count)=0
 Called when a state needs to be replayed.
 
virtual void undoState (BareNetworkString *buffer)=0
 Undo the effects of the given state, but do not rewind to that state (which is done by rewindTo).
 
virtual void reset ()
 Nothing to do here.
 
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.
 
float getRelativeDistanceToCenter () const
 Returns the relative distance of the corresponding kart from the center, i.e.
 
float getDistanceFromStart (bool account_for_checklines, bool strict=false) const
 Returns how far the the object is from the start line.
 
float getDistanceToCenter () const
 Returns the distance to the centre driveline.
 
int getCurrentGraphNode () const
 Returns the current graph node.
 
bool isOnRoad () const
 Returns if this object is on the road (driveline).
 
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).
 
- 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.
 

Private Member Functions

void computeTarget ()
 Determines the first kart that is still in the race.
 
void updateDistanceToTarget ()
 Determines the distance to the target kart.
 
unsigned int getSuccessorToHitTarget (unsigned int node_index, float *f=NULL)
 Determines the successor of a graph node.
 
void getNextControlPoint ()
 Determines the next control points to aim at.
 
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.
 
void interpolate (Vec3 *next_xyz, int ticks)
 Uses Hermite splines (Catmull-Rom) to interpolate the position of the ball between the control points.
 
void moveTowardsTarget (Vec3 *next_xyz, int ticks)
 Moves the rubber ball in a straight line towards the target.
 
void updateWeightedSpeed (int ticks)
 Calculates the current speed of the basket ball.
 
void initializeControlPoints (const Vec3 &xyz)
 Sets up the control points for the interpolation.
 
float getTunnelHeight (const Vec3 &next_xyz, const float vertical_offset) const
 When the ball is in a tunnel, this will return the tunnel height.
 
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.
 
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.
 
const AbstractKartm_target
 A pointer to the target kart.
 
int m_last_aimed_graph_node
 The last graph node who's coordinates are stored in m_control_points[3].
 
Vec3 m_control_points [4]
 Keep the last two, current, and next aiming points for interpolation.
 
Vec3 m_previous_xyz
 Saves the previous location of the ball.
 
float m_previous_height
 To simplify code this stores the previous height above terrain used.
 
float m_length_cp_1_2
 Estimated length of the spline between the control points 1 and 2.
 
float m_length_cp_2_3
 Estimated length of the spline between the control points 2 and 3.
 
float m_t
 The parameter for the spline, m_t in [0,1].
 
float m_t_increase
 How much m_t must increase per second in order to maintain a constant speed, i.e.
 
float m_interval
 How long it takes from one bounce of the ball to the next.
 
float m_distance_to_target
 Distance to target.
 
float m_height_timer
 This timer is used to determine the height depending on the time.
 
float m_current_max_height
 The current maximum height of the ball.
 
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.
 
uint8_t m_tunnel_count
 This variable counts how often a ball tunneled (in consecutive frames).
 
bool m_fast_ping
 This flag is set if the target is within the fast ping distance.
 
bool m_aiming_at_target
 Once the ball is close enough, it will aim for the kart.
 
SFXBasem_ping_sfx
 A 'ping' sound effect to be played when the ball hits the ground.
 
bool m_restoring_state
 

Static Private Attributes

static float m_st_interval
 A class variable to store the default interval size.
 
static float m_st_squash_duration
 A class variable to store the default squash duration.
 
static float m_st_squash_slowdown
 A class variable to store the default squash slowdown.
 
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).
 
static float m_st_max_height_difference
 In somce track, e.g.
 
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).
 
static float m_st_target_max_angle
 The maximum angle the ball can change per second when being close to the taregt.
 
static float m_st_min_interpolation_distance
 Each control point chosen must be at least this far away from the previous one.
 
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.
 
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.
 
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.
 
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.
 

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.
 
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.
 
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
 
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.
 
void removePhysics ()
 
void fixSFXSplitscreen (SFXBase *sfx)
 
- 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.
 
- Protected Member Functions inherited from Rewinder
void setUniqueIdentity (const std::string &uid)
 
- Protected Attributes inherited from Flyable
AbstractKartm_owner
 Kart which shot this flyable.
 
PowerupManager::PowerupType m_type
 Type of the powerup.
 
btCollisionShape * m_shape
 Collision shape of this Flyable.
 
float m_max_height
 Maximum height above terrain.
 
float m_min_height
 Minimum height above terrain.
 
float m_average_height
 Average of average of m_{min,ax}_height.
 
float m_force_updown
 Force pushing the Flyable up.
 
float m_speed
 Speed of this Flyable.
 
const float m_mass
 Mass of this Flyable.
 
Vec3 m_extend
 Size of this flyable.
 
uint16_t m_ticks_since_thrown
 Time since thrown.
 
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.
 
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.
 
int m_created_ticks
 
- Protected Attributes inherited from Moveable
btTransform m_transform
 The bullet transform of this rigid body.
 
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.
 
static scene::IMesh * m_st_model [PowerupManager::POWERUP_MAX]
 The mesh of this Flyable.
 
static float m_st_min_height [PowerupManager::POWERUP_MAX]
 Minimum height above track.
 
static float m_st_max_height [PowerupManager::POWERUP_MAX]
 Max height above track.
 
static float m_st_force_updown [PowerupManager::POWERUP_MAX]
 Force pushing up/down.
 
static Vec3 m_st_extend [PowerupManager::POWERUP_MAX]
 Size of the model.
 

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.

◆ setAnimation()

void RubberBall::setAnimation ( AbstractKartAnimation animation)
virtual

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_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_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_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_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_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_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_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: