Cycles: Fix over-allocation of triangles storage for triangle primitive hair
authorSergey Sharybin <sergey.vfx@gmail.com>
Wed, 26 Apr 2017 13:58:40 +0000 (15:58 +0200)
committerSergey Sharybin <sergey.vfx@gmail.com>
Wed, 26 Apr 2017 14:00:02 +0000 (16:00 +0200)
Was also causing some bad memory access caused by read data from non-initialized
arrays.

Repoted by bzztploink in IRC, thanks!

intern/cycles/blender/blender_curves.cpp

index 6fa038e8bf0ecda32cb4343df5581a9c68777806..ed361cc971ee8e3437e1debe9501b1aa69ba10de 100644 (file)
@@ -411,7 +411,7 @@ static void ExportCurveTrianglePlanes(Mesh *mesh, ParticleCurveData *CData,
                }
        }
 
-       mesh->resize_mesh(mesh->verts.size(), mesh->triangles.size());
+       mesh->resize_mesh(mesh->verts.size(), mesh->num_triangles());
        mesh->attributes.remove(ATTR_STD_VERTEX_NORMAL);
        mesh->attributes.remove(ATTR_STD_FACE_NORMAL);
        mesh->add_face_normals();
@@ -546,7 +546,7 @@ static void ExportCurveTriangleGeometry(Mesh *mesh,
                }
        }
 
-       mesh->resize_mesh(mesh->verts.size(), mesh->triangles.size());
+       mesh->resize_mesh(mesh->verts.size(), mesh->num_triangles());
        mesh->attributes.remove(ATTR_STD_VERTEX_NORMAL);
        mesh->attributes.remove(ATTR_STD_FACE_NORMAL);
        mesh->add_face_normals();