RavEngine
Loading...
Searching...
No Matches
DyArticulationPImpl.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_ARTICULATION_INTERFACE_H
30#define DY_ARTICULATION_INTERFACE_H
31
32#include "DyArticulationUtils.h"
33
34namespace physx
35{
36namespace Dy
37{
38 struct ArticulationSolverDesc;
39
41{
42public:
43
44 typedef PxU32 (*ComputeUnconstrainedVelocitiesFn)(const ArticulationSolverDesc& desc,
45 PxReal dt,
46 PxU32& acCount,
47 const PxVec3& gravity,
49 const PxReal invLengthScale);
50
51 typedef void (*UpdateBodiesFn)(const ArticulationSolverDesc& desc, Cm::SpatialVectorF* deltaV, PxReal dt);
52
53 typedef void (*SaveVelocityFn)(const ArticulationSolverDesc &m, Cm::SpatialVectorF* deltaV);
54
55 typedef void(*SaveVelocityTGSFn)(const ArticulationSolverDesc& m, PxReal invDtF32);
56
57 typedef PxU32(*SetupInternalConstraintsTGSFn)(const ArticulationSolverDesc& desc,
58 PxReal dt,
59 PxReal invDt,
60 PxReal totalDt,
61 const PxReal biasCoefficient,
62 PxU32& acCount,
64
65 typedef void(*ComputeUnconstrainedVelocitiesTGSFn)(const ArticulationSolverDesc& desc,
66 PxReal dt,
67 const PxVec3& gravity, PxU64 contextID, Cm::SpatialVectorF* Z, Cm::SpatialVectorF* DeltaV,
68 const PxReal invLengthScale);
69
70 typedef void(*UpdateDeltaMotionFn)(const ArticulationSolverDesc &m, const PxReal dt, Cm::SpatialVectorF* DeltaV, const PxReal totalInvDt);
71
72 typedef void(*DeltaMotionToMotionVelFn)(const ArticulationSolverDesc &m, const PxReal dt);
73
74 static ComputeUnconstrainedVelocitiesFn sComputeUnconstrainedVelocities;
75 static UpdateBodiesFn sUpdateBodies;
76 static UpdateBodiesFn sUpdateBodiesTGS;
77 static SaveVelocityFn sSaveVelocity;
78 static SaveVelocityTGSFn sSaveVelocityTGS;
79
80 static UpdateDeltaMotionFn sUpdateDeltaMotion;
81 static DeltaMotionToMotionVelFn sDeltaMotionToMotionVel;
82 static ComputeUnconstrainedVelocitiesTGSFn sComputeUnconstrainedVelocitiesTGS;
83 static SetupInternalConstraintsTGSFn sSetupInternalConstraintsTGS;
84
85 static PxU32 computeUnconstrainedVelocities(const ArticulationSolverDesc& desc,
86 PxReal dt,
87 PxU32& acCount,
88 const PxVec3& gravity,
90 Cm::SpatialVectorF* deltaV,
91 const PxReal invLengthScale)
92 {
93 PX_ASSERT(sComputeUnconstrainedVelocities);
94 if (sComputeUnconstrainedVelocities)
95 return (sComputeUnconstrainedVelocities)(desc, dt, acCount,
96 gravity, Z, deltaV, invLengthScale);
97 else
98 return 0;
99 }
100
101 static void updateBodies(const ArticulationSolverDesc& desc, Cm::SpatialVectorF* tempDeltaV,
102 PxReal dt)
103 {
104 PX_ASSERT(sUpdateBodies);
105 if (sUpdateBodies)
106 (*sUpdateBodies)(desc, tempDeltaV, dt);
107 }
108
109 static void updateBodiesTGS(const ArticulationSolverDesc& desc, Cm::SpatialVectorF* tempDeltaV,
110 PxReal dt)
111 {
112 PX_ASSERT(sUpdateBodiesTGS);
113 if (sUpdateBodiesTGS)
114 (*sUpdateBodiesTGS)(desc, tempDeltaV, dt);
115 }
116
117 static void saveVelocity(const ArticulationSolverDesc& desc, Cm::SpatialVectorF* tempDeltaV)
118 {
119 PX_ASSERT(sSaveVelocity);
120 if (sSaveVelocity)
121 (*sSaveVelocity)(desc, tempDeltaV);
122 }
123
124
125 static void saveVelocityTGS(const ArticulationSolverDesc& desc, PxReal invDtF32)
126 {
127 PX_UNUSED(desc);
128 PX_UNUSED(invDtF32);
129 PX_ASSERT(sSaveVelocityTGS);
130 if (sSaveVelocityTGS)
131 (*sSaveVelocityTGS)(desc, invDtF32);
132 }
133
134 static void computeUnconstrainedVelocitiesTGS(const ArticulationSolverDesc& desc,
135 PxReal dt,
136 const PxVec3& gravity, PxU64 contextID, Cm::SpatialVectorF* Z, Cm::SpatialVectorF* DeltaV,
137 const PxReal invLengthScale)
138 {
139 PX_ASSERT(sComputeUnconstrainedVelocitiesTGS);
140 if (sComputeUnconstrainedVelocitiesTGS)
141 (sComputeUnconstrainedVelocitiesTGS)(desc, dt, gravity, contextID, Z, DeltaV, invLengthScale);
142 }
143
144 static void updateDeltaMotion(const ArticulationSolverDesc& desc, const PxReal dt, Cm::SpatialVectorF* DeltaV, const PxReal totalInvDt)
145 {
146 PX_ASSERT(sUpdateDeltaMotion);
147 if (sUpdateDeltaMotion)
148 (*sUpdateDeltaMotion)(desc, dt, DeltaV, totalInvDt);
149 }
150
151 static void deltaMotionToMotionVel(const ArticulationSolverDesc& desc, const PxReal invDt)
152 {
153 PX_ASSERT(sDeltaMotionToMotionVel);
154 if (sDeltaMotionToMotionVel)
155 (*sDeltaMotionToMotionVel)(desc, invDt);
156 }
157
158 static PxU32 setupSolverInternalConstraintsTGS(const ArticulationSolverDesc& desc,
159 PxReal dt,
160 PxReal invDt,
161 PxReal totalDt,
162 const PxReal biasCoefficient,
163 PxU32& acCount,
165 {
166 PX_ASSERT(sSetupInternalConstraintsTGS);
167 if (sSetupInternalConstraintsTGS)
168 return sSetupInternalConstraintsTGS(desc, dt, invDt,
169 totalDt, biasCoefficient, acCount, Z);
170 return 0;
171
172 }
173};
174
175
176}
177}
178#endif
179
Definition DyArticulationPImpl.h:41
3 Element vector class.
Definition PxVec3.h:50
Sorts an array of objects in ascending order, assuming that the predicate implements the < operator:
Definition PxBoxController.h:39
Definition CmSpatialVector.h:134
Definition DyVArticulation.h:102