RavEngine
Loading...
Searching...
No Matches
DySolverConstraintDesc.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_SOLVER_CONSTRAINT_DESC_H
30#define DY_SOLVER_CONSTRAINT_DESC_H
31
32#include "PxvConfig.h"
33#include "DySolverConstraintTypes.h"
34#include "foundation/PxUtilities.h"
35#include "PxConstraintDesc.h"
36#include "solver/PxSolverDefs.h"
37
38namespace physx
39{
40struct PxcNpWorkUnit;
41struct PxsContactManagerOutput;
42
43namespace Cm
44{
45 class SpatialVector;
46}
47
48struct PxSolverBody;
49struct PxSolverBodyData;
50
51namespace Dy
52{
53class FeatherstoneArticulation;
54struct FsData;
55
56// dsequeira: moved this articulation stuff here to sever a build dep on Articulation.h through DyThreadContext.h and onward
57
59{
60 PxU32 startId;
61 PxU32 numSelfConstraints;
62 PxU16 fsDataLength;
63 PxU16 requiredSolverProgress;
64 uintptr_t eaFsData;
65};
66
67//This class rolls together multiple contact managers into a single contact manager.
69{
70 PxU32 mStartIndex;
71 PxU16 mStride;
72 PxU16 mReducedContactCount;
73 PxU16 originalContactCount;
74 PxU8 originalPatchCount;
75 PxU8 originalStatusFlags;
76
77 PxcNpWorkUnit* unit; //This is a work unit but the contact buffer has been adjusted to contain all the contacts for all the subsequent pairs
78 PxsContactManagerOutput* cmOutput;
79 PxU8* originalContactPatches; //This is the original contact buffer that we replaced with a combined buffer
80 PxU8* originalContactPoints;
81
82 PxReal* originalForceBuffer; //This is the original force buffer that we replaced with a combined force buffer
83 PxU16* forceBufferList; //This is a list of indices from the reduced force buffer to the original force buffers - we need this to fix up the write-backs from the solver
84};
85
87{
88enum Enum
89{
90 eOUT_OF_MEMORY,
91 eUNBATCHABLE,
92 eSUCCESS
93};
94};
95
96PX_FORCE_INLINE bool isArticulationConstraint(const PxSolverConstraintDesc& desc)
97{
98 return (desc.linkIndexA != PxSolverConstraintDesc::RIGID_BODY ) ||
99 (desc.linkIndexB != PxSolverConstraintDesc::RIGID_BODY);
100}
101
102
103PX_FORCE_INLINE void setConstraintLength(PxSolverConstraintDesc& desc, const PxU32 constraintLength)
104{
105 PX_ASSERT(0==(constraintLength & 0x0f));
106 PX_ASSERT(constraintLength <= PX_MAX_U16 * 16);
107 desc.constraintLengthOver16 = PxTo16(constraintLength >> 4);
108}
109
110PX_FORCE_INLINE PxU32 getConstraintLength(const PxSolverConstraintDesc& desc)
111{
112 return PxU32(desc.constraintLengthOver16 << 4);
113}
114
115PX_FORCE_INLINE Dy::FeatherstoneArticulation* getArticulationA(const PxSolverConstraintDesc& desc)
116{
117 return reinterpret_cast<Dy::FeatherstoneArticulation*>(desc.articulationA);
118}
119
120PX_FORCE_INLINE Dy::FeatherstoneArticulation* getArticulationB(const PxSolverConstraintDesc& desc)
121{
122 return reinterpret_cast<Dy::FeatherstoneArticulation*>(desc.articulationB);
123}
124
125PX_COMPILE_TIME_ASSERT(0 == (0x0f & sizeof(PxSolverConstraintDesc)));
126
127#define MAX_PERMITTED_SOLVER_PROGRESS 0xFFFF
128
129}
130
131}
132
133#endif
#define PX_FORCE_INLINE
Definition PxPreprocessor.h:335
#define PX_COMPILE_TIME_ASSERT(exp)
Definition PxPreprocessor.h:428
Sorts an array of objects in ascending order, assuming that the predicate implements the < operator:
Definition PxBoxController.h:39
Definition DySolverConstraintDesc.h:69
Definition DySolverConstraintDesc.h:59
Definition DySolverConstraintDesc.h:87
Constraint descriptor used inside the solver.
Definition PxSolverDefs.h:108
PxU16 constraintLengthOver16
constraintLength/16, max constraint length is 1MB, allows PxSolverConstraintDesc to fit in 32 bytes
Definition PxSolverDefs.h:140
PxU32 linkIndexB
Link index defining which link in Articulation B this constraint affects. If not an articulation,...
Definition PxSolverDefs.h:134
PxU32 linkIndexA
Link index defining which link in Articulation A this constraint affects. If not an articulation,...
Definition PxSolverDefs.h:133
Definition PxcNpWorkUnit.h:81