Options
All
  • Public
  • Public/Protected
  • All
Menu

Class b2ParticleSystem

Hierarchy

  • b2ParticleSystem

Index

Constructors

Properties

Methods

Constructors

constructor

Properties

SolveCollision_callback

SolveCollision_callback: b2ParticleSystemSolveCollisionCallback | null = null

UpdateBodyContacts_callback

UpdateBodyContacts_callback: b2ParticleSystemUpdateBodyContactsCallback | null = null

m_accumulation2Buffer

m_accumulation2Buffer: b2Vec2[] = []

When any particles have the flag b2_tensileParticle, this.m_accumulation2Buffer is first allocated and used in SolveTensile() as a temporary buffer for vector values. It will be reallocated on subsequent CreateParticle() calls.

m_accumulationBuffer

m_accumulationBuffer: number[] = []

this.m_accumulationBuffer is used in many functions as a temporary buffer for scalar values.

m_allGroupFlags

m_allGroupFlags: b2ParticleGroupFlag = 0

m_allParticleFlags

m_allParticleFlags: b2ParticleFlag = 0

m_bodyContactBuffer

m_bodyContactBuffer: b2GrowableBuffer<b2ParticleBodyContact> = new b2GrowableBuffer<b2ParticleBodyContact>(() => new b2ParticleBodyContact())

m_bodyContactCountBuffer

m_bodyContactCountBuffer: b2ParticleSystemUserOverridableBuffer<number> = new b2ParticleSystem_UserOverridableBuffer<number>()

m_colorBuffer

m_colorBuffer: b2ParticleSystemUserOverridableBuffer<b2Color> = new b2ParticleSystem_UserOverridableBuffer<b2Color>()

m_consecutiveContactStepsBuffer

m_consecutiveContactStepsBuffer: b2ParticleSystemUserOverridableBuffer<number> = new b2ParticleSystem_UserOverridableBuffer<number>()

m_contactBuffer

m_contactBuffer: b2GrowableBuffer<b2ParticleContact> = new b2GrowableBuffer<b2ParticleContact>(() => new b2ParticleContact())

m_count

m_count: number = 0

m_def

m_def: b2ParticleSystemDef = new b2ParticleSystemDef()

m_depthBuffer

m_depthBuffer: number[] = []

When any particle groups have the flag b2_solidParticleGroup, this.m_depthBuffer is first allocated and populated in ComputeDepth() and used in SolveSolid(). It will be reallocated on subsequent CreateParticle() calls.

m_expirationTimeBuffer

m_expirationTimeBuffer: b2ParticleSystemUserOverridableBuffer<number> = new b2ParticleSystem_UserOverridableBuffer<number>()

Time each particle should be destroyed relative to the last time this.m_timeElapsed was initialized. Each unit of time corresponds to b2ParticleSystemDef::lifetimeGranularity seconds.

m_expirationTimeBufferRequiresSorting

m_expirationTimeBufferRequiresSorting: boolean = false

Whether the expiration time buffer has been modified and needs to be resorted.

m_flagsBuffer

m_flagsBuffer: b2ParticleSystemUserOverridableBuffer<b2ParticleFlag> = new b2ParticleSystem_UserOverridableBuffer<b2ParticleFlag>()

m_forceBuffer

m_forceBuffer: b2Vec2[] = []

m_groupBuffer

m_groupBuffer: Array<b2ParticleGroup | null> = []

m_groupCount

m_groupCount: number = 0

m_groupList

m_groupList: b2ParticleGroup | null = null

m_handleIndexBuffer

m_handleIndexBuffer: b2ParticleSystemUserOverridableBuffer<b2ParticleHandle | null> = new b2ParticleSystem_UserOverridableBuffer<b2ParticleHandle | null>()

Maps particle indicies to handles.

m_hasForce

m_hasForce: boolean = false

m_indexByExpirationTimeBuffer

m_indexByExpirationTimeBuffer: b2ParticleSystemUserOverridableBuffer<number> = new b2ParticleSystem_UserOverridableBuffer<number>()

List of particle indices sorted by expiration time.

m_internalAllocatedCapacity

m_internalAllocatedCapacity: number = 0

m_inverseDensity

m_inverseDensity: number = 0

m_inverseDiameter

m_inverseDiameter: number = 0

m_iterationIndex

m_iterationIndex: number = 0

m_lastBodyContactStepBuffer

m_lastBodyContactStepBuffer: b2ParticleSystemUserOverridableBuffer<number> = new b2ParticleSystem_UserOverridableBuffer<number>()

m_needsUpdateAllGroupFlags

m_needsUpdateAllGroupFlags: boolean = false

m_needsUpdateAllParticleFlags

m_needsUpdateAllParticleFlags: boolean = false

m_next

m_next: b2ParticleSystem | null = null

m_pairBuffer

m_pairBuffer: b2GrowableBuffer<b2ParticlePair> = new b2GrowableBuffer<b2ParticlePair>(() => new b2ParticlePair())

m_particleDiameter

m_particleDiameter: number = 0

m_paused

m_paused: boolean = false

m_positionBuffer

m_positionBuffer: b2ParticleSystemUserOverridableBuffer<b2Vec2> = new b2ParticleSystem_UserOverridableBuffer<b2Vec2>()

m_prev

m_prev: b2ParticleSystem | null = null

m_proxyBuffer

m_proxyBuffer: b2GrowableBuffer<b2ParticleSystemProxy> = new b2GrowableBuffer<b2ParticleSystem_Proxy>(() => new b2ParticleSystem_Proxy())

m_squaredDiameter

m_squaredDiameter: number = 0

m_staticPressureBuffer

m_staticPressureBuffer: number[] = []

