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.
This commit is contained in:
Sergey Sharybin 2015-02-15 02:55:18 +05:00
parent 1862fbf203
commit a83b2d3fd9

@ -913,6 +913,16 @@ void MeshManager::device_update_attributes(Device *device, DeviceScene *dscene,
foreach(AttributeRequest& req, attributes.requests) { foreach(AttributeRequest& req, attributes.requests) {
Attribute *triangle_mattr = mesh->attributes.find(req); Attribute *triangle_mattr = mesh->attributes.find(req);
Attribute *curve_mattr = mesh->curve_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, update_attribute_element_size(mesh,
triangle_mattr, triangle_mattr,
&attr_float_size, &attr_float_size,
@ -945,15 +955,6 @@ void MeshManager::device_update_attributes(Device *device, DeviceScene *dscene,
Attribute *triangle_mattr = mesh->attributes.find(req); Attribute *triangle_mattr = mesh->attributes.find(req);
Attribute *curve_mattr = mesh->curve_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, update_attribute_element_offset(mesh,
attr_float, attr_float_offset, attr_float, attr_float_offset,
attr_float3, attr_float3_offset, attr_float3, attr_float3_offset,