What would be the best data structure for handling particles in a
particle system in D2?
Here's some thoughts:
Particles are simple structs.
Two lists, one for alive particles, one for dead ones.
Memory allocations should be avoided, preallocate everything, no
allocations when moving between l
On Friday, 15 November 2013 at 11:52:44 UTC, Mikko Ronkainen
wrote:
What would be the best data structure for handling particles in
a particle system in D2?
Here's some thoughts:
Particles are simple structs.
Two lists, one for alive particles, one for dead ones.
Memory allocations should be a
On Friday, 15 November 2013 at 11:52:44 UTC, Mikko Ronkainen
wrote:
What would be the best data structure for handling particles in
a particle system in D2?
Here's some thoughts:
Particles are simple structs.
Two lists, one for alive particles, one for dead ones.
Memory allocations should be a
Use just one list with a flag in the particle to see whether the
particle is alive or dead, saves swapping between lists and you
can use a simple array for fast access.
Yes, simplicity, that's a good idea :) I was just wondering how
much time would be saved if just iterating over the active
pa
On Friday, 15 November 2013 at 11:52:44 UTC, Mikko Ronkainen
wrote:
What would be the best data structure for handling particles in
a particle system in D2?
Here's some thoughts:
Particles are simple structs.
Two lists, one for alive particles, one for dead ones.
Memory allocations should be a
On 11/15/2013 9:19 PM, Mikko Ronkainen wrote:
If relevant, doubly-linked might work better? dcollections LinkList, or
maybe DList? I'm asking mostly because I'd like the container to avoid
memory allocations while in use.
For a particle system, I would avoid lists. A list of particles needs to
Ok, thanks! That linked list cache thrashing was just the thing I
knew that I don't know :)
Let's say I just use dynamic array and grow it when adding new
particles to the system, and when particles die, just set their
dead flag on. This means that, when adding a new particle, I need
to scan
Mikko Ronkainen:
Let's say I just use dynamic array and grow it when adding new
particles to the system, and when particles die, just set their
dead flag on. This means that, when adding a new particle, I
need to scan the array first for possible dead particles that
can be reused. Is there so
On Friday, 15 November 2013 at 13:32:38 UTC, Mikko Ronkainen
wrote:
Ok, thanks! That linked list cache thrashing was just the thing
I knew that I don't know :)
Let's say I just use dynamic array and grow it when adding new
particles to the system, and when particles die, just set their
dead f
Chris Cain:
Instead of having a "dead flag", you could swap (
http://dlang.org/phobos/std_algorithm.html#swap ) the dying
particle with the last particle in the list and then decrement
the list's length.
If the array is long you are accessing a cold part of it to swap
with the end.
By de
On Friday, 15 November 2013 at 14:08:20 UTC, bearophile wrote:
The situation is a little more complex, there is a capacity
field that I think is kept in a cold place of the array, it's
also cached, but only if you append to just one array, etc.
An alternative might be hold an array and manage
On Friday, 15 November 2013 at 14:01:36 UTC, Chris Cain wrote:
By default (using the default GC and everything), D does not
reallocate a dynamic array every time you change the length
(even increasing it), so this will still be okay with
allocations.
Not exactly so. If you decrease the lengt
Am Fri, 15 Nov 2013 21:56:15 +0900
schrieb Mike Parker :
> On 11/15/2013 9:19 PM, Mikko Ronkainen wrote:
> >
> > If relevant, doubly-linked might work better? dcollections LinkList, or
> > maybe DList? I'm asking mostly because I'd like the container to avoid
> > memory allocations while in use.
>
On Friday, 15 November 2013 at 14:01:36 UTC, Chris Cain wrote:
On Friday, 15 November 2013 at 13:32:38 UTC, Mikko Ronkainen
wrote:
Ok, thanks! That linked list cache thrashing was just the
thing I knew that I don't know :)
Let's say I just use dynamic array and grow it when adding new
particl
14 matches
Mail list logo