11 #ifndef CUBBYFLOW_CUDA_PARTICLE_SYSTEM_SOLVER_BASE2_HPP 12 #define CUBBYFLOW_CUDA_PARTICLE_SYSTEM_SOLVER_BASE2_HPP 14 #ifdef CUBBYFLOW_USE_CUDA 29 class CUDAParticleSystemSolverBase2 :
public PhysicsAnimation
33 CUDAParticleSystemSolverBase2();
36 CUDAParticleSystemSolverBase2(
const CUDAParticleSystemSolverBase2&) =
40 CUDAParticleSystemSolverBase2(CUDAParticleSystemSolverBase2&&) noexcept =
44 ~CUDAParticleSystemSolverBase2() override = default;
47 CUDAParticleSystemSolverBase2& operator=(
48 const CUDAParticleSystemSolverBase2&) = delete;
51 CUDAParticleSystemSolverBase2& operator=(
52 CUDAParticleSystemSolverBase2&&) noexcept = delete;
55 float DragCoefficient() const;
64 void SetDragCoefficient(
float newDragCoefficient);
73 float RestitutionCoefficient() const;
83 void SetRestitutionCoefficient(
float newRestitutionCoefficient);
89 void SetGravity(const
Vector2F& newGravity);
97 virtual CUDAParticleSystemData2* ParticleSystemData();
105 virtual const CUDAParticleSystemData2* ParticleSystemData() const;
109 void OnInitialize() override;
111 void UpdateCollider(
double timeStepInSeconds);
113 void UpdateEmitter(
double timeStepInSeconds);
116 float m_dragCoefficient = 1e-4f;
117 float m_restitutionCoefficient = 0.0f;
119 CUDAParticleSystemData2Ptr m_particleSystemData;
123 using CUDAParticleSystemSolverBase2Ptr =
124 std::shared_ptr<CUDAParticleSystemSolverBase2>;
129 template <
typename DerivedBuilder>
130 class CUDAParticleSystemSolverBuilderBase2
134 DerivedBuilder& WithDragCoefficient(
float coeff);
137 DerivedBuilder& WithRestitutionCoefficient(
float coeff);
140 DerivedBuilder& WithGravity(
const Vector2F& gravity);
143 float m_dragCoefficient = 1e-4f;
144 float m_restitutionCoefficient = 0.0f;
148 template <
typename T>
149 T& CUDAParticleSystemSolverBuilderBase2<T>::WithDragCoefficient(
float coeff)
151 m_dragCoefficient = coeff;
152 return static_cast<T&
>(*this);
155 template <
typename T>
156 T& CUDAParticleSystemSolverBuilderBase2<T>::WithRestitutionCoefficient(
159 m_restitutionCoefficient = coeff;
160 return static_cast<T&
>(*this);
163 template <
typename T>
164 T& CUDAParticleSystemSolverBuilderBase2<T>::WithGravity(
const Vector2F& gravity)
167 return static_cast<T&
>(*this);
Definition: pybind11Utils.hpp:20
Vector2< float > Vector2F
Definition: Matrix.hpp:773
constexpr float GRAVITY_FLOAT
Gravity.
Definition: Constants.hpp:298