Subversion Repository Public Repository

Divide-Dependencies

This repository has no backups
This repository's network speed is throttled to 100KB/sec

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
//  * Redistributions of source code must retain the above copyright
//    notice, this list of conditions and the following disclaimer.
//  * Redistributions in binary form must reproduce the above copyright
//    notice, this list of conditions and the following disclaimer in the
//    documentation and/or other materials provided with the distribution.
//  * Neither the name of NVIDIA CORPORATION nor the names of its
//    contributors may be used to endorse or promote products derived
//    from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2018 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.  


#ifndef PX_PHYSICS_NX_CLOTH_FABRIC
#define PX_PHYSICS_NX_CLOTH_FABRIC
/** \addtogroup cloth
  @{
*/


#include "common/PxBase.h"

#if !PX_DOXYGEN
namespace physx
{
#endif

/**
\brief Describe type of phase in cloth fabric.
\see PxClothFabric for an explanation of concepts on phase and set.
\deprecated The PhysX cloth feature has been deprecated in PhysX version 3.4.1
*/
struct PX_DEPRECATED PxClothFabricPhaseType
{
	enum Enum
	{
		eINVALID,     //!< invalid type 
		eVERTICAL,    //!< resists stretching or compression, usually along the gravity
		eHORIZONTAL,  //!< resists stretching or compression, perpendicular to the gravity
		eBENDING,     //!< resists out-of-plane bending in angle-based formulation
		eSHEARING,    //!< resists in-plane shearing along (typically) diagonal edges,
        eCOUNT        // internal use only
	};
};

/**
\brief References a set of constraints that can be solved in parallel.
\see PxClothFabric for an explanation of the concepts on phase and set.
\deprecated The PhysX cloth feature has been deprecated in PhysX version 3.4.1
*/
struct PX_DEPRECATED PxClothFabricPhase
{
	PxClothFabricPhase(PxClothFabricPhaseType::Enum type = 
		PxClothFabricPhaseType::eINVALID, PxU32 index = 0);

	/**
	\brief Type of constraints to solve.
	*/
	PxClothFabricPhaseType::Enum phaseType;

	/**
	\brief Index of the set that contains the particle indices.
	*/
	PxU32 setIndex;
};

PX_INLINE PxClothFabricPhase::PxClothFabricPhase(
	PxClothFabricPhaseType::Enum type, PxU32 index)
	: phaseType(type)
	, setIndex(index)
{}

/**
\brief References all the data required to create a fabric.
\see PxPhysics.createClothFabric(), PxClothFabricCooker.getDescriptor()
\deprecated The PhysX cloth feature has been deprecated in PhysX version 3.4.1
*/
class PX_DEPRECATED PxClothFabricDesc
{
public:
	/** \brief The number of particles needed when creating a PxCloth instance from the fabric. */
	PxU32 nbParticles;

	/** \brief The number of solver phases. */
	PxU32 nbPhases;
	/** \brief Array defining which constraints to solve each phase. See #PxClothFabric.getPhases(). */
	const PxClothFabricPhase* phases;

	/** \brief The number of sets in the fabric. */
	PxU32 nbSets;
	/** \brief Array with an index per set which points one entry beyond the last constraint of the set. See #PxClothFabric.getSets(). */
	const PxU32* sets;

	/** \brief Array of particle indices which specifies the pair of constrained vertices. See #PxClothFabric.getParticleIndices(). */
	const PxU32* indices;
	/** \brief Array of rest values for each constraint. See #PxClothFabric.getRestvalues(). */
	const PxReal* restvalues;

	/** \brief Size of tetherAnchors and tetherLengths arrays, needs to be multiple of nbParticles. */
	PxU32 nbTethers;
	/** \brief Array of particle indices specifying the tether anchors. See #PxClothFabric.getTetherAnchors(). */
	const PxU32* tetherAnchors;
	/** \brief Array of rest distance between tethered particle pairs. See #PxClothFabric.getTetherLengths(). */
	const PxReal* tetherLengths;

	/** \brief Array of triangle indices used to calculate air friction. */
	const PxU32* triangles;
	/** \brief The number of triangles in the triangles array. (1 triangle means 3 indices in the array) */
	PxU32 nbTriangles;

	/**
	\brief constructor sets to default.
	*/
	PX_INLINE PxClothFabricDesc();

	/**
	\brief (re)sets the structure to the default.	
	*/
	PX_INLINE void setToDefault();

