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_REPX_META_DATA_PROPERTY_VISITOR_H |
31 | #define PX_REPX_META_DATA_PROPERTY_VISITOR_H |
32 | #include "PvdMetaDataPropertyVisitor.h" |
33 | |
34 | namespace physx { |
35 | |
36 | template<PxU32 TKey, typename TObjectType,typename TSetPropType, typename TPropertyType> |
37 | struct PxRepXPropertyAccessor : public Vd::ValueStructOffsetRecord |
38 | { |
39 | typedef PxPropertyInfo<TKey,TObjectType,TSetPropType,TPropertyType> TPropertyInfoType; |
40 | typedef TPropertyType prop_type; |
41 | |
42 | const TPropertyInfoType mProperty; |
43 | PxRepXPropertyAccessor( const TPropertyInfoType& inProp ) |
44 | : mProperty( inProp ) |
45 | { |
46 | } |
47 | prop_type get( const TObjectType* inObj ) const { return mProperty.get( inObj ); } |
48 | void set( TObjectType* inObj, prop_type val ) const { return mProperty.set( inObj, val ); } |
49 | |
50 | private: |
51 | PxRepXPropertyAccessor& operator=(const PxRepXPropertyAccessor&); |
52 | }; |
53 | |
54 | template<typename TSetPropType, typename TPropertyType> |
55 | struct PxRepXPropertyAccessor<PxPropertyInfoName::PxRigidDynamic_WakeCounter, PxRigidDynamic, TSetPropType, TPropertyType> : public Vd::ValueStructOffsetRecord |
56 | { |
57 | typedef PxPropertyInfo<PxPropertyInfoName::PxRigidDynamic_WakeCounter,PxRigidDynamic,TSetPropType,TPropertyType> TPropertyInfoType; |
58 | typedef TPropertyType prop_type; |
59 | |
60 | const TPropertyInfoType mProperty; |
61 | PxRepXPropertyAccessor( const TPropertyInfoType& inProp ) |
62 | : mProperty( inProp ) |
63 | { |
64 | } |
65 | prop_type get( const PxRigidDynamic* inObj ) const { return mProperty.get( inObj ); } |
66 | void set( PxRigidDynamic* inObj, prop_type val ) const |
67 | { |
68 | PX_UNUSED(val); |
69 | PxRigidBodyFlags flags = inObj->getRigidBodyFlags(); |
70 | if( !(flags & PxRigidBodyFlag::eKINEMATIC) ) |
71 | return mProperty.set( inObj, val ); |
72 | } |
73 | private: |
74 | PxRepXPropertyAccessor& operator=(const PxRepXPropertyAccessor&); |
75 | }; |
76 | |
77 | typedef PxReadOnlyPropertyInfo<PxPropertyInfoName::PxArticulationLink_InboundJoint, PxArticulationLink, PxArticulationJointBase *> TIncomingJointPropType; |
78 | |
79 | |
80 | //RepX cares about fewer property types than PVD does, |
81 | //but I want to reuse the accessor architecture as it |
82 | //greatly simplifies clients dealing with complex datatypes |
83 | template<typename TOperatorType> |
84 | struct RepXPropertyFilter |
85 | { |
86 | RepXPropertyFilter<TOperatorType> &operator=(const RepXPropertyFilter<TOperatorType> &); |
87 | |
88 | Vd::PvdPropertyFilter<TOperatorType> mFilter; |
89 | RepXPropertyFilter( TOperatorType op ) : mFilter( op ) {} |
90 | RepXPropertyFilter( const RepXPropertyFilter<TOperatorType>& other ) : mFilter( other.mFilter ) {} |
91 | |
92 | template<PxU32 TKey, typename TObjType, typename TPropertyType> |
93 | void operator()( const PxReadOnlyPropertyInfo<TKey,TObjType,TPropertyType>&, PxU32 ) {} //repx ignores read only and write only properties |
94 | template<PxU32 TKey, typename TObjType, typename TPropertyType> |
95 | void operator()( const PxWriteOnlyPropertyInfo<TKey,TObjType,TPropertyType>&, PxU32 ) {} |
96 | template<PxU32 TKey, typename TObjType, typename TCollectionType> |
97 | void operator()( const PxReadOnlyCollectionPropertyInfo<TKey, TObjType, TCollectionType>&, PxU32 ) {} |
98 | |
99 | template<PxU32 TKey, typename TObjType, typename TCollectionType, typename TFilterType> |
100 | void operator()( const PxReadOnlyFilteredCollectionPropertyInfo<TKey, TObjType, TCollectionType, TFilterType >&, PxU32 ) {} |
101 | //forward these properties verbatim. |
102 | template<PxU32 TKey, typename TObjType, typename TIndexType, typename TPropertyType> |
103 | void operator()( const PxIndexedPropertyInfo<TKey, TObjType, TIndexType, TPropertyType >& inProp, PxU32 idx ) |
104 | { |
105 | mFilter( inProp, idx ); |
106 | } |
107 | |
108 | template<PxU32 TKey, typename TObjType, typename TIndexType, typename TPropertyType> |
109 | void operator()( const PxFixedSizeLookupTablePropertyInfo<TKey, TObjType, TIndexType,TPropertyType >& inProp, PxU32 idx ) |
110 | { |
111 | mFilter( inProp, idx ); |
112 | } |
113 | |
114 | template<PxU32 TKey, typename TObjType, typename TIndexType, typename TPropertyType> |
115 | void operator()( const PxExtendedIndexedPropertyInfo<TKey, TObjType, TIndexType, TPropertyType >& inProp, PxU32 idx) |
116 | { |
117 | mFilter( inProp, idx); |
118 | } |
119 | |
120 | template<PxU32 TKey, typename TObjType, typename TIndexType, typename TIndex2Type, typename TPropertyType> |
121 | void operator()( const PxDualIndexedPropertyInfo<TKey, TObjType, TIndexType, TIndex2Type, TPropertyType >& inProp, PxU32 idx ) |
122 | { |
123 | mFilter( inProp, idx ); |
124 | } |
125 | |
126 | template<PxU32 TKey, typename TObjType, typename TIndexType, typename TIndex2Type, typename TPropertyType> |
127 | void operator()( const PxExtendedDualIndexedPropertyInfo<TKey, TObjType, TIndexType, TIndex2Type, TPropertyType >& inProp, PxU32 idx ) |
128 | { |
129 | mFilter( inProp, idx ); |
130 | } |
131 | |
132 | template<PxU32 TKey, typename TObjType, typename TPropertyType> |
133 | void operator()( const PxRangePropertyInfo<TKey, TObjType, TPropertyType>& inProp, PxU32 idx ) |
134 | { |
135 | mFilter( inProp, idx ); |
136 | } |
137 | |
138 | template<PxU32 TKey, typename TObjType, typename TPropertyType> |
139 | void operator()( const PxBufferCollectionPropertyInfo<TKey, TObjType, TPropertyType>& inProp, PxU32 count ) |
140 | { |
141 | mFilter( inProp, count ); |
142 | } |
143 | |
144 | template<PxU32 TKey, typename TObjType, typename TSetPropType, typename TPropertyType> |
145 | void operator()( const PxPropertyInfo<TKey,TObjType,TSetPropType,TPropertyType>& prop, PxU32 ) |
146 | { |
147 | PxRepXPropertyAccessor< TKey, TObjType, TSetPropType, TPropertyType > theAccessor( prop ); |
148 | mFilter.mOperator.pushName( prop.mName ); |
149 | mFilter.template handleAccessor<TKey>( theAccessor ); |
150 | mFilter.mOperator.popName(); |
151 | } |
152 | |
153 | void operator()( const PxRigidActorGlobalPosePropertyInfo& inProp, PxU32 ) |
154 | { |
155 | mFilter.mOperator.pushName( inProp.mName ); |
156 | mFilter.mOperator.handleRigidActorGlobalPose( inProp ); |
157 | mFilter.mOperator.popName(); |
158 | } |
159 | |
160 | void operator()( const PxRigidActorShapeCollection& inProp, PxU32 ) |
161 | { |
162 | mFilter.mOperator.pushName( "Shapes" ); |
163 | mFilter.mOperator.handleShapes( inProp ); |
164 | mFilter.mOperator.popName(); |
165 | } |
166 | |
167 | void operator()( const PxArticulationLinkCollectionProp& inProp, PxU32 ) |
168 | { |
169 | mFilter.mOperator.pushName( "Links" ); |
170 | mFilter.mOperator.handleArticulationLinks( inProp ); |
171 | mFilter.mOperator.popName(); |
172 | } |
173 | |
174 | void operator()( const PxShapeMaterialsProperty& inProp, PxU32 ) |
175 | { |
176 | mFilter.mOperator.pushName( "Materials" ); |
177 | mFilter.mOperator.handleShapeMaterials( inProp ); |
178 | mFilter.mOperator.popName(); |
179 | } |
180 | |
181 | void operator()( const TIncomingJointPropType& inProp, PxU32 ) |
182 | { |
183 | mFilter.mOperator.handleIncomingJoint( inProp ); |
184 | } |
185 | |
186 | void operator()( const PxShapeGeometryProperty& inProp, PxU32 ) |
187 | { |
188 | mFilter.mOperator.handleGeometryProperty( inProp ); |
189 | } |
190 | |
191 | #define DEFINE_REPX_PROPERTY_NOP(datatype) \ |
192 | template<PxU32 TKey, typename TObjType, typename TSetPropType> \ |
193 | void operator()( const PxPropertyInfo<TKey,TObjType,TSetPropType,datatype>&, PxU32 ){} |
194 | |
195 | DEFINE_REPX_PROPERTY_NOP( const void* ) |
196 | DEFINE_REPX_PROPERTY_NOP( void* ) |
197 | DEFINE_REPX_PROPERTY_NOP( PxSimulationFilterCallback * ) |
198 | DEFINE_REPX_PROPERTY_NOP( physx::PxTaskManager * ) |
199 | DEFINE_REPX_PROPERTY_NOP( PxSimulationFilterShader * ) |
200 | DEFINE_REPX_PROPERTY_NOP( PxSimulationFilterShader) |
201 | DEFINE_REPX_PROPERTY_NOP( PxContactModifyCallback * ) |
202 | DEFINE_REPX_PROPERTY_NOP( PxCCDContactModifyCallback * ) |
203 | DEFINE_REPX_PROPERTY_NOP( PxSimulationEventCallback * ) |
204 | DEFINE_REPX_PROPERTY_NOP( physx::PxCudaContextManager* ) |
205 | DEFINE_REPX_PROPERTY_NOP( physx::PxCpuDispatcher * ) |
206 | DEFINE_REPX_PROPERTY_NOP( PxRigidActor ) |
207 | DEFINE_REPX_PROPERTY_NOP( const PxRigidActor ) |
208 | DEFINE_REPX_PROPERTY_NOP( PxRigidActor& ) |
209 | DEFINE_REPX_PROPERTY_NOP( const PxRigidActor& ) |
210 | DEFINE_REPX_PROPERTY_NOP( PxScene* ) |
211 | DEFINE_REPX_PROPERTY_NOP( PxAggregate * ) |
212 | DEFINE_REPX_PROPERTY_NOP( PxArticulation& ) |
213 | DEFINE_REPX_PROPERTY_NOP( PxArticulationReducedCoordinate& ) |
214 | DEFINE_REPX_PROPERTY_NOP( const PxArticulationLink * ) |
215 | DEFINE_REPX_PROPERTY_NOP( const PxRigidDynamic * ) |
216 | DEFINE_REPX_PROPERTY_NOP( const PxRigidStatic * ) |
217 | DEFINE_REPX_PROPERTY_NOP( PxStridedData ) //These are handled in a custom fasion. |
218 | }; |
219 | } |
220 | |
221 | #endif |
222 | |