Paged Particles TODO List
General stuff to check
- Unfinished places in code have been tagged by: XXX PAGEDPARTICLES
- Make sure possible SVN trunk commits don't use deprecated struct members (comment out for testing, the DNA will ignore comments, but the compiler won't)
- Check uses of psysGetParticle and replace by iterator where possible
- Make sure the pa->id and pit.index are used correctly! randomization and persistent identifiers should use the particle id, while direct indices should use the index from iterator. check: pd_point_from_particle (and other effect stuff)
- Check all users of pbuffer->totelem. Point caches, render data and the like must be stabilized to be able to work with dynamically growing and shrinking pbuffers!
- Chec pit_init_particle usage: There might be places where this is used for child particles, pit_init_child_particle must be used for those instead!
- Check access of buffer pointers in psys: optional buffers for children and additional layer data can be NULL if the feature is disabled, sometime this is not checked yet!
- Add do_versions code to convert deprecated DNA data to new variables.
- Grid distribution is disabled, this was using some ugly hacks that break with paged buffers (see distribute_grid in particle_system.c)
- Randomization for particles should uses the rather small (1024) float psys->frand array. This must be extended to avoid repetition and loss of detail (much more likely with high emission rates now possible).
- Child distribution apparently used simple BLI_frand, even in threaded distribution (!), needs some clarification too. This now uses a simple child id offset from the parent particle id for randomization, could be better.
- The "show unborn" options will only work for fixed particle counts, i.e. "instant" and "frames" emission modes. This option has to be disabled for rate based emission. Allocate all particles in advance, don't skip unborn particles in iterator functions and test functions for buffer cleanup (free dead pages/compress)
- "show dead" option can also work for rate emission, but only for modest emission rates, or the number of particles will exceed the limit quickly. Don't skip dead particles in iterator functions and test functions for buffer cleanup (free dead pages/compress)
- Enabling the "show unborn/dead" options in the middle of a simulation will not work without recalculation in general, since those particles are otherwise removed. For dead particles: could be done by doing a full cache read from frame 1 instead of rebaking everything.
- Fluid springs are stored in the same way as before: one large array, which is reallocated+copied each frame. There is already another paged buffer stub for this data in psys, just needs to be used. Paged buffer would avoid duplication of large buffer for copying (and also avoid the copy itself for array resize, not sure how well MEM_reallocN handles this). Just has to make sure the spring particle indices are adjusted on particle buffer compression. Springs could be added more efficiently, possibly(?) leading to great performance improvement for fluid particles.
- Point cache undo for particles (hair) is disabled.
- Point cache code for particles needs to be integrated with other cache types again, the default per-point read/write callbacks don't work nicely for paged buffer. Also needs some cleanup from debug stuff.
- "Info" frame 0 does not make much sense for dynamic buffers, this would require knowing all particles in advance. All relevant data needs to be stored in the regular data cache frames. Alternatively the info frame needs to be extensible, so new particles can be added from later frames.
- copy_particlesystem is in object.c, for consistency and code locality i think this should go to particle.c
- When adding particles in edit mode, is pa->time recalculated for all particles? otherwise the result of initialize_particle could be wrong. The new version uses psys->cfra. (see also next point)
- Unlimited particle lifetime could be implemented either as a separate flag or by interpreting lifetime=0 as unlimited
- The fuv attribute in ParticleData is misleading: these are actually per-vertex weights, not UV coordinates. Rename if feasible.
Hair particles are removed on frame 100 (lifetime is 100 for pseudo-animation/physics of initial hair). Hair particles don't get emitted correctly, unless going in and out of edit mode. Emission mode must be restricted to Instant for hair.
- Hair sorting by emitter element index must be reimplemented (optimization for drawing). Particle IDs must be updated to keep order intact!
- Gravity vector for boids only copies the Z component, what happens when using non-standard gravity vectors?!
- Point cache does not read from the first cache frame, particles seem only appear after the second cache step.
- Unresolved reference from hair_new_settings function in rna_main_api.c, obscure ...
- New hair stuff must be added to "particle" edit mode (which should be renamed to a more generic name, e.g. "point cache mode" or something)
- rename psysGetParticle to psysFindParticle (indicate possible performance hit)
- Add ordering number/ID for boids, etc.
- Add pbufGetElement and pbufGetElementData to avoid multiple page lookups for different layers
- Add back a totalloc counter (needed when last page is freed)
- Fix AddElements and SetPageSize to take totalloc counter into account
- Remove GetBorn/GetDead, can use totalloc/totactive counter
- Check functions for feasible index parameter
- Rename pit->data to pit->storage
- What exactly is pa->hair_index used for? can it be moved to HairParticle too? Any other hair stuff that can go to the hair data layer?
- Fixed particle amount should be changed to a "Instant Emission" combined with a "No Death" option: Instant emission meaning that all particles are emitted on frame one (and particles from edit mode get pa->time=0), while "No Death" prevents particles from dying.
- Add next-ID counter to psys for particle initialization
- Avoid NULL checks in the psysGet*** wrappers (see start of BKE_particle.h). These should be as fast as possible and only be called when the according layers are available.
- Cache invalidation when rewinding to frame 1 does not always work reliably.
- pbufGetElement returns an iterator without storage data, this causes problems when trying to get particle data by pit_get_particle (which expects storage to be a psys pointer)
- Jittered distribution is disabled, this was done as a one-time process using a full array of data for each particle. Needs to be implemented as iterative function that can be applied to each particle individually.
Add flag to HairParticle and move relevant flags from pa->flag are there any per-particle hair flags?
Instant emission creates particles in wrong place when changing settings in later frames. Seems to lead to "backward" physics :S Caused by negative dfra in dynamics_step
- Negative part->sta start frame is used to get a "precalculated" state at simulation start. This does not work for emission rates and is too specific. More generic approach for starting state would be appreciated, using explicit cache frame images or the like. At least restrict this to frame range emission.