Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/blender/mesh.cpp
| Show First 20 Lines • Show All 549 Lines • ▼ Show 20 Lines | else { | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| /* Create uv map attributes. */ | /* Create uv map attributes. */ | ||||
| static void attr_create_uv_map(Scene *scene, Mesh *mesh, BL::Mesh &b_mesh) | static void attr_create_uv_map(Scene *scene, Mesh *mesh, BL::Mesh &b_mesh) | ||||
| { | { | ||||
| if (b_mesh.uv_layers.length() != 0) { | if (!b_mesh.uv_layers.empty()) { | ||||
| for (BL::MeshUVLoopLayer &l : b_mesh.uv_layers) { | for (BL::MeshUVLoopLayer &l : b_mesh.uv_layers) { | ||||
| const bool active_render = l.active_render(); | const bool active_render = l.active_render(); | ||||
| AttributeStandard uv_std = (active_render) ? ATTR_STD_UV : ATTR_STD_NONE; | AttributeStandard uv_std = (active_render) ? ATTR_STD_UV : ATTR_STD_NONE; | ||||
| ustring uv_name = ustring(l.name().c_str()); | ustring uv_name = ustring(l.name().c_str()); | ||||
| AttributeStandard tangent_std = (active_render) ? ATTR_STD_UV_TANGENT : ATTR_STD_NONE; | AttributeStandard tangent_std = (active_render) ? ATTR_STD_UV_TANGENT : ATTR_STD_NONE; | ||||
| ustring tangent_name = ustring((string(l.name().c_str()) + ".tangent").c_str()); | ustring tangent_name = ustring((string(l.name().c_str()) + ".tangent").c_str()); | ||||
| /* Denotes whether UV map was requested directly. */ | /* Denotes whether UV map was requested directly. */ | ||||
| ▲ Show 20 Lines • Show All 47 Lines • ▼ Show 20 Lines | else if (mesh->need_attribute(scene, ATTR_STD_UV_TANGENT)) { | ||||
| if (!mesh->need_attribute(scene, ATTR_STD_GENERATED)) { | if (!mesh->need_attribute(scene, ATTR_STD_GENERATED)) { | ||||
| mesh->attributes.remove(ATTR_STD_GENERATED); | mesh->attributes.remove(ATTR_STD_GENERATED); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| static void attr_create_subd_uv_map(Scene *scene, Mesh *mesh, BL::Mesh &b_mesh, bool subdivide_uvs) | static void attr_create_subd_uv_map(Scene *scene, Mesh *mesh, BL::Mesh &b_mesh, bool subdivide_uvs) | ||||
| { | { | ||||
| if (b_mesh.uv_layers.length() != 0) { | if (!b_mesh.uv_layers.empty()) { | ||||
| BL::Mesh::uv_layers_iterator l; | BL::Mesh::uv_layers_iterator l; | ||||
| int i = 0; | int i = 0; | ||||
| for (b_mesh.uv_layers.begin(l); l != b_mesh.uv_layers.end(); ++l, ++i) { | for (b_mesh.uv_layers.begin(l); l != b_mesh.uv_layers.end(); ++l, ++i) { | ||||
| bool active_render = l->active_render(); | bool active_render = l->active_render(); | ||||
| AttributeStandard uv_std = (active_render) ? ATTR_STD_UV : ATTR_STD_NONE; | AttributeStandard uv_std = (active_render) ? ATTR_STD_UV : ATTR_STD_NONE; | ||||
| ustring uv_name = ustring(l->name().c_str()); | ustring uv_name = ustring(l->name().c_str()); | ||||
| AttributeStandard tangent_std = (active_render) ? ATTR_STD_UV_TANGENT : ATTR_STD_NONE; | AttributeStandard tangent_std = (active_render) ? ATTR_STD_UV_TANGENT : ATTR_STD_NONE; | ||||
| ▲ Show 20 Lines • Show All 315 Lines • ▼ Show 20 Lines | static void create_mesh(Scene *scene, | ||||
| Attribute *attr_N = attributes.add(ATTR_STD_VERTEX_NORMAL); | Attribute *attr_N = attributes.add(ATTR_STD_VERTEX_NORMAL); | ||||
| float3 *N = attr_N->data_float3(); | float3 *N = attr_N->data_float3(); | ||||
| for (b_mesh.vertices.begin(v); v != b_mesh.vertices.end(); ++v, ++N) | for (b_mesh.vertices.begin(v); v != b_mesh.vertices.end(); ++v, ++N) | ||||
| *N = get_float3(v->normal()); | *N = get_float3(v->normal()); | ||||
| N = attr_N->data_float3(); | N = attr_N->data_float3(); | ||||
| /* create generated coordinates from undeformed coordinates */ | /* create generated coordinates from undeformed coordinates */ | ||||
| const bool need_default_tangent = (subdivision == false) && (b_mesh.uv_layers.length() == 0) && | const bool need_default_tangent = (subdivision == false) && (b_mesh.uv_layers.empty()) && | ||||
| (mesh->need_attribute(scene, ATTR_STD_UV_TANGENT)); | (mesh->need_attribute(scene, ATTR_STD_UV_TANGENT)); | ||||
| if (mesh->need_attribute(scene, ATTR_STD_GENERATED) || need_default_tangent) { | if (mesh->need_attribute(scene, ATTR_STD_GENERATED) || need_default_tangent) { | ||||
| Attribute *attr = attributes.add(ATTR_STD_GENERATED); | Attribute *attr = attributes.add(ATTR_STD_GENERATED); | ||||
| attr->flags |= ATTR_SUBDIVIDED; | attr->flags |= ATTR_SUBDIVIDED; | ||||
| float3 loc, size; | float3 loc, size; | ||||
| mesh_texture_space(b_mesh, loc, size); | mesh_texture_space(b_mesh, loc, size); | ||||
| ▲ Show 20 Lines • Show All 340 Lines • Show Last 20 Lines | |||||