When any particles have the flag b2_staticPressureParticle, this.m_staticPressureBuffer is first allocated and used in SolveStaticPressure() and SolvePressure(). It will be reallocated on subsequent CreateParticle() calls.

m_stuckParticleBuffer

m_stuckParticleBuffer: b2GrowableBuffer<number> = new b2GrowableBuffer<number>(() => 0)

m_stuckThreshold

m_stuckThreshold: number = 0

Stuck particle detection parameters and record keeping

m_timeElapsed

m_timeElapsed: number = 0

Time elapsed in 32:32 fixed point. Each non-fractional unit of time corresponds to b2ParticleSystemDef::lifetimeGranularity seconds.

m_timestamp

m_timestamp: number = 0

m_triadBuffer

m_triadBuffer: b2GrowableBuffer<b2ParticleTriad> = new b2GrowableBuffer<b2ParticleTriad>(() => new b2ParticleTriad())

m_userDataBuffer

m_userDataBuffer: b2ParticleSystemUserOverridableBuffer<any> = new b2ParticleSystem_UserOverridableBuffer()

m_velocityBuffer

m_velocityBuffer: b2ParticleSystemUserOverridableBuffer<b2Vec2> = new b2ParticleSystem_UserOverridableBuffer<b2Vec2>()

m_weightBuffer

m_weightBuffer: number[] = []

this.m_weightBuffer is populated in ComputeWeight and used in ComputeDepth(), SolveStaticPressure() and SolvePressure().

m_world

m_world: b2World

Static Readonly AddContact_s_d

AddContact_s_d: b2Vec2 = new b2Vec2()

Static Readonly ComputeCollisionEnergy_s_v

ComputeCollisionEnergy_s_v: b2Vec2 = new b2Vec2()

Static Readonly CreateParticleGroup_s_transform

CreateParticleGroup_s_transform: b2Transform = new b2Transform()

Static Readonly CreateParticlesFillShapeForGroup_s_aabb

CreateParticlesFillShapeForGroup_s_aabb: b2AABB = new b2AABB()

Static Readonly CreateParticlesFillShapeForGroup_s_p

CreateParticlesFillShapeForGroup_s_p: b2Vec2 = new b2Vec2()

Static Readonly CreateParticlesStrokeShapeForGroup_s_d

CreateParticlesStrokeShapeForGroup_s_d: b2Vec2 = new b2Vec2()

Static Readonly CreateParticlesStrokeShapeForGroup_s_edge

CreateParticlesStrokeShapeForGroup_s_edge: b2EdgeShape = new b2EdgeShape()

Static Readonly CreateParticlesStrokeShapeForGroup_s_p

CreateParticlesStrokeShapeForGroup_s_p: b2Vec2 = new b2Vec2()

Static Readonly DestroyParticlesInShape_s_aabb

DestroyParticlesInShape_s_aabb: b2AABB = new b2AABB()

Static Readonly QueryPointAABB_s_aabb

QueryPointAABB_s_aabb: b2AABB = new b2AABB()

Static Readonly QueryShapeAABB_s_aabb

QueryShapeAABB_s_aabb: b2AABB = new b2AABB()

Static Readonly RayCast_s_aabb

RayCast_s_aabb: b2AABB = new b2AABB()

Static Readonly RayCast_s_n

RayCast_s_n: b2Vec2 = new b2Vec2()

Static Readonly RayCast_s_p

RayCast_s_p: b2Vec2 = new b2Vec2()

Static Readonly RayCast_s_point

RayCast_s_point: b2Vec2 = new b2Vec2()

Static Readonly RayCast_s_v

RayCast_s_v: b2Vec2 = new b2Vec2()

Static Private RemoveSpuriousBodyContacts_s_n

RemoveSpuriousBodyContacts_s_n: b2Vec2 = new b2Vec2()

Static Private RemoveSpuriousBodyContacts_s_normal

RemoveSpuriousBodyContacts_s_normal: b2Vec2 = new b2Vec2()

Static Private RemoveSpuriousBodyContacts_s_pos

RemoveSpuriousBodyContacts_s_pos: b2Vec2 = new b2Vec2()

Static Readonly SolveBarrier_s_aabb

SolveBarrier_s_aabb: b2AABB = new b2AABB()

Static Readonly SolveBarrier_s_dv

SolveBarrier_s_dv: b2Vec2 = new b2Vec2()

Static Readonly SolveBarrier_s_f

SolveBarrier_s_f: b2Vec2 = new b2Vec2()

Static Readonly SolveBarrier_s_pba

SolveBarrier_s_pba: b2Vec2 = new b2Vec2()

Static Readonly SolveBarrier_s_pca

SolveBarrier_s_pca: b2Vec2 = new b2Vec2()

Static Readonly SolveBarrier_s_qba

SolveBarrier_s_qba: b2Vec2 = new b2Vec2()

Static Readonly SolveBarrier_s_qca

SolveBarrier_s_qca: b2Vec2 = new b2Vec2()

Static Readonly SolveBarrier_s_va

SolveBarrier_s_va: b2Vec2 = new b2Vec2()

Static Readonly SolveBarrier_s_vb

SolveBarrier_s_vb: b2Vec2 = new b2Vec2()

Static Readonly SolveBarrier_s_vba

SolveBarrier_s_vba: b2Vec2 = new b2Vec2()

Static Readonly SolveBarrier_s_vc

SolveBarrier_s_vc: b2Vec2 = new b2Vec2()

Static Readonly SolveBarrier_s_vca

SolveBarrier_s_vca: b2Vec2 = new b2Vec2()

Static Readonly SolveCollision_s_aabb

SolveCollision_s_aabb: b2AABB = new b2AABB()

Static Readonly SolveDamping_s_f

SolveDamping_s_f: b2Vec2 = new b2Vec2()

Static Readonly SolveDamping_s_v

SolveDamping_s_v: b2Vec2 = new b2Vec2()

Static Readonly SolveElastic_s_pa

SolveElastic_s_pa: b2Vec2 = new b2Vec2()

Static Readonly SolveElastic_s_pb

SolveElastic_s_pb: b2Vec2 = new b2Vec2()

Static Readonly SolveElastic_s_pc

SolveElastic_s_pc: b2Vec2 = new b2Vec2()

Static Readonly SolveElastic_s_r

SolveElastic_s_r: b2Rot = new b2Rot()

Static Readonly SolveElastic_s_t0

SolveElastic_s_t0: b2Vec2 = new b2Vec2()

Static Readonly SolveExtraDamping_s_f

SolveExtraDamping_s_f: b2Vec2 = new b2Vec2()

Static Readonly SolveExtraDamping_s_v

SolveExtraDamping_s_v: b2Vec2 = new b2Vec2()

Static Readonly SolveGravity_s_gravity

SolveGravity_s_gravity: b2Vec2 = new b2Vec2()

Static Readonly SolvePowder_s_f

SolvePowder_s_f: b2Vec2 = new b2Vec2()

Static Readonly SolvePressure_s_f

SolvePressure_s_f: b2Vec2 = new b2Vec2()

Static Readonly SolveRepulsive_s_f

SolveRepulsive_s_f: b2Vec2 = new b2Vec2()

Static Readonly SolveRigidDamping_s_p

SolveRigidDamping_s_p: b2Vec2 = new b2Vec2()

Static Readonly SolveRigidDamping_s_t0

SolveRigidDamping_s_t0: b2Vec2 = new b2Vec2()

Static Readonly SolveRigidDamping_s_t1

SolveRigidDamping_s_t1: b2Vec2 = new b2Vec2()

Static Readonly SolveRigidDamping_s_v

SolveRigidDamping_s_v: b2Vec2 = new b2Vec2()

Static Readonly SolveRigid_s_position

SolveRigid_s_position: b2Vec2 = new b2Vec2()

Static Readonly SolveRigid_s_rotation

SolveRigid_s_rotation: b2Rot = new b2Rot()

Static Readonly SolveRigid_s_transform

SolveRigid_s_transform: b2Transform = new b2Transform()

Static Readonly SolveRigid_s_velocityTransform

SolveRigid_s_velocityTransform: b2Transform = new b2Transform()

Static Readonly SolveSolid_s_f

SolveSolid_s_f: b2Vec2 = new b2Vec2()

Static Readonly SolveSpring_s_d

SolveSpring_s_d: b2Vec2 = new b2Vec2()

Static Readonly SolveSpring_s_f

SolveSpring_s_f: b2Vec2 = new b2Vec2()

Static Readonly SolveSpring_s_pa

SolveSpring_s_pa: b2Vec2 = new b2Vec2()

Static Readonly SolveSpring_s_pb

SolveSpring_s_pb: b2Vec2 = new b2Vec2()

Static Readonly SolveTensile_s_f

SolveTensile_s_f: b2Vec2 = new b2Vec2()

Static Readonly SolveTensile_s_s

SolveTensile_s_s: b2Vec2 = new b2Vec2()

Static Readonly SolveTensile_s_weightedNormal

SolveTensile_s_weightedNormal: b2Vec2 = new b2Vec2()

Static Readonly SolveViscous_s_f

SolveViscous_s_f: b2Vec2 = new b2Vec2()

Static Readonly SolveViscous_s_v

SolveViscous_s_v: b2Vec2 = new b2Vec2()

Static Readonly Solve_s_subStep

Solve_s_subStep: b2TimeStep = new b2TimeStep()

Static Readonly UpdateBodyContacts_s_aabb

UpdateBodyContacts_s_aabb: b2AABB = new b2AABB()

Static Private UpdatePairsAndTriads_s_dab

UpdatePairsAndTriads_s_dab: b2Vec2 = new b2Vec2()

Static Private UpdatePairsAndTriads_s_dbc

UpdatePairsAndTriads_s_dbc: b2Vec2 = new b2Vec2()

Static Private UpdatePairsAndTriads_s_dca

UpdatePairsAndTriads_s_dca: b2Vec2 = new b2Vec2()

Static Readonly k_barrierWallFlags

k_barrierWallFlags: number = b2ParticleFlag.b2_barrierParticle | b2ParticleFlag.b2_wallParticle

Static Readonly k_extraDampingFlags

k_extraDampingFlags: b2ParticleFlag = b2ParticleFlag.b2_staticPressureParticle

All particle types that apply extra damping force with bodies

Static Readonly k_noPressureFlags

k_noPressureFlags: number = b2ParticleFlag.b2_powderParticle | b2ParticleFlag.b2_tensileParticle

All particle types that do not produce dynamic pressure

Static Readonly k_pairFlags

k_pairFlags: number = b2ParticleFlag.b2_springParticle

All particle types that require creating pairs

Static Readonly k_triadFlags

k_triadFlags: b2ParticleFlag = b2ParticleFlag.b2_elasticParticle

All particle types that require creating triads

Static Readonly tagBits

tagBits: number = 8 * 4

Static Readonly xMask

xMask: number = ~b2ParticleSystem.yMask

Static Readonly xOffset

xOffset: number = b2ParticleSystem.xScale * (1 << (b2ParticleSystem.xTruncBits - 1))

Static Readonly xScale

xScale: number = 1 << b2ParticleSystem.xShift

Static Readonly xShift

xShift: number = b2ParticleSystem.tagBits - b2ParticleSystem.yTruncBits - b2ParticleSystem.xTruncBits

Static Readonly xTruncBits

xTruncBits: number = 12

