RavEngine
Loading...
Searching...
No Matches
DyThreadContext.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 DY_THREAD_CONTEXT_H
30#define DY_THREAD_CONTEXT_H
31
32#include "foundation/PxTransform.h"
33#include "geomutils/PxContactBuffer.h"
34
35#include "PxvConfig.h"
36#include "PxvDynamics.h"
37#include "PxcThreadCoherentCache.h"
38#include "PxcConstraintBlockStream.h"
39#include "foundation/PxBitMap.h"
40#include "DyThresholdTable.h"
41#include "DyVArticulation.h"
42#include "DyFrictionPatchStreamPair.h"
43#include "DySolverConstraintDesc.h"
44#include "DyCorrelationBuffer.h"
45#include "foundation/PxAllocator.h"
46
47namespace physx
48{
49struct PxsIndexedContactManager;
50
51namespace Dy
52{
53
64 public PxcThreadCoherentCache<ThreadContext, PxcNpMemBlockPool>::EntryBase
65{
66 PX_NOCOPY(ThreadContext)
67public:
68
69#if PX_ENABLE_SIM_STATS
70 struct ThreadSimStats
71 {
72 void clear()
73 {
74
75 numActiveConstraints = 0;
76 numActiveDynamicBodies = 0;
77 numActiveKinematicBodies = 0;
78 numAxisSolverConstraints = 0;
79
80 }
81
82 PxU32 numActiveConstraints;
83 PxU32 numActiveDynamicBodies;
84 PxU32 numActiveKinematicBodies;
85 PxU32 numAxisSolverConstraints;
86
87 };
88#else
89 PX_CATCH_UNDEFINED_ENABLE_SIM_STATS
90#endif
91
92 //TODO: tune cache size based on number of active objects.
93 ThreadContext(PxcNpMemBlockPool* memBlockPool);
94 void reset();
95 void resizeArrays(PxU32 frictionConstraintDescCount, PxU32 articulationCount);
96
97 PX_FORCE_INLINE PxArray<ArticulationSolverDesc>& getArticulations() { return mArticulations; }
98
99
100#if PX_ENABLE_SIM_STATS
101 PX_FORCE_INLINE ThreadSimStats& getSimStats()
102 {
103 return mThreadSimStats;
104 }
105#else
106 PX_CATCH_UNDEFINED_ENABLE_SIM_STATS
107#endif
108
109 PxContactBuffer mContactBuffer;
110
111 // temporary buffer for correlation
112 PX_ALIGN(16, CorrelationBuffer mCorrelationBuffer);
113
114 FrictionPatchStreamPair mFrictionPatchStreamPair; // patch streams
115
116 PxsConstraintBlockManager mConstraintBlockManager; // for when this thread context is "lead" on an island
117 PxcConstraintBlockStream mConstraintBlockStream; // constraint block pool
118
119
120 // this stuff is just used for reformatting the solver data. Hopefully we should have a more
121 // sane format for this when the dust settles - so it's just temporary. If we keep this around
122 // here we should move these from public to private
123
124 PxU32 mNumDifferentBodyConstraints;
125 PxU32 mNumDifferentBodyFrictionConstraints;
126 PxU32 mNumSelfConstraints;
127 PxU32 mNumStaticConstraints;
128 PxU32 mNumSelfFrictionConstraints;
129 PxU32 mNumSelfConstraintFrictionBlocks;
130 bool mHasOverflowPartitions;
131
132 PxArray<PxU32> mConstraintsPerPartition;
133 PxArray<PxU32> mFrictionConstraintsPerPartition;
134 PxArray<PxU32> mPartitionNormalizationBitmap;
135 PxsBodyCore** mBodyCoreArray;
136 PxsRigidBody** mRigidBodyArray;
137 FeatherstoneArticulation** mArticulationArray;
138 Cm::SpatialVector* motionVelocityArray;
139 PxU32* bodyRemapTable;
140 PxU32* mNodeIndexArray;
141
142 //Constraint info for normal constraint sovler
143 PxSolverConstraintDesc* contactConstraintDescArray;
144 PxU32 contactDescArraySize;
145 PxSolverConstraintDesc* orderedContactConstraints;
146 PxConstraintBatchHeader* contactConstraintBatchHeaders;
147 PxU32 numContactConstraintBatches;
148
149 //Constraint info for partitioning
150 PxSolverConstraintDesc* tempConstraintDescArray;
151
152 //Additional constraint info for 1d/2d friction model
153 PxArray<PxSolverConstraintDesc> frictionConstraintDescArray;
154 PxArray<PxConstraintBatchHeader> frictionConstraintBatchHeaders;
155
156 //Info for tracking compound contact managers (temporary data - could use scratch memory!)
157 PxArray<CompoundContactManager> compoundConstraints;
158
159 //Used for sorting constraints. Temporary, could use scratch memory
162 PxArray<PxU32> sortIndexArray;
163
166
167
168 PxU32 numDifferentBodyBatchHeaders;
169 PxU32 numSelfConstraintBatchHeaders;
170
171
172 PxU32 mOrderedContactDescCount;
173 PxU32 mOrderedFrictionDescCount;
174
175 PxU32 mConstraintSize;
176
177 PxU32 mAxisConstraintCount;
178 SelfConstraintBlock* mSelfConstraintBlocks;
179
180 SelfConstraintBlock* mSelfConstraintFrictionBlocks;
181
182 PxU32 mMaxPartitions;
183 PxU32 mMaxFrictionPartitions;
184 PxU32 mMaxSolverPositionIterations;
185 PxU32 mMaxSolverVelocityIterations;
186 PxU32 mMaxArticulationLinks;
187
188 PxSolverConstraintDesc* mContactDescPtr;
189 PxSolverConstraintDesc* mStartContactDescPtr;
190 PxSolverConstraintDesc* mFrictionDescPtr;
191
192private:
193
194 PxArray<ArticulationSolverDesc> mArticulations;
195
196#if PX_ENABLE_SIM_STATS
197 ThreadSimStats mThreadSimStats;
198#else
199 PX_CATCH_UNDEFINED_ENABLE_SIM_STATS
200#endif
201
202 public:
203
204};
205
206}
207
208}
209
210#endif
Definition CmSpatialVector.h:46
Definition DyFeatherstoneArticulation.h:590
Definition DyThreadContext.h:65
Definition DyFrictionPatchStreamPair.h:57
Definition PxArray.h:53
Definition PxContactBuffer.h:42
Definition PxcConstraintBlockStream.h:60
Definition PxcNpMemBlockPool.h:52
Definition PxcThreadCoherentCache.h:52
Definition PxcConstraintBlockStream.h:40
Definition PxsRigidBody.h:43
#define PX_FORCE_INLINE
Definition PxPreprocessor.h:335
#define PX_ALIGN(alignment, decl)
Definition PxPreprocessor.h:402
Sorts an array of objects in ascending order, assuming that the predicate implements the < operator:
Definition PxBoxController.h:39
Definition DyCorrelationBuffer.h:51
Definition DySolverConstraintDesc.h:59
A header that defines the size of a specific batch of constraints (of same type and without dependenc...
Definition PxSolverDefs.h:98
Constraint descriptor used inside the solver.
Definition PxSolverDefs.h:108
Definition PxvDynamics.h:74