Fix T46529: Unwrap UV w/ use-subsurf fails
Regression since moving to looptri.
This commit is contained in:
parent
67e1c97350
commit
2b12cf40a1
Notes:
blender-bot
2023-02-14 08:31:11 +01:00
Referenced by issue #46529, Unwrap UV with "use subdivision modifier" does not work
|
@ -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;
|
||||
}
|
||||
|
||||
/* 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;
|
||||
mloop = &subsurfedLoops[mpoly->loopstart];
|
||||
|
||||
co[0] = subsurfedVerts[face->v1].co;
|
||||
co[1] = subsurfedVerts[face->v2].co;
|
||||
co[2] = subsurfedVerts[face->v3].co;
|
||||
co[3] = subsurfedVerts[face->v4].co;
|
||||
/* We will not check for v4 here. Subsurfed mfaces always have 4 vertices. */
|
||||
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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue