Package physx.physics

Class PxRigidDynamic


public class PxRigidDynamic extends PxRigidBody
PxRigidDynamic represents a dynamic rigid simulation object in the physics SDK.

Creation

Instances of this class are created by calling #PxPhysics::createRigidDynamic() and deleted with #release().

Visualizations

\li #PxVisualizationParameter::eACTOR_AXES \li #PxVisualizationParameter::eBODY_AXES \li #PxVisualizationParameter::eBODY_MASS_AXES \li #PxVisualizationParameter::eBODY_LIN_VELOCITY \li #PxVisualizationParameter::eBODY_ANG_VELOCITY
See Also:
  • Field Details

    • SIZEOF

      public static final int SIZEOF
    • ALIGNOF

      public static final int ALIGNOF
      See Also:
  • Constructor Details

    • PxRigidDynamic

      protected PxRigidDynamic()
    • PxRigidDynamic

      protected PxRigidDynamic(long address)
  • Method Details

    • wrapPointer

      public static PxRigidDynamic wrapPointer(long address)
    • arrayGet

      public static PxRigidDynamic arrayGet(long baseAddress, int index)
    • setKinematicTarget

      public void setKinematicTarget(PxTransform destination)
      Moves kinematically controlled dynamic actors through the game world.

      You set a dynamic actor to be kinematic using the PxRigidBodyFlag::eKINEMATIC flag with setRigidBodyFlag().

      The move command will result in a velocity that will move the body into the desired pose. After the move is carried out during a single time step, the velocity is returned to zero. Thus, you must continuously call this in every time step for kinematic actors so that they move along a path.

      This function simply stores the move destination until the next simulation step is processed, so consecutive calls will simply overwrite the stored target variable.

      The motion is always fully carried out.

      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.

      Sleeping: This call wakes the actor if it is sleeping and will set the wake counter to #PxSceneDesc::wakeCounterResetValue.

      Parameters:
      destination - The desired pose for the kinematic actor, in the global frame. Range: rigid body transform.
      See Also:
    • getKinematicTarget

      public boolean getKinematicTarget(PxTransform target)
      Get target pose of a kinematically controlled dynamic actor.
      Parameters:
      target - Transform to write the target pose to. Only valid if the method returns true.
      Returns:
      True if the actor is a kinematically controlled dynamic and the target has been set, else False.
      See Also:
    • isSleeping

      public boolean isSleeping()
      Returns true if this body is sleeping.

      When an actor does not move for a period of time, it is no longer simulated in order to save time. This state is called sleeping. However, because the object automatically wakes up when it is either touched by an awake object, or one of its properties is changed by the user, the entire sleep mechanism should be transparent to the user.

      In general, a dynamic rigid actor is guaranteed to be awake if at least one of the following holds:

      \li The wake counter is positive (see #setWakeCounter()). \li The linear or angular velocity is non-zero. \li A non-zero force or torque has been applied.

      If a dynamic rigid actor is sleeping, the following state is guaranteed:

      \li The wake counter is zero. \li The linear and angular velocity is zero. \li There is no force update pending.

      When an actor gets inserted into a scene, it will be considered asleep if all the points above hold, else it will be treated as awake.

      If an actor is asleep after the call to PxScene::fetchResults() returns, it is guaranteed that the pose of the actor was not changed. You can use this information to avoid updating the transforms of associated objects.

      Note: A kinematic actor is asleep unless a target pose has been set (in which case it will stay awake until two consecutive simulation steps without a target pose being set have passed). The wake counter will get set to zero or to the reset value #PxSceneDesc::wakeCounterResetValue in the case where a target pose has been set to be consistent with the definitions above.

      Note: It is invalid to use this method if the actor has not been added to a scene already.

      Note: It is not allowed to use this method while the simulation is running.

      Returns:
      True if the actor is sleeping.
      See Also:
    • setSleepThreshold

      public void setSleepThreshold(float threshold)
      Sets the mass-normalized kinetic energy threshold below which an actor may go to sleep.

      Actors whose kinetic energy divided by their mass is below this threshold will be candidates for sleeping.

      Default: 5e-5f * PxTolerancesScale::speed * PxTolerancesScale::speed

      Parameters:
      threshold - Energy below which an actor may go to sleep. Range: [0, PX_MAX_F32)
      See Also:
    • getSleepThreshold

      public float getSleepThreshold()
      Returns the mass-normalized kinetic energy below which an actor may go to sleep.
      Returns:
      The energy threshold for sleeping.
      See Also:
    • setStabilizationThreshold

      public void setStabilizationThreshold(float threshold)
      Sets the mass-normalized kinetic energy threshold below which an actor may participate in stabilization.

      Actors whose kinetic energy divided by their mass is above this threshold will not participate in stabilization.

      This value has no effect if PxSceneFlag::eENABLE_STABILIZATION was not enabled on the PxSceneDesc.

      Default: 1e-5f * PxTolerancesScale::speed * PxTolerancesScale::speed

      Parameters:
      threshold - Energy below which an actor may participate in stabilization. Range: [0,inf)
      See Also:
    • getStabilizationThreshold

      public float getStabilizationThreshold()
      Returns the mass-normalized kinetic energy below which an actor may participate in stabilization.

      Actors whose kinetic energy divided by their mass is above this threshold will not participate in stabilization.

      Returns:
      The energy threshold for participating in stabilization.
      See Also:
    • getRigidDynamicLockFlags

      public PxRigidDynamicLockFlags getRigidDynamicLockFlags()
      Reads the PxRigidDynamic lock flags.

      See the list of flags #PxRigidDynamicLockFlag

      Returns:
      The values of the PxRigidDynamicLock flags.
      See Also:
    • setRigidDynamicLockFlag

      public void setRigidDynamicLockFlag(PxRigidDynamicLockFlagEnum flag, boolean value)
      Raises or clears a particular rigid dynamic lock flag.

      See the list of flags #PxRigidDynamicLockFlag

      Default: no flags are set

      Parameters:
      flag - The PxRigidDynamicLockBody flag to raise(set) or clear. See #PxRigidBodyFlag.
      value - The new boolean value for the flag.
      See Also:
    • setRigidDynamicLockFlags

      public void setRigidDynamicLockFlags(PxRigidDynamicLockFlags flags)
      Parameters:
      flags - WebIDL type: PxRigidDynamicLockFlags [Ref]
    • setLinearVelocity

      public void setLinearVelocity(PxVec3 linVel)
      Sets the linear velocity of the actor.

      Note that if you continuously set the velocity of an actor yourself, forces such as gravity or friction will not be able to manifest themselves, because forces directly influence only the velocity/momentum of an actor.

      Default: (0.0, 0.0, 0.0)

      Sleeping: This call wakes the actor if it is sleeping, and the autowake parameter is true (default) or the new velocity is non-zero.

      Note: It is invalid to use this method if PxActorFlag::eDISABLE_SIMULATION is set.

      Parameters:
      linVel - New linear velocity of actor. Range: velocity vector smaller than #PxSceneDesc::wakeCounterResetValue it will get increased to the reset value.
      See Also:
    • setLinearVelocity

      public void setLinearVelocity(PxVec3 linVel, boolean autowake)
      Sets the linear velocity of the actor.

      Note that if you continuously set the velocity of an actor yourself, forces such as gravity or friction will not be able to manifest themselves, because forces directly influence only the velocity/momentum of an actor.

      Default: (0.0, 0.0, 0.0)

      Sleeping: This call wakes the actor if it is sleeping, and the autowake parameter is true (default) or the new velocity is non-zero.

      Note: It is invalid to use this method if PxActorFlag::eDISABLE_SIMULATION is set.

      Parameters:
      linVel - New linear velocity of actor. Range: velocity vector
      autowake - Whether to wake the object up 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.
      See Also:
    • setAngularVelocity

      public void setAngularVelocity(PxVec3 angVel)
      Sets the angular velocity of the actor.

      Note that if you continuously set the angular velocity of an actor yourself, forces such as friction will not be able to rotate the actor, because forces directly influence only the velocity/momentum.

      Default: (0.0, 0.0, 0.0)

      Sleeping: This call wakes the actor if it is sleeping, and the autowake parameter is true (default) or the new velocity is non-zero.

      Note: It is invalid to use this method if PxActorFlag::eDISABLE_SIMULATION is set.

      Parameters:
      angVel - New angular velocity of actor. Range: angular velocity vector smaller than #PxSceneDesc::wakeCounterResetValue it will get increased to the reset value.
      See Also:
    • setAngularVelocity

      public void setAngularVelocity(PxVec3 angVel, boolean autowake)
      Sets the angular velocity of the actor.

      Note that if you continuously set the angular velocity of an actor yourself, forces such as friction will not be able to rotate the actor, because forces directly influence only the velocity/momentum.

      Default: (0.0, 0.0, 0.0)

      Sleeping: This call wakes the actor if it is sleeping, and the autowake parameter is true (default) or the new velocity is non-zero.

      Note: It is invalid to use this method if PxActorFlag::eDISABLE_SIMULATION is set.

      Parameters:
      angVel - New angular velocity of actor. Range: angular velocity vector
      autowake - Whether to wake the object up 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.
      See Also:
    • setWakeCounter

      public void setWakeCounter(float wakeCounterValue)
      Sets the wake counter for the actor.

      The wake counter value determines the minimum amount of time until the body can be put to sleep. Please note that a body will not be put to sleep if the energy is above the specified threshold (see #setSleepThreshold()) or if other awake bodies are touching it.

      Note: Passing in a positive value will wake the actor up automatically.

      Note: It is invalid to use this method for kinematic actors since the wake counter for kinematics is defined based on whether a target pose has been set (see the comment in #isSleeping()).

      Note: It is invalid to use this method if PxActorFlag::eDISABLE_SIMULATION is set.

      Default: 0.4 (which corresponds to 20 frames for a time step of 0.02)

      Parameters:
      wakeCounterValue - Wake counter value. Range: [0, PX_MAX_F32)
      See Also:
    • getWakeCounter

      public float getWakeCounter()
      Returns the wake counter of the actor.

      Note: It is not allowed to use this method while the simulation is running.

      Returns:
      The wake counter of the actor.
      See Also:
    • wakeUp

      public void wakeUp()
      Wakes up the actor if it is sleeping.

      The actor will get woken up and might cause other touching actors to wake up as well during the next simulation step.

      Note: This will set the wake counter of the actor to the value specified in #PxSceneDesc::wakeCounterResetValue.

      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.

      Note: It is invalid to use this method for kinematic actors since the sleep state for kinematics is defined based on whether a target pose has been set (see the comment in #isSleeping()).

      See Also:
    • putToSleep

      public void putToSleep()
      Forces the actor to sleep.

      The actor will stay asleep during the next simulation step if not touched by another non-sleeping actor.

      Note: Any applied force will be cleared and the velocity and the wake counter of the actor will be set to 0.

      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.

      Note: It is invalid to use this method for kinematic actors since the sleep state for kinematics is defined based on whether a target pose has been set (see the comment in #isSleeping()).

      See Also:
    • setSolverIterationCounts

      public void setSolverIterationCounts(int minPositionIters)
      Sets the solver iteration counts for the body.

      The solver iteration count determines how accurately joints and contacts are resolved. If you are having trouble with jointed bodies oscillating and behaving erratically, then setting a higher position iteration count may improve their stability.

      If intersecting bodies are being depenetrated too violently, increase the number of velocity iterations. More velocity iterations will drive the relative exit velocity of the intersecting objects closer to the correct value given the restitution.

      Default: 4 position iterations, 1 velocity iteration

      Parameters:
      minPositionIters - Number of position iterations the solver should perform for this body. Range: [1,255]
    • setSolverIterationCounts

      public void setSolverIterationCounts(int minPositionIters, int minVelocityIters)
      Sets the solver iteration counts for the body.

      The solver iteration count determines how accurately joints and contacts are resolved. If you are having trouble with jointed bodies oscillating and behaving erratically, then setting a higher position iteration count may improve their stability.

      If intersecting bodies are being depenetrated too violently, increase the number of velocity iterations. More velocity iterations will drive the relative exit velocity of the intersecting objects closer to the correct value given the restitution.

      Default: 4 position iterations, 1 velocity iteration

      Parameters:
      minPositionIters - Number of position iterations the solver should perform for this body. Range: [1,255]
      minVelocityIters - Number of velocity iterations the solver should perform for this body. Range: [0,255]
    • getContactReportThreshold

      public float getContactReportThreshold()
      Retrieves the force threshold for contact reports.

      The contact report threshold is a force threshold. If the force between two actors exceeds this threshold for either of the two actors, a contact report will be generated according to the contact report threshold flags provided by the filter shader/callback. See #PxPairFlag.

      The threshold used for a collision between a dynamic actor and the static environment is the threshold of the dynamic actor, and all contacts with static actors are summed to find the total normal force.

      Default: PX_MAX_F32

      Returns:
      Force threshold for contact reports.
      See Also:
    • setContactReportThreshold

      public void setContactReportThreshold(float threshold)
      Sets the force threshold for contact reports.

      See #getContactReportThreshold().

      Parameters:
      threshold - Force threshold for contact reports. Range: [0, PX_MAX_F32)
      See Also: