force::drag
Applies linear drag to slow down the current element over time.
Declaration
void force::drag(float linearDragFactor)Parameters
- linearDragFactor:
The drag coefficient controlling how quickly the element slows down. Higher values result in faster deceleration. A value of 0 means no drag.
Discussion
This function simulates air resistance or fluid drag by reducing the element’s velocity proportionally to its current speed. The drag is frame-rate independent, ensuring consistent behavior across different frame rates.
The drag force is calculated as: velocity -= velocity * min(1.0, deltaTime * linearDragFactor)