RavEngine
Loading...
Searching...
No Matches
PvdMetaDataExtensions.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// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
27// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
28
29#ifndef PX_META_DATA_EXTENSIONS_H
30#define PX_META_DATA_EXTENSIONS_H
31#include "PxMetaDataObjects.h"
32
33#if PX_SUPPORT_PVD
34#include "PxPvdObjectModelBaseTypes.h"
35
36namespace physx { namespace pvdsdk {
37
38 template<> PX_INLINE NamespacedName getPvdNamespacedNameForType<physx::PxMetaDataPlane>() { return getPvdNamespacedNameForType<PxVec4>(); }
39 template<> PX_INLINE NamespacedName getPvdNamespacedNameForType<physx::PxRigidActor*>() { return getPvdNamespacedNameForType<VoidPtr>(); }
40
41}}
42#endif
43
44namespace physx
45{
46namespace Vd
47{
48//Additional properties that exist only in pvd land.
50{
51 enum Enum
52 {
53 FirstProp = PxPropertyInfoName::LastPxPropertyInfoName,
54 PxScene_Frame,
55 PxScene_Contacts,
56 PxScene_SimulateElapsedTime,
57#define DEFINE_ENUM_RANGE( stem, count ) \
58 stem##Begin, \
59 stem##End = stem##Begin + count
60
61 //I can't easily add up the number of required property entries, but it is large due to the below
62 //geometry count squared properties. Thus I punt and allocate way more than I need right now.
63 DEFINE_ENUM_RANGE( PxScene_SimulationStatistics, 1000 ),
64 DEFINE_ENUM_RANGE( PxSceneDesc_Limits, PxPropertyInfoName::PxSceneLimits_PropertiesStop - PxPropertyInfoName::PxSceneLimits_PropertiesStart ),
65 DEFINE_ENUM_RANGE( PxSimulationStatistics_NumShapes, PxGeometryType::eGEOMETRY_COUNT ),
66 DEFINE_ENUM_RANGE( PxSimulationStatistics_NumDiscreteContactPairs, PxGeometryType::eGEOMETRY_COUNT * PxGeometryType::eGEOMETRY_COUNT ),
67 DEFINE_ENUM_RANGE( PxSimulationStatistics_NumModifiedContactPairs, PxGeometryType::eGEOMETRY_COUNT * PxGeometryType::eGEOMETRY_COUNT ),
68 DEFINE_ENUM_RANGE( PxSimulationStatistics_NumSweptIntegrationPairs, PxGeometryType::eGEOMETRY_COUNT * PxGeometryType::eGEOMETRY_COUNT ),
69 DEFINE_ENUM_RANGE( PxSimulationStatistics_NumTriggerPairs, PxGeometryType::eGEOMETRY_COUNT * PxGeometryType::eGEOMETRY_COUNT ),
70 DEFINE_ENUM_RANGE( PxRigidDynamic_SolverIterationCounts, 2 ),
71 DEFINE_ENUM_RANGE( PxArticulation_SolverIterationCounts, 2 ),
72 DEFINE_ENUM_RANGE( PxArticulationJoint_SwingLimit, 2 ),
73 DEFINE_ENUM_RANGE( PxArticulationJoint_TwistLimit, 2 ),
74 DEFINE_ENUM_RANGE( PxConvexMeshGeometry_Scale, PxPropertyInfoName::PxMeshScale_PropertiesStop - PxPropertyInfoName::PxMeshScale_PropertiesStart ),
75 DEFINE_ENUM_RANGE( PxTriangleMeshGeometry_Scale, PxPropertyInfoName::PxMeshScale_PropertiesStop - PxPropertyInfoName::PxMeshScale_PropertiesStart ),
76
77 LastPxPvdOnlyProperty
78 };
79};
80
81template<PxU32 TKey, typename TObjectType, typename TPropertyType, PxU32 TEnableFlag>
82struct PxBufferPropertyInfo : PxReadOnlyPropertyInfo< TKey, TObjectType, TPropertyType >
83{
85 typedef typename TBaseType::TGetterType TGetterType;
86 PxBufferPropertyInfo( const char* inName, TGetterType inGetter )
87 : TBaseType( inName, inGetter )
88 {
89 }
90 bool isEnabled( PxU32 inFlags ) const { return (inFlags & TEnableFlag) > 0; }
91};
92
93
94#define DECLARE_BUFFER_PROPERTY( objectType, baseType, propType, propName, fieldName, flagName ) \
95typedef PxBufferPropertyInfo< PxPvdOnlyProperties::baseType##_##propName, objectType, propType, flagName > T##objectType##propName##Base; \
96inline propType get##propName( const objectType* inData ) { return inData->fieldName; } \
97struct baseType##propName##Property : T##objectType##propName##Base \
98{ \
99 baseType##propName##Property() : T##objectType##propName##Base( #propName, get##propName ){} \
100};
101
102template<PxU32 PropertyKey, typename TEnumType >
104{
105 PxEnumTraits<TEnumType> Converter;
106};
107
109{
110 mutable bool mHasValidOffset;
111 mutable PxU32 mOffset;
112 ValueStructOffsetRecord() : mHasValidOffset( false ), mOffset( 0 ) {}
113 void setupValueStructOffset( PxU32 inValue ) const
114 {
115 mHasValidOffset = true;
116 mOffset = inValue;
117 }
118};
119
120template<PxU32 TKey, typename TObjectType, typename TPropertyType>
122{
124 typedef TPropertyType prop_type;
125
126 const TPropertyInfoType mProperty;
128 : mProperty( inProp )
129 {
130 }
131 prop_type get( const TObjectType* inObj ) const { return mProperty.get( inObj ); }
132
133private:
135};
136
137template<PxU32 TKey, typename TObjectType, typename TPropertyType>
139{
141 typedef TPropertyType prop_type;
142 const TPropertyInfoType& mProperty;
143 const char* mName;
144
145 PxBufferCollectionPropertyAccessor( const TPropertyInfoType& inProp, const char* inName )
146 : mProperty( inProp )
147 , mName( inName )
148 {
149 }
150
151 const char* name() const { return mName; }
152 PxU32 size( const TObjectType* inObj ) const { return mProperty.size( inObj ); }
153 PxU32 get( const TObjectType* inObj, prop_type* buffer, PxU32 inNumItems) const { return mProperty.get( inObj, buffer, inNumItems); }
154 void set( TObjectType* inObj, prop_type* inBuffer, PxU32 inNumItems ) const { mProperty.set( inObj, inBuffer, inNumItems ); }
155};
156
157template<PxU32 TKey, typename TObjectType, typename TIndexType, typename TPropertyType>
159{
161 typedef TPropertyType prop_type;
162 TIndexType mIndex;
163 const TPropertyInfoType& mProperty;
164 PxPvdIndexedPropertyAccessor( const TPropertyInfoType& inProp, PxU32 inIndex )
165 : mIndex( static_cast<TIndexType>( inIndex ) )
166 , mProperty( inProp )
167 {
168 }
169 prop_type get( const TObjectType* inObj ) const { return mProperty.get( inObj, mIndex ); }
170 void set( TObjectType* inObj, prop_type val ) const { mProperty.set( inObj, mIndex, val ); }
171
172 void operator = (PxPvdIndexedPropertyAccessor&) {}
173};
174
175template<PxU32 TKey, typename TObjectType, typename TIndexType, typename TPropertyType>
177{
179 typedef TPropertyType prop_type;
180 TIndexType mIndex;
181 const TPropertyInfoType& mProperty;
182 PxPvdExtendedIndexedPropertyAccessor( const TPropertyInfoType& inProp, PxU32 inIndex )
183 : mIndex( static_cast<TIndexType>( inIndex ) )
184 , mProperty( inProp )
185 {
186 }
187
188 PxU32 size( const TObjectType* inObj ) const { return mProperty.size( inObj ); }
189 prop_type get( const TObjectType* inObj, TIndexType index ) const { return mProperty.get( inObj, index ); }
190 void set( TObjectType* inObj, TIndexType index, prop_type val ) const { mProperty.set( inObj, index, val ); }
191
192 void operator = (PxPvdExtendedIndexedPropertyAccessor&) {}
193};
194
195template<PxU32 TKey, typename TObjectType, typename TIndexType, typename TPropertyType>
197{
199 typedef TPropertyType prop_type;
200 TIndexType mIndex;
201
202 const TPropertyInfoType& mProperty;
203 PxPvdFixedSizeLookupTablePropertyAccessor( const TPropertyInfoType& inProp, const PxU32 inIndex3 )
204 : mIndex( static_cast<TIndexType>( inIndex3 ) )
205 , mProperty( inProp )
206 {
207 }
208
209 PxU32 size( const TObjectType* inObj ) const { return mProperty.size( inObj ); }
210 prop_type getX( const TObjectType* inObj, const TIndexType index ) const { return mProperty.getX( inObj, index ); }
211 prop_type getY( const TObjectType* inObj, const TIndexType index ) const { return mProperty.getY( inObj, index ); }
212 void addPair( TObjectType* inObj, const PxReal x, const PxReal y ) { const_cast<TPropertyInfoType&>(mProperty).addPair( inObj, x, y ); }
213 void clear( TObjectType* inObj ) { const_cast<TPropertyInfoType&>(mProperty).clear( inObj ); }
215};
216
217template<PxU32 TKey, typename TObjectType, typename TIdx0Type, typename TIdx1Type, typename TPropertyType>
219{
221 typedef TPropertyType prop_type;
222 TIdx0Type mIdx0;
223 TIdx1Type mIdx1;
224 const TPropertyInfoType& mProperty;
225
226 PxPvdDualIndexedPropertyAccessor( const TPropertyInfoType& inProp, PxU32 idx0, PxU32 idx1 )
227 : mIdx0( static_cast<TIdx0Type>( idx0 ) )
228 , mIdx1( static_cast<TIdx1Type>( idx1 ) )
229 , mProperty( inProp )
230 {
231 }
232 prop_type get( const TObjectType* inObj ) const { return mProperty.get( inObj, mIdx0, mIdx1 ); }
233 void set( TObjectType* inObj, prop_type val ) const { mProperty.set( inObj, mIdx0, mIdx1, val ); }
234
235private:
237};
238
239template<PxU32 TKey, typename TObjectType, typename TIdx0Type, typename TIdx1Type, typename TPropertyType>
241{
243 typedef TPropertyType prop_type;
244 TIdx0Type mIdx0;
245 TIdx1Type mIdx1;
246 const TPropertyInfoType& mProperty;
247
248 PxPvdExtendedDualIndexedPropertyAccessor( const TPropertyInfoType& inProp, PxU32 idx0, PxU32 idx1 )
249 : mIdx0( static_cast<TIdx0Type>( idx0 ) )
250 , mIdx1( static_cast<TIdx1Type>( idx1 ) )
251 , mProperty( inProp )
252 {
253 }
254 prop_type get( const TObjectType* inObj ) const { return mProperty.get( inObj, mIdx0, mIdx1 ); }
255 void set( TObjectType* inObj, prop_type val ) const { mProperty.set( inObj, mIdx0, mIdx1, val ); }
256
257private:
259};
260
261template<PxU32 TKey, typename TObjType, typename TPropertyType>
263{
265 typedef TPropertyType prop_type;
266 bool mFirstValue;
267 const TPropertyInfoType& mProperty;
268
269 PxPvdRangePropertyAccessor( const TPropertyInfoType& inProp, bool inFirstValue )
270 : mFirstValue( inFirstValue )
271 , mProperty( inProp )
272 {
273 }
274
275 prop_type get( const TObjType* inObj ) const {
276 prop_type first,second;
277 mProperty.get( inObj, first, second );
278 return mFirstValue ? first : second;
279 }
280 void set( TObjType* inObj, prop_type val ) const
281 {
282 prop_type first,second;
283 mProperty.get( inObj, first, second );
284 if ( mFirstValue ) mProperty.set( inObj, val, second );
285 else mProperty.set( inObj, first, val );
286 }
287
288 void operator = (PxPvdRangePropertyAccessor&) {}
289};
290
291
292template<typename TDataType>
294{
295 bool FlagData;
296};
297
298template<typename TEnumType, typename TStorageType>
299struct IsFlagsType<PxFlags<TEnumType, TStorageType> >
300{
301 const PxU32ToName* FlagData;
302 IsFlagsType<PxFlags<TEnumType, TStorageType> > () : FlagData( PxEnumTraits<TEnumType>().NameConversion ) {}
303};
304
305
306
307template<typename TDataType>
309{
310 bool Unknown;
311};
312
313}
314
315}
316
317#endif
Container for bitfield flag variables associated with a specific enum type.
Definition PxFlags.h:73
#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
Definition PxMetaDataObjects.h:298
Definition PxMetaDataObjects.h:255
Definition PxMetaDataObjects.h:583
Definition PxMetaDataObjects.h:274
Definition PxMetaDataObjects.h:230
Definition PxMetaDataObjects.h:321
@ eGEOMETRY_COUNT
internal use only!
Definition PxGeometry.h:65
Definition PxMetaDataObjects.h:211
Definition PxMetaDataObjects.h:186
Definition PxMetaDataObjects.h:149
Definition PxMetaDataObjects.h:124
Definition PvdMetaDataExtensions.h:104
Definition PvdMetaDataExtensions.h:294
Definition PvdMetaDataExtensions.h:309
Definition PvdMetaDataExtensions.h:139
Definition PvdMetaDataExtensions.h:83
Definition PvdMetaDataExtensions.h:219
Definition PvdMetaDataExtensions.h:241
Definition PvdMetaDataExtensions.h:177
Definition PvdMetaDataExtensions.h:197
Definition PvdMetaDataExtensions.h:159
Definition PvdMetaDataExtensions.h:50
Definition PvdMetaDataExtensions.h:263
Definition PvdMetaDataExtensions.h:122
Definition PvdMetaDataExtensions.h:109