Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/mesh_convert.cc
| Show First 20 Lines • Show All 192 Lines • ▼ Show 20 Lines | static Mesh *mesh_nurbs_displist_to_mesh(const Curve *cu, const ListBase *dispbase) | ||||
| MutableSpan<float3> positions = mesh->vert_positions_for_write(); | MutableSpan<float3> positions = mesh->vert_positions_for_write(); | ||||
| MutableSpan<MEdge> edges = mesh->edges_for_write(); | MutableSpan<MEdge> edges = mesh->edges_for_write(); | ||||
| MutableSpan<MPoly> polys = mesh->polys_for_write(); | MutableSpan<MPoly> polys = mesh->polys_for_write(); | ||||
| MutableSpan<MLoop> loops = mesh->loops_for_write(); | MutableSpan<MLoop> loops = mesh->loops_for_write(); | ||||
| MutableAttributeAccessor attributes = mesh->attributes_for_write(); | MutableAttributeAccessor attributes = mesh->attributes_for_write(); | ||||
| SpanAttributeWriter<int> material_indices = attributes.lookup_or_add_for_write_only_span<int>( | SpanAttributeWriter<int> material_indices = attributes.lookup_or_add_for_write_only_span<int>( | ||||
| "material_index", ATTR_DOMAIN_FACE); | "material_index", ATTR_DOMAIN_FACE); | ||||
| MLoopUV *mloopuv = static_cast<MLoopUV *>(CustomData_add_layer_named( | blender::float2 *mloopuv = static_cast<blender::float2 *>(CustomData_add_layer_named( | ||||
| &mesh->ldata, CD_MLOOPUV, CD_SET_DEFAULT, nullptr, mesh->totloop, DATA_("UVMap"))); | &mesh->ldata, CD_PROP_FLOAT2, CD_SET_DEFAULT, nullptr, mesh->totloop, DATA_("UVMap"))); | ||||
| int dst_vert = 0; | int dst_vert = 0; | ||||
| int dst_edge = 0; | int dst_edge = 0; | ||||
| int dst_poly = 0; | int dst_poly = 0; | ||||
| int dst_loop = 0; | int dst_loop = 0; | ||||
| LISTBASE_FOREACH (const DispList *, dl, dispbase) { | LISTBASE_FOREACH (const DispList *, dl, dispbase) { | ||||
| const bool is_smooth = (dl->rt & CU_SMOOTH) != 0; | const bool is_smooth = (dl->rt & CU_SMOOTH) != 0; | ||||
| ▲ Show 20 Lines • Show All 62 Lines • ▼ Show 20 Lines | else if (dl->type == DL_INDEX3) { | ||||
| loops[dst_loop + 1].v = startvert + index[2]; | loops[dst_loop + 1].v = startvert + index[2]; | ||||
| loops[dst_loop + 2].v = startvert + index[1]; | loops[dst_loop + 2].v = startvert + index[1]; | ||||
| polys[dst_poly].loopstart = dst_loop; | polys[dst_poly].loopstart = dst_loop; | ||||
| polys[dst_poly].totloop = 3; | polys[dst_poly].totloop = 3; | ||||
| material_indices.span[dst_poly] = dl->col; | material_indices.span[dst_poly] = dl->col; | ||||
| if (mloopuv) { | if (mloopuv) { | ||||
| for (int i = 0; i < 3; i++, mloopuv++) { | for (int i = 0; i < 3; i++, mloopuv++) { | ||||
| mloopuv->uv[0] = (loops[dst_loop + i].v - startvert) / float(dl->nr - 1); | (*mloopuv)[0] = (loops[dst_loop + i].v - startvert) / float(dl->nr - 1); | ||||
| mloopuv->uv[1] = 0.0f; | (*mloopuv)[1] = 0.0f; | ||||
| } | } | ||||
| } | } | ||||
| if (is_smooth) { | if (is_smooth) { | ||||
| polys[dst_poly].flag |= ME_SMOOTH; | polys[dst_poly].flag |= ME_SMOOTH; | ||||
| } | } | ||||
| dst_poly++; | dst_poly++; | ||||
| dst_loop += 3; | dst_loop += 3; | ||||
| ▲ Show 20 Lines • Show All 59 Lines • ▼ Show 20 Lines | else if (dl->type == DL_SURF) { | ||||
| else if (dl->flag & DL_CYCL_V) { | else if (dl->flag & DL_CYCL_V) { | ||||
| orco_sizev++; | orco_sizev++; | ||||
| } | } | ||||
| for (int i = 0; i < 4; i++, mloopuv++) { | for (int i = 0; i < 4; i++, mloopuv++) { | ||||
| /* find uv based on vertex index into grid array */ | /* find uv based on vertex index into grid array */ | ||||
| int v = loops[dst_loop + i].v - startvert; | int v = loops[dst_loop + i].v - startvert; | ||||
| mloopuv->uv[0] = (v / dl->nr) / float(orco_sizev); | (*mloopuv)[0] = (v / dl->nr) / float(orco_sizev); | ||||
| mloopuv->uv[1] = (v % dl->nr) / float(orco_sizeu); | (*mloopuv)[1] = (v % dl->nr) / float(orco_sizeu); | ||||
| /* cyclic correction */ | /* cyclic correction */ | ||||
| if (ELEM(i, 1, 2) && mloopuv->uv[0] == 0.0f) { | if ((ELEM(i, 1, 2)) && (*mloopuv)[0] == 0.0f) { | ||||
| mloopuv->uv[0] = 1.0f; | (*mloopuv)[0] = 1.0f; | ||||
| } | } | ||||
| if (ELEM(i, 0, 1) && mloopuv->uv[1] == 0.0f) { | if ((ELEM(i, 0, 1)) && (*mloopuv)[1] == 0.0f) { | ||||
| mloopuv->uv[1] = 1.0f; | (*mloopuv)[1] = 1.0f; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| if (is_smooth) { | if (is_smooth) { | ||||
| polys[dst_poly].flag |= ME_SMOOTH; | polys[dst_poly].flag |= ME_SMOOTH; | ||||
| } | } | ||||
| dst_poly++; | dst_poly++; | ||||
| ▲ Show 20 Lines • Show All 851 Lines • Show Last 20 Lines | |||||