GridEmitter3.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_EMITTER3_HPP
12 #define CUBBYFLOW_GRID_EMITTER3_HPP
13 
14 #include <functional>
15 #include <memory>
16 
17 namespace CubbyFlow
18 {
23 {
24  public:
31  using OnBeginUpdateCallback =
32  std::function<void(GridEmitter3*, double, double)>;
33 
35  GridEmitter3() = default;
36 
38  GridEmitter3(const GridEmitter3&) = default;
39 
41  GridEmitter3(GridEmitter3&&) noexcept = default;
42 
44  virtual ~GridEmitter3() = default;
45 
47  GridEmitter3& operator=(const GridEmitter3&) = default;
48 
50  GridEmitter3& operator=(GridEmitter3&&) 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 GridEmitter3Ptr = std::shared_ptr<GridEmitter3>;
88 } // namespace CubbyFlow
89 
90 #endif
std::shared_ptr< GridEmitter3 > GridEmitter3Ptr
Shared pointer type for the GridEmitter3.
Definition: GridEmitter3.hpp:87
void SetIsEnabled(bool enabled)
Sets true/false to enable/disable the emitter.
std::function< void(GridEmitter3 *, double, double)> OnBeginUpdateCallback
Callback function type for update calls.
Definition: GridEmitter3.hpp:32
void SetOnBeginUpdateCallback(const OnBeginUpdateCallback &callback)
Sets the callback function to be called when GridEmitter3::Update function is invoked.
Definition: pybind11Utils.hpp:20
bool GetIsEnabled() const
Returns true if the emitter is enabled.
void Update(double currentTimeInSeconds, double timeIntervalInSeconds)
GridEmitter3()=default
Default constructor.
Abstract base class for 3-D grid-based emitters.
Definition: GridEmitter3.hpp:22
virtual void OnUpdate(double currentTimeInSeconds, double timeIntervalInSeconds)=0
void CallOnBeginUpdateCallback(double currentTimeInSeconds, double timeIntervalInSeconds)