RavEngine
Loading...
Searching...
No Matches
PxHairSystemDesc.h
1// Redistribution and use in source and binary forms, with or without
2// modification, are permitted provided that the following conditions
3// are met:
4// * Redistributions of source code must retain the above copyright
5// notice, this list of conditions and the following disclaimer.
6// * Redistributions in binary form must reproduce the above copyright
7// notice, this list of conditions and the following disclaimer in the
8// documentation and/or other materials provided with the distribution.
9// * Neither the name of NVIDIA CORPORATION nor the names of its
10// contributors may be used to endorse or promote products derived
11// from this software without specific prior written permission.
12//
13// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
14// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
17// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24//
25// Copyright (c) 2008-2022 NVIDIA Corporation. All rights reserved.
26
27
28#ifndef PX_HAIRSYSTEM_DESC_H
29#define PX_HAIRSYSTEM_DESC_H
34#include "foundation/PxFlags.h"
35#include "common/PxCoreUtilityTypes.h"
36
37#if PX_ENABLE_FEATURES_UNDER_CONSTRUCTION
38
39#if !PX_DOXYGEN
40namespace physx
41{
42#endif
43
44 struct PxHairSystemDescFlag
45 {
46 enum Enum
47 {
51 eDEVICE_MEMORY = (1<<0)
52 };
53 };
54
59 typedef PxFlags<PxHairSystemDescFlag::Enum, PxU16> PxHairSystemDescFlags;
60 PX_FLAGS_OPERATORS(PxHairSystemDescFlag::Enum, PxU16)
61
62
70 class PxHairSystemDesc
71 {
72 public:
78 PxU32 numStrands;
79
85 PxReal segmentLength;
86
92 PxReal segmentRadius;
93
101 PxBoundedData numVerticesPerStrand;
102
112 PxBoundedData vertices;
113
121 PxBoundedData velocities;
122
128 PxHairSystemDescFlags flags;
129
133 PX_INLINE PxHairSystemDesc();
134
138 PX_INLINE void setToDefault();
139
144 PX_INLINE bool isValid() const;
145 };
146
147 PX_INLINE PxHairSystemDesc::PxHairSystemDesc()
148 {
149 numStrands = 0;
150 segmentLength = 0.1f;
151 segmentRadius = 0.01f;
152 }
153
154 PX_INLINE void PxHairSystemDesc::setToDefault()
155 {
156 *this = PxHairSystemDesc();
157 }
158
159 PX_INLINE bool PxHairSystemDesc::isValid() const
160 {
161 if (segmentLength < 0.0f || segmentRadius < 0.0f)
162 return false;
163
164 if (2.0f * segmentRadius >= segmentLength)
165 return false;
166
167 if (numStrands == 0)
168 return false;
169
170 if (numVerticesPerStrand.count != numStrands)
171 return false;
172
173 PxU32 totalNumVertices = 0;
174 for (PxU32 i = 0; i < numVerticesPerStrand.count; i++)
175 {
176 const PxU32 numVertices = numVerticesPerStrand.at<PxU32>(i);
177 totalNumVertices += numVertices;
178 if (numVertices < 2)
179 {
180 return false;
181 }
182 }
183
184 if (vertices.count != totalNumVertices && vertices.count != numStrands)
185 return false;
186
187 if (velocities.count != totalNumVertices && velocities.count != 0)
188 return false;
189
190 return true;
191 }
192
193#if !PX_DOXYGEN
194} // namespace physx
195#endif
196
197#endif
198
200#endif
#define PX_INLINE
Definition PxPreprocessor.h:320
Sorts an array of objects in ascending order, assuming that the predicate implements the < operator:
Definition PxBoxController.h:39