Static Readonly yMask

yMask: number = ((1 << b2ParticleSystem.yTruncBits) - 1) << b2ParticleSystem.yShift

Static Readonly yOffset

yOffset: number = 1 << (b2ParticleSystem.yTruncBits - 1)

Static Readonly yShift

yShift: number = b2ParticleSystem.tagBits - b2ParticleSystem.yTruncBits

Static Readonly yTruncBits

yTruncBits: number = 12

Methods

AddContact

  • Parameters

    Returns void

ApplyDamping

  • ApplyDamping(invMass: number, invInertia: number, tangentDistance: number, isRigidGroup: boolean, group: b2ParticleGroup | null, particleIndex: number, impulse: number, normal: b2Vec2): void
  • Parameters

    • invMass: number
    • invInertia: number
    • tangentDistance: number
    • isRigidGroup: boolean
    • group: b2ParticleGroup | null
    • particleIndex: number
    • impulse: number
    • normal: b2Vec2

    Returns void

ApplyForce

  • ApplyForce(firstIndex: number, lastIndex: number, force: XY): void
  • Distribute a force across several particles. The particles must not be wall particles. Note that the force is distributed across all the particles, so calling this function for indices 0..N is not the same as calling ParticleApplyForce(i, force) for i in 0..N.

    Parameters

    • firstIndex: number

      the first particle to be modified.

    • lastIndex: number

      the last particle to be modified.

    • force: XY

      the world force vector, usually in Newtons (N).

    Returns void

ApplyLinearImpulse

  • ApplyLinearImpulse(firstIndex: number, lastIndex: number, impulse: XY): void
  • Apply an impulse to all particles between 'firstIndex' and 'lastIndex'. This immediately modifies the velocity. Note that the impulse is applied to the total mass of all particles. So, calling ParticleApplyLinearImpulse(0, impulse) and ParticleApplyLinearImpulse(1, impulse) will impart twice as much velocity as calling just ApplyLinearImpulse(0, 1, impulse).

    Parameters

    • firstIndex: number

      the first particle to be modified.

    • lastIndex: number

      the last particle to be modified.

    • impulse: XY

      the world impulse vector, usually in N-seconds or kg-m/s.

    Returns void

CloneParticle

  • Parameters

    Returns number

ComputeAABB

  • ComputeAABB(aabb: b2AABB): void
  • Compute the axis-aligned bounding box for all particles contained within this particle system.

    Parameters

    • aabb: b2AABB

      Returns the axis-aligned bounding box of the system.

    Returns void

ComputeCollisionEnergy

  • ComputeCollisionEnergy(): number
  • Compute the kinetic energy that can be lost by damping force

    Returns number

ComputeDampingImpulse

  • ComputeDampingImpulse(invMassA: number, invInertiaA: number, tangentDistanceA: number, invMassB: number, invInertiaB: number, tangentDistanceB: number, normalVelocity: number): number
  • Parameters

    • invMassA: number
    • invInertiaA: number
    • tangentDistanceA: number
    • invMassB: number
    • invInertiaB: number
    • tangentDistanceB: number
    • normalVelocity: number

    Returns number

ComputeDepth

  • ComputeDepth(): void
  • Returns void

ComputeWeight

  • ComputeWeight(): void
  • Returns void

CreateParticle

  • Create a particle whose properties have been defined.

    No reference to the definition is retained. A simulation step must occur before it's possible to interact with a newly created particle. For example, DestroyParticleInShape() will not destroy a particle until b2World::Step() has been called. warning: This function is locked during callbacks.

    Parameters

    Returns number

CreateParticleForGroup

CreateParticleGroup

  • Create a particle group whose properties have been defined.

    No reference to the definition is retained. warning: This function is locked during callbacks.

    Parameters

    Returns b2ParticleGroup

CreateParticleGroupsFromParticleList

CreateParticlesFillShapeForGroup

CreateParticlesStrokeShapeForGroup

CreateParticlesWithShapeForGroup

CreateParticlesWithShapesForGroup

  • Parameters

    Returns void

DestroyOldestParticle

  • DestroyOldestParticle(index: number, callDestructionListener?: boolean): void
  • Destroy the Nth oldest particle in the system.

    The particle is removed after the next b2World::Step().

    Parameters

    • index: number

      Index of the Nth oldest particle to destroy, 0 will destroy the oldest particle in the system, 1 will destroy the next oldest particle etc.

    • Default value callDestructionListener: boolean = false

      Whether to call the destruction listener just before the particle is destroyed.

    Returns void

DestroyParticle

  • DestroyParticle(index: number, callDestructionListener?: boolean): void
  • Destroy a particle.

    The particle is removed after the next simulation step (see b2World::Step()).

    Parameters

    • index: number

      Index of the particle to destroy.

    • Default value callDestructionListener: boolean = false

      Whether to call the destruction listener just before the particle is destroyed.

    Returns void

DestroyParticleGroup

  • Parameters

    Returns void

DestroyParticlesInGroup

  • DestroyParticlesInGroup(group: b2ParticleGroup, callDestructionListener?: boolean): void
  • Parameters

    • group: b2ParticleGroup
    • Default value callDestructionListener: boolean = false

    Returns void

DestroyParticlesInShape

  • DestroyParticlesInShape(shape: b2Shape, xf: b2Transform, callDestructionListener?: boolean): number
  • Destroy particles inside a shape.

    warning: This function is locked during callbacks. In addition, this function immediately destroys particles in the shape in constrast to DestroyParticle() which defers the destruction until the next simulation step.

    Parameters

    • shape: b2Shape

      Shape which encloses particles that should be destroyed.

    • xf: b2Transform

      Transform applied to the shape.

    • Default value callDestructionListener: boolean = false

      Whether to call the world b2DestructionListener for each particle destroyed.

    Returns number

    Number of particles destroyed.

