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#include "foundation/PxIO.h"
31#include "ScActorCore.h"
32#include "ScActorSim.h"
33#include "ScBodyCore.h"
34#include "ScStaticCore.h"
35#include "ScConstraintCore.h"
36#include "ScMaterialCore.h"
37#include "ScShapeCore.h"
38#include "ScArticulationCore.h"
39#include "ScArticulationJointCore.h"
40
41using namespace physx;
42using namespace Ps;
43using namespace Cm;
44using namespace Sc;
45
46///////////////////////////////////////////////////////////////////////////////
47
48template <typename T> class PxMetaDataArray : public physx::shdfnd::Array<T>
49{
50public:
51 static PX_FORCE_INLINE physx::PxU32 getDataOffset() { return PX_OFFSET_OF(PxMetaDataArray<T>, mData); }
52 static PX_FORCE_INLINE physx::PxU32 getDataSize() { return PX_SIZE_OF(PxMetaDataArray<T>, mData); }
53 static PX_FORCE_INLINE physx::PxU32 getSizeOffset() { return PX_OFFSET_OF(PxMetaDataArray<T>, mSize); }
54 static PX_FORCE_INLINE physx::PxU32 getSizeSize() { return PX_SIZE_OF(PxMetaDataArray<T>, mSize); }
55 static PX_FORCE_INLINE physx::PxU32 getCapacityOffset() { return PX_OFFSET_OF(PxMetaDataArray<T>, mCapacity); }
56 static PX_FORCE_INLINE physx::PxU32 getCapacitySize() { return PX_SIZE_OF(PxMetaDataArray<T>, mCapacity); }
57};
58
59void Sc::ActorCore::getBinaryMetaData(PxOutputStream& stream)
60{
61 PX_DEF_BIN_METADATA_TYPEDEF(stream, PxActorFlags, PxU8)
62 PX_DEF_BIN_METADATA_TYPEDEF(stream, PxDominanceGroup, PxU8)
63 PX_DEF_BIN_METADATA_TYPEDEF(stream, PxClientID, PxU8)
64
65 PX_DEF_BIN_METADATA_CLASS(stream, Sc::ActorCore)
66
67 PX_DEF_BIN_METADATA_ITEM(stream, Sc::ActorCore, ActorSim, mSim, PxMetaDataFlag::ePTR)
68 PX_DEF_BIN_METADATA_ITEM(stream, Sc::ActorCore, PxU32, mAggregateIDOwnerClient, 0)
69 PX_DEF_BIN_METADATA_ITEM(stream, Sc::ActorCore, PxActorFlags, mActorFlags, 0)
70 PX_DEF_BIN_METADATA_ITEM(stream, Sc::ActorCore, PxU8, mActorType, 0)
71 PX_DEF_BIN_METADATA_ITEM(stream, Sc::ActorCore, PxU8, mDominanceGroup, 0)
72}
73
74///////////////////////////////////////////////////////////////////////////////
75
76static void getBinaryMetaData_PxsRigidCore(PxOutputStream& stream)
77{
78 PX_DEF_BIN_METADATA_CLASS(stream, PxsRigidCore)
79
80 PX_DEF_BIN_METADATA_ITEM(stream, PxsBodyCore, PxTransform, body2World, 0)
81 PX_DEF_BIN_METADATA_ITEM(stream, PxsBodyCore, PxRigidBodyFlags, mFlags, 0)
82 PX_DEF_BIN_METADATA_ITEM(stream, PxsBodyCore, PxU16, solverIterationCounts, 0)
83}
84
85namespace
86{
87 class ShadowPxsBodyCore : public PxsBodyCore
88 {
89 public:
90 static void getBinaryMetaData(PxOutputStream& stream)
91 {
92 PX_DEF_BIN_METADATA_CLASS(stream, ShadowPxsBodyCore)
93 PX_DEF_BIN_METADATA_BASE_CLASS(stream, ShadowPxsBodyCore, PxsRigidCore)
94
95 PX_DEF_BIN_METADATA_ITEM(stream, ShadowPxsBodyCore, PxTransform, body2Actor, 0)
96 PX_DEF_BIN_METADATA_ITEM(stream, ShadowPxsBodyCore, PxReal, ccdAdvanceCoefficient, 0)
97 PX_DEF_BIN_METADATA_ITEM(stream, ShadowPxsBodyCore, PxVec3, linearVelocity, 0)
98 PX_DEF_BIN_METADATA_ITEM(stream, ShadowPxsBodyCore, PxReal, maxPenBias, 0)
99 PX_DEF_BIN_METADATA_ITEM(stream, ShadowPxsBodyCore, PxVec3, angularVelocity, 0)
100 PX_DEF_BIN_METADATA_ITEM(stream, ShadowPxsBodyCore, PxReal, contactReportThreshold, 0)
101 PX_DEF_BIN_METADATA_ITEM(stream, ShadowPxsBodyCore, PxReal, maxAngularVelocitySq, 0)
102 PX_DEF_BIN_METADATA_ITEM(stream, ShadowPxsBodyCore, PxReal, maxLinearVelocitySq, 0)
103 PX_DEF_BIN_METADATA_ITEM(stream, ShadowPxsBodyCore, PxReal, linearDamping, 0)
104 PX_DEF_BIN_METADATA_ITEM(stream, ShadowPxsBodyCore, PxReal, angularDamping, 0)
105 PX_DEF_BIN_METADATA_ITEM(stream, ShadowPxsBodyCore, PxVec3, inverseInertia, 0)
106 PX_DEF_BIN_METADATA_ITEM(stream, ShadowPxsBodyCore, PxReal, inverseMass, 0)
107 PX_DEF_BIN_METADATA_ITEM(stream, ShadowPxsBodyCore, PxReal, maxContactImpulse, 0)
108 PX_DEF_BIN_METADATA_ITEM(stream, ShadowPxsBodyCore, PxReal, sleepThreshold, 0)
109 PX_DEF_BIN_METADATA_ITEM(stream, ShadowPxsBodyCore, PxReal, freezeThreshold, 0)
110 PX_DEF_BIN_METADATA_ITEM(stream, ShadowPxsBodyCore, PxReal, wakeCounter, 0)
111 PX_DEF_BIN_METADATA_ITEM(stream, ShadowPxsBodyCore, PxReal, solverWakeCounter, 0)
112 PX_DEF_BIN_METADATA_ITEM(stream, ShadowPxsBodyCore, PxU32, numCountedInteractions, 0)
113 PX_DEF_BIN_METADATA_ITEM(stream, ShadowPxsBodyCore, PxU32, numBodyInteractions, 0)
114 PX_DEF_BIN_METADATA_ITEM(stream, ShadowPxsBodyCore, PxU8, isFastMoving, 0)
115 PX_DEF_BIN_METADATA_ITEM(stream, ShadowPxsBodyCore, PxU8, disableGravity, 0)
116 PX_DEF_BIN_METADATA_ITEM(stream, ShadowPxsBodyCore, PxU8, lockFlags, 0)
117 PX_DEF_BIN_METADATA_ITEM(stream, ShadowPxsBodyCore, PxU8, kinematicLink, 0)
118 }
119 };
120}
121
122static void getBinaryMetaData_PxsBodyCore(PxOutputStream& stream)
123{
124 getBinaryMetaData_PxsRigidCore(stream);
125
126/* PX_DEF_BIN_METADATA_CLASS(stream, PxsBodyCore)
127 PX_DEF_BIN_METADATA_BASE_CLASS(stream, PxsBodyCore, PxsRigidCore)
128
129 PX_DEF_BIN_METADATA_ITEM(stream, PxsBodyCore, PxTransform, body2Actor, 0)
130 PX_DEF_BIN_METADATA_ITEM(stream, PxsBodyCore, PxReal, ccdAdvanceCoefficient, 0)
131 PX_DEF_BIN_METADATA_ITEM(stream, PxsBodyCore, PxVec3, linearVelocity, 0)
132 PX_DEF_BIN_METADATA_ITEM(stream, PxsBodyCore, PxReal, maxPenBias, 0)
133 PX_DEF_BIN_METADATA_ITEM(stream, PxsBodyCore, PxVec3, angularVelocity, 0)
134 PX_DEF_BIN_METADATA_ITEM(stream, PxsBodyCore, PxReal, contactReportThreshold, 0)
135 PX_DEF_BIN_METADATA_ITEM(stream, PxsBodyCore, PxReal, maxAngularVelocitySq, 0)
136 PX_DEF_BIN_METADATA_ITEM(stream, PxsBodyCore, PxReal, maxLinearVelocitySq, 0)
137 PX_DEF_BIN_METADATA_ITEM(stream, PxsBodyCore, PxReal, linearDamping, 0)
138 PX_DEF_BIN_METADATA_ITEM(stream, PxsBodyCore, PxReal, angularDamping, 0)
139 PX_DEF_BIN_METADATA_ITEM(stream, PxsBodyCore, PxVec3, inverseInertia, 0)
140 PX_DEF_BIN_METADATA_ITEM(stream, PxsBodyCore, PxReal, inverseMass, 0)
141 PX_DEF_BIN_METADATA_ITEM(stream, PxsBodyCore, PxReal, maxContactImpulse, 0)
142 PX_DEF_BIN_METADATA_ITEM(stream, PxsBodyCore, PxReal, sleepThreshold, 0)
143 PX_DEF_BIN_METADATA_ITEM(stream, PxsBodyCore, PxReal, freezeThreshold, 0)
144 PX_DEF_BIN_METADATA_ITEM(stream, PxsBodyCore, PxReal, wakeCounter, 0)
145 PX_DEF_BIN_METADATA_ITEM(stream, PxsBodyCore, PxReal, solverWakeCounter, 0)
146 PX_DEF_BIN_METADATA_ITEM(stream, PxsBodyCore, PxU32, numCountedInteractions, 0)*/
147
148 ShadowPxsBodyCore::getBinaryMetaData(stream);
149 PX_DEF_BIN_METADATA_TYPEDEF(stream, PxsBodyCore, ShadowPxsBodyCore)
150}
151
152/*
153We need to fix the header deps by moving the API out of PhysXCore and into its own dir where other code can get to it.
154[25.08.2010 18:34:57] Dilip Sequeira: In the meantime, I think it's Ok to include PxSDK.h, but you're right, we need to be very careful about include deps in that direction.
155[25.08.2010 18:38:15] Dilip Sequeira: On the memory thing... PxsBodyCore has 28 bytes of padding at the end, for no reason. In addition, it has two words of padding after the velocity fields, to facilitate SIMD loads. But in fact, Vec3FromVec4 is fast enough such that unless you were using it in an inner loop (which we never are with PxsBodyCore) that padding isn't worth it.
156[25.08.2010 18:38:58] Dilip Sequeira: So, we should drop the end-padding, and move the damping values to replace the velocity padding. This probably requires a bit of fixup in the places where we do SIMD writes to the velocity.
157[25.08.2010 18:39:18] Dilip Sequeira: Then we're down to 92 bytes of data, and 4 bytes of padding I think.
158[25.08.2010 18:50:41] Dilip Sequeira: The reason we don't want to put the sleep data there explicitly is that it isn't LL data so I'd rather not have it in an LL interface struct.
159[25.08.2010 19:04:53] Gordon Yeoman nvidia: simd loads are faster when they are 16-byte aligned. I think the padding might be to ensure the second vector is also 16-byte aligned. We could drop the second 4-byte pad but dropping the 1st 4-byte pad will likely have performance implications.
160[25.08.2010 19:06:22] Dilip Sequeira: We should still align the vec3s, as now - but we shouldn't use padding to do it, since there are a boatload of scalar data fields floating around in that struct too.
161*/
162void Sc::BodyCore::getBinaryMetaData(PxOutputStream& stream)
163{
164 getBinaryMetaData_PxsBodyCore(stream);
165 PX_DEF_BIN_METADATA_TYPEDEF(stream, PxRigidBodyFlags, PxU16)
166
167 PX_DEF_BIN_METADATA_CLASS(stream, Sc::BodyCore)
168 PX_DEF_BIN_METADATA_BASE_CLASS(stream, Sc::BodyCore, Sc::RigidCore)
169
170 PX_DEF_BIN_METADATA_ITEM(stream, Sc::BodyCore, PxsBodyCore, mCore, 0)
171 PX_DEF_BIN_METADATA_ITEM(stream, Sc::BodyCore, SimStateData, mSimStateData, PxMetaDataFlag::ePTR)
172}
173
174///////////////////////////////////////////////////////////////////////////////
175
176void Sc::ConstraintCore::getBinaryMetaData(PxOutputStream& stream)
177{
178 PX_DEF_BIN_METADATA_TYPEDEF(stream, PxConstraintFlags, PxU16)
179
180 PX_DEF_BIN_METADATA_CLASS(stream, ConstraintCore)
181
182 PX_DEF_BIN_METADATA_ITEM(stream, ConstraintCore, PxConstraintFlags, mFlags, 0)
183 PX_DEF_BIN_METADATA_ITEM(stream, ConstraintCore, PxU16, mPaddingFromFlags, PxMetaDataFlag::ePADDING)
184 PX_DEF_BIN_METADATA_ITEM(stream, ConstraintCore, PxVec3, mAppliedForce, 0)
185 PX_DEF_BIN_METADATA_ITEM(stream, ConstraintCore, PxVec3, mAppliedTorque, 0)
186 PX_DEF_BIN_METADATA_ITEM(stream, ConstraintCore, PxConstraintConnector, mConnector, PxMetaDataFlag::ePTR)
187 PX_DEF_BIN_METADATA_ITEM(stream, ConstraintCore, PxConstraintProject, mProject, PxMetaDataFlag::ePTR)
188 PX_DEF_BIN_METADATA_ITEM(stream, ConstraintCore, PxConstraintSolverPrep, mSolverPrep, PxMetaDataFlag::ePTR)
189 PX_DEF_BIN_METADATA_ITEM(stream, ConstraintCore, PxConstraintVisualize, mVisualize, PxMetaDataFlag::ePTR)
190 PX_DEF_BIN_METADATA_ITEM(stream, ConstraintCore, PxU32, mDataSize, 0)
191 PX_DEF_BIN_METADATA_ITEM(stream, ConstraintCore, PxReal, mLinearBreakForce, 0)
192 PX_DEF_BIN_METADATA_ITEM(stream, ConstraintCore, PxReal, mAngularBreakForce, 0)
193 PX_DEF_BIN_METADATA_ITEM(stream, ConstraintCore, PxReal, mMinResponseThreshold, 0)
194
195 PX_DEF_BIN_METADATA_ITEM(stream, ConstraintCore, ConstraintSim, mSim, PxMetaDataFlag::ePTR)
196}
197
198///////////////////////////////////////////////////////////////////////////////
199
200void Sc::MaterialCore::getBinaryMetaData(PxOutputStream& stream)
201{
202 PX_DEF_BIN_METADATA_TYPEDEF(stream, PxCombineMode::Enum, PxU32)
203 PX_DEF_BIN_METADATA_TYPEDEF(stream, PxMaterialFlags, PxU16)
204
205 PX_DEF_BIN_METADATA_CLASS(stream, MaterialCore)
206
207 // MaterialData
208 PX_DEF_BIN_METADATA_ITEM(stream, MaterialCore, PxReal, dynamicFriction, 0)
209 PX_DEF_BIN_METADATA_ITEM(stream, MaterialCore, PxReal, staticFriction, 0)
210 PX_DEF_BIN_METADATA_ITEM(stream, MaterialCore, PxReal, restitution, 0)
211
212 PX_DEF_BIN_METADATA_ITEM(stream, MaterialCore, PxMaterialFlags, flags, 0)
213 PX_DEF_BIN_METADATA_ITEM(stream, MaterialCore, PxU8, fricRestCombineMode, 0)
214 PX_DEF_BIN_METADATA_ITEM(stream, MaterialCore, PxU8, padding, PxMetaDataFlag::ePADDING)
215
216 // MaterialCore
217 PX_DEF_BIN_METADATA_ITEM(stream, MaterialCore, PxMaterial, mNxMaterial, PxMetaDataFlag::ePTR)
218 PX_DEF_BIN_METADATA_ITEM(stream, MaterialCore, PxU16, mMaterialIndex, PxMetaDataFlag::eHANDLE)
219 PX_DEF_BIN_METADATA_ITEM(stream, MaterialCore, PxU16, mPadding, PxMetaDataFlag::ePADDING)
220}
221
222///////////////////////////////////////////////////////////////////////////////
223
224void Sc::RigidCore::getBinaryMetaData(PxOutputStream& stream)
225{
226 PX_DEF_BIN_METADATA_CLASS(stream, Sc::RigidCore)
227 PX_DEF_BIN_METADATA_BASE_CLASS(stream, Sc::RigidCore, Sc::ActorCore)
228}
229
230
231///////////////////////////////////////////////////////////////////////////////
232
233void Sc::StaticCore::getBinaryMetaData(PxOutputStream& stream)
234{
235 PX_DEF_BIN_METADATA_CLASS(stream, Sc::StaticCore)
236 PX_DEF_BIN_METADATA_BASE_CLASS(stream, Sc::StaticCore, Sc::RigidCore)
237
238 PX_DEF_BIN_METADATA_ITEM(stream, Sc::StaticCore, PxsRigidCore, mCore, 0)
239
240}
241
242///////////////////////////////////////////////////////////////////////////////
243
244static void getBinaryMetaData_PxFilterData(PxOutputStream& stream)
245{
246 PX_DEF_BIN_METADATA_CLASS(stream, PxFilterData)
247
248 PX_DEF_BIN_METADATA_ITEM(stream, PxFilterData, PxU32, word0, 0)
249 PX_DEF_BIN_METADATA_ITEM(stream, PxFilterData, PxU32, word1, 0)
250 PX_DEF_BIN_METADATA_ITEM(stream, PxFilterData, PxU32, word2, 0)
251 PX_DEF_BIN_METADATA_ITEM(stream, PxFilterData, PxU32, word3, 0)
252}
253
254static void getBinaryMetaData_PxsShapeCore(PxOutputStream& stream)
255{
256 PX_DEF_BIN_METADATA_CLASS(stream, PxsShapeCore)
257
258 PX_DEF_BIN_METADATA_ITEM(stream, PxsShapeCore, PxTransform, transform, 0)
259 PX_DEF_BIN_METADATA_ITEM(stream, PxsShapeCore, Gu::GeometryUnion, geometry, 0)
260 PX_DEF_BIN_METADATA_ITEM(stream, PxsShapeCore, PxReal, contactOffset, 0)
261 PX_DEF_BIN_METADATA_ITEM(stream, PxsShapeCore, PxShapeFlags, mShapeFlags, 0)
262 PX_DEF_BIN_METADATA_ITEM(stream, PxsShapeCore, PxU8, mOwnsMaterialIdxMemory, 0)
263 PX_DEF_BIN_METADATA_ITEM(stream, PxsShapeCore, PxU16, materialIndex, PxMetaDataFlag::eHANDLE)
264}
265
266void Sc::ShapeCore::getBinaryMetaData(PxOutputStream& stream)
267{
268 getBinaryMetaData_PxFilterData(stream);
269 getBinaryMetaData_PxsShapeCore(stream);
270
271 PX_DEF_BIN_METADATA_TYPEDEF(stream, PxShapeFlags, PxU8)
272
273 PX_DEF_BIN_METADATA_CLASS(stream, ShapeCore)
274
275 PX_DEF_BIN_METADATA_ITEM(stream, ShapeCore, PxFilterData, mQueryFilterData, 0)
276 PX_DEF_BIN_METADATA_ITEM(stream, ShapeCore, PxFilterData, mSimulationFilterData, 0)
277 PX_DEF_BIN_METADATA_ITEM(stream, ShapeCore, PxsShapeCore, mCore, 0)
278 PX_DEF_BIN_METADATA_ITEM(stream, ShapeCore, PxReal, mRestOffset, 0)
279 PX_DEF_BIN_METADATA_ITEM(stream, ShapeCore, PxReal, mTorsionalRadius, 0)
280 PX_DEF_BIN_METADATA_ITEM(stream, ShapeCore, PxReal, mMinTorsionalPatchRadius, 0)
281}
282
283///////////////////////////////////////////////////////////////////////////////
284
285static void getBinaryMetaData_ArticulationCore(PxOutputStream& stream)
286{
287 PX_DEF_BIN_METADATA_CLASS(stream, Dy::ArticulationCore)
288
289 PX_DEF_BIN_METADATA_TYPEDEF(stream, PxArticulationFlags, PxU8)
290
291 PX_DEF_BIN_METADATA_ITEM(stream, Dy::ArticulationCore, PxU32, internalDriveIterations, 0)
292 PX_DEF_BIN_METADATA_ITEM(stream, Dy::ArticulationCore, PxU32, externalDriveIterations, 0)
293 PX_DEF_BIN_METADATA_ITEM(stream, Dy::ArticulationCore, PxU32, maxProjectionIterations, 0)
294 PX_DEF_BIN_METADATA_ITEM(stream, Dy::ArticulationCore, PxU16, solverIterationCounts, 0)
295 PX_DEF_BIN_METADATA_ITEM(stream, Dy::ArticulationCore, PxReal, separationTolerance, 0)
296 PX_DEF_BIN_METADATA_ITEM(stream, Dy::ArticulationCore, PxReal, sleepThreshold, 0)
297 PX_DEF_BIN_METADATA_ITEM(stream, Dy::ArticulationCore, PxReal, freezeThreshold, 0)
298 PX_DEF_BIN_METADATA_ITEM(stream, Dy::ArticulationCore, PxReal, wakeCounter, 0)
299 PX_DEF_BIN_METADATA_ITEM(stream, Dy::ArticulationCore, PxArticulationFlags, flags, 0)
300}
301
302void Sc::ArticulationCore::getBinaryMetaData(PxOutputStream& stream)
303{
304 getBinaryMetaData_ArticulationCore(stream);
305
306 PX_DEF_BIN_METADATA_CLASS(stream, ArticulationCore)
307
308 PX_DEF_BIN_METADATA_ITEM(stream, ArticulationCore, ArticulationSim, mSim, PxMetaDataFlag::ePTR)
309 PX_DEF_BIN_METADATA_ITEM(stream, ArticulationCore, Dy::ArticulationCore, mCore, 0)
310 PX_DEF_BIN_METADATA_ITEM(stream, ArticulationCore, bool, mIsReducedCoordinate, 0)
311}
312
313///////////////////////////////////////////////////////////////////////////////
314
315static void getBinaryMetaData_ArticulationLimit(PxOutputStream& stream)
316{
317 PX_DEF_BIN_METADATA_CLASS(stream, PxArticulationLimit)
318 PX_DEF_BIN_METADATA_ITEM(stream, PxArticulationLimit, PxReal, low, 0)
319 PX_DEF_BIN_METADATA_ITEM(stream, PxArticulationLimit, PxReal, high, 0)
320}
321
322static void getBinaryMetaData_ArticulationDrive(PxOutputStream& stream)
323{
324 PX_DEF_BIN_METADATA_TYPEDEF(stream, PxArticulationDriveType::Enum, PxU32)
325
326 PX_DEF_BIN_METADATA_CLASS(stream, PxArticulationDrive)
327 PX_DEF_BIN_METADATA_ITEM(stream, PxArticulationDrive, PxReal, stiffness, 0)
328 PX_DEF_BIN_METADATA_ITEM(stream, PxArticulationDrive, PxReal, damping, 0)
329 PX_DEF_BIN_METADATA_ITEM(stream, PxArticulationDrive, PxReal, maxForce, 0)
330 PX_DEF_BIN_METADATA_ITEM(stream, PxArticulationDrive, PxArticulationDriveType::Enum, driveType, 0)
331}
332
333static void getBinaryMetaData_ArticulationJointCoreBase(PxOutputStream& stream)
334{
335 getBinaryMetaData_ArticulationLimit(stream);
336 getBinaryMetaData_ArticulationDrive(stream);
337
338 PX_DEF_BIN_METADATA_CLASS(stream, Dy::ArticulationJointCoreBase)
339
340 PX_DEF_BIN_METADATA_TYPEDEF(stream, ArticulationJointCoreDirtyFlags, PxU8)
341
342 PX_DEF_BIN_METADATA_ITEM(stream, Dy::ArticulationJointCoreBase, PxTransform, parentPose, 0)
343 PX_DEF_BIN_METADATA_ITEM(stream, Dy::ArticulationJointCoreBase, PxTransform, childPose, 0)
344
345 PX_DEF_BIN_METADATA_ITEMS_AUTO(stream, Dy::ArticulationJointCoreBase, PxArticulationLimit, limits, 0)
346 PX_DEF_BIN_METADATA_ITEMS_AUTO(stream, Dy::ArticulationJointCoreBase, PxArticulationDrive, drives, 0)
347
348 PX_DEF_BIN_METADATA_ITEMS_AUTO(stream, Dy::ArticulationJointCoreBase, PxReal, targetP, 0)
349 PX_DEF_BIN_METADATA_ITEMS_AUTO(stream, Dy::ArticulationJointCoreBase, PxReal, targetV, 0)
350
351 PX_DEF_BIN_METADATA_ITEM(stream, Dy::ArticulationJointCoreBase, PxReal, frictionCoefficient, 0)
352
353 PX_DEF_BIN_METADATA_ITEMS_AUTO(stream, Dy::ArticulationJointCoreBase, PxU8, dofIds, 0)
354
355 PX_DEF_BIN_METADATA_ITEMS_AUTO(stream, Dy::ArticulationJointCoreBase, PxU8, motion, 0)
356
357 PX_DEF_BIN_METADATA_ITEM(stream, Dy::ArticulationJointCoreBase, PxReal, maxJointVelocity, 0)
358
359 PX_DEF_BIN_METADATA_ITEM(stream, Dy::ArticulationJointCoreBase, ArticulationJointCoreDirtyFlags, dirtyFlag, 0)
360
361 PX_DEF_BIN_METADATA_ITEM(stream, Dy::ArticulationJointCoreBase, PxU8, jointOffset, 0)
362
363 PX_DEF_BIN_METADATA_ITEM(stream, Dy::ArticulationJointCoreBase, PxU8, jointType, 0)
364}
365
366
367static void getBinaryMetaData_ArticulationJointCore(PxOutputStream& stream)
368{
369 getBinaryMetaData_ArticulationJointCoreBase(stream);
370 PX_DEF_BIN_METADATA_CLASS(stream, Dy::ArticulationJointCore)
371 PX_DEF_BIN_METADATA_BASE_CLASS(stream, Dy::ArticulationJointCore, Dy::ArticulationJointCoreBase)
372
373 PX_DEF_BIN_METADATA_ITEM(stream, Dy::ArticulationJointCore, PxQuat, targetPosition, 0)
374 PX_DEF_BIN_METADATA_ITEM(stream, Dy::ArticulationJointCore, PxVec3, targetVelocity, 0)
375
376 PX_DEF_BIN_METADATA_ITEM(stream, Dy::ArticulationJointCore, PxReal, spring, 0)
377 PX_DEF_BIN_METADATA_ITEM(stream, Dy::ArticulationJointCore, PxReal, damping, 0)
378 PX_DEF_BIN_METADATA_ITEM(stream, Dy::ArticulationJointCore, PxReal, internalCompliance, 0)
379 PX_DEF_BIN_METADATA_ITEM(stream, Dy::ArticulationJointCore, PxReal, externalCompliance, 0)
380
381 PX_DEF_BIN_METADATA_ITEM(stream, Dy::ArticulationJointCore, PxReal, swingLimitContactDistance, 0)
382 PX_DEF_BIN_METADATA_ITEM(stream, Dy::ArticulationJointCore, PxReal, tangentialStiffness, 0)
383 PX_DEF_BIN_METADATA_ITEM(stream, Dy::ArticulationJointCore, PxReal, tangentialDamping, 0)
384
385 PX_DEF_BIN_METADATA_ITEM(stream, Dy::ArticulationJointCore, bool, swingLimited, 0)
386 PX_DEF_BIN_METADATA_ITEM(stream, Dy::ArticulationJointCore, bool, twistLimited, 0)
387
388 PX_DEF_BIN_METADATA_ITEM(stream, Dy::ArticulationJointCore, PxU8, driveType, 0)
389
390 PX_DEF_BIN_METADATA_ITEM(stream, Dy::ArticulationJointCore, PxReal, twistLimitContactDistance, 0)
391
392 PX_DEF_BIN_METADATA_ITEM(stream, Dy::ArticulationJointCore, PxReal, tanQSwingY, 0)
393 PX_DEF_BIN_METADATA_ITEM(stream, Dy::ArticulationJointCore, PxReal, tanQSwingZ, 0)
394 PX_DEF_BIN_METADATA_ITEM(stream, Dy::ArticulationJointCore, PxReal, tanQSwingPad, 0)
395 PX_DEF_BIN_METADATA_ITEM(stream, Dy::ArticulationJointCore, PxReal, tanQTwistHigh, 0)
396 PX_DEF_BIN_METADATA_ITEM(stream, Dy::ArticulationJointCore, PxReal, tanQTwistLow, 0)
397 PX_DEF_BIN_METADATA_ITEM(stream, Dy::ArticulationJointCore, PxReal, tanQTwistPad, 0)
398}
399
400void Sc::ArticulationJointCore::getBinaryMetaData(PxOutputStream& stream)
401{
402 getBinaryMetaData_ArticulationJointCore(stream);
403 PX_DEF_BIN_METADATA_CLASS(stream, ArticulationJointCore)
404 PX_DEF_BIN_METADATA_ITEM(stream, ArticulationJointCore, ArticulationJointSim, mSim, PxMetaDataFlag::ePTR)
405 PX_DEF_BIN_METADATA_ITEM(stream, ArticulationJointCore, Dy::ArticulationJointCore, mCore, 0)
406 PX_DEF_BIN_METADATA_ITEM(stream, ArticulationJointCore, Dy::ArticulationCore, mArticulation, PxMetaDataFlag::ePTR)
407 PX_DEF_BIN_METADATA_ITEM(stream, ArticulationJointCore, Dy::PxArticulationJointBase, mRootType, PxMetaDataFlag::ePTR)
408}
409
410///////////////////////////////////////////////////////////////////////////////
411
412#define PX_DEF_BIN_METADATA_ARRAY(stream, Class, type, array) \
413{ PxMetaDataEntry tmp = {"void", #array".mData", PxU32(PX_OFFSET_OF(Class, array)) + PxMetaDataArray<type>::getDataOffset(), PxMetaDataArray<type>::getDataSize(), 1, 0, PxMetaDataFlag::ePTR, 0}; PX_STORE_METADATA(stream, tmp); } \
414{ PxMetaDataEntry tmp = {"PxU32", #array".mSize", PxU32(PX_OFFSET_OF(Class, array)) + PxMetaDataArray<type>::getSizeOffset(), PxMetaDataArray<type>::getSizeSize(), 1, 0, 0, 0}; PX_STORE_METADATA(stream, tmp); } \
415{ PxMetaDataEntry tmp = {"PxU32", #array".mCapacity", PxU32(PX_OFFSET_OF(Class, array)) + PxMetaDataArray<type>::getCapacityOffset(), PxMetaDataArray<type>::getCapacitySize(), 1, 0, PxMetaDataFlag::eCOUNT_MASK_MSB, 0}; PX_STORE_METADATA(stream, tmp); } \
416{ PxMetaDataEntry tmp = {#type, 0, PxU32(PX_OFFSET_OF(Class, array)) + PxMetaDataArray<type>::getSizeOffset(), PxMetaDataArray<type>::getSizeSize(), 0, 0, PxMetaDataFlag::eEXTRA_DATA, 0}; PX_STORE_METADATA(stream, tmp); }
417
418
419
420
421
422

source code of qtquick3dphysics/src/3rdparty/PhysX/source/simulationcontroller/src/ScMetaData.cpp