ParticleEmitter3.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_PARTICLE_EMITTER3_HPP
12 #define CUBBYFLOW_PARTICLE_EMITTER3_HPP
13 
15 
16 namespace CubbyFlow
17 {
22 {
23  public:
30  using OnBeginUpdateCallback =
31  std::function<void(ParticleEmitter3*, double, double)>;
32 
34  ParticleEmitter3() = default;
35 
37  ParticleEmitter3(const ParticleEmitter3&) = default;
38 
40  ParticleEmitter3(ParticleEmitter3&&) noexcept = default;
41 
43  virtual ~ParticleEmitter3() = default;
44 
46  ParticleEmitter3& operator=(const ParticleEmitter3&) = default;
47 
49  ParticleEmitter3& operator=(ParticleEmitter3&&) noexcept = default;
50 
53  void Update(double currentTimeInSeconds, double timeIntervalInSeconds);
54 
56  [[nodiscard]] const ParticleSystemData3Ptr& GetTarget() const;
57 
59  void SetTarget(const ParticleSystemData3Ptr& particles);
60 
62  [[nodiscard]] bool GetIsEnabled() const;
63 
65  void SetIsEnabled(bool enabled);
66 
77  void SetOnBeginUpdateCallback(const OnBeginUpdateCallback& callback);
78 
79  protected:
81  virtual void OnSetTarget(const ParticleSystemData3Ptr& particles);
82 
84  virtual void OnUpdate(double currentTimeInSeconds,
85  double timeIntervalInSeconds) = 0;
86 
87  private:
88  ParticleSystemData3Ptr m_particles;
89  OnBeginUpdateCallback m_onBeginUpdateCallback;
90  bool m_isEnabled = true;
91 };
92 
94 using ParticleEmitter3Ptr = std::shared_ptr<ParticleEmitter3>;
95 } // namespace CubbyFlow
96 
97 #endif
std::function< void(ParticleEmitter3 *, double, double)> OnBeginUpdateCallback
Callback function type for update calls.
Definition: ParticleEmitter3.hpp:31
void SetIsEnabled(bool enabled)
Sets true/false to enable/disable the emitter.
Abstract base class for 3-D particle emitter.
Definition: ParticleEmitter3.hpp:21
std::shared_ptr< ParticleEmitter3 > ParticleEmitter3Ptr
Shared pointer for the ParticleEmitter3 type.
Definition: ParticleEmitter3.hpp:94
virtual void OnUpdate(double currentTimeInSeconds, double timeIntervalInSeconds)=0
Called when ParticleEmitter3::Update is executed.
std::shared_ptr< ParticleSystemData3 > ParticleSystemData3Ptr
Shared pointer type of ParticleSystemData3.
Definition: ParticleSystemData.hpp:284
const ParticleSystemData3Ptr & GetTarget() const
Returns the target particle system to emit.
void Update(double currentTimeInSeconds, double timeIntervalInSeconds)
void SetOnBeginUpdateCallback(const OnBeginUpdateCallback &callback)
Sets the callback function to be called when ParticleEmitter3::Update function is invoked...
bool GetIsEnabled() const
Returns true if the emitter is enabled.
Definition: pybind11Utils.hpp:20
ParticleEmitter3()=default
Default constructor.
void SetTarget(const ParticleSystemData3Ptr &particles)
Sets the target particle system to emit.
virtual void OnSetTarget(const ParticleSystemData3Ptr &particles)
Called when ParticleEmitter3::SetTarget is executed.