Loading...
Searching...
No Matches
PointParticleEmitter3.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_EMITTER3_HPP
12#define CUBBYFLOW_POINT_PARTICLE_EMITTER3_HPP
13
15
16#include <random>
17
18namespace CubbyFlow
19{
27{
28 public:
29 class Builder;
30
47 const Vector3D& origin, const Vector3D& 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 = 1;
88 size_t m_maxNumberOfParticles = std::numeric_limits<size_t>::max();
89
90 Vector3D m_origin;
91 Vector3D m_direction;
92 double m_speed;
93 double m_spreadAngleInRadians;
94};
95
97using PointParticleEmitter3Ptr = std::shared_ptr<PointParticleEmitter3>;
98
103{
104 public:
107
109 [[nodiscard]] Builder& WithDirection(const Vector3D& 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 Vector3D m_origin{ 0, 0, 0 };
138 Vector3D m_direction{ 0, 1, 0 };
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 3-D particle emitter.
Definition ParticleEmitter3.hpp:22
Front-end to create PointParticleEmitter3 objects step by step.
Definition PointParticleEmitter3.hpp:103
Builder & WithDirection(const Vector3D &direction)
Returns builder with direction.
Builder & WithSpreadAngleInDegrees(double spreadAngleInDegrees)
Returns builder with spread angle in degrees.
Builder & WithOrigin(const Vector3D &origin)
Returns builder with origin.
Builder & WithSpeed(double speed)
Returns builder with speed.
Builder & WithRandomSeed(uint32_t seed)
Returns builder with random seed.
PointParticleEmitter3Ptr MakeShared() const
Builds shared pointer of PointParticleEmitter3 instance.
PointParticleEmitter3 Build() const
Builds PointParticleEmitter3.
Builder & WithMaxNumberOfParticles(size_t maxNumberOfParticles)
Returns builder with max number of particles.
Builder & WithMaxNumberOfNewParticlesPerSecond(size_t maxNumOfNewParticlesPerSec)
3-D point particle emitter.
Definition PointParticleEmitter3.hpp:27
PointParticleEmitter3(const Vector3D &origin, const Vector3D &direction, double speed, double spreadAngleInDegrees, size_t maxNumOfNewParticlesPerSec=1, size_t maxNumOfParticles=std::numeric_limits< size_t >::max(), uint32_t seed=0)
void SetMaxNumberOfNewParticlesPerSecond(size_t rate)
Sets max number of new particles per second.
static Builder GetBuilder()
Returns builder fox PointParticleEmitter3.
size_t GetMaxNumberOfNewParticlesPerSecond() const
Returns max number of new particles per second.
size_t GetMaxNumberOfParticles() const
Returns max number of particles to be emitted.
void SetMaxNumberOfParticles(size_t maxNumberOfParticles)
Sets max number of particles to be emitted.
Definition pybind11Utils.hpp:21
std::shared_ptr< PointParticleEmitter3 > PointParticleEmitter3Ptr
Shared pointer for the PointParticleEmitter3 type.
Definition PointParticleEmitter3.hpp:97
Matrix< T, Rows, 1 > Vector
Definition Matrix.hpp:738