diff options
author | Jacques Lucke <jacques@blender.org> | 2020-07-22 15:16:08 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2020-07-22 15:16:08 +0300 |
commit | 980dd43bd4be7d5f2d893148984e5fd96c5747f4 (patch) | |
tree | bcfd4a1f02358f97ea1804f81f469689be00f31a /source/blender/blenloader/intern/readfile.c | |
parent | 47b6c332587ca45eddc98e75b3f563e2f17a0d47 (diff) |
Particles: give emitter its own state
High quality emitters need to maintain state themselves. For example,
this it needs to remember when it spawned the last particle.
This is especially important when the birth rate is changing over time.
Otherwise, there will be very visible artifacts.
It is quite likely that other components of the simulation need their own
state as well. Therefore, I refactored the `SimulationState` type a bit,
to make it more extensible. Instead of using hardcoded type numbers, a
string is used to identify the state type. Also, instead of having switch
statements in many places, there is a new `SimulationStateType` that
encapsulates information about how a specific state is created/freed/copied/...
I removed the integration with the point cache for now, because it was
not used anyway in it's current state.
Diffstat (limited to 'source/blender/blenloader/intern/readfile.c')
-rw-r--r-- | source/blender/blenloader/intern/readfile.c | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index f443859e62c..9320187f2a0 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -8691,14 +8691,10 @@ static void direct_link_simulation(BlendDataReader *reader, Simulation *simulati BLO_read_list(reader, &simulation->states); LISTBASE_FOREACH (SimulationState *, state, &simulation->states) { BLO_read_data_address(reader, &state->name); - switch ((eSimulationStateType)state->type) { - case SIM_STATE_TYPE_PARTICLES: { - ParticleSimulationState *particle_state = (ParticleSimulationState *)state; - direct_link_customdata(reader, &particle_state->attributes, particle_state->tot_particles); - direct_link_pointcache_list( - reader, &particle_state->ptcaches, &particle_state->point_cache, 0); - break; - }; + BLO_read_data_address(reader, &state->type); + if (STREQ(state->type, SIM_TYPE_NAME_PARTICLE_SIMULATION)) { + ParticleSimulationState *particle_state = (ParticleSimulationState *)state; + direct_link_customdata(reader, &particle_state->attributes, particle_state->tot_particles); } } |