| 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_PROPERTY_VISITOR_H |
| 31 | #define PX_META_DATA_PROPERTY_VISITOR_H |
| 32 | |
| 33 | #include <stdio.h> |
| 34 | #include "PvdMetaDataExtensions.h" |
| 35 | namespace physx |
| 36 | { |
| 37 | |
| 38 | namespace Vd |
| 39 | { |
| 40 | |
| 41 | //PVD only deals with read-only properties, indexed, and properties like this by in large. |
| 42 | //so we have a filter that expands properties to a level where we can get to them and expands them into |
| 43 | //named functions that make more sense and are easier to read than operator() |
| 44 | template<typename TOperatorType> |
| 45 | struct PvdPropertyFilter |
| 46 | { |
| 47 | |
| 48 | private: |
| 49 | PvdPropertyFilter& operator=(const PvdPropertyFilter&); |
| 50 | |
| 51 | public: |
| 52 | |
| 53 | TOperatorType mOperator; |
| 54 | PxU32* mKeyOverride; |
| 55 | PxU32* mOffsetOverride; |
| 56 | |
| 57 | PvdPropertyFilter( TOperatorType& inOperator ) |
| 58 | : mOperator( inOperator ) |
| 59 | , mKeyOverride( 0 ) |
| 60 | , mOffsetOverride( 0 ) {} |
| 61 | |
| 62 | PvdPropertyFilter( TOperatorType& inOperator, PxU32* inKeyOverride, PxU32* inOffsetOverride ) |
| 63 | : mOperator( inOperator ) |
| 64 | , mKeyOverride( inKeyOverride ) |
| 65 | , mOffsetOverride( inOffsetOverride ) {} |
| 66 | |
| 67 | PvdPropertyFilter( const PvdPropertyFilter& inOther ) : mOperator( inOther.mOperator ), mKeyOverride( inOther.mKeyOverride ), mOffsetOverride( inOther.mOffsetOverride ) {} |
| 68 | |
| 69 | template<PxU32 TKey, typename TAccessorType> |
| 70 | void dispatchAccessor( PxU32 inKey, const TAccessorType& inAccessor, bool, bool, bool) |
| 71 | { |
| 72 | mOperator.simpleProperty(inKey, inAccessor ); |
| 73 | } |
| 74 | |
| 75 | template<PxU32 TKey, typename TAccessorType> |
| 76 | void dispatchAccessor( PxU32 inKey, const TAccessorType& inAccessor, bool, bool, const PxU32ToName* inConversions ) |
| 77 | { |
| 78 | mOperator.flagsProperty(inKey, inAccessor, inConversions ); |
| 79 | } |
| 80 | |
| 81 | template<PxU32 TKey, typename TAccessorType> |
| 82 | void dispatchAccessor( PxU32 inKey, const TAccessorType& inAccessor, const PxU32ToName* inConversions, bool, bool ) |
| 83 | { |
| 84 | mOperator.enumProperty( inKey, inAccessor, inConversions ); |
| 85 | } |
| 86 | |
| 87 | template<PxU32 TKey, typename TAccessorType, typename TInfoType> |
| 88 | void dispatchAccessor(PxU32, const TAccessorType& inAccessor, bool, const TInfoType* inInfo, bool ) |
| 89 | { |
| 90 | PxU32 rangeStart = TKey; |
| 91 | PxU32& propIdx = mKeyOverride == NULL ? rangeStart : *mKeyOverride; |
| 92 | mOperator.complexProperty( &propIdx, inAccessor, *inInfo ); |
| 93 | } |
| 94 | |
| 95 | PxU32 getKeyValue( PxU32 inPropertyKey ) |
| 96 | { |
| 97 | PxU32 retval = inPropertyKey; |
| 98 | if ( mKeyOverride ) |
| 99 | { |
| 100 | retval = *mKeyOverride; |
| 101 | (*mKeyOverride)++; |
| 102 | } |
| 103 | return retval; |
| 104 | } |
| 105 | |
| 106 | |
| 107 | void setupValueStructOffset( const ValueStructOffsetRecord&, bool, PxU32* ) {} |
| 108 | void setupValueStructOffset( const ValueStructOffsetRecord& inAccessor, PxU32 inOffset, PxU32* inAdditionalOffset ) |
| 109 | { |
| 110 | //This allows us to nest properties correctly. |
| 111 | if ( inAdditionalOffset ) inOffset += *inAdditionalOffset; |
| 112 | inAccessor.setupValueStructOffset( inOffset ); |
| 113 | } |
| 114 | |
| 115 | template<PxU32 TKey, typename TAccessorType> |
| 116 | void handleAccessor( PxU32 inKey, const TAccessorType& inAccessor ) |
| 117 | { |
| 118 | typedef typename TAccessorType::prop_type TPropertyType; |
| 119 | dispatchAccessor<TKey>( inKey |
| 120 | , inAccessor |
| 121 | , PxEnumTraits<TPropertyType>().NameConversion |
| 122 | , PxClassInfoTraits<TPropertyType>().getInfo() |
| 123 | , IsFlagsType<TPropertyType>().FlagData ); |
| 124 | } |
| 125 | |
| 126 | |
| 127 | template<PxU32 TKey, typename TAccessorType> |
| 128 | void handleAccessor( const TAccessorType& inAccessor ) |
| 129 | { |
| 130 | setupValueStructOffset( inAccessor, PxPropertyToValueStructMemberMap<TKey>().Offset, mOffsetOverride ); |
| 131 | handleAccessor<TKey>( getKeyValue( inPropertyKey: TKey ), inAccessor ); |
| 132 | } |
| 133 | |
| 134 | template<PxU32 TKey, typename TObjType, typename TPropertyType> |
| 135 | void operator()( const PxReadOnlyPropertyInfo<TKey,TObjType,TPropertyType>& inProperty, PxU32 ) |
| 136 | { |
| 137 | PxPvdReadOnlyPropertyAccessor< TKey, TObjType, TPropertyType > theAccessor( inProperty ); |
| 138 | mOperator.pushName( inProperty.mName ); |
| 139 | handleAccessor<TKey>( theAccessor ); |
| 140 | mOperator.popName(); |
| 141 | } |
| 142 | |
| 143 | //We don't handle unbounded indexed properties |
| 144 | template<PxU32 TKey, typename TObjType, typename TIndexType, typename TPropertyType, typename TValueConversionType, typename TInfoType> |
| 145 | void indexedProperty( PxU32, const PxIndexedPropertyInfo<TKey, TObjType, TIndexType, TPropertyType >&, bool, TValueConversionType, const TInfoType& ) {} |
| 146 | |
| 147 | |
| 148 | template<PxU32 TKey, typename TObjType, typename TIndexType, typename TPropertyType> |
| 149 | void indexedProperty( PxU32, const PxIndexedPropertyInfo<TKey, TObjType, TIndexType, TPropertyType >& inProp, const PxU32ToName* theConversions, const PxUnknownClassInfo& ) |
| 150 | { |
| 151 | mOperator.pushName( inProp.mName ); |
| 152 | PxU32 rangeStart = TKey; |
| 153 | PxU32& propIdx = mKeyOverride == NULL ? rangeStart : *mKeyOverride; |
| 154 | PxU32 theOffset = 0; |
| 155 | if ( mOffsetOverride ) theOffset = *mOffsetOverride; |
| 156 | |
| 157 | while( theConversions->mName != NULL ) |
| 158 | { |
| 159 | mOperator.pushBracketedName( theConversions->mName ); |
| 160 | PxPvdIndexedPropertyAccessor<TKey, TObjType, TIndexType, TPropertyType> theAccessor( inProp, theConversions->mValue ); |
| 161 | setupValueStructOffset( theAccessor, PxPropertyToValueStructMemberMap<TKey>().Offset, &theOffset ); |
| 162 | handleAccessor<TKey>( propIdx, theAccessor ); |
| 163 | mOperator.popName(); |
| 164 | ++propIdx; |
| 165 | ++theConversions; |
| 166 | theOffset += sizeof( TPropertyType ); |
| 167 | } |
| 168 | mOperator.popName(); |
| 169 | } |
| 170 | |
| 171 | template<PxU32 TKey, typename TObjType, typename TIndexType, typename TPropertyType, typename TInfoType> |
| 172 | void indexedProperty( PxU32, const PxIndexedPropertyInfo<TKey, TObjType, TIndexType, TPropertyType >& inProp, const PxU32ToName* theConversions, const TInfoType& inInfo ) |
| 173 | { |
| 174 | //ouch, not nice. Indexed complex property. |
| 175 | mOperator.pushName( inProp.mName ); |
| 176 | PxU32 propIdx = TKey; |
| 177 | PxU32 theOffset = 0; |
| 178 | if ( mOffsetOverride ) theOffset = *mOffsetOverride; |
| 179 | |
| 180 | while( theConversions->mName != NULL ) |
| 181 | { |
| 182 | mOperator.pushBracketedName( theConversions->mName ); |
| 183 | PxPvdIndexedPropertyAccessor<TKey, TObjType, TIndexType, TPropertyType> theAccessor( inProp, theConversions->mValue ); |
| 184 | setupValueStructOffset( theAccessor, PxPropertyToValueStructMemberMap<TKey>().Offset, &theOffset ); |
| 185 | PX_ASSERT( theAccessor.mHasValidOffset ); |
| 186 | mOperator.complexProperty( &propIdx, theAccessor, inInfo ); |
| 187 | mOperator.popName(); |
| 188 | ++theConversions; |
| 189 | theOffset += sizeof( TPropertyType ); |
| 190 | } |
| 191 | mOperator.popName(); |
| 192 | } |
| 193 | |
| 194 | static char* myStrcat(const char* a,const char * b) |
| 195 | { |
| 196 | size_t len = strlen(s: a)+strlen(s: b); |
| 197 | char* result = new char[len+1]; |
| 198 | |
| 199 | strcpy(dest: result,src: a); |
| 200 | strcat(dest: result,src: b); |
| 201 | result[len] = 0; |
| 202 | |
| 203 | return result; |
| 204 | } |
| 205 | |
| 206 | template<PxU32 TKey, typename TObjType, typename TPropertyType, typename TInfoType> |
| 207 | void handleBufferCollectionProperty(PxU32 , const PxBufferCollectionPropertyInfo<TKey, TObjType, TPropertyType >& inProp, const TInfoType& inInfo) |
| 208 | { |
| 209 | //append 'Collection' to buffer properties |
| 210 | char* name = myStrcat(a: inProp.mName, b: "Collection" ); |
| 211 | |
| 212 | mOperator.pushName(name); |
| 213 | PxU32 propIdx = TKey; |
| 214 | PxU32 theOffset = 0; |
| 215 | |
| 216 | PxBufferCollectionPropertyAccessor<TKey, TObjType, TPropertyType> theAccessor( inProp, inProp.mName ); |
| 217 | setupValueStructOffset( theAccessor, PxPropertyToValueStructMemberMap<TKey>().Offset, &theOffset ); |
| 218 | |
| 219 | mOperator.bufferCollectionProperty( &propIdx, theAccessor, inInfo ); |
| 220 | mOperator.popName(); |
| 221 | delete []name; |
| 222 | } |
| 223 | |
| 224 | template<PxU32 TKey, typename TObjType, typename TIndexType, typename TPropertyType> |
| 225 | void operator()( const PxIndexedPropertyInfo<TKey, TObjType, TIndexType, TPropertyType >& inProp, PxU32 inIndex ) |
| 226 | { |
| 227 | indexedProperty( inIndex, inProp, IndexerToNameMap<TKey,TIndexType>().Converter.NameConversion |
| 228 | , PxClassInfoTraits<TPropertyType>().Info ); |
| 229 | } |
| 230 | |
| 231 | template<PxU32 TKey, typename TObjType, typename TPropertyType, typename TIndexType, typename TInfoType> |
| 232 | void handleExtendedIndexProperty(PxU32 inIndex, const PxExtendedIndexedPropertyInfo<TKey, TObjType, TIndexType, TPropertyType >& inProp, const TInfoType& inInfo) |
| 233 | { |
| 234 | mOperator.pushName(inProp.mName); |
| 235 | PxU32 propIdx = TKey; |
| 236 | PxU32 theOffset = 0; |
| 237 | |
| 238 | PxPvdExtendedIndexedPropertyAccessor<TKey, TObjType, TIndexType, TPropertyType> theAccessor( inProp, inIndex ); |
| 239 | setupValueStructOffset( theAccessor, PxPropertyToValueStructMemberMap<TKey>().Offset, &theOffset ); |
| 240 | |
| 241 | mOperator.extendedIndexedProperty( &propIdx, theAccessor, inInfo ); |
| 242 | mOperator.popName(); |
| 243 | } |
| 244 | |
| 245 | template<PxU32 TKey, typename TObjType, typename TPropertyType, typename TIndexType, typename TInfoType> |
| 246 | void handlePxFixedSizeLookupTableProperty( const PxU32 inIndex, const PxFixedSizeLookupTablePropertyInfo<TKey, TObjType, TIndexType, TPropertyType >& inProp, const TInfoType& inInfo) |
| 247 | { |
| 248 | mOperator.pushName(inProp.mName); |
| 249 | |
| 250 | PxU32 propIdx = TKey; |
| 251 | PxU32 theOffset = 0; |
| 252 | |
| 253 | PxPvdFixedSizeLookupTablePropertyAccessor<TKey, TObjType, TIndexType, TPropertyType> theAccessor( inProp, inIndex ); |
| 254 | setupValueStructOffset( theAccessor, PxPropertyToValueStructMemberMap<TKey>().Offset, &theOffset ); |
| 255 | |
| 256 | mOperator.PxFixedSizeLookupTableProperty( &propIdx, theAccessor, inInfo ); |
| 257 | |
| 258 | mOperator.popName(); |
| 259 | } |
| 260 | |
| 261 | template<PxU32 TKey, typename TObjType, typename TIndexType, typename TPropertyType> |
| 262 | void operator()( const PxExtendedIndexedPropertyInfo<TKey, TObjType, TIndexType, TPropertyType >& inProp, PxU32 inIndex ) |
| 263 | { |
| 264 | handleExtendedIndexProperty( inIndex, inProp, PxClassInfoTraits<TPropertyType>().Info ); |
| 265 | } |
| 266 | |
| 267 | template<PxU32 TKey, typename TObjType, typename TIndexType, typename TPropertyType> |
| 268 | void operator()( const PxFixedSizeLookupTablePropertyInfo<TKey, TObjType, TIndexType, TPropertyType >& inProp, PxU32 inIndex) |
| 269 | { |
| 270 | handlePxFixedSizeLookupTableProperty(inIndex, inProp, PxClassInfoTraits<TPropertyType>().Info); |
| 271 | } |
| 272 | |
| 273 | //We don't handle unbounded indexed properties |
| 274 | template<PxU32 TKey, typename TObjType, typename TIndexType, typename TIndex2Type, typename TPropertyType, typename TNameConv, typename TNameConv2 > |
| 275 | void dualIndexedProperty( PxU32 idx, const PxDualIndexedPropertyInfo<TKey, TObjType, TIndexType, TIndex2Type, TPropertyType >&, TNameConv, TNameConv2 ) { PX_UNUSED(idx); } |
| 276 | |
| 277 | template<PxU32 TKey, typename TObjType, typename TIndexType, typename TIndex2Type, typename TPropertyType> |
| 278 | void dualIndexedProperty( PxU32 /*idx*/, const PxDualIndexedPropertyInfo<TKey, TObjType, TIndexType, TIndex2Type, TPropertyType >& inProp, const PxU32ToName* c1, const PxU32ToName* c2 ) |
| 279 | { |
| 280 | mOperator.pushName( inProp.mName ); |
| 281 | PxU32 rangeStart = TKey; |
| 282 | PxU32& propIdx = mKeyOverride == NULL ? rangeStart : *mKeyOverride; |
| 283 | PxU32 theOffset = 0; |
| 284 | if ( mOffsetOverride ) theOffset = *mOffsetOverride; |
| 285 | while( c1->mName != NULL ) |
| 286 | { |
| 287 | mOperator.pushBracketedName( c1->mName ); |
| 288 | const PxU32ToName* c2Idx = c2; |
| 289 | while( c2Idx->mName != NULL ) |
| 290 | { |
| 291 | mOperator.pushBracketedName( c2Idx->mName ); |
| 292 | PxPvdDualIndexedPropertyAccessor<TKey, TObjType, TIndexType, TIndex2Type, TPropertyType> theAccessor( inProp, c1->mValue, c2Idx->mValue ); |
| 293 | setupValueStructOffset( theAccessor, PxPropertyToValueStructMemberMap<TKey>().Offset, &theOffset ); |
| 294 | handleAccessor<TKey>( propIdx, theAccessor ); |
| 295 | mOperator.popName(); |
| 296 | ++propIdx; |
| 297 | ++c2Idx; |
| 298 | theOffset += sizeof( TPropertyType ); |
| 299 | } |
| 300 | mOperator.popName(); |
| 301 | ++c1; |
| 302 | } |
| 303 | mOperator.popName(); |
| 304 | } |
| 305 | |
| 306 | template<PxU32 TKey, typename TObjType, typename TIndexType, typename TIndex2Type, typename TPropertyType> |
| 307 | void extendedDualIndexedProperty( PxU32 /*idx*/, const PxExtendedDualIndexedPropertyInfo<TKey, TObjType, TIndexType, TIndex2Type, TPropertyType >& inProp, PxU32 id0Count, PxU32 id1Count ) |
| 308 | { |
| 309 | mOperator.pushName( inProp.mName ); |
| 310 | PxU32 rangeStart = TKey; |
| 311 | PxU32& propIdx = mKeyOverride == NULL ? rangeStart : *mKeyOverride; |
| 312 | PxU32 theOffset = 0; |
| 313 | if ( mOffsetOverride ) theOffset = *mOffsetOverride; |
| 314 | for(PxU32 i = 0; i < id0Count; ++i) |
| 315 | { |
| 316 | char buffer1[32] = { 0 }; |
| 317 | sprintf( s: buffer1, format: "eId1_%u" , i ); |
| 318 | |
| 319 | mOperator.pushBracketedName( buffer1 ); |
| 320 | for(PxU32 j = 0; j < id1Count; ++j) |
| 321 | { |
| 322 | char buffer2[32] = { 0 }; |
| 323 | sprintf( s: buffer2, format: "eId2_%u" , j ); |
| 324 | |
| 325 | mOperator.pushBracketedName( buffer2 ); |
| 326 | PxPvdExtendedDualIndexedPropertyAccessor<TKey, TObjType, TIndexType, TIndex2Type, TPropertyType> theAccessor( inProp, i, j ); |
| 327 | setupValueStructOffset( theAccessor, PxPropertyToValueStructMemberMap<TKey>().Offset, &theOffset ); |
| 328 | handleAccessor<TKey>( propIdx, theAccessor ); |
| 329 | mOperator.popName(); |
| 330 | ++propIdx; |
| 331 | theOffset += sizeof( TPropertyType ); |
| 332 | } |
| 333 | mOperator.popName(); |
| 334 | } |
| 335 | mOperator.popName(); |
| 336 | } |
| 337 | |
| 338 | template<PxU32 TKey, typename TObjType, typename TIndexType, typename TIndex2Type, typename TPropertyType> |
| 339 | void operator()( const PxDualIndexedPropertyInfo<TKey, TObjType, TIndexType, TIndex2Type, TPropertyType >& inProp, PxU32 idx ) |
| 340 | { |
| 341 | dualIndexedProperty( idx, inProp |
| 342 | , IndexerToNameMap<TKey,TIndexType>().Converter.NameConversion |
| 343 | , IndexerToNameMap<TKey,TIndex2Type>().Converter.NameConversion ); |
| 344 | } |
| 345 | |
| 346 | template<PxU32 TKey, typename TObjType, typename TIndexType, typename TIndex2Type, typename TPropertyType> |
| 347 | void operator()( const PxExtendedDualIndexedPropertyInfo<TKey, TObjType, TIndexType, TIndex2Type, TPropertyType >& inProp, PxU32 idx ) |
| 348 | { |
| 349 | extendedDualIndexedProperty( idx, inProp, inProp.mId0Count, inProp.mId1Count ); |
| 350 | } |
| 351 | |
| 352 | template<PxU32 TKey, typename TObjType, typename TPropertyType> |
| 353 | void operator()( const PxRangePropertyInfo<TKey, TObjType, TPropertyType>& inProperty, PxU32 /*idx*/) |
| 354 | { |
| 355 | PxU32 rangeStart = TKey; |
| 356 | PxU32& propIdx = mKeyOverride == NULL ? rangeStart : *mKeyOverride; |
| 357 | PxU32 theOffset = 0; |
| 358 | if ( mOffsetOverride ) theOffset = *mOffsetOverride; |
| 359 | |
| 360 | mOperator.pushName( inProperty.mName ); |
| 361 | mOperator.pushName( inProperty.mArg0Name ); |
| 362 | PxPvdRangePropertyAccessor<TKey, TObjType, TPropertyType> theAccessor( inProperty, true ); |
| 363 | setupValueStructOffset( theAccessor, PxPropertyToValueStructMemberMap<TKey>().Offset, &theOffset ); |
| 364 | handleAccessor<TKey>( propIdx, theAccessor ); |
| 365 | ++propIdx; |
| 366 | theOffset += sizeof( TPropertyType ); |
| 367 | mOperator.popName(); |
| 368 | mOperator.pushName( inProperty.mArg1Name ); |
| 369 | theAccessor.mFirstValue = false; |
| 370 | setupValueStructOffset( theAccessor, PxPropertyToValueStructMemberMap<TKey>().Offset, &theOffset ); |
| 371 | handleAccessor<TKey>( propIdx, theAccessor ); |
| 372 | mOperator.popName(); |
| 373 | mOperator.popName(); |
| 374 | } |
| 375 | |
| 376 | template<PxU32 TKey, typename TObjType, typename TPropertyType> |
| 377 | void operator()( const PxBufferCollectionPropertyInfo<TKey, TObjType, TPropertyType>& inProp, PxU32 count ) |
| 378 | { |
| 379 | handleBufferCollectionProperty( count, inProp, PxClassInfoTraits<TPropertyType>().Info ); |
| 380 | } |
| 381 | |
| 382 | template<PxU32 TKey, typename TObjectType, typename TPropertyType, PxU32 TEnableFlag> |
| 383 | void handleBuffer( const PxBufferPropertyInfo<TKey, TObjectType, TPropertyType, TEnableFlag>& inProp ) |
| 384 | { |
| 385 | mOperator.handleBuffer( inProp ); |
| 386 | } |
| 387 | |
| 388 | template<PxU32 TKey, typename TObjectType, typename TPropertyType, PxU32 TEnableFlag> |
| 389 | void operator()( const PxBufferPropertyInfo<TKey, TObjectType, TPropertyType, TEnableFlag>& inProp, PxU32 ) |
| 390 | { |
| 391 | handleBuffer( inProp ); |
| 392 | } |
| 393 | |
| 394 | template<PxU32 TKey, typename TObjType> |
| 395 | void operator()( const PxReadOnlyCollectionPropertyInfo<TKey, TObjType, PxU32>& prop, PxU32 ) |
| 396 | { |
| 397 | mOperator.handleCollection( prop ); |
| 398 | } |
| 399 | |
| 400 | template<PxU32 TKey, typename TObjType> |
| 401 | void operator()( const PxReadOnlyCollectionPropertyInfo<TKey, TObjType, PxReal>& prop, PxU32 ) |
| 402 | { |
| 403 | mOperator.handleCollection( prop ); |
| 404 | } |
| 405 | |
| 406 | template<PxU32 TKey, typename TObjType, typename TPropertyType> |
| 407 | void operator()( const PxWriteOnlyPropertyInfo<TKey,TObjType,TPropertyType>&, PxU32 ) {} |
| 408 | |
| 409 | template<PxU32 TKey, typename TObjType, typename TCollectionType> |
| 410 | void operator()( const PxReadOnlyCollectionPropertyInfo<TKey, TObjType, TCollectionType>&, PxU32 ) {} |
| 411 | |
| 412 | template<PxU32 TKey, typename TObjType, typename TCollectionType, typename TFilterType> |
| 413 | void operator()( const PxReadOnlyFilteredCollectionPropertyInfo<TKey, TObjType, TCollectionType, TFilterType >&, PxU32 ) {} |
| 414 | |
| 415 | |
| 416 | //We don't deal with these property datatypes. |
| 417 | #define DEFINE_PVD_PROPERTY_NOP(datatype) \ |
| 418 | template<PxU32 TKey, typename TObjType> \ |
| 419 | void operator()( const PxReadOnlyPropertyInfo<TKey,TObjType,datatype>& inProperty, PxU32 ){PX_UNUSED(inProperty); } |
| 420 | |
| 421 | DEFINE_PVD_PROPERTY_NOP( const void* ) |
| 422 | DEFINE_PVD_PROPERTY_NOP( void* ) |
| 423 | DEFINE_PVD_PROPERTY_NOP( PxSimulationFilterCallback * ) |
| 424 | DEFINE_PVD_PROPERTY_NOP( physx::PxTaskManager * ) |
| 425 | DEFINE_PVD_PROPERTY_NOP( PxSimulationFilterShader * ) |
| 426 | DEFINE_PVD_PROPERTY_NOP( PxSimulationFilterShader) |
| 427 | DEFINE_PVD_PROPERTY_NOP( PxContactModifyCallback * ) |
| 428 | DEFINE_PVD_PROPERTY_NOP( PxCCDContactModifyCallback * ) |
| 429 | DEFINE_PVD_PROPERTY_NOP( PxSimulationEventCallback * ) |
| 430 | DEFINE_PVD_PROPERTY_NOP( physx::PxCudaContextManager* ) |
| 431 | DEFINE_PVD_PROPERTY_NOP( physx::PxCpuDispatcher * ) |
| 432 | DEFINE_PVD_PROPERTY_NOP( PxRigidActor ) |
| 433 | DEFINE_PVD_PROPERTY_NOP( const PxRigidActor ) |
| 434 | DEFINE_PVD_PROPERTY_NOP( PxRigidActor& ) |
| 435 | DEFINE_PVD_PROPERTY_NOP( const PxRigidActor& ) |
| 436 | DEFINE_PVD_PROPERTY_NOP( PxScene* ) |
| 437 | DEFINE_PVD_PROPERTY_NOP( PxConstraint ) |
| 438 | DEFINE_PVD_PROPERTY_NOP( PxConstraint* ) |
| 439 | DEFINE_PVD_PROPERTY_NOP( PxConstraint& ) |
| 440 | DEFINE_PVD_PROPERTY_NOP( const PxConstraint& ) |
| 441 | DEFINE_PVD_PROPERTY_NOP( PxAggregate * ) |
| 442 | DEFINE_PVD_PROPERTY_NOP( PxArticulationBase& ) |
| 443 | DEFINE_PVD_PROPERTY_NOP( PxArticulation& ) |
| 444 | DEFINE_PVD_PROPERTY_NOP( PxArticulationReducedCoordinate&) |
| 445 | DEFINE_PVD_PROPERTY_NOP( const PxArticulationLink * ) |
| 446 | DEFINE_PVD_PROPERTY_NOP( const PxRigidDynamic * ) |
| 447 | DEFINE_PVD_PROPERTY_NOP( const PxRigidStatic * ) |
| 448 | DEFINE_PVD_PROPERTY_NOP( PxArticulationJointBase * ) |
| 449 | DEFINE_PVD_PROPERTY_NOP( PxArticulationJointReducedCoordinate * ) |
| 450 | DEFINE_PVD_PROPERTY_NOP( PxArticulationJoint * ) |
| 451 | DEFINE_PVD_PROPERTY_NOP( PxBroadPhaseCallback * ) |
| 452 | DEFINE_PVD_PROPERTY_NOP( const PxBroadPhaseRegion * ) |
| 453 | DEFINE_PVD_PROPERTY_NOP( PxU32 * ) |
| 454 | |
| 455 | }; |
| 456 | |
| 457 | template<typename TOperator> |
| 458 | inline PvdPropertyFilter<TOperator> makePvdPropertyFilter( TOperator inOperator ) |
| 459 | { |
| 460 | return PvdPropertyFilter<TOperator>( inOperator ); |
| 461 | } |
| 462 | |
| 463 | template<typename TOperator> |
| 464 | inline PvdPropertyFilter<TOperator> makePvdPropertyFilter( TOperator inOperator, PxU32* inKey, PxU32* inOffset ) |
| 465 | { |
| 466 | return PvdPropertyFilter<TOperator>( inOperator, inKey, inOffset ); |
| 467 | } |
| 468 | |
| 469 | template<typename TOperator, typename TFuncType> |
| 470 | inline void visitWithPvdFilter( TOperator inOperator, TFuncType inFuncType ) |
| 471 | { |
| 472 | PX_UNUSED(inFuncType); |
| 473 | TFuncType( makePvdPropertyFilter( inOperator ) ); |
| 474 | } |
| 475 | |
| 476 | template<typename TObjType, typename TOperator> |
| 477 | inline void visitInstancePvdProperties( TOperator inOperator ) |
| 478 | { |
| 479 | visitInstanceProperties<TObjType>( makePvdPropertyFilter( inOperator ) ); |
| 480 | } |
| 481 | |
| 482 | template<typename TOperator> |
| 483 | struct PvdAllPropertyVisitor |
| 484 | { |
| 485 | TOperator mOperator; |
| 486 | PvdAllPropertyVisitor( TOperator op ) : mOperator( op ) {} |
| 487 | template<typename TObjectType> |
| 488 | bool operator()( const TObjectType* ) { visitInstancePvdProperties<TObjectType>( mOperator ); return false; } |
| 489 | }; |
| 490 | |
| 491 | |
| 492 | template<typename TOperator> |
| 493 | struct PvdAllInfoVisitor |
| 494 | { |
| 495 | TOperator mOperator; |
| 496 | PvdAllInfoVisitor( TOperator op ) : mOperator( op ) {} |
| 497 | template<typename TInfoType> |
| 498 | void operator()( TInfoType inInfo ) |
| 499 | { |
| 500 | inInfo.template visitType<bool>( PvdAllPropertyVisitor<TOperator>( mOperator ) ); |
| 501 | inInfo.visitBases( *this ); |
| 502 | } |
| 503 | }; |
| 504 | |
| 505 | |
| 506 | template<typename TObjType, typename TOperator> |
| 507 | inline void visitAllPvdProperties( TOperator inOperator ) |
| 508 | { |
| 509 | visitAllProperties<TObjType>( makePvdPropertyFilter( inOperator ) ); |
| 510 | } |
| 511 | |
| 512 | |
| 513 | |
| 514 | template<typename TOperator> |
| 515 | inline void visitRigidDynamicPerFrameProperties( TOperator inOperator ) |
| 516 | { |
| 517 | PvdPropertyFilter<TOperator> theFilter( inOperator ); |
| 518 | PxRigidDynamicGeneratedInfo theInfo; |
| 519 | theFilter( theInfo.GlobalPose, 0 ); |
| 520 | theFilter( theInfo.LinearVelocity, 1 ); |
| 521 | theFilter( theInfo.AngularVelocity, 2 ); |
| 522 | theFilter( theInfo.IsSleeping, 3 ); |
| 523 | } |
| 524 | |
| 525 | template<typename TOperator> |
| 526 | inline void visitArticulationLinkPerFrameProperties( TOperator inOperator ) |
| 527 | { |
| 528 | PvdPropertyFilter<TOperator> theFilter( inOperator ); |
| 529 | PxArticulationLinkGeneratedInfo theInfo; |
| 530 | theFilter( theInfo.GlobalPose, 0 ); |
| 531 | theFilter( theInfo.LinearVelocity, 1 ); |
| 532 | theFilter( theInfo.AngularVelocity, 2 ); |
| 533 | } |
| 534 | |
| 535 | } |
| 536 | |
| 537 | } |
| 538 | |
| 539 | #endif |
| 540 | |