applyTouchPhysics method

  1. @Deprecated('Use handleTouchInteraction for combined physics and rendering')
void applyTouchPhysics(
  1. List<int> visibleParticles
)

Legacy method for applying touch physics (deprecated) Use handleTouchInteraction instead for better performance

Implementation

@Deprecated('Use handleTouchInteraction for combined physics and rendering')
void applyTouchPhysics(List<int> visibleParticles) {
  final Offset? touch = touchPoint;
  if (touch == null) return;

  final double touchX = touch.dx;
  final double touchY = touch.dy;

  for (final int i in visibleParticles) {
    final Particle p = particles[i];
    final double dx = p.position.dx - touchX;
    final double dy = p.position.dy - touchY;
    final double distance = math.sqrt(dx * dx + dy * dy);

    if (distance < lineDistance) {
      const double force = 0.00111;
      final double pullX = -dx * force;
      final double pullY = -dy * force;
      p.velocity += Offset(pullX, pullY);
      p.wasAccelerated = true;
    }
  }
}