From 2419d4c4ebf63c04c9c33efc8acc379d06661d9a Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Sun, 8 May 2016 00:09:08 +0200 Subject: Code refactor: modify mesh storage to use arrays rather than vectors, separate some arrays. Differential Revision: https://developer.blender.org/D2016 --- intern/cycles/render/particles.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'intern/cycles/render/particles.cpp') diff --git a/intern/cycles/render/particles.cpp b/intern/cycles/render/particles.cpp index 50726bb4574..1a35d60fb4b 100644 --- a/intern/cycles/render/particles.cpp +++ b/intern/cycles/render/particles.cpp @@ -58,8 +58,8 @@ void ParticleSystemManager::device_update_particles(Device *device, DeviceScene * adds one dummy particle at the beginning to avoid invalid lookups, * in case a shader uses particle info without actual particle data. */ int num_particles = 1; - foreach(ParticleSystem *psys, scene->particle_systems) - num_particles += psys->particles.size(); + for(size_t j = 0; j < scene->particle_systems.size(); j++) + num_particles += scene->particle_systems[j]->particles.size(); float4 *particles = dscene->particles.resize(PARTICLE_SIZE*num_particles); @@ -71,9 +71,12 @@ void ParticleSystemManager::device_update_particles(Device *device, DeviceScene particles[4] = make_float4(0.0f, 0.0f, 0.0f, 0.0f); int i = 1; - foreach(ParticleSystem *psys, scene->particle_systems) { - foreach(Particle &pa, psys->particles) { + for(size_t j = 0; j < scene->particle_systems.size(); j++) { + ParticleSystem *psys = scene->particle_systems[j]; + + for(size_t k = 0; k < psys->particles.size(); k++) { /* pack in texture */ + Particle& pa = psys->particles[k]; int offset = i*PARTICLE_SIZE; particles[offset] = make_float4(pa.index, pa.age, pa.lifetime, pa.size); -- cgit v1.2.3