	/**
	\brief Returns true if the descriptor is valid.
	\return True if the current settings are valid
	*/
	PX_INLINE bool isValid() const;
};

PX_INLINE PxClothFabricDesc::PxClothFabricDesc()
{
	setToDefault();
}

PX_INLINE void PxClothFabricDesc::setToDefault()
{
	memset(this, 0, sizeof(PxClothFabricDesc));
}

PX_INLINE bool PxClothFabricDesc::isValid() const
{
	return nbParticles && nbPhases && phases && restvalues && nbSets 
		&& sets && indices && (!nbTethers || (tetherAnchors && tetherLengths))
		&& (!nbTriangles || triangles);
}


/**
\brief A cloth fabric is a structure that contains all the internal solver constraints of a cloth mesh.
\details A fabric consists of \c phases that represent a group of internal constraints of the same type.
Each phase references an array of \c rest-values and a \c set of particle indices.
The data representation for the fabric has layers of indirect indices:
\arg All particle indices for the constraints of the fabric are stored in one linear array and referenced by the sets.
\arg Each constraint (particle index pair) has one entry in the restvalues array.
\arg The set array holds the prefix sum of the number of constraints per set and is referenced by the phases.
\arg A phase consists of the type of constraints, the index of the set referencing the indices.

Additionally, a fabric also stores the data for the tether constraints, which limit the distances 
between two particles. The tether constraints are stored in an array, and the index of a constraint
determines which particle is affected: element i affects particle i%N, where N is the number of particles.
The tether anchor is the index of the other particle, and the tether length is the maximum distance that
these two particles are allowed to be away from each other. A tether constraint is momentum conserving 
if the anchor particle has infinite mass (zero inverse weight).

\deprecated The PhysX cloth feature has been deprecated in PhysX version 3.4.1

@see The fabric structure can be created from a mesh using PxClothFabricCreate. Alternatively, the fabric data can 
be saved into a stream (see PxClothFabricCooker.save()) and later created from the stream using PxPhysics.createClothFabric(PxInputStream&).
*/
class PX_DEPRECATED PxClothFabric	: public PxBase
{
public:
	/**
	\brief Decrements the cloth fabric's reference count, and releases it if the new reference count is zero.
	
	\see PxPhysics.createClothFabric()
	*/
	virtual void release() = 0;

	/**
    \brief Returns number of particles.
    \return The number of particles needed when creating a PxCloth instance from the fabric.
    */ 
	virtual	PxU32 getNbParticles() const = 0;

	/**
    \brief Returns number of phases.
    \return The number of solver phases. 
    */ 
	virtual PxU32 getNbPhases() const = 0;

	/**
    \brief Returns number of rest values.
    \return The size of the rest values array.
    */ 
	virtual PxU32 getNbRestvalues() const = 0;

    /**
    \brief Returns number of sets.
    \return The size of the set array.
    */ 
	virtual	PxU32 getNbSets() const = 0;

    /**
    \brief Get number of particle indices.
	\return The size of the particle indices array.
    */
	virtual	PxU32 getNbParticleIndices() const = 0;

    /**
    \brief Get number of tether constraints.
	\return The size of the tether anchors and lengths arrays.
    */
	virtual PxU32 getNbTethers() const = 0;

    /**
    \brief Copies the phase array to a user specified buffer.
	\details The phase array is a mapping of the phase index to the corresponding phase.
	The array has the same length as getNbPhases().
    \param [in] userPhaseBuffer Destination buffer to copy the phase data to.
    \param [in] bufferSize Size of userPhaseBuffer, should be at least getNbPhases().
    \return getNbPhases() if the copy was successful, 0 otherwise.
	\note This function is potentially slow. Consider caching 
	the (static) result instead of retrieving it multiple times.
    */    
    virtual PxU32 getPhases(PxClothFabricPhase* userPhaseBuffer, PxU32 bufferSize) const = 0;

    /**
	\brief Copies the set array to a user specified buffer.
	\details The set array is the inclusive prefix sum of the number of constraints per set.
	It has the same length as getNbSets().
	\param [in] userSetBuffer Destination buffer to copy the set data to.
	\param [in] bufferSize Size of userSetBuffer, should be at least getNbSets().
	\return getNbSets() if the copy was successful, 0 otherwise.
	\note Indices of the i-th set are stored at indices [i?2*set[i-1]:0, 2*set[i]) in the indices array.
	\note This function is potentially slow. Consider caching 
	the (static) result instead of retrieving it multiple times.
    */    
    virtual PxU32 getSets(PxU32* userSetBuffer, PxU32 bufferSize) const = 0;

