|
When an affector acts on a particle, it will add it to a set
of "seen" particles. This means an allocation, per particle,
per frame.
In Qt 6 the problem is less dramatic due to the new QHash
implementation, which uses "wider" buckets, but in Qt 5 this is
hundreds of memory allocations (and deallocations) per frame.
Just reimplement a minimal flat-set API for this use case,
and replace the QSet usages with it. On a testcase with
200 active particles, this reduces memory allocations from
~20'000 per second to 0 when the scene is "stable".
Pick-to: 5.15
Change-Id: I4be1e12a23b8dffca91955148532db243e383a4c
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
|