Wavelength
Privacy-focused, cross-platform, and open-source communication application
Loading...
Searching...
No Matches
MovingState Class Referencefinal

Implements the Moving state behavior for the Blob animation. More...

#include <moving_state.h>

Inheritance diagram for MovingState:
Collaboration diagram for MovingState:

Public Member Functions

void Apply (std::vector< QPointF > &control_points, std::vector< QPointF > &velocity, QPointF &blob_center, const BlobConfig::BlobParameters &params) override
 Applies a stretching effect to the blob based on its average internal velocity. Calculates the average velocity of all control points and applies a force to each point in that direction, scaled by the point's distance from the center. This creates a visual stretch or "smear" effect when the blob is moving internally.
 
void ApplyForce (const QVector2D &force, std::vector< QPointF > &velocity, QPointF &blob_center, const std::vector< QPointF > &control_points, double blob_radius) override
 Applies an external force directly to the blob's velocity and center. The force applied to each control point's velocity is scaled based on its distance from the center. A portion of the force is also applied directly to the blob's center position.
 
 MovingState ()
 Default constructor for MovingState.
 
- Public Member Functions inherited from BlobState
virtual ~BlobState ()=default
 Virtual destructor. Ensures proper cleanup when deleting derived state objects through a base class pointer.
 

Static Public Member Functions

static void ApplyInertiaForce (std::vector< QPointF > &velocity, QPointF &blob_center, const std::vector< QPointF > &control_points, double blob_radius, const QVector2D &window_velocity)
 Applies an inertia force based on the calculated window velocity. This static method is typically called by the BlobTransitionManager when significant window movement is detected. It applies a force opposite to the window's velocity to the blob's control points and center, simulating inertia. The force magnitude is scaled based on window speed and point distance from the center. Includes optimizations like pre-calculation and early exit for low speeds.
 

Detailed Description

Implements the Moving state behavior for the Blob animation.

This state is active when the application window is being moved. It applies forces to the blob based on the window's velocity (inertia) and also introduces a stretching effect in the direction of the blob's internal average velocity. External forces are applied more directly compared to the Idle state.

Constructor & Destructor Documentation

◆ MovingState()

MovingState::MovingState ( )
default

Default constructor for MovingState.

Member Function Documentation

◆ Apply()

void MovingState::Apply ( std::vector< QPointF > & control_points,
std::vector< QPointF > & velocity,
QPointF & blob_center,
const BlobConfig::BlobParameters & params )
overridevirtual

Applies a stretching effect to the blob based on its average internal velocity. Calculates the average velocity of all control points and applies a force to each point in that direction, scaled by the point's distance from the center. This creates a visual stretch or "smear" effect when the blob is moving internally.

Parameters
control_pointsReference to the vector of current control point positions (read-only).
velocityReference to the vector of current control point velocities (modified).
blob_centerThe current center position of the blob (read-only).
paramsBlob appearance parameters (read-only, used for radius).

Implements BlobState.

◆ ApplyForce()

void MovingState::ApplyForce ( const QVector2D & force,
std::vector< QPointF > & velocity,
QPointF & blob_center,
const std::vector< QPointF > & control_points,
double blob_radius )
overridevirtual

Applies an external force directly to the blob's velocity and center. The force applied to each control point's velocity is scaled based on its distance from the center. A portion of the force is also applied directly to the blob's center position.

Parameters
forceThe external force vector to apply.
velocityReference to the vector of current control point velocities (modified).
blob_centerReference to the blob's center position (modified).
control_pointsReference to the vector of current control point positions (read-only, used for distance calculation).
blob_radiusThe current average radius of the blob (read-only, used for scaling).

Implements BlobState.

◆ ApplyInertiaForce()

void MovingState::ApplyInertiaForce ( std::vector< QPointF > & velocity,
QPointF & blob_center,
const std::vector< QPointF > & control_points,
double blob_radius,
const QVector2D & window_velocity )
static

Applies an inertia force based on the calculated window velocity. This static method is typically called by the BlobTransitionManager when significant window movement is detected. It applies a force opposite to the window's velocity to the blob's control points and center, simulating inertia. The force magnitude is scaled based on window speed and point distance from the center. Includes optimizations like pre-calculation and early exit for low speeds.

Parameters
velocityReference to the vector of current control point velocities (modified).
blob_centerReference to the blob's center position (modified).
control_pointsReference to the vector of current control point positions (read-only).
blob_radiusThe current average radius of the blob (read-only).
window_velocityThe calculated velocity vector of the application window.

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