diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2018-07-18 18:34:44 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2018-07-19 12:23:59 +0300 |
commit | 64bbfaf42144e26718bfb789cba81a409536cf73 (patch) | |
tree | 712bacfca2b1dda9e42e0f6f3ed0c1b4e9a4dd31 /source/blender/blenkernel/intern/subdiv_mesh.c | |
parent | 9df1e54079344ed4e2becef9e57cf1b925b46dff (diff) |
Subsurf: Set original index for high-poly vertices
Diffstat (limited to 'source/blender/blenkernel/intern/subdiv_mesh.c')
-rw-r--r-- | source/blender/blenkernel/intern/subdiv_mesh.c | 39 |
1 files changed, 36 insertions, 3 deletions
diff --git a/source/blender/blenkernel/intern/subdiv_mesh.c b/source/blender/blenkernel/intern/subdiv_mesh.c index c2a10483e26..9090ebe9f0f 100644 --- a/source/blender/blenkernel/intern/subdiv_mesh.c +++ b/source/blender/blenkernel/intern/subdiv_mesh.c @@ -416,7 +416,10 @@ static void loop_interpolation_end(LoopsForInterpolation *loop_interpolation) static void subdiv_copy_vertex_data( const SubdivMeshContext *ctx, MVert *subdiv_vertex, + const Mesh *coarse_mesh, + const MPoly *coarse_poly, const VerticesForInterpolation *vertex_interpolation, + const int ptex_of_poly_index, const float u, const float v) { const int subdiv_vertex_index = subdiv_vertex - ctx->subdiv_mesh->mvert; @@ -430,7 +433,34 @@ static void subdiv_copy_vertex_data( weights, NULL, 4, subdiv_vertex_index); - /* TODO(sergey): Set ORIGINDEX. */ + if (ctx->vert_origindex != NULL) { + ctx->vert_origindex[subdiv_vertex_index] = ORIGINDEX_NONE; + if (coarse_poly->totloop == 4) { + if (u == 0.0f && v == 0.0f) { + ctx->vert_origindex[subdiv_vertex_index] = + vertex_interpolation->vertex_indices[0]; + } + else if (u == 1.0f && v == 0.0f) { + ctx->vert_origindex[subdiv_vertex_index] = + vertex_interpolation->vertex_indices[1]; + } + else if (u == 1.0f && v == 1.0f) { + ctx->vert_origindex[subdiv_vertex_index] = + vertex_interpolation->vertex_indices[2]; + } + else if (u == 0.0f && v == 1.0f) { + ctx->vert_origindex[subdiv_vertex_index] = + vertex_interpolation->vertex_indices[3]; + } + } else { + if (u == 0.0f && v == 0.0f) { + const MLoop *coarse_mloop = coarse_mesh->mloop; + ctx->vert_origindex[subdiv_vertex_index] = + coarse_mloop[coarse_poly->loopstart + + ptex_of_poly_index].v; + } + } + } } static void subdiv_evaluate_vertices(SubdivMeshContext *ctx, @@ -447,12 +477,12 @@ static void subdiv_evaluate_vertices(SubdivMeshContext *ctx, const int num_poly_ptex_faces = mpoly_ptex_faces_count_get(coarse_poly); /* Hi-poly subdivided mesh. */ Mesh *subdiv_mesh = ctx->subdiv_mesh; - MVert *subdiv_vertert = subdiv_mesh->mvert; + MVert *subdiv_vertex = subdiv_mesh->mvert; const int ptex_face_index = subdiv->face_ptex_offset[poly_index]; /* Actual evaluation. */ VerticesForInterpolation vertex_interpolation; vertex_interpolation_init(ctx, &vertex_interpolation, coarse_poly); - MVert *subdiv_vert = &subdiv_vertert[ptex_face_index * resolution2]; + MVert *subdiv_vert = &subdiv_vertex[ptex_face_index * resolution2]; for (int ptex_of_poly_index = 0; ptex_of_poly_index < num_poly_ptex_faces; ptex_of_poly_index++) @@ -475,7 +505,10 @@ static void subdiv_evaluate_vertices(SubdivMeshContext *ctx, const float u = x * inv_resolution_1; subdiv_copy_vertex_data(ctx, subdiv_vert, + coarse_mesh, + coarse_poly, &vertex_interpolation, + ptex_of_poly_index, u, v); } } |