Brian Osman | 7c979f5 | 2019-02-12 13:27:51 -0500 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright 2019 Google LLC |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
| 8 | #ifndef SkParticleData_DEFINED |
| 9 | #define SkParticleData_DEFINED |
| 10 | |
| 11 | #include "SkPoint.h" |
| 12 | #include "SkRandom.h" |
| 13 | #include "SkRSXform.h" |
| 14 | |
| 15 | /* |
| 16 | * Various structs used to communicate particle information among emitters, affectors, etc. |
| 17 | */ |
| 18 | |
| 19 | struct SkParticlePose { |
| 20 | SkPoint fPosition; |
| 21 | SkVector fHeading; |
| 22 | SkScalar fScale; |
| 23 | |
| 24 | SkRSXform asRSXform(SkPoint ofs) const { |
| 25 | const float s = fHeading.fX * fScale; |
| 26 | const float c = -fHeading.fY * fScale; |
| 27 | return SkRSXform::Make(c, s, |
| 28 | fPosition.fX + -c * ofs.fX + s * ofs.fY, |
| 29 | fPosition.fY + -s * ofs.fX + -c * ofs.fY); |
| 30 | } |
| 31 | }; |
| 32 | |
| 33 | struct SkParticleVelocity { |
| 34 | SkVector fLinear; |
| 35 | SkScalar fAngular; |
| 36 | }; |
| 37 | |
| 38 | struct SkParticlePoseAndVelocity { |
| 39 | SkParticlePose fPose; |
| 40 | SkParticleVelocity fVelocity; |
| 41 | }; |
| 42 | |
| 43 | struct SkParticleUpdateParams { |
| 44 | SkRandom* fRandom; |
| 45 | SkRandom* fStableRandom; |
| 46 | float fDeltaTime; |
| 47 | float fParticleT; |
| 48 | }; |
| 49 | |
| 50 | #endif // SkParticleData_DEFINED |