Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/blender/blender_mesh.cpp
| Show First 20 Lines • Show All 279 Lines • ▼ Show 20 Lines | |||||
| /* Create vertex color attributes. */ | /* Create vertex color attributes. */ | ||||
| static void attr_create_vertex_color(Scene *scene, Mesh *mesh, BL::Mesh &b_mesh, bool subdivision) | static void attr_create_vertex_color(Scene *scene, Mesh *mesh, BL::Mesh &b_mesh, bool subdivision) | ||||
| { | { | ||||
| if (subdivision) { | if (subdivision) { | ||||
| BL::Mesh::vertex_colors_iterator l; | BL::Mesh::vertex_colors_iterator l; | ||||
| for (b_mesh.vertex_colors.begin(l); l != b_mesh.vertex_colors.end(); ++l) { | for (b_mesh.vertex_colors.begin(l); l != b_mesh.vertex_colors.end(); ++l) { | ||||
| if (!mesh->need_attribute(scene, ustring(l->name().c_str()))) | const bool active_render = l->active_render(); | ||||
| AttributeStandard vcol_std = (active_render) ? ATTR_STD_VERTEX_COLOR : ATTR_STD_NONE; | |||||
| ustring vcol_name = ustring(l->name().c_str()); | |||||
| const bool need_vcol = mesh->need_attribute(scene, vcol_name) || | |||||
| mesh->need_attribute(scene, vcol_std); | |||||
| if (!need_vcol) { | |||||
| continue; | continue; | ||||
| } | |||||
| Attribute *attr = mesh->subd_attributes.add( | Attribute *vcol_attr = NULL; | ||||
| ustring(l->name().c_str()), TypeRGBA, ATTR_ELEMENT_CORNER_BYTE); | if (active_render) { | ||||
| vcol_attr = mesh->subd_attributes.add(vcol_std, vcol_name); | |||||
| } | |||||
| else { | |||||
| vcol_attr = mesh->subd_attributes.add(vcol_name, TypeRGBA, ATTR_ELEMENT_CORNER_BYTE); | |||||
| } | |||||
| BL::Mesh::polygons_iterator p; | BL::Mesh::polygons_iterator p; | ||||
| uchar4 *cdata = attr->data_uchar4(); | uchar4 *cdata = vcol_attr->data_uchar4(); | ||||
| for (b_mesh.polygons.begin(p); p != b_mesh.polygons.end(); ++p) { | for (b_mesh.polygons.begin(p); p != b_mesh.polygons.end(); ++p) { | ||||
| int n = p->loop_total(); | int n = p->loop_total(); | ||||
| for (int i = 0; i < n; i++) { | for (int i = 0; i < n; i++) { | ||||
| float4 color = get_float4(l->data[p->loop_start() + i].color()); | float4 color = get_float4(l->data[p->loop_start() + i].color()); | ||||
| /* Compress/encode vertex color using the sRGB curve. */ | /* Compress/encode vertex color using the sRGB curve. */ | ||||
| *(cdata++) = color_float4_to_uchar4(color_srgb_to_linear_v4(color)); | *(cdata++) = color_float4_to_uchar4(color_srgb_to_linear_v4(color)); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| BL::Mesh::vertex_colors_iterator l; | BL::Mesh::vertex_colors_iterator l; | ||||
| for (b_mesh.vertex_colors.begin(l); l != b_mesh.vertex_colors.end(); ++l) { | for (b_mesh.vertex_colors.begin(l); l != b_mesh.vertex_colors.end(); ++l) { | ||||
| if (!mesh->need_attribute(scene, ustring(l->name().c_str()))) | const bool active_render = l->active_render(); | ||||
| AttributeStandard vcol_std = (active_render) ? ATTR_STD_VERTEX_COLOR : ATTR_STD_NONE; | |||||
| ustring vcol_name = ustring(l->name().c_str()); | |||||
| const bool need_vcol = mesh->need_attribute(scene, vcol_name) || | |||||
| mesh->need_attribute(scene, vcol_std); | |||||
| if (!need_vcol) { | |||||
| continue; | continue; | ||||
| } | |||||
| Attribute *attr = mesh->attributes.add( | Attribute *vcol_attr = NULL; | ||||
| ustring(l->name().c_str()), TypeRGBA, ATTR_ELEMENT_CORNER_BYTE); | if (active_render) { | ||||
| vcol_attr = mesh->attributes.add(vcol_std, vcol_name); | |||||
| } | |||||
| else { | |||||
| vcol_attr = mesh->attributes.add(vcol_name, TypeRGBA, ATTR_ELEMENT_CORNER_BYTE); | |||||
| } | |||||
| BL::Mesh::loop_triangles_iterator t; | BL::Mesh::loop_triangles_iterator t; | ||||
| uchar4 *cdata = attr->data_uchar4(); | uchar4 *cdata = vcol_attr->data_uchar4(); | ||||
| for (b_mesh.loop_triangles.begin(t); t != b_mesh.loop_triangles.end(); ++t) { | for (b_mesh.loop_triangles.begin(t); t != b_mesh.loop_triangles.end(); ++t) { | ||||
| int3 li = get_int3(t->loops()); | int3 li = get_int3(t->loops()); | ||||
| float4 c1 = get_float4(l->data[li[0]].color()); | float4 c1 = get_float4(l->data[li[0]].color()); | ||||
| float4 c2 = get_float4(l->data[li[1]].color()); | float4 c2 = get_float4(l->data[li[1]].color()); | ||||
| float4 c3 = get_float4(l->data[li[2]].color()); | float4 c3 = get_float4(l->data[li[2]].color()); | ||||
| /* Compress/encode vertex color using the sRGB curve. */ | /* Compress/encode vertex color using the sRGB curve. */ | ||||
| ▲ Show 20 Lines • Show All 739 Lines • Show Last 20 Lines | |||||