Class PxParticleSystem

Direct Known Subclasses:
PxPBDParticleSystem

public class PxParticleSystem extends PxActor
The shared base class for all particle systems

A particle system simulates a bunch of particles that interact with each other. The interactions can be simple collisions with friction (granular material) ore more complex like fluid interactions, cloth, inflatables etc.

  • Field Details

    • SIZEOF

      public static final int SIZEOF
    • ALIGNOF

      public static final int ALIGNOF
      See Also:
  • Constructor Details

    • PxParticleSystem

      protected PxParticleSystem()
    • PxParticleSystem

      protected PxParticleSystem(long address)
  • Method Details

    • wrapPointer

      public static PxParticleSystem wrapPointer(long address)
    • arrayGet

      public static PxParticleSystem arrayGet(long baseAddress, int index)
    • 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: [1,255]

      See #getSolverIterationCounts()

    • getSimulationFilterData

      public PxFilterData getSimulationFilterData()
      Retrieves the collision filter settings.
      Returns:
      The filter data
    • setSimulationFilterData

      public void setSimulationFilterData(PxFilterData data)
      Set collision filter settings

      Allows to control with which objects the particle system collides

      Parameters:
      data - The filter data
    • setParticleFlag

      public void setParticleFlag(PxParticleFlagEnum flag, boolean val)
      Set particle flag

      Allows to control self collision etc.

      Parameters:
      flag - The flag to set
      val - The new value of the flag
    • setParticleFlags

      public void setParticleFlags(PxParticleFlags flags)
      Set particle flags

      Allows to control self collision etc.

      Parameters:
      flags - The flags to set
    • getParticleFlags

      public PxParticleFlags getParticleFlags()
      Retrieves the particle flags.
      Returns:
      The particle flags
    • setMaxDepenetrationVelocity

      public void setMaxDepenetrationVelocity(float maxDepenetrationVelocity)
      Set the maximal depenetration velocity particles can reach

      Allows to limit the particles' maximal depenetration velocity to avoid that collision responses lead to very high particle velocities

      Parameters:
      maxDepenetrationVelocity - The maximal depenetration velocity
    • getMaxDepenetrationVelocity

      public float getMaxDepenetrationVelocity()
      Retrieves maximal depenetration velocity a particle can have.
      Returns:
      The maximal depenetration velocity
    • setMaxVelocity

      public void setMaxVelocity(float maxVelocity)
      Set the maximal velocity particles can reach

      Allows to limit the particles' maximal velocity to control the maximal distance a particle can move per frame

      Parameters:
      maxVelocity - The maximal velocity
    • getMaxVelocity

      public float getMaxVelocity()
      Retrieves maximal velocity a particle can have.
      Returns:
      The maximal velocity
    • getCudaContextManager

      public PxCudaContextManager getCudaContextManager()
      Return the cuda context manager
      Returns:
      The cuda context manager
    • setRestOffset

      public void setRestOffset(float restOffset)
      Set the rest offset for the collision between particles and rigids or soft bodies.

      A particle and a rigid or soft body will come to rest at a distance equal to the sum of their restOffset values.

      Parameters:
      restOffset - Range: (0, contactOffset)
    • getRestOffset

      public float getRestOffset()
      Return the rest offset
      Returns:
      the rest offset

      See #setRestOffset()

    • setContactOffset

      public void setContactOffset(float contactOffset)
      Set the contact offset for the collision between particles and rigids or soft bodies

      The contact offset needs to be larger than the rest offset. Contact constraints are generated for a particle and a rigid or softbody below the distance equal to the sum of their contacOffset values.

      Parameters:
      contactOffset - Range: (restOffset, PX_MAX_F32)
    • getContactOffset

      public float getContactOffset()
      Return the contact offset
      Returns:
      the contact offset

      See #setContactOffset()

    • setParticleContactOffset

      public void setParticleContactOffset(float particleContactOffset)
      Set the contact offset for the interactions between particles

      The particle contact offset needs to be larger than the fluid rest offset and larger than the solid rest offset. Interactions for two particles are computed if their distance is below twice the particleContactOffset value.

      Parameters:
      particleContactOffset - Range: (Max(solidRestOffset, fluidRestOffset), PX_MAX_F32)
    • getParticleContactOffset

      public float getParticleContactOffset()
      Return the particle contact offset
      Returns:
      the particle contact offset

      See #setParticleContactOffset()

    • setSolidRestOffset

      public void setSolidRestOffset(float solidRestOffset)
      Set the solid rest offset

      Two solid particles (or a solid and a fluid particle) will come to rest at a distance equal to twice the solidRestOffset value.

      Parameters:
      solidRestOffset - Range: (0, particleContactOffset)
    • getSolidRestOffset

      public float getSolidRestOffset()
      Return the solid rest offset
      Returns:
      the solid rest offset

      See #setSolidRestOffset()

    • addRigidAttachment

      public void addRigidAttachment(PxRigidActor actor)
      Creates a rigid attachment between a particle and a rigid actor.

      This method creates a symbolic attachment between the particle system and a rigid body for the purpose of island management. The actual attachments will be contained in the particle buffers.

      Be aware that destroying the rigid body before destroying the attachment is illegal and may cause a crash. The particle system keeps track of these attachments but the rigid body does not.

      Parameters:
      actor - The rigid actor used for the attachment
    • removeRigidAttachment

      public void removeRigidAttachment(PxRigidActor actor)
      Removes a rigid attachment between a particle and a rigid body.

      This method destroys a symbolic attachment between the particle system and a rigid body for the purpose of island management.

      Be aware that destroying the rigid body before destroying the attachment is illegal and may cause a crash. The particle system keeps track of these attachments but the rigid body does not.

      Parameters:
      actor - The rigid body actor used for the attachment
    • enableCCD

      public void enableCCD(boolean enable)
      Enable continuous collision detection for particles
      Parameters:
      enable - Boolean indicates whether continuous collision detection is enabled.
    • createPhase

      public int createPhase(PxParticleMaterial material, PxParticlePhaseFlags flags)
      Creates combined particle flag with particle material and particle phase flags.
      Parameters:
      material - A material instance to associate with the new particle group.
      flags - The particle phase flags.
      Returns:
      The combined particle group index and phase flags.

      See #PxParticlePhaseFlag

    • getNbParticleMaterials

      public int getNbParticleMaterials()
      Returns number of particle materials
      Returns:
      The number of particle materials
    • setParticleSystemCallback

      public void setParticleSystemCallback(PxParticleSystemCallback callback)
      Sets a user notify object which receives special simulation events when they occur.

      Note: Do not set the callback while the simulation is running. Calls to this method while the simulation is running will be ignored. Note: A call to fetchResultsParticleSystem() on the PxScene will synchronize the work such that the caller knows that all worke done in the callback completed.

      Parameters:
      callback - User notification callback. See PxSimulationEventCallback.

      See #PxParticleSystemCallback, #getParticleSystemCallback()

    • getParticleSystemCallback

      public PxParticleSystemCallback getParticleSystemCallback()
      Retrieves the simulationEventCallback pointer set with setSimulationEventCallback().
      Returns:
      The current user notify pointer. See PxSimulationEventCallback.

      See #PxParticleSystemCallback, #setParticleSystemCallback()

    • addParticleBuffer

      public void addParticleBuffer(PxParticleBuffer particleBuffer)
      Add an existing particle buffer to the particle system.
      Parameters:
      particleBuffer - a PxParticleBuffer*.

      See #PxParticleBuffer.

    • removeParticleBuffer

      public void removeParticleBuffer(PxParticleBuffer particleBuffer)
      Remove particle buffer from the particle system.
      Parameters:
      particleBuffer - a PxParticleBuffer*.

      See #PxParticleBuffer.

    • getGpuParticleSystemIndex

      public int getGpuParticleSystemIndex()
      Returns the GPU particle system index.
      Returns:
      The GPU index, if the particle system is in a scene and PxSceneFlag::eENABLE_DIRECT_GPU_API is set, or 0xFFFFFFFF otherwise.