diff options
author | Campbell Barton <ideasman42@gmail.com> | 2015-10-19 14:15:03 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2015-10-19 14:15:03 +0300 |
commit | 2b12cf40a1912b44f76eb382d7999b66b66a6c6c (patch) | |
tree | 0d24ebf92353034f273819bad777d32b7119fa33 /source/blender/editors/uvedit/uvedit_unwrap_ops.c | |
parent | 67e1c9735003bea56efb6ccfe7348dd7518ff25b (diff) |
Fix T46529: Unwrap UV w/ use-subsurf fails
Regression since moving to looptri.
Diffstat (limited to 'source/blender/editors/uvedit/uvedit_unwrap_ops.c')
-rw-r--r-- | source/blender/editors/uvedit/uvedit_unwrap_ops.c | 51 |
1 files changed, 27 insertions, 24 deletions
diff --git a/source/blender/editors/uvedit/uvedit_unwrap_ops.c b/source/blender/editors/uvedit/uvedit_unwrap_ops.c index f915a4b2e51..3ff3e29f79d 100644 --- a/source/blender/editors/uvedit/uvedit_unwrap_ops.c +++ b/source/blender/editors/uvedit/uvedit_unwrap_ops.c @@ -344,7 +344,8 @@ static ParamHandle *construct_param_handle_subsurfed(Scene *scene, Object *ob, B { ParamHandle *handle; /* index pointers */ - MFace *face; + MPoly *mpoly; + MLoop *mloop; MEdge *edge; int i; @@ -356,11 +357,12 @@ static ParamHandle *construct_param_handle_subsurfed(Scene *scene, Object *ob, B /* Used to hold subsurfed Mesh */ DerivedMesh *derivedMesh, *initialDerived; /* holds original indices for subsurfed mesh */ - const int *origVertIndices, *origEdgeIndices, *origFaceIndices, *origPolyIndices; + const int *origVertIndices, *origEdgeIndices, *origPolyIndices; /* Holds vertices of subsurfed mesh */ MVert *subsurfedVerts; MEdge *subsurfedEdges; - MFace *subsurfedFaces; + MPoly *subsurfedPolys; + MLoop *subsurfedLoops; /* number of vertices and faces for subsurfed mesh*/ int numOfEdges, numOfFaces; @@ -398,15 +400,15 @@ static ParamHandle *construct_param_handle_subsurfed(Scene *scene, Object *ob, B /* get the derived data */ subsurfedVerts = derivedMesh->getVertArray(derivedMesh); subsurfedEdges = derivedMesh->getEdgeArray(derivedMesh); - subsurfedFaces = derivedMesh->getTessFaceArray(derivedMesh); + subsurfedPolys = derivedMesh->getPolyArray(derivedMesh); + subsurfedLoops = derivedMesh->getLoopArray(derivedMesh); origVertIndices = derivedMesh->getVertDataArray(derivedMesh, CD_ORIGINDEX); origEdgeIndices = derivedMesh->getEdgeDataArray(derivedMesh, CD_ORIGINDEX); - origFaceIndices = derivedMesh->getTessFaceDataArray(derivedMesh, CD_ORIGINDEX); origPolyIndices = derivedMesh->getPolyDataArray(derivedMesh, CD_ORIGINDEX); numOfEdges = derivedMesh->getNumEdges(derivedMesh); - numOfFaces = derivedMesh->getNumTessFaces(derivedMesh); + numOfFaces = derivedMesh->getNumPolys(derivedMesh); faceMap = MEM_mallocN(numOfFaces * sizeof(BMFace *), "unwrap_edit_face_map"); @@ -415,7 +417,7 @@ static ParamHandle *construct_param_handle_subsurfed(Scene *scene, Object *ob, B /* map subsurfed faces to original editFaces */ for (i = 0; i < numOfFaces; i++) - faceMap[i] = BM_face_at_index(em->bm, DM_origindex_mface_mpoly(origFaceIndices, origPolyIndices, i)); + faceMap[i] = BM_face_at_index(em->bm, origPolyIndices[i]); edgeMap = MEM_mallocN(numOfEdges * sizeof(BMEdge *), "unwrap_edit_edge_map"); @@ -427,15 +429,13 @@ static ParamHandle *construct_param_handle_subsurfed(Scene *scene, Object *ob, B } /* Prepare and feed faces to the solver */ - for (i = 0; i < numOfFaces; i++) { + for (i = 0, mpoly = subsurfedPolys; i < numOfFaces; i++, mpoly++) { ParamKey key, vkeys[4]; ParamBool pin[4], select[4]; float *co[4]; float *uv[4]; BMFace *origFace = faceMap[i]; - face = subsurfedFaces + i; - if (scene->toolsettings->uv_flag & UV_SYNC_SELECTION) { if (BM_elem_flag_test(origFace, BM_ELEM_HIDDEN)) continue; @@ -445,24 +445,27 @@ static ParamHandle *construct_param_handle_subsurfed(Scene *scene, Object *ob, B continue; } + mloop = &subsurfedLoops[mpoly->loopstart]; + /* We will not check for v4 here. Subsurfed mfaces always have 4 vertices. */ - key = (ParamKey)face; - vkeys[0] = (ParamKey)face->v1; - vkeys[1] = (ParamKey)face->v2; - vkeys[2] = (ParamKey)face->v3; - vkeys[3] = (ParamKey)face->v4; - - co[0] = subsurfedVerts[face->v1].co; - co[1] = subsurfedVerts[face->v2].co; - co[2] = subsurfedVerts[face->v3].co; - co[3] = subsurfedVerts[face->v4].co; + BLI_assert(mpoly->totloop == 4); + key = (ParamKey)mpoly; + vkeys[0] = (ParamKey)mloop[0].v; + vkeys[1] = (ParamKey)mloop[1].v; + vkeys[2] = (ParamKey)mloop[2].v; + vkeys[3] = (ParamKey)mloop[3].v; + + co[0] = subsurfedVerts[mloop[0].v].co; + co[1] = subsurfedVerts[mloop[1].v].co; + co[2] = subsurfedVerts[mloop[2].v].co; + co[3] = subsurfedVerts[mloop[3].v].co; /* This is where all the magic is done. If the vertex exists in the, we pass the original uv pointer to the solver, thus * flushing the solution to the edit mesh. */ - texface_from_original_index(origFace, origVertIndices[face->v1], &uv[0], &pin[0], &select[0], scene, cd_loop_uv_offset); - texface_from_original_index(origFace, origVertIndices[face->v2], &uv[1], &pin[1], &select[1], scene, cd_loop_uv_offset); - texface_from_original_index(origFace, origVertIndices[face->v3], &uv[2], &pin[2], &select[2], scene, cd_loop_uv_offset); - texface_from_original_index(origFace, origVertIndices[face->v4], &uv[3], &pin[3], &select[3], scene, cd_loop_uv_offset); + texface_from_original_index(origFace, origVertIndices[mloop[0].v], &uv[0], &pin[0], &select[0], scene, cd_loop_uv_offset); + texface_from_original_index(origFace, origVertIndices[mloop[1].v], &uv[1], &pin[1], &select[1], scene, cd_loop_uv_offset); + texface_from_original_index(origFace, origVertIndices[mloop[2].v], &uv[2], &pin[2], &select[2], scene, cd_loop_uv_offset); + texface_from_original_index(origFace, origVertIndices[mloop[3].v], &uv[3], &pin[3], &select[3], scene, cd_loop_uv_offset); param_face_add(handle, key, 4, vkeys, co, uv, pin, select, NULL); } |