Loading...
Searching...
No Matches
VolumeGridEmitter2.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_VOLUME_GRID_EMITTER2_HPP
12#define CUBBYFLOW_VOLUME_GRID_EMITTER2_HPP
13
19
20#include <memory>
21#include <utility>
22
23namespace CubbyFlow
24{
29{
30 public:
31 class Builder;
32
34 using ScalarMapper = std::function<double(double, const Vector2D&, double)>;
35
38 std::function<Vector2D(double, const Vector2D&, const Vector2D&)>;
39
48 bool isOneShot = true);
49
52
55
58
61
64
67
76 double minValue, double maxValue);
77
94
111
114
117
120
121 private:
122 using ScalarTarget = std::pair<ScalarGrid2Ptr, ScalarMapper>;
123 using VectorTarget = std::pair<VectorGrid2Ptr, VectorMapper>;
124
125 void OnUpdate(double currentTimeInSeconds,
126 double timeIntervalInSeconds) override;
127
128 void Emit();
129
130 ImplicitSurface2Ptr m_sourceRegion;
131 std::vector<ScalarTarget> m_customScalarTargets;
132 std::vector<VectorTarget> m_customVectorTargets;
133 bool m_isOneShot = true;
134 bool m_hasEmitted = false;
135};
136
139
144{
145 public:
148
151
154
157
158 private:
159 ImplicitSurface2Ptr m_sourceRegion;
160 bool m_isOneShot = true;
161};
162} // namespace CubbyFlow
163
164#endif
Abstract base class for 2-D grid-based emitters.
Definition GridEmitter2.hpp:23
Definition Matrix.hpp:30
Front-end to create VolumeGridEmitter2 objects step by step.
Definition VolumeGridEmitter2.hpp:144
Builder & WithIsOneShot(bool isOneShot)
Returns builder with one-shot flag.
VolumeGridEmitter2 Build() const
Builds VolumeGridEmitter2.
VolumeGridEmitter2Ptr MakeShared() const
Builds shared pointer of VolumeGridEmitter2 instance.
Builder & WithSourceRegion(const Surface2Ptr &sourceRegion)
Returns builder with surface defining source region.
2-D grid-based volumetric emitter.
Definition VolumeGridEmitter2.hpp:29
void AddSignedDistanceTarget(const ScalarGrid2Ptr &scalarGridTarget)
Adds signed-distance target to the scalar grid.
std::function< double(double, const Vector2D &, double)> ScalarMapper
Maps to a scalar value for given signed-dist, location, and old value.
Definition VolumeGridEmitter2.hpp:34
VolumeGridEmitter2(VolumeGridEmitter2 &&) noexcept=default
Default move constructor.
void AddStepFunctionTarget(const ScalarGrid2Ptr &scalarGridTarget, double minValue, double maxValue)
Adds step function target to the scalar grid.
void AddTarget(const ScalarGrid2Ptr &scalarGridTarget, const ScalarMapper &customMapper)
Adds a scalar grid target.
VolumeGridEmitter2(const VolumeGridEmitter2 &)=default
Default copy constructor.
static Builder GetBuilder()
Returns builder fox VolumeGridEmitter2.
std::function< Vector2D(double, const Vector2D &, const Vector2D &)> VectorMapper
Maps to a vector value for given signed-dist, location, and old value.
Definition VolumeGridEmitter2.hpp:38
const ImplicitSurface2Ptr & GetSourceRegion() const
Returns implicit surface which defines the source region.
VolumeGridEmitter2(ImplicitSurface2Ptr sourceRegion, bool isOneShot=true)
Constructs an emitter with a source and is-one-shot flag.
bool GetIsOneShot() const
Returns true if this emits only once.
Definition pybind11Utils.hpp:22
Vector2< double > Vector2D
Definition Matrix.hpp:755
std::shared_ptr< VolumeGridEmitter2 > VolumeGridEmitter2Ptr
Shared pointer type for the VolumeGridEmitter2.
Definition VolumeGridEmitter2.hpp:138
std::shared_ptr< Surface2 > Surface2Ptr
Shared pointer for the Surface2 type.
Definition Surface.hpp:144
Matrix< T, Rows, 1 > Vector
Definition Matrix.hpp:719
std::shared_ptr< VectorGrid2 > VectorGrid2Ptr
Shared pointer for the VectorGrid2 type.
Definition VectorGrid.hpp:110
std::shared_ptr< ScalarGrid2 > ScalarGrid2Ptr
Shared pointer for the ScalarGrid2 type.
Definition ScalarGrid.hpp:266
std::shared_ptr< ImplicitSurface2 > ImplicitSurface2Ptr
Shared pointer type for the ImplicitSurface2.
Definition ImplicitSurface.hpp:67