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_PARTICLESYSTEM_NXPARTICLECREATIONDATA |
15 | #define PX_PARTICLESYSTEM_NXPARTICLECREATIONDATA |
16 | /** \addtogroup particles |
17 | @{ |
18 | */ |
19 | |
20 | #include "PxPhysXConfig.h" |
21 | #include "foundation/PxVec3.h" |
22 | #include "foundation/PxStrideIterator.h" |
23 | |
24 | #ifndef PX_DOXYGEN |
25 | namespace physx |
26 | { |
27 | #endif |
28 | |
29 | /** |
30 | \brief Descriptor-like user-side class describing buffers for particle creation. |
31 | |
32 | PxParticleCreationData is used to create particles within the SDK. The SDK copies the particle data referenced by PxParticleCreationData, it |
33 | may therefore be deallocated right after the creation call returned. |
34 | |
35 | @see PxParticleBase::createParticles() |
36 | */ |
37 | class PxParticleCreationData |
38 | { |
39 | public: |
40 | |
41 | /** |
42 | \brief The number of particles stored in the buffer. |
43 | */ |
44 | PxU32 numParticles; |
45 | |
46 | /** |
47 | \brief Particle index data. |
48 | |
49 | When creating particles, providing the particle indices is mandatory. |
50 | */ |
51 | PxStrideIterator<const PxU32> indexBuffer; |
52 | |
53 | /** |
54 | \brief Particle position data. |
55 | |
56 | When creating particles, providing the particle positions is mandatory. |
57 | */ |
58 | PxStrideIterator<const PxVec3> positionBuffer; |
59 | |
60 | /** |
61 | \brief Particle velocity data. |
62 | |
63 | Providing velocity data is optional. |
64 | */ |
65 | PxStrideIterator<const PxVec3> velocityBuffer; |
66 | |
67 | /** |
68 | \brief Particle rest offset data. |
69 | |
70 | Values need to be in the range [0.0f, restOffset]. |
71 | If PxParticleBaseFlag.ePER_PARTICLE_REST_OFFSET is set, providing per particle rest offset data is mandatory. |
72 | @see PxParticleBaseFlag.ePER_PARTICLE_REST_OFFSET. |
73 | */ |
74 | PxStrideIterator<const PxF32> restOffsetBuffer; |
75 | |
76 | /** |
77 | \brief Particle flags. |
78 | |
79 | PxParticleFlag.eVALID, PxParticleFlag.eCOLLISION_WITH_STATIC, PxParticleFlag.eCOLLISION_WITH_DYNAMIC, |
80 | PxParticleFlag.eCOLLISION_WITH_DRAIN, PxParticleFlag.eSPATIAL_DATA_STRUCTURE_OVERFLOW are all flags that |
81 | can't be set on particle creation. They are written by the SDK exclusively. |
82 | |
83 | Providing flag data is optional. |
84 | @see PxParticleFlag |
85 | */ |
86 | PxStrideIterator<const PxU32> flagBuffer; |
87 | |
88 | /** |
89 | \brief (Re)sets the structure to the default. |
90 | */ |
91 | PX_INLINE void setToDefault(); |
92 | |
93 | /** |
94 | \brief Returns true if the current settings are valid |
95 | */ |
96 | PX_INLINE bool isValid() const; |
97 | |
98 | /** |
99 | \brief Constructor sets to default. |
100 | */ |
101 | PX_INLINE PxParticleCreationData(); |
102 | }; |
103 | |
104 | PX_INLINE PxParticleCreationData::PxParticleCreationData() |
105 | { |
106 | indexBuffer = PxStrideIterator<const PxU32>(); |
107 | positionBuffer = PxStrideIterator<const PxVec3>(); |
108 | velocityBuffer = PxStrideIterator<const PxVec3>(); |
109 | restOffsetBuffer = PxStrideIterator<const PxF32>(); |
110 | flagBuffer = PxStrideIterator<const PxU32>(); |
111 | } |
112 | |
113 | PX_INLINE void PxParticleCreationData::setToDefault() |
114 | { |
115 | *this = PxParticleCreationData(); |
116 | } |
117 | |
118 | PX_INLINE bool PxParticleCreationData::isValid() const |
119 | { |
120 | if (numParticles > 0 && !(indexBuffer.ptr() && positionBuffer.ptr())) return false; |
121 | return true; |
122 | } |
123 | |
124 | #ifndef PX_DOXYGEN |
125 | } // namespace physx |
126 | #endif |
127 | |
128 | /** @} */ |
129 | #endif |
130 | |