Fix part of #33662: cycles crash using displacement on meshes with vertices not
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Wed, 26 Dec 2012 20:59:35 +0000 (20:59 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Wed, 26 Dec 2012 20:59:35 +0000 (20:59 +0000)
attached to any face.

intern/cycles/render/mesh_displace.cpp

index fdfaaf4d7de5b17364a90c87aadd368ee89152f2..04267697b29f621b069c9f719de713308a4a2f4c 100644 (file)
@@ -59,7 +59,7 @@ bool MeshManager::displace(Device *device, Scene *scene, Mesh *mesh, Progress& p
        vector<bool> done(mesh->verts.size(), false);
        device_vector<uint4> d_input;
        uint4 *d_input_data = d_input.resize(mesh->verts.size());
-       size_t d_input_offset = 0;
+       size_t d_input_size = 0;
 
        for(size_t i = 0; i < mesh->triangles.size(); i++) {
                Mesh::Triangle t = mesh->triangles[i];
@@ -95,16 +95,16 @@ bool MeshManager::displace(Device *device, Scene *scene, Mesh *mesh, Progress& p
 
                        /* back */
                        uint4 in = make_uint4(object, prim, __float_as_int(u), __float_as_int(v));
-                       d_input_data[d_input_offset++] = in;
+                       d_input_data[d_input_size++] = in;
                }
        }
 
-       if(d_input_offset == 0)
+       if(d_input_size == 0)
                return false;
        
        /* run device task */
        device_vector<float4> d_output;
-       d_output.resize(d_input.size());
+       d_output.resize(d_input_size);
 
        device->mem_alloc(d_input, MEM_READ_ONLY);
        device->mem_copy_to(d_input);
@@ -115,7 +115,7 @@ bool MeshManager::displace(Device *device, Scene *scene, Mesh *mesh, Progress& p
        task.shader_output = d_output.device_pointer;
        task.shader_eval_type = SHADER_EVAL_DISPLACE;
        task.shader_x = 0;
-       task.shader_w = d_input.size();
+       task.shader_w = d_output.size();
 
        device->task_add(task);
        device->task_wait();