GridEmitter2.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_GRID_EMITTER2_HPP
12 #define CUBBYFLOW_GRID_EMITTER2_HPP
13 
14 #include <functional>
15 #include <memory>
16 
17 namespace CubbyFlow
18 {
23 {
24  public:
31  using OnBeginUpdateCallback =
32  std::function<void(GridEmitter2*, double, double)>;
33 
35  GridEmitter2() = default;
36 
38  GridEmitter2(const GridEmitter2&) = default;
39 
41  GridEmitter2(GridEmitter2&&) noexcept = default;
42 
44  virtual ~GridEmitter2() = default;
45 
47  GridEmitter2& operator=(const GridEmitter2&) = default;
48 
50  GridEmitter2& operator=(GridEmitter2&&) noexcept = default;
51 
54  void Update(double currentTimeInSeconds, double timeIntervalInSeconds);
55 
57  [[nodiscard]] bool GetIsEnabled() const;
58 
60  void SetIsEnabled(bool enabled);
61 
72  void SetOnBeginUpdateCallback(const OnBeginUpdateCallback& callback);
73 
74  protected:
75  virtual void OnUpdate(double currentTimeInSeconds,
76  double timeIntervalInSeconds) = 0;
77 
78  void CallOnBeginUpdateCallback(double currentTimeInSeconds,
79  double timeIntervalInSeconds);
80 
81  private:
82  OnBeginUpdateCallback m_onBeginUpdateCallback;
83  bool m_isEnabled = true;
84 };
85 
87 using GridEmitter2Ptr = std::shared_ptr<GridEmitter2>;
88 } // namespace CubbyFlow
89 
90 #endif
std::function< void(GridEmitter2 *, double, double)> OnBeginUpdateCallback
Callback function type for update calls.
Definition: GridEmitter2.hpp:32
void Update(double currentTimeInSeconds, double timeIntervalInSeconds)
void SetOnBeginUpdateCallback(const OnBeginUpdateCallback &callback)
Sets the callback function to be called when GridEmitter2::Update function is invoked.
Abstract base class for 2-D grid-based emitters.
Definition: GridEmitter2.hpp:22
bool GetIsEnabled() const
Returns true if the emitter is enabled.
std::shared_ptr< GridEmitter2 > GridEmitter2Ptr
Shared pointer type for the GridEmitter2.
Definition: GridEmitter2.hpp:87
Definition: pybind11Utils.hpp:20
virtual void OnUpdate(double currentTimeInSeconds, double timeIntervalInSeconds)=0
void CallOnBeginUpdateCallback(double currentTimeInSeconds, double timeIntervalInSeconds)
GridEmitter2()=default
Default constructor.
void SetIsEnabled(bool enabled)
Sets true/false to enable/disable the emitter.