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_EXTENSIONS_RIGIDBODY_H |
32 | #define PX_PHYSICS_EXTENSIONS_RIGIDBODY_H |
33 | /** \addtogroup extensions |
34 | @{ |
35 | */ |
36 | |
37 | #include "PxPhysXConfig.h" |
38 | #include "PxRigidBody.h" |
39 | #include "PxQueryReport.h" |
40 | #include "PxQueryFiltering.h" |
41 | #include "extensions/PxMassProperties.h" |
42 | |
43 | #if !PX_DOXYGEN |
44 | namespace physx |
45 | { |
46 | #endif |
47 | |
48 | class PxScene; |
49 | struct PxQueryCache; |
50 | class PxShape; |
51 | |
52 | /** |
53 | \brief utility functions for use with PxRigidBody and subclasses |
54 | |
55 | @see PxRigidBody PxRigidDynamic PxArticulationLink |
56 | */ |
57 | |
58 | class PxRigidBodyExt |
59 | { |
60 | public: |
61 | /** |
62 | \brief Computation of mass properties for a rigid body actor |
63 | |
64 | To simulate a dynamic rigid actor, the SDK needs a mass and an inertia tensor. |
65 | |
66 | This method offers functionality to compute the necessary mass and inertia properties based on the shapes declared in |
67 | the PxRigidBody descriptor and some additionally specified parameters. For each shape, the shape geometry, |
68 | the shape positioning within the actor and the specified shape density are used to compute the body's mass and |
69 | inertia properties. |
70 | |
71 | <ul> |
72 | <li>Shapes without PxShapeFlag::eSIMULATION_SHAPE set are ignored unless includeNonSimShapes is true.</li> |
73 | <li>Shapes with plane, triangle mesh or heightfield geometry and PxShapeFlag::eSIMULATION_SHAPE set are not allowed for PxRigidBody collision.</li> |
74 | </ul> |
75 | |
76 | This method will set the mass, center of mass, and inertia tensor |
77 | |
78 | if no collision shapes are found, the inertia tensor is set to (1,1,1) and the mass to 1 |
79 | |
80 | if massLocalPose is non-NULL, the rigid body's center of mass parameter will be set |
81 | to the user provided value (massLocalPose) and the inertia tensor will be resolved at that point. |
82 | |
83 | \note If all shapes of the actor have the same density then the overloaded method updateMassAndInertia() with a single density parameter can be used instead. |
84 | |
85 | \param[in,out] body The rigid body. |
86 | \param[in] shapeDensities The per shape densities. There must be one entry for each shape which has the PxShapeFlag::eSIMULATION_SHAPE set (or for all shapes if includeNonSimShapes is set to true). Other shapes are ignored. The density values must be greater than 0. |
87 | \param[in] shapeDensityCount The number of provided density values. |
88 | \param[in] massLocalPose The center of mass relative to the actor frame. If set to null then (0,0,0) is assumed. |
89 | \param[in] includeNonSimShapes True if all kind of shapes (PxShapeFlag::eSCENE_QUERY_SHAPE, PxShapeFlag::eTRIGGER_SHAPE) should be taken into account. |
90 | \return Boolean. True on success else false. |
91 | |
92 | @see PxRigidBody::setMassLocalPose PxRigidBody::setMassSpaceInertiaTensor PxRigidBody::setMass |
93 | */ |
94 | static bool updateMassAndInertia(PxRigidBody& body, const PxReal* shapeDensities, PxU32 shapeDensityCount, const PxVec3* massLocalPose = NULL, bool includeNonSimShapes = false); |
95 | |
96 | |
97 | /** |
98 | \brief Computation of mass properties for a rigid body actor |
99 | |
100 | See previous method for details. |
101 | |
102 | \param[in,out] body The rigid body. |
103 | \param[in] density The density of the body. Used to compute the mass of the body. The density must be greater than 0. |
104 | \param[in] massLocalPose The center of mass relative to the actor frame. If set to null then (0,0,0) is assumed. |
105 | \param[in] includeNonSimShapes True if all kind of shapes (PxShapeFlag::eSCENE_QUERY_SHAPE, PxShapeFlag::eTRIGGER_SHAPE) should be taken into account. |
106 | \return Boolean. True on success else false. |
107 | |
108 | @see PxRigidBody::setMassLocalPose PxRigidBody::setMassSpaceInertiaTensor PxRigidBody::setMass |
109 | */ |
110 | static bool updateMassAndInertia(PxRigidBody& body, PxReal density, const PxVec3* massLocalPose = NULL, bool includeNonSimShapes = false); |
111 | |
112 | |
113 | /** |
114 | \brief Computation of mass properties for a rigid body actor |
115 | |
116 | This method sets the mass, inertia and center of mass of a rigid body. The mass is set to the sum of all user-supplied |
117 | shape mass values, and the inertia and center of mass are computed according to the rigid body's shapes and the per shape mass input values. |
118 | |
119 | If no collision shapes are found, the inertia tensor is set to (1,1,1) |
120 | |
121 | \note If a single mass value should be used for the actor as a whole then the overloaded method setMassAndUpdateInertia() with a single mass parameter can be used instead. |
122 | |
123 | @see updateMassAndInertia for more details. |
124 | |
125 | \param[in,out] body The rigid body for which to set the mass and centre of mass local pose properties. |
126 | \param[in] shapeMasses The per shape mass values. There must be one entry for each shape which has the PxShapeFlag::eSIMULATION_SHAPE set. Other shapes are ignored. The mass values must be greater than 0. |
127 | \param[in] shapeMassCount The number of provided mass values. |
128 | \param[in] massLocalPose The center of mass relative to the actor frame. If set to null then (0,0,0) is assumed. |
129 | \param[in] includeNonSimShapes True if all kind of shapes (PxShapeFlag::eSCENE_QUERY_SHAPE, PxShapeFlag::eTRIGGER_SHAPE) should be taken into account. |
130 | \return Boolean. True on success else false. |
131 | |
132 | @see PxRigidBody::setCMassLocalPose PxRigidBody::setMassSpaceInertiaTensor PxRigidBody::setMass |
133 | */ |
134 | static bool setMassAndUpdateInertia(PxRigidBody& body, const PxReal* shapeMasses, PxU32 shapeMassCount, const PxVec3* massLocalPose = NULL, bool includeNonSimShapes = false); |
135 | |
136 | |
137 | /** |
138 | \brief Computation of mass properties for a rigid body actor |
139 | |
140 | This method sets the mass, inertia and center of mass of a rigid body. The mass is set to the user-supplied |
141 | value, and the inertia and center of mass are computed according to the rigid body's shapes and the input mass. |
142 | |
143 | If no collision shapes are found, the inertia tensor is set to (1,1,1) |
144 | |
145 | @see updateMassAndInertia for more details. |
146 | |
147 | \param[in,out] body The rigid body for which to set the mass and centre of mass local pose properties. |
148 | \param[in] mass The mass of the body. Must be greater than 0. |
149 | \param[in] massLocalPose The center of mass relative to the actor frame. If set to null then (0,0,0) is assumed. |
150 | \param[in] includeNonSimShapes True if all kind of shapes (PxShapeFlag::eSCENE_QUERY_SHAPE, PxShapeFlag::eTRIGGER_SHAPE) should be taken into account. |
151 | \return Boolean. True on success else false. |
152 | |
153 | @see PxRigidBody::setCMassLocalPose PxRigidBody::setMassSpaceInertiaTensor PxRigidBody::setMass |
154 | */ |
155 | static bool setMassAndUpdateInertia(PxRigidBody& body, PxReal mass, const PxVec3* massLocalPose = NULL, bool includeNonSimShapes = false); |
156 | |
157 | |
158 | /** |
159 | \brief Compute the mass, inertia tensor and center of mass from a list of shapes. |
160 | |
161 | \param[in] shapes The shapes to compute the mass properties from. |
162 | \param[in] shapeCount The number of provided shapes. |
163 | \return The mass properties from the combined shapes. |
164 | |
165 | @see PxRigidBody::setCMassLocalPose PxRigidBody::setMassSpaceInertiaTensor PxRigidBody::setMass |
166 | */ |
167 | static PxMassProperties computeMassPropertiesFromShapes(const PxShape* const* shapes, PxU32 shapeCount); |
168 | |
169 | |
170 | /** |
171 | \brief Applies a force (or impulse) defined in the global coordinate frame, acting at a particular |
172 | point in global coordinates, to the actor. |
173 | |
174 | Note that if the force does not act along the center of mass of the actor, this |
175 | will also add the corresponding torque. Because forces are reset at the end of every timestep, |
176 | you can maintain a total external force on an object by calling this once every frame. |
177 | |
178 | \note if this call is used to apply a force or impulse to an articulation link, only the link is updated, not the entire |
179 | articulation |
180 | |
181 | ::PxForceMode determines if the force is to be conventional or impulsive. Only eFORCE and eIMPULSE are supported, as the |
182 | force required to produce a given velocity change or acceleration is underdetermined given only the desired change at a |
183 | given point. |
184 | |
185 | <b>Sleeping:</b> This call wakes the actor if it is sleeping and the wakeup parameter is true (default). |
186 | |
187 | \param[in] body The rigid body to apply the force to. |
188 | \param[in] force Force/impulse to add, defined in the global frame. <b>Range:</b> force vector |
189 | \param[in] pos Position in the global frame to add the force at. <b>Range:</b> position vector |
190 | \param[in] mode The mode to use when applying the force/impulse(see #PxForceMode). |
191 | \param[in] wakeup Specify if the call should wake up the actor. |
192 | |
193 | @see PxForceMode |
194 | @see addForceAtLocalPos() addLocalForceAtPos() addLocalForceAtLocalPos() |
195 | */ |
196 | static void addForceAtPos(PxRigidBody& body, const PxVec3& force, const PxVec3& pos, PxForceMode::Enum mode = PxForceMode::eFORCE, bool wakeup = true); |
197 | |
198 | /** |
199 | \brief Applies a force (or impulse) defined in the global coordinate frame, acting at a particular |
200 | point in local coordinates, to the actor. |
201 | |
202 | Note that if the force does not act along the center of mass of the actor, this |
203 | will also add the corresponding torque. Because forces are reset at the end of every timestep, you can maintain a |
204 | total external force on an object by calling this once every frame. |
205 | |
206 | \note if this call is used to apply a force or impulse to an articulation link, only the link is updated, not the entire |
207 | articulation |
208 | |
209 | ::PxForceMode determines if the force is to be conventional or impulsive. Only eFORCE and eIMPULSE are supported, as the |
210 | force required to produce a given velocity change or acceleration is underdetermined given only the desired change at a |
211 | given point. |
212 | |
213 | <b>Sleeping:</b> This call wakes the actor if it is sleeping and the wakeup parameter is true (default). |
214 | |
215 | \param[in] body The rigid body to apply the force to. |
216 | \param[in] force Force/impulse to add, defined in the global frame. <b>Range:</b> force vector |
217 | \param[in] pos Position in the local frame to add the force at. <b>Range:</b> position vector |
218 | \param[in] mode The mode to use when applying the force/impulse(see #PxForceMode). |
219 | \param[in] wakeup Specify if the call should wake up the actor. |
220 | |
221 | @see PxForceMode |
222 | @see addForceAtPos() addLocalForceAtPos() addLocalForceAtLocalPos() |
223 | */ |
224 | static void addForceAtLocalPos(PxRigidBody& body, const PxVec3& force, const PxVec3& pos, PxForceMode::Enum mode = PxForceMode::eFORCE, bool wakeup = true); |
225 | |
226 | /** |
227 | \brief Applies a force (or impulse) defined in the actor local coordinate frame, acting at a |
228 | particular point in global coordinates, to the actor. |
229 | |
230 | Note that if the force does not act along the center of mass of the actor, this |
231 | will also add the corresponding torque. Because forces are reset at the end of every timestep, you can maintain a |
232 | total external force on an object by calling this once every frame. |
233 | |
234 | \note if this call is used to apply a force or impulse to an articulation link, only the link is updated, not the entire |
235 | articulation |
236 | |
237 | ::PxForceMode determines if the force is to be conventional or impulsive. Only eFORCE and eIMPULSE are supported, as the |
238 | force required to produce a given velocity change or acceleration is underdetermined given only the desired change at a |
239 | given point. |
240 | |
241 | <b>Sleeping:</b> This call wakes the actor if it is sleeping and the wakeup parameter is true (default). |
242 | |
243 | \param[in] body The rigid body to apply the force to. |
244 | \param[in] force Force/impulse to add, defined in the local frame. <b>Range:</b> force vector |
245 | \param[in] pos Position in the global frame to add the force at. <b>Range:</b> position vector |
246 | \param[in] mode The mode to use when applying the force/impulse(see #PxForceMode). |
247 | \param[in] wakeup Specify if the call should wake up the actor. |
248 | |
249 | @see PxForceMode |
250 | @see addForceAtPos() addForceAtLocalPos() addLocalForceAtLocalPos() |
251 | */ |
252 | static void addLocalForceAtPos(PxRigidBody& body, const PxVec3& force, const PxVec3& pos, PxForceMode::Enum mode = PxForceMode::eFORCE, bool wakeup = true); |
253 | |
254 | /** |
255 | \brief Applies a force (or impulse) defined in the actor local coordinate frame, acting at a |
256 | particular point in local coordinates, to the actor. |
257 | |
258 | Note that if the force does not act along the center of mass of the actor, this |
259 | will also add the corresponding torque. Because forces are reset at the end of every timestep, you can maintain a |
260 | total external force on an object by calling this once every frame. |
261 | |
262 | \note if this call is used to apply a force or impulse to an articulation link, only the link is updated, not the entire |
263 | articulation |
264 | |
265 | ::PxForceMode determines if the force is to be conventional or impulsive. Only eFORCE and eIMPULSE are supported, as the |
266 | force required to produce a given velocity change or acceleration is underdetermined given only the desired change at a |
267 | given point. |
268 | |
269 | <b>Sleeping:</b> This call wakes the actor if it is sleeping and the wakeup parameter is true (default). |
270 | |
271 | \param[in] body The rigid body to apply the force to. |
272 | \param[in] force Force/impulse to add, defined in the local frame. <b>Range:</b> force vector |
273 | \param[in] pos Position in the local frame to add the force at. <b>Range:</b> position vector |
274 | \param[in] mode The mode to use when applying the force/impulse(see #PxForceMode). |
275 | \param[in] wakeup Specify if the call should wake up the actor. |
276 | |
277 | @see PxForceMode |
278 | @see addForceAtPos() addForceAtLocalPos() addLocalForceAtPos() |
279 | */ |
280 | static void addLocalForceAtLocalPos(PxRigidBody& body, const PxVec3& force, const PxVec3& pos, PxForceMode::Enum mode = PxForceMode::eFORCE, bool wakeup = true); |
281 | |
282 | /** |
283 | \brief Computes the velocity of a point given in world coordinates if it were attached to the |
284 | specified body and moving with it. |
285 | |
286 | \param[in] body The rigid body the point is attached to. |
287 | \param[in] pos Position we wish to determine the velocity for, defined in the global frame. <b>Range:</b> position vector |
288 | \return The velocity of point in the global frame. |
289 | |
290 | @see getLocalPointVelocity() |
291 | */ |
292 | static PxVec3 getVelocityAtPos(const PxRigidBody& body, const PxVec3& pos); |
293 | |
294 | /** |
295 | \brief Computes the velocity of a point given in local coordinates if it were attached to the |
296 | specified body and moving with it. |
297 | |
298 | \param[in] body The rigid body the point is attached to. |
299 | \param[in] pos Position we wish to determine the velocity for, defined in the local frame. <b>Range:</b> position vector |
300 | \return The velocity of point in the local frame. |
301 | |
302 | @see getLocalPointVelocity() |
303 | */ |
304 | static PxVec3 getLocalVelocityAtLocalPos(const PxRigidBody& body, const PxVec3& pos); |
305 | |
306 | /** |
307 | \brief Computes the velocity of a point (offset from the origin of the body) given in world coordinates if it were attached to the |
308 | specified body and moving with it. |
309 | |
310 | \param[in] body The rigid body the point is attached to. |
311 | \param[in] pos Position (offset from the origin of the body) we wish to determine the velocity for, defined in the global frame. <b>Range:</b> position vector |
312 | \return The velocity of point (offset from the origin of the body) in the global frame. |
313 | |
314 | @see getLocalPointVelocity() |
315 | */ |
316 | static PxVec3 getVelocityAtOffset(const PxRigidBody& body, const PxVec3& pos); |
317 | |
318 | |
319 | /** |
320 | \brief Performs a linear sweep through space with the body's geometry objects. |
321 | |
322 | \note Supported geometries are: box, sphere, capsule, convex. Other geometry types will be ignored. |
323 | \note If eTOUCH is returned from the filter callback, it will trigger an error and the hit will be discarded. |
324 | |
325 | The function sweeps all shapes attached to a given rigid body through space and reports the nearest |
326 | object in the scene which intersects any of of the shapes swept paths. |
327 | Information about the closest intersection is written to a #PxSweepHit structure. |
328 | |
329 | \param[in] body The rigid body to sweep. |
330 | \param[in] scene The scene object to process the query. |
331 | \param[in] unitDir Normalized direction of the sweep. |
332 | \param[in] distance Sweep distance. Needs to be larger than 0. |
333 | \param[in] outputFlags Specifies which properties should be written to the hit information. |
334 | \param[out] closestHit Closest hit result. |
335 | \param[out] shapeIndex Index of the body shape that caused the closest hit. |
336 | \param[in] filterData If any word in filterData.data is non-zero then filterData.data will be used for filtering, |
337 | otherwise shape->getQueryFilterData() will be used instead. |
338 | \param[in] filterCall Custom filtering logic (optional). Only used if the corresponding #PxQueryFlag flags are set. If NULL, all hits are assumed to be blocking. |
339 | \param[in] cache Cached hit shape (optional). Ray is tested against cached shape first then against the scene. |
340 | Note: Filtering is not executed for a cached shape if supplied; instead, if a hit is found, it is assumed to be a blocking hit. |
341 | \param[in] inflation This parameter creates a skin around the swept geometry which increases its extents for sweeping. The sweep will register a hit as soon as the skin touches a shape, and will return the corresponding distance and normal. |
342 | |
343 | \return True if a blocking hit was found. |
344 | |
345 | @see PxScene PxQueryFlags PxFilterData PxBatchQueryPreFilterShader PxBatchQueryPostFilterShader PxSweepHit |
346 | */ |
347 | static bool linearSweepSingle( |
348 | PxRigidBody& body, PxScene& scene, const PxVec3& unitDir, const PxReal distance, |
349 | PxHitFlags outputFlags, |
350 | PxSweepHit& closestHit, PxU32& shapeIndex, |
351 | const PxQueryFilterData& filterData = PxQueryFilterData(), |
352 | PxQueryFilterCallback* filterCall = NULL, |
353 | const PxQueryCache* cache = NULL, |
354 | const PxReal inflation=0.0f); |
355 | |
356 | /** |
357 | \brief Performs a linear sweep through space with the body's geometry objects, returning all overlaps. |
358 | |
359 | \note Supported geometries are: box, sphere, capsule, convex. Other geometry types will be ignored. |
360 | |
361 | This function sweeps all shapes attached to a given rigid body through space and reports all |
362 | objects in the scene that intersect any of the shapes' swept paths until there are no more objects to report |
363 | or a blocking hit is encountered. |
364 | |
365 | \param[in] body The rigid body to sweep. |
366 | \param[in] scene The scene object to process the query. |
367 | \param[in] unitDir Normalized direction of the sweep. |
368 | \param[in] distance Sweep distance. Needs to be larger than 0. |
369 | \param[in] outputFlags Specifies which properties should be written to the hit information. |
370 | \param[out] touchHitBuffer Raycast hit information buffer. If the buffer overflows, an arbitrary subset of touch hits |
371 | is returned (typically the query should be restarted with a larger buffer). |
372 | \param[out] touchHitShapeIndices After the query is completed, touchHitShapeIndices[i] will contain the body index that caused the hit stored in hitBuffer[i] |
373 | \param[in] touchHitBufferSize Size of both touch hit buffers in elements. |
374 | \param[out] block Closest blocking hit is returned via this reference. |
375 | \param[out] blockingShapeIndex Set to -1 if if a blocking hit was not found, otherwise set to closest blocking hit shape index. The touching hits are reported separately in hitBuffer. |
376 | \param[out] overflow Set to true if touchHitBuffer didn't have enough space for all results. Touch hits will be incomplete if overflow occurred. Possible solution is to restart the query with a larger buffer. |
377 | \param[in] filterData If any word in filterData.data is non-zero then filterData.data will be used for filtering, |
378 | otherwise shape->getQueryFilterData() will be used instead. |
379 | \param[in] filterCall Custom filtering logic (optional). Only used if the corresponding #PxQueryFlag flags are set. If NULL, all hits are assumed to be blocking. |
380 | \param[in] cache Cached hit shape (optional). Ray is tested against cached shape first then against the scene. |
381 | Note: Filtering is not executed for a cached shape if supplied; instead, if a hit is found, it is assumed to be a blocking hit. |
382 | \param[in] inflation This parameter creates a skin around the swept geometry which increases its extents for sweeping. The sweep will register a hit as soon as the skin touches a shape, and will return the corresponding distance and normal. |
383 | |
384 | \return the number of touching hits. If overflow is set to true, the results are incomplete. In case of overflow there are also no guarantees that all touching hits returned are closer than the blocking hit. |
385 | |
386 | @see PxScene PxQueryFlags PxFilterData PxBatchQueryPreFilterShader PxBatchQueryPostFilterShader PxSweepHit |
387 | */ |
388 | static PxU32 linearSweepMultiple( |
389 | PxRigidBody& body, PxScene& scene, const PxVec3& unitDir, const PxReal distance, |
390 | PxHitFlags outputFlags, |
391 | PxSweepHit* touchHitBuffer, PxU32* touchHitShapeIndices, PxU32 touchHitBufferSize, |
392 | PxSweepHit& block, PxI32& blockingShapeIndex, bool& overflow, |
393 | const PxQueryFilterData& filterData = PxQueryFilterData(), |
394 | PxQueryFilterCallback* filterCall = NULL, |
395 | const PxQueryCache* cache = NULL, const PxReal inflation = 0.0f); |
396 | |
397 | |
398 | /** |
399 | \brief Compute the change to linear and angular velocity that would occur if an impulsive force and torque were to be applied to a specified rigid body. |
400 | |
401 | The rigid body is left unaffected unless a subsequent independent call is executed that actually applies the computed changes to velocity and angular velocity. |
402 | |
403 | \note if this call is used to determine the velocity delta for an articulation link, only the mass properties of the link are taken into account. |
404 | |
405 | @see PxRigidBody::getLinearVelocity, PxRigidBody::setLinearVelocity, PxRigidBody::getAngularVelocity, PxRigidBody::setAngularVelocity |
406 | |
407 | \param[in] body The body under consideration. |
408 | \param[in] impulsiveForce The impulsive force that would be applied to the specified rigid body. |
409 | \param[in] impulsiveTorque The impulsive torque that would be applied to the specified rigid body. |
410 | \param[out] deltaLinearVelocity The change in linear velocity that would arise if impulsiveForce was to be applied to the specified rigid body. |
411 | \param[out] deltaAngularVelocity The change in angular velocity that would arise if impulsiveTorque was to be applied to the specified rigid body. |
412 | */ |
413 | static void computeVelocityDeltaFromImpulse(const PxRigidBody& body, const PxVec3& impulsiveForce, const PxVec3& impulsiveTorque, PxVec3& deltaLinearVelocity, PxVec3& deltaAngularVelocity); |
414 | |
415 | /** |
416 | \brief Computes the linear and angular velocity change vectors for a given impulse at a world space position taking a mass and inertia scale into account |
417 | |
418 | This function is useful for extracting the respective linear and angular velocity changes from a contact or joint when the mass/inertia ratios have been adjusted. |
419 | |
420 | \note if this call is used to determine the velocity delta for an articulation link, only the mass properties of the link are taken into account. |
421 | |
422 | \param[in] body The rigid body |
423 | \param[in] globalPose The body's world space transform |
424 | \param[in] point The point in world space where the impulse is applied |
425 | \param[in] impulse The impulse vector in world space |
426 | \param[in] invMassScale The inverse mass scale |
427 | \param[in] invInertiaScale The inverse inertia scale |
428 | \param[out] deltaLinearVelocity The linear velocity change |
429 | \param[out] deltaAngularVelocity The angular velocity change |
430 | */ |
431 | |
432 | static void computeVelocityDeltaFromImpulse(const PxRigidBody& body, const PxTransform& globalPose, const PxVec3& point, const PxVec3& impulse, const PxReal invMassScale, |
433 | const PxReal invInertiaScale, PxVec3& deltaLinearVelocity, PxVec3& deltaAngularVelocity); |
434 | |
435 | /** |
436 | \brief Computes the linear and angular impulse vectors for a given impulse at a world space position taking a mass and inertia scale into account |
437 | |
438 | This function is useful for extracting the respective linear and angular impulses from a contact or joint when the mass/inertia ratios have been adjusted. |
439 | |
440 | \param[in] body The rigid body |
441 | \param[in] globalPose The body's world space transform |
442 | \param[in] point The point in world space where the impulse is applied |
443 | \param[in] impulse The impulse vector in world space |
444 | \param[in] invMassScale The inverse mass scale |
445 | \param[in] invInertiaScale The inverse inertia scale |
446 | \param[out] linearImpulse The linear impulse |
447 | \param[out] angularImpulse The angular impulse |
448 | */ |
449 | static void computeLinearAngularImpulse(const PxRigidBody& body, const PxTransform& globalPose, const PxVec3& point, const PxVec3& impulse, const PxReal invMassScale, |
450 | const PxReal invInertiaScale, PxVec3& linearImpulse, PxVec3& angularImpulse); |
451 | |
452 | |
453 | }; |
454 | |
455 | #if !PX_DOXYGEN |
456 | } // namespace physx |
457 | #endif |
458 | |
459 | /** @} */ |
460 | #endif |
461 | |