blob: b99576b56bde43cf26ef3886fb37d86c5a906134 [file] [log] [blame]
Brian Osman7c979f52019-02-12 13:27:51 -05001/*
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
19struct 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
33struct SkParticleVelocity {
34 SkVector fLinear;
35 SkScalar fAngular;
36};
37
38struct SkParticlePoseAndVelocity {
39 SkParticlePose fPose;
40 SkParticleVelocity fVelocity;
41};
42
43struct SkParticleUpdateParams {
44 SkRandom* fRandom;
45 SkRandom* fStableRandom;
46 float fDeltaTime;
47 float fParticleT;
48};
49
50#endif // SkParticleData_DEFINED