Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/subdiv_eval.cc
| Show First 20 Lines • Show All 77 Lines • ▼ Show 20 Lines | |||||
| } | } | ||||
| static void set_coarse_positions(Subdiv *subdiv, | static void set_coarse_positions(Subdiv *subdiv, | ||||
| const Mesh *mesh, | const Mesh *mesh, | ||||
| const float (*coarse_vertex_cos)[3]) | const float (*coarse_vertex_cos)[3]) | ||||
| { | { | ||||
| const float(*positions)[3] = BKE_mesh_vert_positions(mesh); | const float(*positions)[3] = BKE_mesh_vert_positions(mesh); | ||||
| const MPoly *mpoly = BKE_mesh_polys(mesh); | const MPoly *mpoly = BKE_mesh_polys(mesh); | ||||
| const MLoop *mloop = BKE_mesh_loops(mesh); | const blender::Span<int> corner_verts = mesh->corner_verts(); | ||||
| /* Mark vertices which needs new coordinates. */ | /* Mark vertices which needs new coordinates. */ | ||||
| /* TODO(sergey): This is annoying to calculate this on every update, | /* TODO(sergey): This is annoying to calculate this on every update, | ||||
| * maybe it's better to cache this mapping. Or make it possible to have | * maybe it's better to cache this mapping. Or make it possible to have | ||||
| * OpenSubdiv's vertices match mesh ones? */ | * OpenSubdiv's vertices match mesh ones? */ | ||||
| BLI_bitmap *vertex_used_map = BLI_BITMAP_NEW(mesh->totvert, "vert used map"); | BLI_bitmap *vertex_used_map = BLI_BITMAP_NEW(mesh->totvert, "vert used map"); | ||||
| for (int poly_index = 0; poly_index < mesh->totpoly; poly_index++) { | for (int poly_index = 0; poly_index < mesh->totpoly; poly_index++) { | ||||
| const MPoly *poly = &mpoly[poly_index]; | const MPoly *poly = &mpoly[poly_index]; | ||||
| for (int corner = 0; corner < poly->totloop; corner++) { | for (int i = 0; i < poly->totloop; i++) { | ||||
| const MLoop *loop = &mloop[poly->loopstart + corner]; | BLI_BITMAP_ENABLE(vertex_used_map, corner_verts[poly->loopstart + i]); | ||||
| BLI_BITMAP_ENABLE(vertex_used_map, loop->v); | |||||
| } | } | ||||
| } | } | ||||
| /* Use a temporary buffer so we do not upload vertices one at a time to the GPU. */ | /* Use a temporary buffer so we do not upload vertices one at a time to the GPU. */ | ||||
| float(*buffer)[3] = static_cast<float(*)[3]>( | float(*buffer)[3] = static_cast<float(*)[3]>( | ||||
| MEM_mallocN(sizeof(float[3]) * mesh->totvert, __func__)); | MEM_mallocN(sizeof(float[3]) * mesh->totvert, __func__)); | ||||
| int manifold_vertex_count = 0; | int manifold_vertex_count = 0; | ||||
| for (int vertex_index = 0, manifold_vertex_index = 0; vertex_index < mesh->totvert; | for (int vertex_index = 0, manifold_vertex_index = 0; vertex_index < mesh->totvert; | ||||
| vertex_index++) { | vertex_index++) { | ||||
| ▲ Show 20 Lines • Show All 92 Lines • Show Last 20 Lines | |||||