1/*
2 * Copyright (c) 2008-2015, NVIDIA CORPORATION. All rights reserved.
3 *
4 * NVIDIA CORPORATION and its licensors retain all intellectual property
5 * and proprietary rights in and to this software, related documentation
6 * and any modifications thereto. Any use, reproduction, disclosure or
7 * distribution of this software and related documentation without an express
8 * license agreement from NVIDIA CORPORATION is strictly prohibited.
9 */
10// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
11// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
12
13
14#ifndef PX_PHYSICS_NX_PARTICLEFLUID
15#define PX_PHYSICS_NX_PARTICLEFLUID
16/** \addtogroup particles
17 @{
18*/
19#include "particles/PxParticleFluidReadData.h"
20#include "particles/PxParticleBase.h"
21
22#ifndef PX_DOXYGEN
23namespace physx
24{
25#endif
26
27/**
28\brief The particle fluid class represents the main module for particle based fluid simulation.
29SPH (Smoothed Particle Hydrodynamics) is used to animate the particles. This class inherits the properties
30of the PxParticleBase class and adds particle-particle interactions.
31
32There are two kinds of particle interaction forces which govern the behaviour of the fluid:
33<ol>
34<li>
35 Pressure forces: These forces result from particle densities higher than the
36 "rest density" of the fluid. The rest density is given by specifying the inter-particle
37 distance at which the fluid is in its relaxed state. Particles which are closer than
38 the rest spacing are pushed away from each other.
39<li>
40 Viscosity forces: These forces act on neighboring particles depending on the difference
41 of their velocities. Particles drag other particles with them which is used to simulate the
42 viscous behaviour of the fluid.
43</ol>
44
45For a good introduction to SPH fluid simulation,
46see http://www.matthiasmueller.info/publications/sca03.pdf
47
48@see PxParticleBase, PxParticleFluidReadData, PxPhysics.createParticleFluid
49*/
50class PxParticleFluid : public PxParticleBase
51{
52
53public:
54
55/************************************************************************************************/
56
57/** @name Particle Access and Manipulation
58*/
59//@{
60
61 /**
62 \brief Locks the particle data and provides the data descriptor for accessing the particles including fluid particle densities.
63 \note Only PxDataAccessFlag::eREADABLE and PxDataAccessFlag::eDEVICE are supported, PxDataAccessFlag::eWRITABLE will be ignored.
64 @see PxParticleFluidReadData
65 @see PxParticleBase::lockParticleReadData()
66 */
67 virtual PxParticleFluidReadData* lockParticleFluidReadData(PxDataAccessFlags flags) = 0;
68
69 /**
70 \brief Locks the particle data and provides the data descriptor for accessing the particles including fluid particle densities.
71 \note This is the same as calling lockParticleFluidReadData(PxDataAccessFlag::eREADABLE).
72 @see PxParticleFluidReadData
73 @see PxParticleBase::lockParticleReadData()
74 */
75 virtual PxParticleFluidReadData* lockParticleFluidReadData() = 0;
76
77//@}
78/************************************************************************************************/
79
80
81/** @name Particle Fluid Parameters
82*/
83//@{
84
85 /**
86 \brief Returns the fluid stiffness.
87
88 \return The fluid stiffness.
89 */
90 virtual PxReal getStiffness() const = 0;
91
92 /**
93 \brief Sets the fluid stiffness (must be positive).
94
95 \param stiffness The new fluid stiffness.
96 */
97 virtual void setStiffness(PxReal stiffness) = 0;
98
99 /**
100 \brief Returns the fluid viscosity.
101
102 \return The viscosity of the fluid.
103 */
104 virtual PxReal getViscosity() const = 0;
105
106 /**
107 \brief Sets the fluid viscosity (must be positive).
108
109 \param viscosity The new viscosity of the fluid.
110 */
111 virtual void setViscosity(PxReal viscosity) = 0;
112
113//@}
114/************************************************************************************************/
115
116/** @name Particle Fluid Property Read Back
117*/
118//@{
119
120 /**
121 \brief Returns the typical distance of particles in the relaxed state of the fluid.
122
123 \return Rest particle distance.
124 */
125 virtual PxReal getRestParticleDistance() const = 0;
126
127//@}
128/************************************************************************************************/
129
130/** @name Particle Fluid Parameters
131*/
132//@{
133
134 /**
135 \brief Sets the typical distance of particles in the relaxed state of the fluid.
136
137 \param restParticleDistance The new restParticleDistance of the fluid.
138 */
139 virtual void setRestParticleDistance(PxReal restParticleDistance) = 0;
140
141//@}
142/************************************************************************************************/
143
144 virtual const char* getConcreteTypeName() const { return "PxParticleFluid"; }
145
146protected:
147 PX_INLINE PxParticleFluid(PxType concreteType, PxBaseFlags baseFlags) : PxParticleBase(concreteType, baseFlags) {}
148 PX_INLINE PxParticleFluid(PxBaseFlags baseFlags) : PxParticleBase(baseFlags) {}
149 virtual ~PxParticleFluid() {}
150 virtual bool isKindOf(const char* name) const { return !strcmp("PxParticleFluid", name) || PxParticleBase::isKindOf(name); }
151};
152
153PX_DEPRECATED PX_INLINE PxParticleFluid* PxActor::isParticleFluid() { return is<PxParticleFluid>(); }
154PX_DEPRECATED PX_INLINE const PxParticleFluid* PxActor::isParticleFluid() const { return is<PxParticleFluid>(); }
155
156
157#ifndef PX_DOXYGEN
158} // namespace physx
159#endif
160
161/** @} */
162#endif
163