diff options
Diffstat (limited to 'source/blender/blenloader/intern/writefile.c')
-rw-r--r-- | source/blender/blenloader/intern/writefile.c | 48 |
1 files changed, 25 insertions, 23 deletions
diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index d33d8032ed1..46ac6b43c92 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -3833,31 +3833,33 @@ static void write_simulation(BlendWriter *writer, Simulation *simulation, const LISTBASE_FOREACH (SimulationState *, state, &simulation->states) { BLO_write_string(writer, state->name); - switch ((eSimulationStateType)state->type) { - case SIM_STATE_TYPE_PARTICLES: { - ParticleSimulationState *particle_state = (ParticleSimulationState *)state; - BLO_write_struct(writer, ParticleSimulationState, particle_state); - - CustomDataLayer *layers = NULL; - CustomDataLayer layers_buff[CD_TEMP_CHUNK_SIZE]; - CustomData_file_write_prepare( - &particle_state->attributes, &layers, layers_buff, ARRAY_SIZE(layers_buff)); - - write_customdata(writer, - &simulation->id, - particle_state->tot_particles, - &particle_state->attributes, - layers, - CD_MASK_ALL); - - if (layers != NULL && layers != layers_buff) { - MEM_freeN(layers); - } - - write_pointcaches(writer, &particle_state->ptcaches); - break; + BLO_write_string(writer, state->type); + /* TODO: Decentralize this part. */ + if (STREQ(state->type, SIM_TYPE_NAME_PARTICLE_SIMULATION)) { + ParticleSimulationState *particle_state = (ParticleSimulationState *)state; + BLO_write_struct(writer, ParticleSimulationState, particle_state); + + CustomDataLayer *layers = NULL; + CustomDataLayer layers_buff[CD_TEMP_CHUNK_SIZE]; + CustomData_file_write_prepare( + &particle_state->attributes, &layers, layers_buff, ARRAY_SIZE(layers_buff)); + + write_customdata(writer, + &simulation->id, + particle_state->tot_particles, + &particle_state->attributes, + layers, + CD_MASK_ALL); + + if (layers != NULL && layers != layers_buff) { + MEM_freeN(layers); } } + else if (STREQ(state->type, SIM_TYPE_NAME_PARTICLE_MESH_EMITTER)) { + ParticleMeshEmitterSimulationState *emitter_state = (ParticleMeshEmitterSimulationState *) + state; + BLO_write_struct(writer, ParticleMeshEmitterSimulationState, emitter_state); + } } BLO_write_struct_list(writer, PersistentDataHandleItem, &simulation->persistent_data_handles); |