add BLI_strcpy_rlen, replace strcat, which was used in misleading way.
[blender.git] / intern / cycles / render / particles.cpp
index 539a233350646d1f3e69e7a6ee11fa62fc2a72b8..2a1570f7a0d3cb35657a500791a45fafeef705bc 100644 (file)
@@ -57,8 +57,7 @@ void ParticleSystemManager::device_update_particles(Device *device, DeviceScene
 {
        /* count particles.
         * adds one dummy particle at the beginning to avoid invalid lookups,
-        * in case a shader uses particle info without actual particle data.
-        */
+        * 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();
@@ -67,6 +66,10 @@ void ParticleSystemManager::device_update_particles(Device *device, DeviceScene
        
        /* dummy particle */
        particles[0] = make_float4(0.0f, 0.0f, 0.0f, 0.0f);
+       particles[1] = make_float4(0.0f, 0.0f, 0.0f, 0.0f);
+       particles[2] = make_float4(0.0f, 0.0f, 0.0f, 0.0f);
+       particles[3] = make_float4(0.0f, 0.0f, 0.0f, 0.0f);
+       particles[4] = make_float4(0.0f, 0.0f, 0.0f, 0.0f);
        
        int i = 1;
        foreach(ParticleSystem *psys, scene->particle_systems) {
@@ -74,7 +77,11 @@ void ParticleSystemManager::device_update_particles(Device *device, DeviceScene
                        /* pack in texture */
                        int offset = i*PARTICLE_SIZE;
                        
-                       particles[offset] = make_float4(pa.index, pa.age, pa.lifetime, 0.0f);
+                       particles[offset] = make_float4(pa.index, pa.age, pa.lifetime, pa.size);
+                       particles[offset+1] = pa.rotation;
+                       particles[offset+2] = make_float4(pa.location.x, pa.location.y, pa.location.z, pa.velocity.x);
+                       particles[offset+3] = make_float4(pa.velocity.y, pa.velocity.z, pa.angular_velocity.x, pa.angular_velocity.y);
+                       particles[offset+4] = make_float4(pa.angular_velocity.z, 0.0f, 0.0f, 0.0f);
                        
                        i++;
                        
@@ -92,9 +99,6 @@ void ParticleSystemManager::device_update(Device *device, DeviceScene *dscene, S
        
        device_free(device, dscene);
 
-       if(scene->particle_systems.size() == 0)
-               return;
-
        progress.set_status("Updating Particle Systems", "Copying Particles to device");
        device_update_particles(device, dscene, scene, progress);