From a83b2d3fd93cde482db3cfe4f481a5ff7df49c63 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Sun, 15 Feb 2015 02:55:18 +0500 Subject: Cycles: Fix wrong attribute count calculation in prevous commit The workaround for generated texture coordinates is to be done before calculating number of elements for attribute, otherwise counter wouldn't include those attributes. --- intern/cycles/render/mesh.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'intern/cycles/render/mesh.cpp') diff --git a/intern/cycles/render/mesh.cpp b/intern/cycles/render/mesh.cpp index e672aab49d9..9c7310d4a05 100644 --- a/intern/cycles/render/mesh.cpp +++ b/intern/cycles/render/mesh.cpp @@ -913,6 +913,16 @@ void MeshManager::device_update_attributes(Device *device, DeviceScene *dscene, foreach(AttributeRequest& req, attributes.requests) { Attribute *triangle_mattr = mesh->attributes.find(req); Attribute *curve_mattr = mesh->curve_attributes.find(req); + + /* todo: get rid of this exception, it's only here for giving some + * working texture coordinate for subdivision as we can't preserve + * any attributes yet */ + if(!triangle_mattr && req.std == ATTR_STD_GENERATED) { + triangle_mattr = mesh->attributes.add(ATTR_STD_GENERATED); + if(mesh->verts.size()) + memcpy(triangle_mattr->data_float3(), &mesh->verts[0], sizeof(float3)*mesh->verts.size()); + } + update_attribute_element_size(mesh, triangle_mattr, &attr_float_size, @@ -945,15 +955,6 @@ void MeshManager::device_update_attributes(Device *device, DeviceScene *dscene, Attribute *triangle_mattr = mesh->attributes.find(req); Attribute *curve_mattr = mesh->curve_attributes.find(req); - /* todo: get rid of this exception, it's only here for giving some - * working texture coordinate for subdivision as we can't preserve - * any attributes yet */ - if(!triangle_mattr && req.std == ATTR_STD_GENERATED) { - triangle_mattr = mesh->attributes.add(ATTR_STD_GENERATED); - if(mesh->verts.size()) - memcpy(triangle_mattr->data_float3(), &mesh->verts[0], sizeof(float3)*mesh->verts.size()); - } - update_attribute_element_offset(mesh, attr_float, attr_float_offset, attr_float3, attr_float3_offset, -- cgit v1.2.3