DetectStuckParticle

  • DetectStuckParticle(particle: number): void
  • Parameters

    • particle: number

    Returns void

Drop

  • Drop(): void
  • Returns void

ExpirationTimeToLifetime

  • ExpirationTimeToLifetime(expirationTime: number): number
  • Convert a expiration time value in returned by GetExpirationTimeBuffer() to a time in seconds relative to the current simulation time.

    Parameters

    • expirationTime: number

    Returns number

FilterContacts

FindContacts

FindContactsReference

ForceCanBeApplied

  • Parameters

    Returns boolean

FreeBuffer

  • FreeBuffer<T>(b: T[] | null, capacity: number): void
  • Type parameters

    • T

    Parameters

    • b: T[] | null
    • capacity: number

    Returns void

FreeUserOverridableBuffer

GetAllGroupFlags

  • Get all existing particle group flags.

    Returns b2ParticleGroupFlag

GetAllParticleFlags

  • Get all existing particle flags.

    Returns b2ParticleFlag

GetBodyContactCount

  • GetBodyContactCount(): number
  • Returns number

GetBodyContacts

  • Get contacts between particles and bodies

    Contact data can be used for many reasons, for example to trigger rendering or audio effects.

    Returns b2ParticleBodyContact[]

GetColorBuffer

  • Get the color of each particle

    Array is length GetParticleCount()

    Returns b2Color[]

    the pointer to the head of the particle colors array.

GetContactCount

  • GetContactCount(): number
  • Returns number

GetContacts

  • Get contacts between particles Contact data can be used for many reasons, for example to trigger rendering or audio effects.

    Returns b2ParticleContact[]

GetCriticalPressure

  • Parameters

    Returns number

GetCriticalVelocity

  • Parameters

    Returns number

GetCriticalVelocitySquared

  • GetCriticalVelocitySquared(step: b2TimeStep): number
  • Parameters

    Returns number

GetDamping

  • GetDamping(): number
  • Get damping for particles

    Returns number

GetDensity

  • GetDensity(): number
  • Get the particle density.

    Returns number

GetDestructionByAge

  • GetDestructionByAge(): boolean
  • Get whether the oldest particle will be destroyed in CreateParticle() when the maximum number of particles are present in the system.

    Returns boolean

GetExpirationTimeBuffer

  • GetExpirationTimeBuffer(): number[]
  • Get the array of particle expiration times indexed by particle index.

    GetParticleCount() items are in the returned array.

    Returns number[]

GetFixtureContactFilter

  • Get the world's contact filter if any particles with the b2_contactFilterParticle flag are present in the system.

    Returns b2ContactFilter | null

GetFixtureContactListener

  • Get the world's contact listener if any particles with the b2_fixtureContactListenerParticle flag are present in the system.

    Returns b2ContactListener | null

GetFlagsBuffer

  • Get the flags for each particle. See the b2ParticleFlag enum.

    Array is length GetParticleCount()

    Returns b2ParticleFlag[]

    the pointer to the head of the particle-flags array.

GetGravityScale

  • GetGravityScale(): number
  • Get the particle gravity scale.

    Returns number

GetGroupBuffer

  • Get the particle-group of each particle.

    Array is length GetParticleCount()

    Returns Array<b2ParticleGroup | null>

    the pointer to the head of the particle group array.

GetIndexByExpirationTimeBuffer

  • GetIndexByExpirationTimeBuffer(): number[]
  • Get the array of particle indices ordered by reverse lifetime. The oldest particle indexes are at the end of the array with the newest at the start. Particles with infinite lifetimes (i.e expiration times less than or equal to 0) are placed at the start of the array. ExpirationTimeToLifetime(GetExpirationTimeBuffer()[index]) is equivalent to GetParticleLifetime(index).

    GetParticleCount() items are in the returned array.

    Returns number[]

GetInsideBoundsEnumerator

GetLinearVelocity

  • Parameters

    Returns b2Vec2

GetMaxParticleCount

  • GetMaxParticleCount(): number
  • Get the maximum number of particles.

    Returns number

GetNext

  • Get the next particle-system in the world's particle-system list.

    Returns b2ParticleSystem | null

GetPairCount

  • GetPairCount(): number
  • Returns number

GetPairs

  • Get array of particle pairs. The particles in a pair: (1) are contacting, (2) are in the same particle group, (3) are part of a rigid particle group, or are spring, elastic, or wall particles. (4) have at least one particle that is a spring or barrier particle (i.e. one of the types in k_pairFlags), (5) have at least one particle that returns true for ConnectionFilter::IsNecessary, (6) are not zombie particles.

    Essentially, this is an array of spring or barrier particles that are interacting. The array is sorted by b2ParticlePair's indexA, and then indexB. There are no duplicate entries.

    Returns b2ParticlePair[]

GetParticleContactFilter

  • Get the world's contact filter if any particles with the b2_particleContactFilterParticle flag are present in the system.

    Returns b2ContactFilter | null

GetParticleContactListener

  • Get the world's contact listener if any particles with the b2_particleContactListenerParticle flag are present in the system.

    Returns b2ContactListener | null

GetParticleCount

  • GetParticleCount(): number
  • Get the number of particles.

    Returns number

GetParticleFlags

  • Get flags for a particle. See the b2ParticleFlag enum.

    Parameters

    • index: number

    Returns b2ParticleFlag

GetParticleGroupCount

  • GetParticleGroupCount(): number
  • Get the number of particle groups.

    Returns number

GetParticleGroupList

  • Get the world particle group list. With the returned group, use b2ParticleGroup::GetNext to get the next group in the world list.

    A null group indicates the end of the list.

    Returns b2ParticleGroup | null

    the head of the world particle group list.

