Skip to content

BUG: In the update method of the ParticleSystem, the particle objects are not correctly recycled back to the object pool. Here, the incorrect reference p of Point2D is used for the recycling process. #1417

@poetryBoy

Description

@poetryBoy

com.almasb.fxgl.particle.ParticleSystem

override fun onUpdate(tpf: Double) {
        emitters.forEach { (emitter, p) ->
            val particlesList = particles[emitter]!!

            particlesList.addAll(emitter.emit(p.x, p.y))

            val iter = particlesList.iterator()
            while (iter.hasNext()) {
                val particle = iter.next()

                if (particle.update(tpf)) {
                    iter.remove()

                    pane.children.remove(particle.view)
                    Pools.free(p)  //# Here, the incorrect objects have been retrieved.
                } else {
                    if (particle.view.parent == null)
                        pane.children.add(particle.view)
                }
            }
        }
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    type:bugDoesn't behave according to specification

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions