Loading...
Searching...
No Matches
PointParticleEmitter2.hpp
Go to the documentation of this file.
1// This code is based on Jet framework.
2// Copyright (c) 2018 Doyub Kim
3// CubbyFlow is voxel-based fluid simulation engine for computer games.
4// Copyright (c) 2020 CubbyFlow Team
5// Core Part: Chris Ohk, Junwoo Hwang, Jihong Sin, Seungwoo Yoo
6// AI Part: Dongheon Cho, Minseo Kim
7// We are making my contributions/submissions to this project solely in our
8// personal capacity and are not conveying any rights to any intellectual
9// property of any third parties.
10
11#ifndef CUBBYFLOW_POINT_PARTICLE_EMITTER2_HPP
12#define CUBBYFLOW_POINT_PARTICLE_EMITTER2_HPP
13
15
16#include <random>
17
18namespace CubbyFlow
19{
27{
28 public:
29 class Builder;
30
47 const Vector2D& origin, const Vector2D& direction, double speed,
49 size_t maxNumOfParticles = std::numeric_limits<size_t>::max(),
50 uint32_t seed = 0);
51
54
57
60
63
66
67 private:
74 void OnUpdate(double currentTimeInSeconds,
75 double timeIntervalInSeconds) override;
76
79
80 [[nodiscard]] double Random();
81
82 std::mt19937 m_rng;
83
84 double m_firstFrameTimeInSeconds = 0.0;
85 size_t m_numberOfEmittedParticles = 0;
86
87 size_t m_maxNumberOfNewParticlesPerSecond;
88 size_t m_maxNumberOfParticles;
89
90 Vector2D m_origin;
91 Vector2D m_direction;
92 double m_speed;
93 double m_spreadAngleInRadians;
94};
95
97using PointParticleEmitter2Ptr = std::shared_ptr<PointParticleEmitter2>;
98
103{
104 public:
107
109 [[nodiscard]] Builder& WithDirection(const Vector2D& direction);
110
113
116 double spreadAngleInDegrees);
117
120
123 size_t maxNumberOfParticles);
124
127
130
133
134 private:
135 size_t m_maxNumberOfNewParticlesPerSecond = 1;
136 size_t m_maxNumberOfParticles = std::numeric_limits<size_t>::max();
137 Vector2D m_origin{ 0, 0 };
138 Vector2D m_direction{ 0, 1 };
139 double m_speed = 1.0;
140 double m_spreadAngleInDegrees = 90.0;
141 uint32_t m_seed = 0;
142};
143} // namespace CubbyFlow
144
145#endif
Definition Matrix.hpp:30
Abstract base class for 2-D particle emitter.
Definition ParticleEmitter2.hpp:22
Front-end to create PointParticleEmitter2 objects step by step.
Definition PointParticleEmitter2.hpp:103
Builder & WithDirection(const Vector2D &direction)
Returns builder with direction.
Builder & WithRandomSeed(uint32_t seed)
Returns builder with random seed.
Builder & WithMaxNumberOfNewParticlesPerSecond(size_t maxNumOfNewParticlesPerSec)
Builder & WithMaxNumberOfParticles(size_t maxNumberOfParticles)
Returns builder with max number of particles.
Builder & WithSpreadAngleInDegrees(double spreadAngleInDegrees)
Returns builder with spread angle in degrees.
Builder & WithOrigin(const Vector2D &origin)
Returns builder with origin.
Builder & WithSpeed(double speed)
Returns builder with speed.
PointParticleEmitter2Ptr MakeShared() const
Builds shared pointer of PointParticleEmitter2 instance.
PointParticleEmitter2 Build() const
Builds PointParticleEmitter2.
2-D point particle emitter.
Definition PointParticleEmitter2.hpp:27
static Builder GetBuilder()
Returns builder fox PointParticleEmitter2.
void SetMaxNumberOfNewParticlesPerSecond(size_t rate)
Sets max number of new particles per second.
size_t GetMaxNumberOfParticles() const
Returns max number of particles to be emitted.
PointParticleEmitter2(const Vector2D &origin, const Vector2D &direction, double speed, double spreadAngleInDegrees, size_t maxNumOfNewParticlesPerSec=1, size_t maxNumOfParticles=std::numeric_limits< size_t >::max(), uint32_t seed=0)
size_t GetMaxNumberOfNewParticlesPerSecond() const
Returns max number of new particles per second.
void SetMaxNumberOfParticles(size_t maxNumberOfParticles)
Sets max number of particles to be emitted.
Definition pybind11Utils.hpp:21
std::shared_ptr< PointParticleEmitter2 > PointParticleEmitter2Ptr
Shared pointer for the PointParticleEmitter2 type.
Definition PointParticleEmitter2.hpp:97
Matrix< T, Rows, 1 > Vector
Definition Matrix.hpp:738