diff options
author | Lukas Toenne <lukas.toenne@googlemail.com> | 2012-07-26 15:40:58 +0400 |
---|---|---|
committer | Lukas Toenne <lukas.toenne@googlemail.com> | 2012-07-26 15:40:58 +0400 |
commit | fec872ef9c0bb6904cbe9a7b59b3f51ae7bb0702 (patch) | |
tree | aeb75f40ec873b33dd1e76e55ab0f05eac1768a9 /intern/cycles/blender/blender_particles.cpp | |
parent | 53a861b6f9ece221089b9364fa5a9e87175b580c (diff) |
Added a particle index output to the Particle Info Cycles node. This is required to get consistent ID numbers for particles. The Object ID is not usable since it's a user defined value of the instanced object, which does not vary per instance. Also the random value from the object info node is not consistent over time, since it only depends on the index in the dupli list (so each emitted or dying particle shifts the value).
The particle index is always the same for a specific particle. Randomized values can be generated from this with the use of a noise texture.
Diffstat (limited to 'intern/cycles/blender/blender_particles.cpp')
-rw-r--r-- | intern/cycles/blender/blender_particles.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/intern/cycles/blender/blender_particles.cpp b/intern/cycles/blender/blender_particles.cpp index f591aaa6d83..d669aa34a68 100644 --- a/intern/cycles/blender/blender_particles.cpp +++ b/intern/cycles/blender/blender_particles.cpp @@ -144,16 +144,20 @@ void BlenderSync::sync_particles(Object *ob, BL::Object b_ob) BL::Object::particle_systems_iterator b_psys; for(b_ob.particle_systems.begin(b_psys); b_psys != b_ob.particle_systems.end(); ++b_psys) { if (use_particle_system(*b_psys)) { + int pa_index = 0; BL::ParticleSystem::particles_iterator b_pa; for(b_psys->particles.begin(b_pa), index = 0; b_pa != b_psys->particles.end(); ++b_pa, ++index) { if(use_particle(*b_pa)) { Particle pa; + pa.index = pa_index; pa.age = b_scene.frame_current() - b_pa->birth_time(); pa.lifetime = b_pa->lifetime(); ob->particles.push_back(pa); } + + ++pa_index; } } } |