    /**
	\brief Copies the particle indices array to a user specified buffer.
	\details The particle indices array determines which particles are affected by each constraint.
	It has the same length as getNbParticleIndices() and twice the number of constraints.
	\param [in] userParticleIndexBuffer Destination buffer to copy the set data to.
	\param [in] bufferSize Size of userParticleIndexBuffer, should be at least getNbParticleIndices().
	\return getNbParticleIndices() if the copy was successful, 0 otherwise.
	\note This function is potentially slow. Consider caching 
	the (static) result instead of retrieving it multiple times.
    */
    virtual PxU32 getParticleIndices(PxU32* userParticleIndexBuffer, PxU32 bufferSize) const = 0;

    /**
	\brief Copies the rest values array to a user specified buffer.
	\details The rest values array holds the target value of the constraint in rest state, 
	for example edge length for stretch constraints.
	It stores one value per constraint, so its length is half of getNbParticleIndices(), and 
	it has the same length as getNbRestvalues(). The rest-values are stored in the order
	they are (indirectly) referenced by the phases. 
	\param [in] userRestvalueBuffer Destination buffer to copy the set data to.
	\param [in] bufferSize Size of userRestvalueBuffer, should be at least getNbRestvalues().
	\return getNbRestvalues() if the copy was successful, 0 otherwise.
	\note This function is potentially slow. Between calling scaleRestlengths(), 
	consider caching the result instead of retrieving it multiple times.
    */
	virtual PxU32 getRestvalues(PxReal* userRestvalueBuffer, PxU32 bufferSize) const = 0;

    /**
	\brief Copies the tether anchors array to a user specified buffer.
	\details The tether anchors array stores for each particle the index of 
	another particle from which it cannot move further away than specified by the 
	tether lengths array. 
	\param [in] userAnchorBuffer Destination buffer to copy the set data to.
	\param [in] bufferSize Size of userAnchorBuffer, should be at least getNbTethers().
	\return getNbTethers() if the copy was successful, 0 otherwise.
	\note This function is potentially slow, consider caching the 
	result instead of retrieving the data multiple times.
	\see getTetherLengths, getNbTethers
    */
	virtual PxU32 getTetherAnchors(PxU32* userAnchorBuffer, PxU32 bufferSize) const = 0;

    /**
	\brief Copies the tether lengths array to a user specified buffer.
	\details The tether lengths array stores for each particle how far it is 
	allowed to move away from the particle specified by the tether anchor array. 
	\param [in] userLengthBuffer Destination buffer to copy the set data to.
	\param [in] bufferSize Size of userLengthBuffer, should be at least getNbTethers().
	\return getNbTethers() if the copy was successful, 0 otherwise.
	\note This function is potentially slow. Between calling scaleRestlengths(), 
	consider caching the result instead of retrieving it multiple times.
	\see getTetherAnchors, getNbTethers
    */
	virtual PxU32 getTetherLengths(PxReal* userLengthBuffer, PxU32 bufferSize) const = 0;


    /**
    \brief Scale all rest values of length dependent constraints.
    \param[in] scale The scale factor to multiply each rest value with.
    */
	virtual	void scaleRestlengths(PxReal scale) = 0;

	/**
	\brief Reference count of the cloth instance
	\details At creation, the reference count of the fabric is 1. Every cloth instance referencing this fabric increments the
	count by 1.	When the reference count reaches 0, and only then, the fabric gets released automatically.
	\see PxCloth
	*/
	virtual	PxU32 getReferenceCount() const = 0;

	/**
	\brief Acquires a counted reference to a cloth fabric.

	This method increases the reference count of the cloth fabric by 1. Decrement the reference count by calling release()
	*/
	virtual void acquireReference() = 0;


	virtual	const char*	getConcreteTypeName() const	{ return "PxClothFabric";	}

protected:

	PX_INLINE PxClothFabric(PxType concreteType, PxBaseFlags baseFlags) : PxBase(concreteType, baseFlags) {}
	PX_INLINE PxClothFabric(PxBaseFlags baseFlags) : PxBase(baseFlags) {}
	virtual	~PxClothFabric() {}
	virtual	bool isKindOf(const char* name) const { return !::strcmp("PxClothFabric", name) || PxBase::isKindOf(name); }
};

#if !PX_DOXYGEN
} // namespace physx
#endif

/** @} */
#endif

Commits for Divide-Dependencies/physx/PhysX_3.4/Include/cloth/PxClothFabric.h

Diff revisions: vs.
Revision Author Commited Message
105 IonutCava picture IonutCava Tue 16 Apr, 2019 19:55:41 +0000

Forgot to actually add physx