Loading...
Searching...
No Matches
VolumeGridEmitter3.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_EMITTER3_HPP
12#define CUBBYFLOW_VOLUME_GRID_EMITTER3_HPP
13
19
20#include <memory>
21
22namespace CubbyFlow
23{
28{
29 public:
30 class Builder;
31
33 using ScalarMapper = std::function<double(double, const Vector3D&, double)>;
34
37 std::function<Vector3D(double, const Vector3D&, const Vector3D&)>;
38
47 bool isOneShot = true);
48
51
54
57
60
63
66
75 double minValue, double maxValue);
76
93
110
113
116
119
120 private:
121 using ScalarTarget = std::tuple<ScalarGrid3Ptr, ScalarMapper>;
122 using VectorTarget = std::tuple<VectorGrid3Ptr, VectorMapper>;
123
124 void OnUpdate(double currentTimeInSeconds,
125 double timeIntervalInSeconds) override;
126
127 void Emit();
128
129 ImplicitSurface3Ptr m_sourceRegion;
130 std::vector<ScalarTarget> m_customScalarTargets;
131 std::vector<VectorTarget> m_customVectorTargets;
132 bool m_isOneShot = true;
133 bool m_hasEmitted = false;
134};
135
138
143{
144 public:
147
150
153
156
157 private:
158 ImplicitSurface3Ptr m_sourceRegion;
159 bool m_isOneShot = true;
160};
161} // namespace CubbyFlow
162
163#endif
Abstract base class for 3-D grid-based emitters.
Definition GridEmitter3.hpp:23
Definition Matrix.hpp:30
Front-end to create VolumeGridEmitter3 objects step by step.
Definition VolumeGridEmitter3.hpp:143
Builder & WithSourceRegion(const Surface3Ptr &sourceRegion)
Returns builder with surface defining source region.
VolumeGridEmitter3Ptr MakeShared() const
Builds shared pointer of VolumeGridEmitter3 instance.
Builder & WithIsOneShot(bool isOneShot)
Returns builder with one-shot flag.
VolumeGridEmitter3 Build() const
Builds VolumeGridEmitter3.
3-D grid-based volumetric emitter.
Definition VolumeGridEmitter3.hpp:28
const ImplicitSurface3Ptr & GetSourceRegion() const
Returns implicit surface which defines the source region.
VolumeGridEmitter3(const VolumeGridEmitter3 &)=default
Default copy constructor.
void AddSignedDistanceTarget(const ScalarGrid3Ptr &scalarGridTarget)
Adds signed-distance target to the scalar grid.
void AddStepFunctionTarget(const ScalarGrid3Ptr &scalarGridTarget, double minValue, double maxValue)
Adds step function target to the scalar grid.
std::function< Vector3D(double, const Vector3D &, const Vector3D &)> VectorMapper
Maps to a vector value for given signed-dist, location, and old value.
Definition VolumeGridEmitter3.hpp:37
static Builder GetBuilder()
Returns builder fox VolumeGridEmitter3.
bool GetIsOneShot() const
Returns true if this emits only once.
VolumeGridEmitter3(VolumeGridEmitter3 &&) noexcept=default
Default move constructor.
VolumeGridEmitter3(ImplicitSurface3Ptr sourceRegion, bool isOneShot=true)
Constructs an emitter with a source and is-one-shot flag.
std::function< double(double, const Vector3D &, double)> ScalarMapper
Maps to a scalar value for given signed-dist, location, and old value.
Definition VolumeGridEmitter3.hpp:33
void AddTarget(const ScalarGrid3Ptr &scalarGridTarget, const ScalarMapper &customMapper)
Adds a scalar grid target.
Definition pybind11Utils.hpp:21
std::shared_ptr< VectorGrid3 > VectorGrid3Ptr
Shared pointer for the VectorGrid3 type.
Definition VectorGrid.hpp:113
std::shared_ptr< ImplicitSurface3 > ImplicitSurface3Ptr
Shared pointer type for the ImplicitSurface3.
Definition ImplicitSurface.hpp:70
std::shared_ptr< Surface3 > Surface3Ptr
Shared pointer for the Surface3 type.
Definition Surface.hpp:147
std::shared_ptr< VolumeGridEmitter3 > VolumeGridEmitter3Ptr
Shared pointer type for the VolumeGridEmitter3.
Definition VolumeGridEmitter3.hpp:137
Vector3< double > Vector3D
Definition Matrix.hpp:787
std::shared_ptr< ScalarGrid3 > ScalarGrid3Ptr
Shared pointer for the ScalarGrid3 type.
Definition ScalarGrid.hpp:269
Matrix< T, Rows, 1 > Vector
Definition Matrix.hpp:738