GetParticleHandleFromIndex

  • Retrieve a handle to the particle at the specified index.

    Please see #b2ParticleHandle for why you might want a handle.

    Parameters

    • index: number

    Returns b2ParticleHandle

GetParticleInvMass

  • GetParticleInvMass(): number
  • Returns number

GetParticleLifetime

  • GetParticleLifetime(index: number): number
  • Get the lifetime (in seconds) of a particle relative to the current time. A value > 0.0f is returned if the particle is scheduled to be destroyed in the future, values <= 0.0f indicate the particle has an infinite lifetime.

    Parameters

    • index: number

    Returns number

GetParticleMass

  • GetParticleMass(): number
  • Returns number

GetParticleStride

  • GetParticleStride(): number
  • Returns number

GetPaused

  • GetPaused(): boolean
  • Initially, true, then, the last value passed into SetPaused().

    Returns boolean

    true if the particle system is being updated in b2World::Step().

GetPositionBuffer

  • GetPositionBuffer(): b2Vec2[]
  • Get the position of each particle

    Array is length GetParticleCount()

    Returns b2Vec2[]

    the pointer to the head of the particle positions array.

GetQuantizedTimeElapsed

  • GetQuantizedTimeElapsed(): number
  • Get the time elapsed in b2ParticleSystemDef::lifetimeGranularity.

    Returns number

GetRadius

  • GetRadius(): number
  • Get the particle radius.

    Returns number

GetStaticPressureIterations

  • GetStaticPressureIterations(): number
  • Get the number of iterations for static pressure of particles.

    Returns number

GetStrictContactCheck

  • GetStrictContactCheck(): boolean
  • Get the status of the strict contact check.

    Returns boolean

GetStuckCandidateCount

  • GetStuckCandidateCount(): number
  • Get the number of stuck particle candidates from the last step.

    Returns number

GetStuckCandidates

  • GetStuckCandidates(): number[]
  • Get potentially stuck particles from the last step; the user must decide if they are stuck or not, and if so, delete or move them

    Returns number[]

GetTriadCount

  • GetTriadCount(): number
  • Returns number

GetTriads

  • Get array of particle triads. The particles in a triad: (1) are in the same particle group, (2) are in a Voronoi triangle together, (3) are within b2_maxTriadDistance particle diameters of each other, (4) return true for ConnectionFilter::ShouldCreateTriad (5) have at least one particle of type elastic (i.e. one of the types in k_triadFlags), (6) are part of a rigid particle group, or are spring, elastic, or wall particles. (7) are not zombie particles.

    Essentially, this is an array of elastic particles that are interacting. The array is sorted by b2ParticleTriad's indexA, then indexB, then indexC. There are no duplicate entries.

    Returns b2ParticleTriad[]

GetUserDataBuffer

  • GetUserDataBuffer<T>(): T[]
  • Get the user-specified data of each particle.

    Array is length GetParticleCount()

    Type parameters

    • T

    Returns T[]

    the pointer to the head of the particle user-data array.

GetVelocityBuffer

  • GetVelocityBuffer(): b2Vec2[]
  • Get the velocity of each particle

    Array is length GetParticleCount()

    Returns b2Vec2[]

    the pointer to the head of the particle velocities array.

GetWeightBuffer

  • GetWeightBuffer(): number[]
  • Get the weight of each particle

    Array is length GetParticleCount()

    Returns number[]

    the pointer to the head of the particle positions array.

InitDampingParameter

  • InitDampingParameter(invMass: number[], invInertia: number[], tangentDistance: number[], mass: number, inertia: number, center: b2Vec2, point: b2Vec2, normal: b2Vec2): void
  • Parameters

    • invMass: number[]
    • invInertia: number[]
    • tangentDistance: number[]
    • mass: number
    • inertia: number
    • center: b2Vec2
    • point: b2Vec2
    • normal: b2Vec2

    Returns void

InitDampingParameterWithRigidGroupOrParticle

  • InitDampingParameterWithRigidGroupOrParticle(invMass: number[], invInertia: number[], tangentDistance: number[], isRigidGroup: boolean, group: b2ParticleGroup | null, particleIndex: number, point: b2Vec2, normal: b2Vec2): void
  • Parameters

    • invMass: number[]
    • invInertia: number[]
    • tangentDistance: number[]
    • isRigidGroup: boolean
    • group: b2ParticleGroup | null
    • particleIndex: number
    • point: b2Vec2
    • normal: b2Vec2

    Returns void

IsRigidGroup

  • Parameters

    Returns boolean

JoinParticleGroups

  • Join two particle groups.

    warning: This function is locked during callbacks.

    Parameters

    Returns void

LifetimeToExpirationTime

  • LifetimeToExpirationTime(lifetime: number): number
  • Convert a lifetime in seconds to an expiration time.

    Parameters

    • lifetime: number

    Returns number

LimitVelocity

  • Parameters

    Returns void

MergeParticleListsInContact

MergeZombieParticleListNodes

NotifyBodyContactListenerPostContact

NotifyBodyContactListenerPreContact

NotifyContactListenerPostContact

  • Parameters

    Returns void

NotifyContactListenerPreContact

  • Parameters

    Returns void

ParticleApplyForce

  • ParticleApplyForce(index: number, force: XY): void
  • Apply a force to the center of a particle.

    Parameters

    • index: number

      the particle that will be modified.

    • force: XY

      the world force vector, usually in Newtons (N).

    Returns void

ParticleApplyLinearImpulse

  • ParticleApplyLinearImpulse(index: number, impulse: XY): void
  • Apply an impulse to one particle. This immediately modifies the velocity. Similar to b2Body::ApplyLinearImpulse.

    Parameters

    • index: number

      the particle that will be modified.

    • impulse: XY

      impulse the world impulse vector, usually in N-seconds or kg-m/s.

    Returns void

