1//
2// Redistribution and use in source and binary forms, with or without
3// modification, are permitted provided that the following conditions
4// are met:
5// * Redistributions of source code must retain the above copyright
6// notice, this list of conditions and the following disclaimer.
7// * Redistributions in binary form must reproduce the above copyright
8// notice, this list of conditions and the following disclaimer in the
9// documentation and/or other materials provided with the distribution.
10// * Neither the name of NVIDIA CORPORATION nor the names of its
11// contributors may be used to endorse or promote products derived
12// from this software without specific prior written permission.
13//
14// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
15// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
18// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
21// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
22// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25//
26// Copyright (c) 2008-2021 NVIDIA Corporation. All rights reserved.
27// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
28// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
29
30#ifndef PX_META_DATA_EXTENSIONS_H
31#define PX_META_DATA_EXTENSIONS_H
32#include "PxMetaDataObjects.h"
33
34#if PX_SUPPORT_PVD
35#include "PxPvdObjectModelBaseTypes.h"
36
37namespace physx { namespace pvdsdk {
38
39 template<> PX_INLINE NamespacedName getPvdNamespacedNameForType<physx::PxMetaDataPlane>() { return getPvdNamespacedNameForType<PxVec4>(); }
40 template<> PX_INLINE NamespacedName getPvdNamespacedNameForType<physx::PxRigidActor*>() { return getPvdNamespacedNameForType<VoidPtr>(); }
41
42}}
43#endif
44
45namespace physx
46{
47namespace Vd
48{
49//Additional properties that exist only in pvd land.
50struct PxPvdOnlyProperties
51{
52 enum Enum
53 {
54 FirstProp = PxPropertyInfoName::LastPxPropertyInfoName,
55 PxScene_Frame,
56 PxScene_Contacts,
57 PxScene_SimulateElapsedTime,
58#define DEFINE_ENUM_RANGE( stem, count ) \
59 stem##Begin, \
60 stem##End = stem##Begin + count
61
62 //I can't easily add up the number of required property entries, but it is large due to the below
63 //geometry count squared properties. Thus I punt and allocate way more than I need right now.
64 DEFINE_ENUM_RANGE( PxScene_SimulationStatistics, 1000 ),
65 DEFINE_ENUM_RANGE( PxSceneDesc_Limits, PxPropertyInfoName::PxSceneLimits_PropertiesStop - PxPropertyInfoName::PxSceneLimits_PropertiesStart ),
66 DEFINE_ENUM_RANGE( PxSimulationStatistics_NumShapes, PxGeometryType::eGEOMETRY_COUNT ),
67 DEFINE_ENUM_RANGE( PxSimulationStatistics_NumDiscreteContactPairs, PxGeometryType::eGEOMETRY_COUNT * PxGeometryType::eGEOMETRY_COUNT ),
68 DEFINE_ENUM_RANGE( PxSimulationStatistics_NumModifiedContactPairs, PxGeometryType::eGEOMETRY_COUNT * PxGeometryType::eGEOMETRY_COUNT ),
69 DEFINE_ENUM_RANGE( PxSimulationStatistics_NumSweptIntegrationPairs, PxGeometryType::eGEOMETRY_COUNT * PxGeometryType::eGEOMETRY_COUNT ),
70 DEFINE_ENUM_RANGE( PxSimulationStatistics_NumTriggerPairs, PxGeometryType::eGEOMETRY_COUNT * PxGeometryType::eGEOMETRY_COUNT ),
71 DEFINE_ENUM_RANGE( PxRigidDynamic_SolverIterationCounts, 2 ),
72 DEFINE_ENUM_RANGE( PxArticulation_SolverIterationCounts, 2 ),
73 DEFINE_ENUM_RANGE( PxArticulationJoint_SwingLimit, 2 ),
74 DEFINE_ENUM_RANGE( PxArticulationJoint_TwistLimit, 2 ),
75 DEFINE_ENUM_RANGE( PxConvexMeshGeometry_Scale, PxPropertyInfoName::PxMeshScale_PropertiesStop - PxPropertyInfoName::PxMeshScale_PropertiesStart ),
76 DEFINE_ENUM_RANGE( PxTriangleMeshGeometry_Scale, PxPropertyInfoName::PxMeshScale_PropertiesStop - PxPropertyInfoName::PxMeshScale_PropertiesStart ),
77
78 LastPxPvdOnlyProperty
79 };
80};
81
82template<PxU32 TKey, typename TObjectType, typename TPropertyType, PxU32 TEnableFlag>
83struct PxBufferPropertyInfo : PxReadOnlyPropertyInfo< TKey, TObjectType, TPropertyType >
84{
85 typedef PxReadOnlyPropertyInfo< TKey, TObjectType, TPropertyType > TBaseType;
86 typedef typename TBaseType::TGetterType TGetterType;
87 PxBufferPropertyInfo( const char* inName, TGetterType inGetter )
88 : TBaseType( inName, inGetter )
89 {
90 }
91 bool isEnabled( PxU32 inFlags ) const { return (inFlags & TEnableFlag) > 0; }
92};
93
94
95#define DECLARE_BUFFER_PROPERTY( objectType, baseType, propType, propName, fieldName, flagName ) \
96typedef PxBufferPropertyInfo< PxPvdOnlyProperties::baseType##_##propName, objectType, propType, flagName > T##objectType##propName##Base; \
97inline propType get##propName( const objectType* inData ) { return inData->fieldName; } \
98struct baseType##propName##Property : T##objectType##propName##Base \
99{ \
100 baseType##propName##Property() : T##objectType##propName##Base( #propName, get##propName ){} \
101};
102
103template<PxU32 PropertyKey, typename TEnumType >
104struct IndexerToNameMap
105{
106 PxEnumTraits<TEnumType> Converter;
107};
108
109struct ValueStructOffsetRecord
110{
111 mutable bool mHasValidOffset;
112 mutable PxU32 mOffset;
113 ValueStructOffsetRecord() : mHasValidOffset( false ), mOffset( 0 ) {}
114 void setupValueStructOffset( PxU32 inValue ) const
115 {
116 mHasValidOffset = true;
117 mOffset = inValue;
118 }
119};
120
121template<PxU32 TKey, typename TObjectType, typename TPropertyType>
122struct PxPvdReadOnlyPropertyAccessor : public ValueStructOffsetRecord
123{
124 typedef PxReadOnlyPropertyInfo<TKey,TObjectType,TPropertyType> TPropertyInfoType;
125 typedef TPropertyType prop_type;
126
127 const TPropertyInfoType mProperty;
128 PxPvdReadOnlyPropertyAccessor( const TPropertyInfoType& inProp )
129 : mProperty( inProp )
130 {
131 }
132 prop_type get( const TObjectType* inObj ) const { return mProperty.get( inObj ); }
133
134private:
135 PxPvdReadOnlyPropertyAccessor& operator=(const PxPvdReadOnlyPropertyAccessor&);
136};
137
138template<PxU32 TKey, typename TObjectType, typename TPropertyType>
139struct PxBufferCollectionPropertyAccessor : public ValueStructOffsetRecord
140{
141 typedef PxBufferCollectionPropertyInfo< TKey, TObjectType, TPropertyType > TPropertyInfoType;
142 typedef TPropertyType prop_type;
143 const TPropertyInfoType& mProperty;
144 const char* mName;
145
146 PxBufferCollectionPropertyAccessor( const TPropertyInfoType& inProp, const char* inName )
147 : mProperty( inProp )
148 , mName( inName )
149 {
150 }
151
152 const char* name() const { return mName; }
153 PxU32 size( const TObjectType* inObj ) const { return mProperty.size( inObj ); }
154 PxU32 get( const TObjectType* inObj, prop_type* buffer, PxU32 inNumItems) const { return mProperty.get( inObj, buffer, inNumItems); }
155 void set( TObjectType* inObj, prop_type* inBuffer, PxU32 inNumItems ) const { mProperty.set( inObj, inBuffer, inNumItems ); }
156};
157
158template<PxU32 TKey, typename TObjectType, typename TIndexType, typename TPropertyType>
159struct PxPvdIndexedPropertyAccessor : public ValueStructOffsetRecord
160{
161 typedef PxIndexedPropertyInfo< TKey, TObjectType, TIndexType, TPropertyType > TPropertyInfoType;
162 typedef TPropertyType prop_type;
163 TIndexType mIndex;
164 const TPropertyInfoType& mProperty;
165 PxPvdIndexedPropertyAccessor( const TPropertyInfoType& inProp, PxU32 inIndex )
166 : mIndex( static_cast<TIndexType>( inIndex ) )
167 , mProperty( inProp )
168 {
169 }
170 prop_type get( const TObjectType* inObj ) const { return mProperty.get( inObj, mIndex ); }
171 void set( TObjectType* inObj, prop_type val ) const { mProperty.set( inObj, mIndex, val ); }
172
173 void operator = (PxPvdIndexedPropertyAccessor&) {}
174};
175
176template<PxU32 TKey, typename TObjectType, typename TIndexType, typename TPropertyType>
177struct PxPvdExtendedIndexedPropertyAccessor : public ValueStructOffsetRecord
178{
179 typedef PxExtendedIndexedPropertyInfo< TKey, TObjectType, TIndexType, TPropertyType > TPropertyInfoType;
180 typedef TPropertyType prop_type;
181 TIndexType mIndex;
182 const TPropertyInfoType& mProperty;
183 PxPvdExtendedIndexedPropertyAccessor( const TPropertyInfoType& inProp, PxU32 inIndex )
184 : mIndex( static_cast<TIndexType>( inIndex ) )
185 , mProperty( inProp )
186 {
187 }
188
189 PxU32 size( const TObjectType* inObj ) const { return mProperty.size( inObj ); }
190 prop_type get( const TObjectType* inObj, TIndexType index ) const { return mProperty.get( inObj, index ); }
191 void set( TObjectType* inObj, TIndexType index, prop_type val ) const { mProperty.set( inObj, index, val ); }
192
193 void operator = (PxPvdExtendedIndexedPropertyAccessor&) {}
194};
195
196template<PxU32 TKey, typename TObjectType, typename TIndexType, typename TPropertyType>
197struct PxPvdFixedSizeLookupTablePropertyAccessor : public ValueStructOffsetRecord
198{
199 typedef PxFixedSizeLookupTablePropertyInfo< TKey, TObjectType, TIndexType, TPropertyType > TPropertyInfoType;
200 typedef TPropertyType prop_type;
201 TIndexType mIndex;
202
203 const TPropertyInfoType& mProperty;
204 PxPvdFixedSizeLookupTablePropertyAccessor( const TPropertyInfoType& inProp, const PxU32 inIndex3 )
205 : mIndex( static_cast<TIndexType>( inIndex3 ) )
206 , mProperty( inProp )
207 {
208 }
209
210 PxU32 size( const TObjectType* inObj ) const { return mProperty.size( inObj ); }
211 prop_type getX( const TObjectType* inObj, const TIndexType index ) const { return mProperty.getX( inObj, index ); }
212 prop_type getY( const TObjectType* inObj, const TIndexType index ) const { return mProperty.getY( inObj, index ); }
213 void addPair( TObjectType* inObj, const PxReal x, const PxReal y ) { const_cast<TPropertyInfoType&>(mProperty).addPair( inObj, x, y ); }
214 void clear( TObjectType* inObj ) { const_cast<TPropertyInfoType&>(mProperty).clear( inObj ); }
215 void operator = (PxPvdFixedSizeLookupTablePropertyAccessor&) {}
216};
217
218template<PxU32 TKey, typename TObjectType, typename TIdx0Type, typename TIdx1Type, typename TPropertyType>
219struct PxPvdDualIndexedPropertyAccessor : public ValueStructOffsetRecord
220{
221 typedef PxDualIndexedPropertyInfo< TKey, TObjectType, TIdx0Type, TIdx1Type, TPropertyType > TPropertyInfoType;
222 typedef TPropertyType prop_type;
223 TIdx0Type mIdx0;
224 TIdx1Type mIdx1;
225 const TPropertyInfoType& mProperty;
226
227 PxPvdDualIndexedPropertyAccessor( const TPropertyInfoType& inProp, PxU32 idx0, PxU32 idx1 )
228 : mIdx0( static_cast<TIdx0Type>( idx0 ) )
229 , mIdx1( static_cast<TIdx1Type>( idx1 ) )
230 , mProperty( inProp )
231 {
232 }
233 prop_type get( const TObjectType* inObj ) const { return mProperty.get( inObj, mIdx0, mIdx1 ); }
234 void set( TObjectType* inObj, prop_type val ) const { mProperty.set( inObj, mIdx0, mIdx1, val ); }
235
236private:
237 PxPvdDualIndexedPropertyAccessor& operator = (const PxPvdDualIndexedPropertyAccessor&);
238};
239
240template<PxU32 TKey, typename TObjectType, typename TIdx0Type, typename TIdx1Type, typename TPropertyType>
241struct PxPvdExtendedDualIndexedPropertyAccessor : public ValueStructOffsetRecord
242{
243 typedef PxExtendedDualIndexedPropertyInfo< TKey, TObjectType, TIdx0Type, TIdx1Type, TPropertyType > TPropertyInfoType;
244 typedef TPropertyType prop_type;
245 TIdx0Type mIdx0;
246 TIdx1Type mIdx1;
247 const TPropertyInfoType& mProperty;
248
249 PxPvdExtendedDualIndexedPropertyAccessor( const TPropertyInfoType& inProp, PxU32 idx0, PxU32 idx1 )
250 : mIdx0( static_cast<TIdx0Type>( idx0 ) )
251 , mIdx1( static_cast<TIdx1Type>( idx1 ) )
252 , mProperty( inProp )
253 {
254 }
255 prop_type get( const TObjectType* inObj ) const { return mProperty.get( inObj, mIdx0, mIdx1 ); }
256 void set( TObjectType* inObj, prop_type val ) const { mProperty.set( inObj, mIdx0, mIdx1, val ); }
257
258private:
259 PxPvdExtendedDualIndexedPropertyAccessor& operator = (const PxPvdExtendedDualIndexedPropertyAccessor&);
260};
261
262template<PxU32 TKey, typename TObjType, typename TPropertyType>
263struct PxPvdRangePropertyAccessor : public ValueStructOffsetRecord
264{
265 typedef PxRangePropertyInfo<TKey, TObjType, TPropertyType> TPropertyInfoType;
266 typedef TPropertyType prop_type;
267 bool mFirstValue;
268 const TPropertyInfoType& mProperty;
269
270 PxPvdRangePropertyAccessor( const TPropertyInfoType& inProp, bool inFirstValue )
271 : mFirstValue( inFirstValue )
272 , mProperty( inProp )
273 {
274 }
275
276 prop_type get( const TObjType* inObj ) const {
277 prop_type first,second;
278 mProperty.get( inObj, first, second );
279 return mFirstValue ? first : second;
280 }
281 void set( TObjType* inObj, prop_type val ) const
282 {
283 prop_type first,second;
284 mProperty.get( inObj, first, second );
285 if ( mFirstValue ) mProperty.set( inObj, val, second );
286 else mProperty.set( inObj, first, val );
287 }
288
289 void operator = (PxPvdRangePropertyAccessor&) {}
290};
291
292
293template<typename TDataType>
294struct IsFlagsType
295{
296 bool FlagData;
297};
298
299template<typename TEnumType, typename TStorageType>
300struct IsFlagsType<PxFlags<TEnumType, TStorageType> >
301{
302 const PxU32ToName* FlagData;
303 IsFlagsType() : FlagData( PxEnumTraits<TEnumType>().NameConversion ) {}
304};
305
306
307
308template<typename TDataType>
309struct PvdClassForType
310{
311 bool Unknown;
312};
313
314}
315
316}
317
318#endif
319

source code of qtquick3dphysics/src/3rdparty/PhysX/source/physxmetadata/core/include/PvdMetaDataExtensions.h