| 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 | |
| 31 | #ifndef PX_PHYSICS_NX_ARTICULATION |
| 32 | #define PX_PHYSICS_NX_ARTICULATION |
| 33 | /** \addtogroup physics |
| 34 | @{ */ |
| 35 | |
| 36 | #include "PxArticulationBase.h" |
| 37 | |
| 38 | |
| 39 | #if !PX_DOXYGEN |
| 40 | namespace physx |
| 41 | { |
| 42 | #endif |
| 43 | |
| 44 | class PxArticulationLink; |
| 45 | |
| 46 | /** |
| 47 | \brief Articulation drive cache |
| 48 | |
| 49 | This cache is used for making one or more impulse applications to the articulation. |
| 50 | |
| 51 | @see PxArticulation PxArticulation.createDriveCache |
| 52 | */ |
| 53 | class PxArticulationDriveCache |
| 54 | { |
| 55 | protected: |
| 56 | PxArticulationDriveCache(); |
| 57 | }; |
| 58 | |
| 59 | |
| 60 | /** |
| 61 | \brief a tree structure of bodies connected by joints that is treated as a unit by the dynamics solver |
| 62 | |
| 63 | Articulations are more expensive to simulate than the equivalent collection of |
| 64 | PxRigidDynamic and PxJoint structures, but because the dynamics solver treats |
| 65 | each articulation as a single object, they are much less prone to separation and |
| 66 | have better support for actuation. An articulation may have at most 64 links. |
| 67 | |
| 68 | @see PxArticulationJoint PxArticulationLink PxPhysics.createArticulation |
| 69 | */ |
| 70 | |
| 71 | #if PX_VC |
| 72 | #pragma warning(push) |
| 73 | #pragma warning(disable : 4435) |
| 74 | #endif |
| 75 | |
| 76 | class PxArticulation : public PxArticulationBase |
| 77 | { |
| 78 | public: |
| 79 | |
| 80 | virtual void release() = 0; |
| 81 | |
| 82 | /** |
| 83 | \brief sets maxProjectionIterations. |
| 84 | |
| 85 | This is the maximum number of iterations to run projection on the articulation to bring |
| 86 | the links back together if the separation tolerance is exceeded. |
| 87 | |
| 88 | |
| 89 | \param[in] iterations the maximum number of projection iterations |
| 90 | <b>Default:</b> 4 |
| 91 | |
| 92 | @see getMaxProjectionIterations() |
| 93 | */ |
| 94 | virtual void setMaxProjectionIterations(PxU32 iterations) = 0; |
| 95 | |
| 96 | /** |
| 97 | \brief gets maxProjectionIterations. |
| 98 | |
| 99 | \return the maximum number of projection iterations |
| 100 | |
| 101 | @see setMaxProjectionIterations() |
| 102 | */ |
| 103 | |
| 104 | virtual PxU32 getMaxProjectionIterations() const = 0; |
| 105 | |
| 106 | /** |
| 107 | \brief sets separationTolerance. |
| 108 | |
| 109 | This is the maximum allowed separation of any joint in the articulation before projection is used |
| 110 | |
| 111 | <b>Default: 0.1f, scaled by the tolerance scale </b> |
| 112 | |
| 113 | \param[in] tolerance the separation tolerance for the articulation |
| 114 | |
| 115 | @see getSeparationTolerance() |
| 116 | */ |
| 117 | virtual void setSeparationTolerance(PxReal tolerance) = 0; |
| 118 | |
| 119 | /** |
| 120 | \brief gets separationTolerance. |
| 121 | |
| 122 | \return the separation tolerance |
| 123 | |
| 124 | @see setSeparationTolerance() |
| 125 | */ |
| 126 | |
| 127 | virtual PxReal getSeparationTolerance() const = 0; |
| 128 | |
| 129 | |
| 130 | /** |
| 131 | \brief sets the number of iterations used to compute the drive response to internal forces |
| 132 | |
| 133 | The drive model uses an iterative algorithm to determine the load on each joint of the articulation. |
| 134 | This is the number of iterations to use when computing response of the drive to internal forces. |
| 135 | |
| 136 | \param[in] iterations the number of iterations used to compute the drive response to internal forces. |
| 137 | |
| 138 | <b>Default:</b> 4 |
| 139 | |
| 140 | @see getInternalDriveIterations() |
| 141 | */ |
| 142 | virtual void setInternalDriveIterations(PxU32 iterations) = 0; |
| 143 | |
| 144 | /** |
| 145 | \brief gets internal driveIterations. |
| 146 | |
| 147 | \return the number of iterations used to compute the drive response to internal forces |
| 148 | |
| 149 | @see setInternalDriveIterations() |
| 150 | */ |
| 151 | |
| 152 | virtual PxU32 getInternalDriveIterations() const = 0; |
| 153 | |
| 154 | |
| 155 | /** |
| 156 | \brief sets the number of iterations for drive response to external forces. |
| 157 | |
| 158 | The drive model uses an iterative algorithm to determine the load on each joint of the articulation. |
| 159 | This is the number of iterations to use when computing response of the drive to external forces. |
| 160 | |
| 161 | \param[in] iterations the number of iterations used to compute the drive response to external forces. |
| 162 | |
| 163 | <b>Default:</b> 4 |
| 164 | |
| 165 | @see getExternalDriveIterations() |
| 166 | */ |
| 167 | |
| 168 | virtual void setExternalDriveIterations(PxU32 iterations) = 0; |
| 169 | |
| 170 | /** |
| 171 | \brief gets externalDriveIterations. |
| 172 | |
| 173 | \return the number of iterations used to compute the drive response to external forces |
| 174 | |
| 175 | @see setExternalDriveIterations() |
| 176 | */ |
| 177 | |
| 178 | virtual PxU32 getExternalDriveIterations() const = 0; |
| 179 | |
| 180 | /** |
| 181 | \brief create a drive cache for applying impulses which are propagated to the entire articulation |
| 182 | |
| 183 | \param[in] compliance the compliance value to use at all joints of the articulation. This is equivalent to the external compliance |
| 184 | parameter for articulation joints, as the impulse is treated as an external force |
| 185 | \param[in] driveIterations the number of iterations to use to evaluate the drive strengths |
| 186 | |
| 187 | \return a drive cache |
| 188 | |
| 189 | @see PxArticulationDriveCache updateDriveCache releaseDriveCache applyImpulse computeImpulseResponse |
| 190 | |
| 191 | \note this call may only be made on articulations that are in a scene, and may not be made during simulation |
| 192 | |
| 193 | */ |
| 194 | virtual PxArticulationDriveCache* |
| 195 | createDriveCache(PxReal compliance, PxU32 driveIterations) const = 0; |
| 196 | |
| 197 | |
| 198 | /** |
| 199 | \brief update a drive cache |
| 200 | |
| 201 | \param[in] driveCache the drive cache to update |
| 202 | \param[in] compliance the compliance value to use at all joints of the articulation. |
| 203 | \param[in] driveIterations the number of iterations to use to evaluate the drive strengths |
| 204 | |
| 205 | @see releaseDriveCache createDriveCache applyImpulse computeImpulseResponse |
| 206 | |
| 207 | \note this call may only be made on articulations that are in a scene, and may not be made during simulation |
| 208 | |
| 209 | */ |
| 210 | virtual void updateDriveCache(PxArticulationDriveCache& driveCache, |
| 211 | PxReal compliance, |
| 212 | PxU32 driveIterations) const = 0; |
| 213 | |
| 214 | /** |
| 215 | \brief release a drive cache |
| 216 | |
| 217 | \param[in] driveCache the drive cache to release |
| 218 | |
| 219 | @see createDriveCache updateDriveCache |
| 220 | */ |
| 221 | virtual void releaseDriveCache(PxArticulationDriveCache& driveCache) const = 0; |
| 222 | |
| 223 | /** |
| 224 | \brief apply an impulse to an entire articulation |
| 225 | |
| 226 | \param[in] link the link to which to apply the impulse |
| 227 | \param[in] driveCache the drive cache |
| 228 | \param[in] linearImpulse the linear impulse to apply |
| 229 | \param[in] angularImpulse the angular impulse to apply |
| 230 | |
| 231 | @see computeImpulseResponse |
| 232 | |
| 233 | \note this call may only be made on articulations that are in a scene, and may not be made during simulation |
| 234 | |
| 235 | */ |
| 236 | virtual void applyImpulse(PxArticulationLink* link, |
| 237 | const PxArticulationDriveCache& driveCache, |
| 238 | const PxVec3& linearImpulse, |
| 239 | const PxVec3& angularImpulse) = 0; |
| 240 | |
| 241 | /** |
| 242 | \brief determine the effect of applying an impulse to an entire articulation, without applying the impulse |
| 243 | |
| 244 | \param[in] link the link to which to apply the impulse |
| 245 | \param[out] linearResponse the change in linear velocity of the articulation link |
| 246 | \param[out] angularResponse the change in angular velocity of the articulation link |
| 247 | \param[in] driveCache the drive cache |
| 248 | \param[in] linearImpulse the linear impulse to apply |
| 249 | \param[in] angularImpulse the angular impulse to apply |
| 250 | |
| 251 | @see applyImpulse |
| 252 | |
| 253 | This call will wake up the articulation if it is asleep. |
| 254 | |
| 255 | \note this call may only be made on articulations that are in a scene, and may not be made during simulation |
| 256 | */ |
| 257 | |
| 258 | virtual void computeImpulseResponse(PxArticulationLink*link, |
| 259 | PxVec3& linearResponse, |
| 260 | PxVec3& angularResponse, |
| 261 | const PxArticulationDriveCache& driveCache, |
| 262 | const PxVec3& linearImpulse, |
| 263 | const PxVec3& angularImpulse) const = 0; |
| 264 | |
| 265 | protected: |
| 266 | PX_INLINE PxArticulation(PxType concreteType, PxBaseFlags baseFlags) : PxArticulationBase(concreteType, baseFlags){} |
| 267 | PX_INLINE PxArticulation(PxBaseFlags baseFlags) : PxArticulationBase(baseFlags){} |
| 268 | virtual ~PxArticulation() {} |
| 269 | |
| 270 | }; |
| 271 | |
| 272 | #if PX_VC |
| 273 | #pragma warning(pop) |
| 274 | #endif |
| 275 | |
| 276 | #if !PX_DOXYGEN |
| 277 | } // namespace physx |
| 278 | #endif |
| 279 | |
| 280 | /** @} */ |
| 281 | #endif |
| 282 | |