Loading...
Searching...
No Matches
CUDAParticleSystemSolverBase2.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_CUDA_PARTICLE_SYSTEM_SOLVER_BASE2_HPP
12#define CUBBYFLOW_CUDA_PARTICLE_SYSTEM_SOLVER_BASE2_HPP
13
14#ifdef CUBBYFLOW_USE_CUDA
15
20
21namespace CubbyFlow
22{
29class CUDAParticleSystemSolverBase2 : public PhysicsAnimation
30{
31 public:
34
37 delete;
38
41 delete;
42
45
49
53
55 float DragCoefficient() const;
56
64 void SetDragCoefficient(float newDragCoefficient);
65
74
83 void SetRestitutionCoefficient(float newRestitutionCoefficient);
84
87
89 void SetGravity(const Vector2F& newGravity);
90
97 virtual CUDAParticleSystemData2* ParticleSystemData();
98
105 virtual const CUDAParticleSystemData2* ParticleSystemData() const;
106
107 protected:
109 void OnInitialize() override;
110
111 void UpdateCollider(double timeStepInSeconds);
112
113 void UpdateEmitter(double timeStepInSeconds);
114
115 private:
116 float m_dragCoefficient = 1e-4f;
117 float m_restitutionCoefficient = 0.0f;
118 Vector2F m_gravity{ 0.0f, GRAVITY_FLOAT };
119 CUDAParticleSystemData2Ptr m_particleSystemData;
120};
121
124 std::shared_ptr<CUDAParticleSystemSolverBase2>;
125
129template <typename DerivedBuilder>
131{
132 public:
135
138
141
142 protected:
143 float m_dragCoefficient = 1e-4f;
144 float m_restitutionCoefficient = 0.0f;
145 Vector2F m_gravity{ 0.0f, GRAVITY_FLOAT };
146};
147
148template <typename T>
149T& CUDAParticleSystemSolverBuilderBase2<T>::WithDragCoefficient(float coeff)
150{
151 m_dragCoefficient = coeff;
152 return static_cast<T&>(*this);
153}
154
155template <typename T>
156T& CUDAParticleSystemSolverBuilderBase2<T>::WithRestitutionCoefficient(
157 float coeff)
158{
159 m_restitutionCoefficient = coeff;
160 return static_cast<T&>(*this);
161}
162
163template <typename T>
164T& CUDAParticleSystemSolverBuilderBase2<T>::WithGravity(const Vector2F& gravity)
165{
166 m_gravity = gravity;
167 return static_cast<T&>(*this);
168}
169} // namespace CubbyFlow
170
171#endif
172
173#endif
Definition pybind11Utils.hpp:21
Vector2< float > Vector2F
Definition Matrix.hpp:773
Matrix< T, Rows, 1 > Vector
Definition Matrix.hpp:738
constexpr float GRAVITY_FLOAT
Gravity.
Definition Constants.hpp:298