PrepareForceBuffer

  • PrepareForceBuffer(): void
  • Returns void

QueryAABB

  • Query the particle system for all particles that potentially overlap the provided AABB. b2QueryCallback::ShouldQueryParticleSystem is ignored.

    Parameters

    Returns void

QueryPointAABB

  • Parameters

    Returns void

QueryShapeAABB

  • Query the particle system for all particles that potentially overlap the provided shape's AABB. Calls QueryAABB internally. b2QueryCallback::ShouldQueryParticleSystem is ignored.

    Parameters

    • callback: b2QueryCallback

      a user implemented callback class.

    • shape: b2Shape

      the query shape

    • xf: b2Transform

      the transform of the AABB

    • Default value childIndex: number = 0

    Returns void

RayCast

  • Ray-cast the particle system for all particles in the path of the ray. Your callback controls whether you get the closest point, any point, or n-points. The ray-cast ignores particles that contain the starting point. b2RayCastCallback::ShouldQueryParticleSystem is ignored.

    Parameters

    • callback: b2RayCastCallback

      a user implemented callback class.

    • point1: XY

      the ray starting point

    • point2: XY

      the ray ending point

    Returns void

ReallocateBuffer3

  • ReallocateBuffer3<T>(oldBuffer: T[] | null, oldCapacity: number, newCapacity: number): T[]
  • Reallocate a buffer

    Type parameters

    • T

    Parameters

    • oldBuffer: T[] | null
    • oldCapacity: number
    • newCapacity: number

    Returns T[]

ReallocateBuffer4

  • Reallocate a buffer

    Type parameters

    • T

    Parameters

    Returns T[]

ReallocateBuffer5

  • ReallocateBuffer5<T>(buffer: T[] | null, userSuppliedCapacity: number, oldCapacity: number, newCapacity: number, deferred: boolean): T[]
  • Reallocate a buffer

    Type parameters

    • T

    Parameters

    • buffer: T[] | null
    • userSuppliedCapacity: number
    • oldCapacity: number
    • newCapacity: number
    • deferred: boolean

    Returns T[]

ReallocateHandleBuffers

  • ReallocateHandleBuffers(newCapacity: number): void
  • Reallocate the handle / index map and schedule the allocation of a new pool for handle allocation.

    Parameters

    • newCapacity: number

    Returns void

ReallocateInternalAllocatedBuffers

  • ReallocateInternalAllocatedBuffers(capacity: number): void
  • Parameters

    • capacity: number

    Returns void

RemoveSpuriousBodyContacts

  • RemoveSpuriousBodyContacts(): void
  • Returns void

RequestBuffer

  • RequestBuffer<T>(buffer: T[] | null): T[]
  • Type parameters

    • T

    Parameters

    • buffer: T[] | null

    Returns T[]

RotateBuffer

  • RotateBuffer(start: number, mid: number, end: number): void
  • Parameters

    • start: number
    • mid: number
    • end: number

    Returns void

SetColorBuffer

  • SetColorBuffer(buffer: b2Color[] | Float32Array): void
  • Parameters

    Returns void

SetDamping

  • SetDamping(damping: number): void
  • Damping is used to reduce the velocity of particles. The damping parameter can be larger than 1.0f but the damping effect becomes sensitive to the time step when the damping parameter is large.

    Parameters

    • damping: number

    Returns void

SetDensity

  • SetDensity(density: number): void
  • Change the particle density.

    Particle density affects the mass of the particles, which in turn affects how the particles interact with b2Bodies. Note that the density does not affect how the particles interact with each other.

    Parameters

    • density: number

    Returns void

SetDestructionByAge

  • SetDestructionByAge(enable: boolean): void
  • Enable / disable destruction of particles in CreateParticle() when no more particles can be created due to a prior call to SetMaxParticleCount(). When this is enabled, the oldest particle is destroyed in CreateParticle() favoring the destruction of particles with a finite lifetime over particles with infinite lifetimes. This feature is enabled by default when particle lifetimes are tracked. Explicitly enabling this feature using this function enables particle lifetime tracking.

    Parameters

    • enable: boolean

    Returns void

SetFlagsBuffer

  • Set an external buffer for particle data.

    Normally, the b2World's block allocator is used for particle data. However, sometimes you may have an OpenGL or Java buffer for particle data. To avoid data duplication, you may supply this external buffer. Note that, when b2World's block allocator is used, the particle data buffers can grow as required. However, when external buffers are used, the maximum number of particles is clamped to the size of the smallest external buffer.

    Parameters

    Returns void

SetGravityScale

  • SetGravityScale(gravityScale: number): void
  • Change the particle gravity scale. Adjusts the effect of the global gravity vector on particles.

    Parameters

    • gravityScale: number

    Returns void

SetGroupFlags

SetMaxParticleCount

  • SetMaxParticleCount(count: number): void
  • Set the maximum number of particles.

    A value of 0 means there is no maximum. The particle buffers can continue to grow while b2World's block allocator still has memory. Note: If you try to CreateParticle() with more than this count, b2_invalidParticleIndex is returned unless SetDestructionByAge() is used to enable the destruction of the oldest particles in the system.

    Parameters

    • count: number

    Returns void

SetParticleFlags

  • Set flags for a particle. See the b2ParticleFlag enum.

    Parameters

    Returns void

SetParticleLifetime

  • SetParticleLifetime(index: number, lifetime: number): void
  • Set the lifetime (in seconds) of a particle relative to the current time. A lifetime of less than or equal to 0.0f results in the particle living forever until it's manually destroyed by the application.

    Parameters

    • index: number
    • lifetime: number

    Returns void

