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_RIGIDBODY
32#define PX_PHYSICS_NX_RIGIDBODY
33/** \addtogroup physics
34@{
35*/
36
37#include "PxRigidActor.h"
38#include "PxForceMode.h"
39
40#if !PX_DOXYGEN
41namespace physx
42{
43#endif
44
45
46/**
47\brief Collection of flags describing the behavior of a rigid body.
48
49@see PxRigidBody.setRigidBodyFlag(), PxRigidBody.getRigidBodyFlags()
50*/
51
52struct PxRigidBodyFlag
53{
54 enum Enum
55 {
56
57 /**
58 \brief Enables kinematic mode for the actor.
59
60 Kinematic actors are special dynamic actors that are not
61 influenced by forces (such as gravity), and have no momentum. They are considered to have infinite
62 mass and can be moved around the world using the setKinematicTarget() method. They will push
63 regular dynamic actors out of the way. Kinematics will not collide with static or other kinematic objects.
64
65 Kinematic actors are great for moving platforms or characters, where direct motion control is desired.
66
67 You can not connect Reduced joints to kinematic actors. Lagrange joints work ok if the platform
68 is moving with a relatively low, uniform velocity.
69
70 <b>Sleeping:</b>
71 \li Setting this flag on a dynamic actor will put the actor to sleep and set the velocities to 0.
72 \li If this flag gets cleared, the current sleep state of the actor will be kept.
73
74 \note kinematic actors are incompatible with CCD so raising this flag will automatically clear eENABLE_CCD
75
76 @see PxRigidDynamic.setKinematicTarget()
77 */
78 eKINEMATIC = (1<<0), //!< Enable kinematic mode for the body.
79
80 /**
81 \brief Use the kinematic target transform for scene queries.
82
83 If this flag is raised, then scene queries will treat the kinematic target transform as the current pose
84 of the body (instead of using the actual pose). Without this flag, the kinematic target will only take
85 effect with respect to scene queries after a simulation step.
86
87 @see PxRigidDynamic.setKinematicTarget()
88 */
89 eUSE_KINEMATIC_TARGET_FOR_SCENE_QUERIES = (1<<1),
90
91 /**
92 \brief Enables swept integration for the actor.
93
94 If this flag is raised and CCD is enabled on the scene, then this body will be simulated by the CCD system to ensure that collisions are not missed due to
95 high-speed motion. Note individual shape pairs still need to enable PxPairFlag::eDETECT_CCD_CONTACT in the collision filtering to enable the CCD to respond to
96 individual interactions.
97
98 \note kinematic actors are incompatible with CCD so this flag will be cleared automatically when raised on a kinematic actor
99
100 */
101 eENABLE_CCD = (1<<2), //!< Enable CCD for the body.
102
103 /**
104 \brief Enabled CCD in swept integration for the actor.
105
106 If this flag is raised and CCD is enabled, CCD interactions will simulate friction. By default, friction is disabled in CCD interactions because
107 CCD friction has been observed to introduce some simulation artifacts. CCD friction was enabled in previous versions of the SDK. Raising this flag will result in behavior
108 that is a closer match for previous versions of the SDK.
109
110 \note This flag requires PxRigidBodyFlag::eENABLE_CCD to be raised to have any effect.
111 */
112 eENABLE_CCD_FRICTION = (1<<3),
113
114 /**
115 \brief Register a rigid body for reporting pose changes by the simulation at an early stage.
116
117 Sometimes it might be advantageous to get access to the new pose of a rigid body as early as possible and
118 not wait until the call to fetchResults() returns. Setting this flag will schedule the rigid body to get reported
119 in #PxSimulationEventCallback::onAdvance(). Please refer to the documentation of that callback to understand
120 the behavior and limitations of this functionality.
121
122 @see PxSimulationEventCallback::onAdvance()
123 */
124 eENABLE_POSE_INTEGRATION_PREVIEW = (1 << 4),
125
126 /**
127 \brief Register a rigid body to dynamicly adjust contact offset based on velocity. This can be used to achieve a CCD effect.
128 */
129 eENABLE_SPECULATIVE_CCD = (1 << 5),
130
131 /**
132 \brief Permit CCD to limit maxContactImpulse. This is useful for use-cases like a destruction system but can cause visual artefacts so is not enabled by default.
133 */
134 eENABLE_CCD_MAX_CONTACT_IMPULSE = (1 << 6),
135
136 /**
137 \brief Carries over forces/accelerations between frames, rather than clearning them
138 */
139 eRETAIN_ACCELERATIONS = (1<<7),
140
141 /**
142 \brief Forces kinematic-kinematic pairs notifications for this actor.
143
144 This flag overrides the global scene-level PxPairFilteringMode setting for kinematic actors.
145 This is equivalent to having PxPairFilteringMode::eKEEP for pairs involving this actor.
146
147 A particular use case is when you have a large amount of kinematic actors, but you are only
148 interested in interactions between a few of them. In this case it is best to use set
149 PxSceneDesc.kineKineFilteringMode = PxPairFilteringMode::eKILL, and then raise the
150 eFORCE_KINE_KINE_NOTIFICATIONS flag on the small set of kinematic actors that need
151 notifications.
152
153 \note This has no effect if PxRigidBodyFlag::eKINEMATIC is not set.
154
155 \warning Changing this flag at runtime will not have an effect until you remove and re-add the actor to the scene.
156
157 @see PxPairFilteringMode PxSceneDesc.kineKineFilteringMode
158 */
159 eFORCE_KINE_KINE_NOTIFICATIONS = (1<<8),
160
161 /**
162 \brief Forces static-kinematic pairs notifications for this actor.
163
164 Similar to eFORCE_KINE_KINE_NOTIFICATIONS, but for static-kinematic interactions.
165
166 \note This has no effect if PxRigidBodyFlag::eKINEMATIC is not set.
167
168 \warning Changing this flag at runtime will not have an effect until you remove and re-add the actor to the scene.
169
170 @see PxPairFilteringMode PxSceneDesc.staticKineFilteringMode
171 */
172 eFORCE_STATIC_KINE_NOTIFICATIONS = (1<<9),
173
174 /**
175 \brief Reserved for internal usage
176 */
177 eRESERVED = (1<<15)
178 };
179};
180
181/**
182\brief collection of set bits defined in PxRigidBodyFlag.
183
184@see PxRigidBodyFlag
185*/
186typedef PxFlags<PxRigidBodyFlag::Enum,PxU16> PxRigidBodyFlags;
187PX_FLAGS_OPERATORS(PxRigidBodyFlag::Enum,PxU16)
188
189/**
190\brief PxRigidBody is a base class shared between dynamic rigid body objects.
191
192@see PxRigidActor
193*/
194
195class PxRigidBody : public PxRigidActor
196{
197public:
198 // Runtime modifications
199
200/************************************************************************************************/
201/** @name Mass Manipulation
202*/
203
204 /**
205 \brief Sets the pose of the center of mass relative to the actor.
206
207 \note Changing this transform will not move the actor in the world!
208
209 \note Setting an unrealistic center of mass which is a long way from the body can make it difficult for
210 the SDK to solve constraints. Perhaps leading to instability and jittering bodies.
211
212 <b>Default:</b> the identity transform
213
214 \param[in] pose Mass frame offset transform relative to the actor frame. <b>Range:</b> rigid body transform.
215
216 @see getCMassLocalPose() PxRigidBodyDesc.massLocalPose
217 */
218 virtual void setCMassLocalPose(const PxTransform& pose) = 0;
219
220
221 /**
222 \brief Retrieves the center of mass pose relative to the actor frame.
223
224 \return The center of mass pose relative to the actor frame.
225
226 @see setCMassLocalPose() PxRigidBodyDesc.massLocalPose
227 */
228 virtual PxTransform getCMassLocalPose() const = 0;
229
230
231 /**
232 \brief Sets the mass of a dynamic actor.
233
234 The mass must be non-negative.
235
236 setMass() does not update the inertial properties of the body, to change the inertia tensor
237 use setMassSpaceInertiaTensor() or the PhysX extensions method #PxRigidBodyExt::updateMassAndInertia().
238
239 \note A value of 0 is interpreted as infinite mass.
240 \note Values of 0 are not permitted for instances of PxArticulationLink but are permitted for instances of PxRigidDynamic.
241
242 <b>Default:</b> 1.0
243
244 <b>Sleeping:</b> Does <b>NOT</b> wake the actor up automatically.
245
246 \param[in] mass New mass value for the actor. <b>Range:</b> [0, PX_MAX_F32)
247
248 @see getMass() PxRigidBodyDesc.mass setMassSpaceInertiaTensor()
249 */
250 virtual void setMass(PxReal mass) = 0;
251
252 /**
253 \brief Retrieves the mass of the actor.
254
255 \note A value of 0 is interpreted as infinite mass.
256
257 \return The mass of this actor.
258
259 @see setMass() PxRigidBodyDesc.mass setMassSpaceInertiaTensor()
260 */
261 virtual PxReal getMass() const = 0;
262
263 /**
264 \brief Retrieves the inverse mass of the actor.
265
266 \return The inverse mass of this actor.
267
268 @see setMass() PxRigidBodyDesc.mass setMassSpaceInertiaTensor()
269 */
270 virtual PxReal getInvMass() const = 0;
271
272 /**
273 \brief Sets the inertia tensor, using a parameter specified in mass space coordinates.
274
275 Note that such matrices are diagonal -- the passed vector is the diagonal.
276
277 If you have a non diagonal world/actor space inertia tensor(3x3 matrix). Then you need to
278 diagonalize it and set an appropriate mass space transform. See #setCMassLocalPose().
279
280 The inertia tensor elements must be non-negative.
281
282 \note A value of 0 in an element is interpreted as infinite inertia along that axis.
283 \note Values of 0 are not permitted for instances of PxArticulationLink but are permitted for instances of PxRigidDynamic.
284
285 <b>Default:</b> (1.0, 1.0, 1.0)
286
287 <b>Sleeping:</b> Does <b>NOT</b> wake the actor up automatically.
288
289 \param[in] m New mass space inertia tensor for the actor.
290
291 @see PxRigidBodyDesc.massSpaceInertia getMassSpaceInertia() setMass() setCMassLocalPose()
292 */
293 virtual void setMassSpaceInertiaTensor(const PxVec3& m) = 0;
294
295 /**
296 \brief Retrieves the diagonal inertia tensor of the actor relative to the mass coordinate frame.
297
298 This method retrieves a mass frame inertia vector.
299
300 \return The mass space inertia tensor of this actor.
301
302 \note A value of 0 in an element is interpreted as infinite inertia along that axis.
303
304 @see PxRigidBodyDesc.massSpaceInertia setMassSpaceInertiaTensor() setMass() setCMassLocalPose()
305 */
306 virtual PxVec3 getMassSpaceInertiaTensor() const = 0;
307
308 /**
309 \brief Retrieves the diagonal inverse inertia tensor of the actor relative to the mass coordinate frame.
310
311 This method retrieves a mass frame inverse inertia vector.
312
313 \note A value of 0 in an element is interpreted as infinite inertia along that axis.
314
315 \return The mass space inverse inertia tensor of this actor.
316
317 @see PxRigidBodyDesc.massSpaceInertia setMassSpaceInertiaTensor() setMass() setCMassLocalPose()
318 */
319 virtual PxVec3 getMassSpaceInvInertiaTensor() const = 0;
320
321 /************************************************************************************************/
322 /** @name Damping
323 */
324
325 /**
326 \brief Sets the linear damping coefficient.
327
328 Zero represents no damping. The damping coefficient must be nonnegative.
329
330 <b>Default:</b> 0.0
331
332 \param[in] linDamp Linear damping coefficient. <b>Range:</b> [0, PX_MAX_F32)
333
334 @see getLinearDamping() setAngularDamping()
335 */
336 virtual void setLinearDamping(PxReal linDamp) = 0;
337
338 /**
339 \brief Retrieves the linear damping coefficient.
340
341 \return The linear damping coefficient associated with this actor.
342
343 @see setLinearDamping() getAngularDamping()
344 */
345 virtual PxReal getLinearDamping() const = 0;
346
347 /**
348 \brief Sets the angular damping coefficient.
349
350 Zero represents no damping.
351
352 The angular damping coefficient must be nonnegative.
353
354 <b>Default:</b> 0.05
355
356 \param[in] angDamp Angular damping coefficient. <b>Range:</b> [0, PX_MAX_F32)
357
358 @see getAngularDamping() setLinearDamping()
359 */
360 virtual void setAngularDamping(PxReal angDamp) = 0;
361
362 /**
363 \brief Retrieves the angular damping coefficient.
364
365 \return The angular damping coefficient associated with this actor.
366
367 @see setAngularDamping() getLinearDamping()
368 */
369 virtual PxReal getAngularDamping() const = 0;
370
371
372/************************************************************************************************/
373/** @name Velocity
374*/
375
376
377 /**
378 \brief Retrieves the linear velocity of an actor.
379
380 \return The linear velocity of the actor.
381
382 @see PxRigidDynamic.setLinearVelocity() getAngularVelocity()
383 */
384 virtual PxVec3 getLinearVelocity() const = 0;
385
386 /**
387 \brief Sets the linear velocity of the actor.
388
389 Note that if you continuously set the velocity of an actor yourself,
390 forces such as gravity or friction will not be able to manifest themselves, because forces directly
391 influence only the velocity/momentum of an actor.
392
393 <b>Default:</b> (0.0, 0.0, 0.0)
394
395 <b>Sleeping:</b> This call wakes the actor if it is sleeping, the autowake parameter is true (default) or the
396 new velocity is non-zero
397
398 \note It is invalid to use this method if PxActorFlag::eDISABLE_SIMULATION is set.
399
400 \param[in] linVel New linear velocity of actor. <b>Range:</b> velocity vector
401 \param[in] autowake Whether to wake the object up if it is asleep and the velocity is non-zero. If true and the current wake counter value is smaller than #PxSceneDesc::wakeCounterResetValue it will get increased to the reset value.
402
403 @see getLinearVelocity() setAngularVelocity()
404 */
405 virtual void setLinearVelocity(const PxVec3& linVel, bool autowake = true ) = 0;
406
407
408
409 /**
410 \brief Retrieves the angular velocity of the actor.
411
412 \return The angular velocity of the actor.
413
414 @see PxRigidDynamic.setAngularVelocity() getLinearVelocity()
415 */
416 virtual PxVec3 getAngularVelocity() const = 0;
417
418
419 /**
420 \brief Sets the angular velocity of the actor.
421
422 Note that if you continuously set the angular velocity of an actor yourself,
423 forces such as friction will not be able to rotate the actor, because forces directly influence only the velocity/momentum.
424
425 <b>Default:</b> (0.0, 0.0, 0.0)
426
427 <b>Sleeping:</b> This call wakes the actor if it is sleeping, the autowake parameter is true (default) or the
428 new velocity is non-zero
429
430 \note It is invalid to use this method if PxActorFlag::eDISABLE_SIMULATION is set.
431
432 \param[in] angVel New angular velocity of actor. <b>Range:</b> angular velocity vector
433 \param[in] autowake Whether to wake the object up if it is asleep and the velocity is non-zero. If true and the current wake
434 counter value is smaller than #PxSceneDesc::wakeCounterResetValue it will get increased to the reset value.
435
436 @see getAngularVelocity() setLinearVelocity()
437 */
438 virtual void setAngularVelocity(const PxVec3& angVel, bool autowake = true ) = 0;
439
440 /**
441 \brief Lets you set the maximum angular velocity permitted for this actor.
442
443 For various internal computations, very quickly rotating actors introduce error
444 into the simulation, which leads to undesired results.
445
446 With this function, you can set the maximum angular velocity permitted for this rigid body.
447 Higher angular velocities are clamped to this value.
448
449 Note: The angular velocity is clamped to the set value <i>before</i> the solver, which means that
450 the limit may still be momentarily exceeded.
451
452 <b>Default:</b> 100.0
453
454 \param[in] maxAngVel Max allowable angular velocity for actor. <b>Range:</b> [0, PX_MAX_F32)
455
456 @see getMaxAngularVelocity()
457 */
458 virtual void setMaxAngularVelocity(PxReal maxAngVel) = 0;
459
460 /**
461 \brief Retrieves the maximum angular velocity permitted for this actor.
462
463 \return The maximum allowed angular velocity for this actor.
464
465 @see setMaxAngularVelocity
466 */
467 virtual PxReal getMaxAngularVelocity() const = 0;
468
469
470 /**
471 \brief Lets you set the maximum linear velocity permitted for this actor.
472
473 With this function, you can set the maximum linear velocity permitted for this rigid body.
474 Higher angular velocities are clamped to this value.
475
476 Note: The angular velocity is clamped to the set value <i>before</i> the solver, which means that
477 the limit may still be momentarily exceeded.
478
479 <b>Default:</b> PX_MAX_F32
480
481 \param[in] maxLinVel Max allowable linear velocity for actor. <b>Range:</b> [0, PX_MAX_F32)
482
483 @see getMaxAngularVelocity()
484 */
485 virtual void setMaxLinearVelocity(PxReal maxLinVel) = 0;
486
487 /**
488 \brief Retrieves the maximum angular velocity permitted for this actor.
489
490 \return The maximum allowed angular velocity for this actor.
491
492 @see setMaxLinearVelocity
493 */
494 virtual PxReal getMaxLinearVelocity() const = 0;
495
496
497/************************************************************************************************/
498/** @name Forces
499*/
500
501 /**
502 \brief Applies a force (or impulse) defined in the global coordinate frame to the actor at its center of mass.
503
504 <b>This will not induce a torque</b>.
505
506 ::PxForceMode determines if the force is to be conventional or impulsive.
507
508 Each actor has an acceleration and a velocity change accumulator which are directly modified using the modes PxForceMode::eACCELERATION
509 and PxForceMode::eVELOCITY_CHANGE respectively. The modes PxForceMode::eFORCE and PxForceMode::eIMPULSE also modify these same
510 accumulators and are just short hand for multiplying the vector parameter by inverse mass and then using PxForceMode::eACCELERATION and
511 PxForceMode::eVELOCITY_CHANGE respectively.
512
513
514 \note It is invalid to use this method if the actor has not been added to a scene already or if PxActorFlag::eDISABLE_SIMULATION is set.
515
516 \note The force modes PxForceMode::eIMPULSE and PxForceMode::eVELOCITY_CHANGE can not be applied to articulation links.
517
518 \note if this is called on an articulation link, only the link is updated, not the entire articulation.
519
520 \note see #PxRigidBodyExt::computeVelocityDeltaFromImpulse for details of how to compute the change in linear velocity that
521 will arise from the application of an impulsive force, where an impulsive force is applied force multiplied by a timestep.
522
523 <b>Sleeping:</b> This call wakes the actor if it is sleeping and the autowake parameter is true (default) or the force is non-zero.
524
525 \param[in] force Force/Impulse to apply defined in the global frame.
526 \param[in] mode The mode to use when applying the force/impulse(see #PxForceMode)
527 \param[in] autowake Specify if the call should wake up the actor if it is currently asleep. If true and the current wake counter value is smaller than #PxSceneDesc::wakeCounterResetValue it will get increased to the reset value.
528
529 @see PxForceMode addTorque
530 */
531 virtual void addForce(const PxVec3& force, PxForceMode::Enum mode = PxForceMode::eFORCE, bool autowake = true) = 0;
532
533 /**
534 \brief Applies an impulsive torque defined in the global coordinate frame to the actor.
535
536 ::PxForceMode determines if the torque is to be conventional or impulsive.
537
538 Each actor has an angular acceleration and an angular velocity change accumulator which are directly modified using the modes
539 PxForceMode::eACCELERATION and PxForceMode::eVELOCITY_CHANGE respectively. The modes PxForceMode::eFORCE and PxForceMode::eIMPULSE
540 also modify these same accumulators and are just short hand for multiplying the vector parameter by inverse inertia and then
541 using PxForceMode::eACCELERATION and PxForceMode::eVELOCITY_CHANGE respectively.
542
543
544 \note It is invalid to use this method if the actor has not been added to a scene already or if PxActorFlag::eDISABLE_SIMULATION is set.
545
546 \note The force modes PxForceMode::eIMPULSE and PxForceMode::eVELOCITY_CHANGE can not be applied to articulation links.
547
548 \note if this called on an articulation link, only the link is updated, not the entire articulation.
549
550 \note see #PxRigidBodyExt::computeVelocityDeltaFromImpulse for details of how to compute the change in angular velocity that
551 will arise from the application of an impulsive torque, where an impulsive torque is an applied torque multiplied by a timestep.
552
553 <b>Sleeping:</b> This call wakes the actor if it is sleeping and the autowake parameter is true (default) or the torque is non-zero.
554
555 \param[in] torque Torque to apply defined in the global frame. <b>Range:</b> torque vector
556 \param[in] mode The mode to use when applying the force/impulse(see #PxForceMode).
557 \param[in] autowake whether to wake up the object if it is asleep. If true and the current wake counter value is smaller than #PxSceneDesc::wakeCounterResetValue it will get increased to the reset value.
558
559 @see PxForceMode addForce()
560 */
561 virtual void addTorque(const PxVec3& torque, PxForceMode::Enum mode = PxForceMode::eFORCE, bool autowake = true) = 0;
562
563 /**
564 \brief Clears the accumulated forces (sets the accumulated force back to zero).
565
566 Each actor has an acceleration and a velocity change accumulator which are directly modified using the modes PxForceMode::eACCELERATION
567 and PxForceMode::eVELOCITY_CHANGE respectively. The modes PxForceMode::eFORCE and PxForceMode::eIMPULSE also modify these same
568 accumulators (see PxRigidBody::addForce() for details); therefore the effect of calling clearForce(PxForceMode::eFORCE) is equivalent to calling
569 clearForce(PxForceMode::eACCELERATION), and the effect of calling clearForce(PxForceMode::eIMPULSE) is equivalent to calling
570 clearForce(PxForceMode::eVELOCITY_CHANGE).
571
572 ::PxForceMode determines if the cleared force is to be conventional or impulsive.
573
574 \note The force modes PxForceMode::eIMPULSE and PxForceMode::eVELOCITY_CHANGE can not be applied to articulation links.
575
576 \note It is invalid to use this method if the actor has not been added to a scene already or if PxActorFlag::eDISABLE_SIMULATION is set.
577
578 \param[in] mode The mode to use when clearing the force/impulse(see #PxForceMode)
579
580 @see PxForceMode addForce
581 */
582 virtual void clearForce(PxForceMode::Enum mode = PxForceMode::eFORCE) = 0;
583
584 /**
585 \brief Clears the impulsive torque defined in the global coordinate frame to the actor.
586
587 ::PxForceMode determines if the cleared torque is to be conventional or impulsive.
588
589 Each actor has an angular acceleration and a velocity change accumulator which are directly modified using the modes PxForceMode::eACCELERATION
590 and PxForceMode::eVELOCITY_CHANGE respectively. The modes PxForceMode::eFORCE and PxForceMode::eIMPULSE also modify these same
591 accumulators (see PxRigidBody::addTorque() for details); therefore the effect of calling clearTorque(PxForceMode::eFORCE) is equivalent to calling
592 clearTorque(PxForceMode::eACCELERATION), and the effect of calling clearTorque(PxForceMode::eIMPULSE) is equivalent to calling
593 clearTorque(PxForceMode::eVELOCITY_CHANGE).
594
595 \note The force modes PxForceMode::eIMPULSE and PxForceMode::eVELOCITY_CHANGE can not be applied to articulation links.
596
597 \note It is invalid to use this method if the actor has not been added to a scene already or if PxActorFlag::eDISABLE_SIMULATION is set.
598
599 \param[in] mode The mode to use when clearing the force/impulse(see #PxForceMode).
600
601 @see PxForceMode addTorque
602 */
603 virtual void clearTorque(PxForceMode::Enum mode = PxForceMode::eFORCE) = 0;
604
605
606 /**
607 \brief Sets the impulsive force and torque defined in the global coordinate frame to the actor.
608
609 ::PxForceMode determines if the cleared torque is to be conventional or impulsive.
610
611 \note The force modes PxForceMode::eIMPULSE and PxForceMode::eVELOCITY_CHANGE can not be applied to articulation links.
612
613 \note It is invalid to use this method if the actor has not been added to a scene already or if PxActorFlag::eDISABLE_SIMULATION is set.
614
615 @see PxForceMode addTorque
616 */
617 virtual void setForceAndTorque(const PxVec3& force, const PxVec3& torque, PxForceMode::Enum mode = PxForceMode::eFORCE) = 0;
618
619 /**
620 \brief Raises or clears a particular rigid body flag.
621
622 See the list of flags #PxRigidBodyFlag
623
624 <b>Default:</b> no flags are set
625
626 <b>Sleeping:</b> Does <b>NOT</b> wake the actor up automatically.
627
628 \param[in] flag The PxRigidBody flag to raise(set) or clear. See #PxRigidBodyFlag.
629 \param[in] value The new boolean value for the flag.
630
631 @see PxRigidBodyFlag getRigidBodyFlags()
632 */
633
634 virtual void setRigidBodyFlag(PxRigidBodyFlag::Enum flag, bool value) = 0;
635 virtual void setRigidBodyFlags(PxRigidBodyFlags inFlags) = 0;
636
637 /**
638 \brief Reads the PxRigidBody flags.
639
640 See the list of flags #PxRigidBodyFlag
641
642 \return The values of the PxRigidBody flags.
643
644 @see PxRigidBodyFlag setRigidBodyFlag()
645 */
646 virtual PxRigidBodyFlags getRigidBodyFlags() const = 0;
647
648 /**
649 \brief Sets the CCD minimum advance coefficient.
650
651 The CCD minimum advance coefficient is a value in the range [0, 1] that is used to control the minimum amount of time a body is integrated when
652 it has a CCD contact. The actual minimum amount of time that is integrated depends on various properties, including the relative speed and collision shapes
653 of the bodies involved in the contact. From these properties, a numeric value is calculated that determines the maximum distance (and therefore maximum time)
654 which these bodies could be integrated forwards that would ensure that these bodies did not pass through each-other. This value is then scaled by CCD minimum advance
655 coefficient to determine the amount of time that will be consumed in the CCD pass.
656
657 <b>Things to consider:</b>
658 A large value (approaching 1) ensures that the objects will always advance some time. However, larger values increase the chances of objects gently drifting through each-other in
659 scenes which the constraint solver can't converge, e.g. scenes where an object is being dragged through a wall with a constraint.
660 A value of 0 ensures that the pair of objects stop at the exact time-of-impact and will not gently drift through each-other. However, with very small/thin objects initially in
661 contact, this can lead to a large amount of time being dropped and increases the chances of jamming. Jamming occurs when the an object is persistently in contact with an object
662 such that the time-of-impact is 0, which results in no time being advanced for those objects in that CCD pass.
663
664 The chances of jamming can be reduced by increasing the number of CCD mass @see PxSceneDesc.ccdMaxPasses. However, increasing this number increases the CCD overhead.
665
666 \param[in] advanceCoefficient The CCD min advance coefficient. <b>Range:</b> [0, 1] <b>Default:</b> 0.15
667 */
668
669 virtual void setMinCCDAdvanceCoefficient(PxReal advanceCoefficient) = 0;
670
671 /**
672 \brief Gets the CCD minimum advance coefficient.
673
674 \return The value of the CCD min advance coefficient.
675
676 @see setMinCCDAdvanceCoefficient
677
678 */
679
680 virtual PxReal getMinCCDAdvanceCoefficient() const = 0;
681
682
683 /**
684 \brief Sets the maximum depenetration velocity permitted to be introduced by the solver.
685 This value controls how much velocity the solver can introduce to correct for penetrations in contacts.
686 \param[in] biasClamp The maximum velocity to de-penetrate by <b>Range:</b> (0, PX_MAX_F32].
687 */
688 virtual void setMaxDepenetrationVelocity(PxReal biasClamp) = 0;
689
690 /**
691 \brief Returns the maximum depenetration velocity the solver is permitted to introduced.
692 This value controls how much velocity the solver can introduce to correct for penetrations in contacts.
693 \return The maximum penetration bias applied by the solver.
694 */
695 virtual PxReal getMaxDepenetrationVelocity() const = 0;
696
697
698 /**
699 \brief Sets a limit on the impulse that may be applied at a contact. The maximum impulse at a contact between two dynamic or kinematic
700 bodies will be the minimum of the two limit values. For a collision between a static and a dynamic body, the impulse is limited
701 by the value for the dynamic body.
702
703 \param[in] maxImpulse the maximum contact impulse. <b>Range:</b> [0, PX_MAX_F32] <b>Default:</b> PX_MAX_F32
704
705 @see getMaxContactImpulse
706 */
707 virtual void setMaxContactImpulse(PxReal maxImpulse) = 0;
708
709 /**
710 \brief Returns the maximum impulse that may be applied at a contact.
711
712 \return The maximum impulse that may be applied at a contact
713
714 @see setMaxContactImpulse
715 */
716 virtual PxReal getMaxContactImpulse() const = 0;
717
718 /**
719 \brief Returns the island node index that only for internal use only
720
721 \return The island node index that only for internal use only
722 */
723 virtual PxU32 getInternalIslandNodeIndex() const = 0;
724
725
726protected:
727 PX_INLINE PxRigidBody(PxType concreteType, PxBaseFlags baseFlags) : PxRigidActor(concreteType, baseFlags) {}
728 PX_INLINE PxRigidBody(PxBaseFlags baseFlags) : PxRigidActor(baseFlags) {}
729 virtual ~PxRigidBody() {}
730 virtual bool isKindOf(const char* name)const { return !::strcmp(s1: "PxRigidBody", s2: name) || PxRigidActor::isKindOf(name); }
731};
732
733
734#if !PX_DOXYGEN
735} // namespace physx
736#endif
737
738/** @} */
739#endif
740

source code of qtquick3dphysics/src/3rdparty/PhysX/include/PxRigidBody.h