Changeset View
Changeset View
Standalone View
Standalone View
source/blender/modifiers/intern/MOD_volume_to_mesh.cc
| Show First 20 Lines • Show All 231 Lines • ▼ Show 20 Lines | for (const int i : verts.index_range()) { | ||||
| copy_v3_v3(mesh->mvert[i].co, co); | copy_v3_v3(mesh->mvert[i].co, co); | ||||
| } | } | ||||
| /* Write triangles. */ | /* Write triangles. */ | ||||
| for (const int i : tris.index_range()) { | for (const int i : tris.index_range()) { | ||||
| mesh->mpoly[i].loopstart = 3 * i; | mesh->mpoly[i].loopstart = 3 * i; | ||||
| mesh->mpoly[i].totloop = 3; | mesh->mpoly[i].totloop = 3; | ||||
| for (int j = 0; j < 3; j++) { | for (int j = 0; j < 3; j++) { | ||||
| mesh->mloop[3 * i + j].v = tris[i][j]; | /* Reverse vertex order to get correct normals. */ | ||||
| mesh->mloop[3 * i + j].v = tris[i][2 - j]; | |||||
| } | } | ||||
| } | } | ||||
| /* Write quads. */ | /* Write quads. */ | ||||
| const int poly_offset = tris.size(); | const int poly_offset = tris.size(); | ||||
| const int loop_offset = tris.size() * 3; | const int loop_offset = tris.size() * 3; | ||||
| for (const int i : quads.index_range()) { | for (const int i : quads.index_range()) { | ||||
| mesh->mpoly[poly_offset + i].loopstart = loop_offset + 4 * i; | mesh->mpoly[poly_offset + i].loopstart = loop_offset + 4 * i; | ||||
| mesh->mpoly[poly_offset + i].totloop = 4; | mesh->mpoly[poly_offset + i].totloop = 4; | ||||
| for (int j = 0; j < 4; j++) { | for (int j = 0; j < 4; j++) { | ||||
| mesh->mloop[loop_offset + 4 * i + j].v = quads[i][j]; | /* Reverse vertex order to get correct normals. */ | ||||
| mesh->mloop[loop_offset + 4 * i + j].v = quads[i][3 - j]; | |||||
| } | } | ||||
| } | } | ||||
| BKE_mesh_calc_edges(mesh, false, false); | BKE_mesh_calc_edges(mesh, false, false); | ||||
| BKE_mesh_calc_normals(mesh); | BKE_mesh_calc_normals(mesh); | ||||
| return mesh; | return mesh; | ||||
| } | } | ||||
| #endif | #endif | ||||
| ▲ Show 20 Lines • Show All 84 Lines • Show Last 20 Lines | |||||