SetPaused

  • SetPaused(paused: boolean): void
  • Pause or unpause the particle system. When paused, b2World::Step() skips over this particle system. All b2ParticleSystem function calls still work.

    Parameters

    • paused: boolean

      paused is true to pause, false to un-pause.

    Returns void

SetPositionBuffer

  • SetPositionBuffer(buffer: b2Vec2[] | Float32Array): void
  • Parameters

    • buffer: b2Vec2[] | Float32Array

    Returns void

SetRadius

  • SetRadius(radius: number): void
  • Change the particle radius.

    You should set this only once, on world start. If you change the radius during execution, existing particles may explode, shrink, or behave unexpectedly.

    Parameters

    • radius: number

    Returns void

SetStaticPressureIterations

  • SetStaticPressureIterations(iterations: number): void
  • Change the number of iterations when calculating the static pressure of particles. By default, 8 iterations. You can reduce the number of iterations down to 1 in some situations, but this may cause instabilities when many particles come together. If you see particles popping away from each other like popcorn, you may have to increase the number of iterations.

    For a description of static pressure, see http://en.wikipedia.org/wiki/Static_pressure#Static_pressure_in_fluid_dynamics

    Parameters

    • iterations: number

    Returns void

SetStrictContactCheck

  • SetStrictContactCheck(enabled: boolean): void
  • Set strict Particle/Body contact check.

    This is an option that will help ensure correct behavior if there are corners in the world model where Particle/Body contact is ambiguous. This option scales at n*log(n) of the number of Particle/Body contacts, so it is best to only enable if it is necessary for your geometry. Enable if you see strange particle behavior around b2Body intersections.

    Parameters

    • enabled: boolean

    Returns void

SetStuckThreshold

  • SetStuckThreshold(steps: number): void
  • Set an optional threshold for the maximum number of consecutive particle iterations that a particle may contact multiple bodies before it is considered a candidate for being "stuck". Setting to zero or less disables.

    Parameters

    • steps: number

    Returns void

SetUserDataBuffer

  • SetUserDataBuffer<T>(buffer: T[]): void
  • Type parameters

    • T

    Parameters

    • buffer: T[]

    Returns void

SetUserOverridableBuffer

SetVelocityBuffer

  • SetVelocityBuffer(buffer: b2Vec2[] | Float32Array): void
  • Parameters

    • buffer: b2Vec2[] | Float32Array

    Returns void

Solve

  • Parameters

    Returns void

SolveBarrier

  • Parameters

    Returns void

SolveCollision

  • Parameters

    Returns void

SolveColorMixing

  • SolveColorMixing(): void
  • Returns void

SolveDamping

  • Parameters

    Returns void

SolveElastic

  • Parameters

    Returns void

SolveExtraDamping

  • SolveExtraDamping(): void
  • Returns void

SolveForce

  • Parameters

    Returns void

SolveGravity

  • Parameters

    Returns void

SolveLifetimes

  • Destroy all particles which have outlived their lifetimes set by SetParticleLifetime().

    Parameters

    Returns void

SolvePowder

  • Parameters

    Returns void

SolvePressure

  • Parameters

    Returns void

SolveRepulsive

  • Parameters

    Returns void

SolveRigid

  • Parameters

    Returns void

SolveRigidDamping

  • SolveRigidDamping(): void
  • Returns void

SolveSolid

  • Parameters

    Returns void

SolveSpring

  • Parameters

    Returns void

SolveStaticPressure

  • Parameters

    Returns void

SolveTensile

  • Parameters

    Returns void

SolveViscous

  • SolveViscous(): void
  • Returns void

SolveWall

  • SolveWall(): void
  • Returns void

SolveZombie

  • SolveZombie(): void
  • Returns void

SortProxies

SplitParticleGroup

  • Split particle group into multiple disconnected groups.

    warning: This function is locked during callbacks.

    Parameters

    Returns void

UpdateAllGroupFlags

  • UpdateAllGroupFlags(): void
  • Returns void

UpdateAllParticleFlags

  • UpdateAllParticleFlags(): void
  • Returns void

UpdateBodyContacts

  • UpdateBodyContacts(): void
  • Returns void

UpdateContacts

  • UpdateContacts(exceptZombie: boolean): void
  • Parameters

    • exceptZombie: boolean

    Returns void

UpdatePairsAndTriads

  • Parameters

    Returns void

UpdatePairsAndTriadsWithParticleList

UpdatePairsAndTriadsWithReactiveParticles

  • UpdatePairsAndTriadsWithReactiveParticles(): void
  • Returns void

UpdateProxies

UpdateProxiesReference

ValidateParticleIndex

  • ValidateParticleIndex(index: number): boolean
  • Determine whether a particle index is valid.

    Parameters

    • index: number

    Returns boolean

Static BodyContactCompare

Static ComparePairIndices

  • Parameters

    Returns boolean

Static CompareTriadIndices

Static FindLongestParticleList

Static InitializeParticleLists

Static IsSignificantForce

  • IsSignificantForce(force: XY): boolean
  • Parameters

    • force: XY

    Returns boolean

Static MatchPairIndices

  • Parameters

    Returns boolean

Static MatchTriadIndices

Static MergeParticleListAndNode

Static MergeParticleLists

Static ParticleCanBeConnected

  • Parameters

    Returns boolean

Static b2ParticleContactIsZombie

  • Parameters

    Returns boolean

Static computeRelativeTag

  • computeRelativeTag(tag: number, x: number, y: number): number
  • Parameters

    • tag: number
    • x: number
    • y: number

    Returns number

Static computeTag

  • computeTag(x: number, y: number): number
  • Parameters

    • x: number
    • y: number

    Returns number

Generated using TypeDoc