CParticleEvolver Collisions

From PopcornFX
Jump to: navigation, search

Collisions evolver Last update: v1.10.0 - Main page : Particle evolvers Particle evolvers


The collisions evolver makes the particles collide with the physical world, like the Physics evolver Physics evolver.
However, unlike the physics evolver, it can also collide against a custom Shape sampler shape or Shape sampler shape collection

You can chain multiple collisions evolvers that collide with different shapes or shape collections, and/or with the full physical scene.


Collisions evolver


Collisions evolver Node properties

Field name Default value Description
Collisions evolver General
FilterID 0 Custom low-level FilterID that will be passed to the ingame collision callbacks, allowing code to track and filter "Physical layers" of particles
Collider <None> Optional shape to collide with. If not set, will collide with the world
WorldInteractionMode OneWay
  • OneWay : Particles collide with world, world makes particles bounce-off.
  • TwoWay : Particles collide with world, world makes particles bounce-off, particles apply forces on world.
DieOnContact false When checked, particle dies when it hits something.
BouncesBeforeDeath 1 Number of bounces before the particle is forced to die. 0 = never dies because of collisions. If death on first contact is needed, activate the 'DieOnContact' property

range : [0, 127]

BounceRestitution 0.5 Determines how much the particle will bounce back. 0 = doesn't bounce, 1 = bounces back with the full pre-impact speed.

range : [0, 1]

ContactFrictionModel Absorbsive v1.9.0 Friction model to apply :
  • Coulomb : traditional, more realistic behaviour, with a separate friction property
  • Absorbsive
ContactFriction 0.7 v1.9.0

0 = no friction, for examples of physically-based friction coefficients, see here: coefficients of friction

DefaultMass 1 Default per-particle mass to be used for impulse calculations, if there is no 'MassField'.
Collisions evolver Events
EventOnCollide "OnCollide" Name of the event to trigger when a collision is detected
EventUsesPostContactVelocity false If active, will forward the post-contact (bounced) velocity to the triggered events
EventTransformsMode ContactSurface Determines the way the triggered event's transforms will be built
  • World : New v1.10.0 transforms will be aligned to the world axes.
  • ContactSurface : transforms will be aligned to the surface normal.
  • PreContactVelocity : transforms will be aligned to the particle's velocity before collision.
  • PostContactVelocity : transforms will be aligned to the particle's velocity after collision.
EventIsSticky false If enabled, the action spawned by the OnCollide event will be parented to the ingame object that was hit
Collisions evolver Advanced
BounceOffset 0.002 Offset along the contact normal the particle is displaced by after it has collided. useful to avoid numerical imprecisions with low bounce restitutions, or large bounce counts. Should be kept small
WeightBounceWithNdotV false if activated, bounce restutution will be scaled down when the particle collide at grazing angles with the surface.
MaxIterations 1 v1.9.0 Control the max number of scene raycast iterations the physics evolver will perform when intersecting the scene. 1 gives the best performance.
StopIfFinalIterationHits false v1.9.0 If enabled and the last move iteration collided, will not keep the particle at the last impact location to avoid risking penetrating the scene.
CollisionQueryType
(EXPERIMENTAL)
Raytrace

Tells the runtime which kind of collision queries to perform with the world.

  • Raytrace : when moving, the particles will trace a ray in the world along their movement to see if they collide. This assumes the particle is an infinitely small point.
  • SphereSweep : more compute-intensive. When moving, the particles will be treated as a sphere swept into the world, and produce more realistic collisions.
SweepRadiusFactor
(EXPERIMENTAL)
1.0f Factor to apply to the particle sweep radius field, controls how large the particle appears to the collision system.
IgnoreSurfaceProperties false if checked, Particles will ignore surface properties on hit.
RestitutionCombineMode Surface

v1.9.0 Defines how the particle restitution and contact surface restitution are combined.

  • Surface : uses the combine mode of the game engine
  • Average : averages both frictions : (a+b)/2
  • Multiplies : multiplies both frictions together : a*b
  • Min : uses the smallest friction : min(a,b)
  • Max : uses the largest friction : max(a,b)
FrictionCombineMode Surface

v1.9.0 Defines how the particle friction and contact surface friction are combined.

  • Surface : uses the combine mode of the game engine
  • Average : averages both frictions : (a+b)/2
  • Multiplies : multiplies both frictions together : a*b
  • Min : uses the smallest friction : min(a,b)
  • Max : uses the largest friction : max(a,b)
Collisions evolver Field customization
PositionField "Position" If this field is declared as a <float3>, it will be used as the particle position
VelocityField "Velocity" If this field is declared as a <float3>, it will be used as the particle velocity
MassField "Mass" If this field is declared as a <float>, it will be scaled by the static 'DefaultMass' field, before being used as the particle mass.
BounceRestitutionField "BounceRestitution" If this field is declared as a <float>, it will be scaled by the static 'BounceRestitution' field, before being used as the particle bounce restitution.
CollisionCountField "CollisionCount" If this field is declared as an <int>, it will be incremented by the evolver each time the particle collides.
SweepRadiusField
(EXPERIMENTAL)
"Size" Name of the field to be used as the sweep radius. If empty, uses 'SweepRadiusFactor' as a constant sweep radius
Collisions evolver layout


Collisions evolver Auto-fields

The collisions evolver automatically creates, if they don't exist, the following particle fields:


Name Type Footprint TransformMode self access to field
Position float3 16 bytes Transform read/write
Velocity float3 16 bytes Rotate read/write
PrevPosition float3 16 bytes none read/write
CollisionFlags u8 1 bytes none read/write


Collisions evolver Side-effects

The collisions evolver will modify the following fields:

  • Position
  • Velocity
  • CollisionFlags


It will also automatically internally insert an evolve kernel in the evolve kernel graph that will take care of copying 'Position' to 'PrevPosition'. This might be shared with other evolvers, such as the CParticleEvolver Spawner.png spawner evolver.
You do not have to worry about 'PrevPosition' being correctly setup for the collisions evolver, the system will figure it out by itself.