| 81 | // |
| 82 | |
| 83 | inline void normalize_point(float x, float y, particle_point* out) |
| 84 | { |
| 85 | float n = x * x + y * y; |
| 86 | // Already normalized. |
| 87 | if (n == 1.0f) |
| 88 | return; |
| 89 | |
| 90 | n = sqrt(n); |
| 91 | // Too close to zero. |
| 92 | if (n < MATH_TOLERANCE) |
| 93 | return; |
| 94 | |
| 95 | n = 1.0f / n; |
| 96 | out->x = x * n; |
| 97 | out->y = y * n; |
| 98 | } |
| 99 | |
| 100 | ParticleData::ParticleData() |
| 101 | { |