From f0d247748408bd10f49c54d3a28a925e37683c4b Mon Sep 17 00:00:00 2001 From: Lukas Toenne Date: Fri, 31 Aug 2012 17:27:08 +0000 Subject: Fix for #32184 and redesign of particle storage in Cycles. The particle data used by the Particle Info node was stored in cycles as a list in each object. This is a problem when the particle emitter mesh is hidden: Objects in cycles are only intended as instances of renderable meshes, so when hiding the emitter mesh the particle data doesn't get stored either. Also the particle data can potentially be copied to multiple instances of the same object, which is a waste of texture space. The solution in this patch is to make a completely separate list of particle systems in the Cycles scene data. This way the particle data can be generated even when the emitter object itself is not visible. --- intern/cycles/render/object.cpp | 40 ---------------------------------------- 1 file changed, 40 deletions(-) (limited to 'intern/cycles/render/object.cpp') diff --git a/intern/cycles/render/object.cpp b/intern/cycles/render/object.cpp index 0fe227fd171..7389b239627 100644 --- a/intern/cycles/render/object.cpp +++ b/intern/cycles/render/object.cpp @@ -249,38 +249,6 @@ void ObjectManager::device_update_transforms(Device *device, DeviceScene *dscene device->tex_alloc("__object_flag", dscene->object_flag); } -void ObjectManager::device_update_particles(Device *device, DeviceScene *dscene, Scene *scene, Progress& progress) -{ - /* count particles. - * 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(Object *ob, scene->objects) - num_particles += ob->particles.size(); - - float4 *particles = dscene->particles.resize(PARTICLE_SIZE*num_particles); - - /* dummy particle */ - particles[0] = make_float4(0.0f, 0.0f, 0.0f, 0.0f); - - int i = 1; - foreach(Object *ob, scene->objects) { - foreach(Particle &pa, ob->particles) { - /* pack in texture */ - int offset = i*PARTICLE_SIZE; - - particles[offset] = make_float4(pa.index, pa.age, pa.lifetime, 0.0f); - - i++; - - if(progress.get_cancel()) return; - } - } - - device->tex_alloc("__particles", dscene->particles); -} - void ObjectManager::device_update(Device *device, DeviceScene *dscene, Scene *scene, Progress& progress) { if(!need_update) @@ -306,11 +274,6 @@ void ObjectManager::device_update(Device *device, DeviceScene *dscene, Scene *sc if(progress.get_cancel()) return; - progress.set_status("Updating Objects", "Copying Particles to device"); - device_update_particles(device, dscene, scene, progress); - - if(progress.get_cancel()) return; - need_update = false; } @@ -321,9 +284,6 @@ void ObjectManager::device_free(Device *device, DeviceScene *dscene) device->tex_free(dscene->object_flag); dscene->object_flag.clear(); - - device->tex_free(dscene->particles); - dscene->particles.clear(); } void ObjectManager::apply_static_transforms(Scene *scene, Progress& progress) -- cgit v1.2.3