Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/subsurf_ccg.c
| Show First 20 Lines • Show All 256 Lines • ▼ Show 20 Lines | for (j = 0; j < nverts; j++) { | ||||
| fverts[j] = POINTER_FROM_UINT(mpoly[nv->poly_index].loopstart + nv->loop_of_poly_index); | fverts[j] = POINTER_FROM_UINT(mpoly[nv->poly_index].loopstart + nv->loop_of_poly_index); | ||||
| } | } | ||||
| } | } | ||||
| static int ss_sync_from_uv(CCGSubSurf *ss, | static int ss_sync_from_uv(CCGSubSurf *ss, | ||||
| CCGSubSurf *origss, | CCGSubSurf *origss, | ||||
| DerivedMesh *dm, | DerivedMesh *dm, | ||||
| const MLoopUV *mloopuv) | const float (*mloopuv)[2]) | ||||
| { | { | ||||
| MPoly *mpoly = dm->getPolyArray(dm); | MPoly *mpoly = dm->getPolyArray(dm); | ||||
| MLoop *mloop = dm->getLoopArray(dm); | MLoop *mloop = dm->getLoopArray(dm); | ||||
| int totvert = dm->getNumVerts(dm); | int totvert = dm->getNumVerts(dm); | ||||
| int totface = dm->getNumPolys(dm); | int totface = dm->getNumPolys(dm); | ||||
| int i, seam; | int i, seam; | ||||
| UvMapVert *v; | UvMapVert *v; | ||||
| UvVertMap *vmap; | UvVertMap *vmap; | ||||
| Show All 33 Lines | for (i = 0; i < totvert; i++) { | ||||
| seam = (v != NULL); | seam = (v != NULL); | ||||
| for (v = BKE_mesh_uv_vert_map_get_vert(vmap, i); v; v = v->next) { | for (v = BKE_mesh_uv_vert_map_get_vert(vmap, i); v; v = v->next) { | ||||
| if (v->separate) { | if (v->separate) { | ||||
| CCGVert *ssv; | CCGVert *ssv; | ||||
| int loopid = mpoly[v->poly_index].loopstart + v->loop_of_poly_index; | int loopid = mpoly[v->poly_index].loopstart + v->loop_of_poly_index; | ||||
| CCGVertHDL vhdl = POINTER_FROM_INT(loopid); | CCGVertHDL vhdl = POINTER_FROM_INT(loopid); | ||||
| copy_v2_v2(uv, mloopuv[loopid].uv); | copy_v2_v2(uv, mloopuv[loopid]); | ||||
| ccgSubSurf_syncVert(ss, vhdl, uv, seam, &ssv); | ccgSubSurf_syncVert(ss, vhdl, uv, seam, &ssv); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| /* create edges */ | /* create edges */ | ||||
| eset = BLI_edgeset_new_ex(__func__, BLI_EDGEHASH_SIZE_GUESS_FROM_POLYS(totface)); | eset = BLI_edgeset_new_ex(__func__, BLI_EDGEHASH_SIZE_GUESS_FROM_POLYS(totface)); | ||||
| ▲ Show 20 Lines • Show All 58 Lines • ▼ Show 20 Lines | #endif | ||||
| return 1; | return 1; | ||||
| } | } | ||||
| static void set_subsurf_legacy_uv(CCGSubSurf *ss, DerivedMesh *dm, DerivedMesh *result, int n) | static void set_subsurf_legacy_uv(CCGSubSurf *ss, DerivedMesh *dm, DerivedMesh *result, int n) | ||||
| { | { | ||||
| CCGFaceIterator fi; | CCGFaceIterator fi; | ||||
| int index, gridSize, gridFaces, /*edgeSize,*/ totface, x, y, S; | int index, gridSize, gridFaces, /*edgeSize,*/ totface, x, y, S; | ||||
| const MLoopUV *dmloopuv = CustomData_get_layer_n(&dm->loopData, CD_MLOOPUV, n); | const float(*dmloopuv)[2] = CustomData_get_layer_n(&dm->loopData, CD_PROP_FLOAT2, n); | ||||
| /* need to update both CD_MTFACE & CD_MLOOPUV, hrmf, we could get away with | /* need to update both CD_MTFACE & CD_PROP_FLOAT2, hrmf, we could get away with | ||||
| * just tface except applying the modifier then looses subsurf UV */ | * just tface except applying the modifier then looses subsurf UV */ | ||||
| MTFace *tface = CustomData_get_layer_n(&result->faceData, CD_MTFACE, n); | MTFace *tface = CustomData_get_layer_n(&result->faceData, CD_MTFACE, n); | ||||
| MLoopUV *mloopuv = CustomData_get_layer_n(&result->loopData, CD_MLOOPUV, n); | float(*mloopuv)[2] = CustomData_get_layer_n(&result->loopData, CD_PROP_FLOAT2, n); | ||||
| if (!dmloopuv || (!tface && !mloopuv)) { | if (!dmloopuv || (!tface && !mloopuv)) { | ||||
| return; | return; | ||||
| } | } | ||||
| /* create a CCGSubSurf from uv's */ | /* create a CCGSubSurf from uv's */ | ||||
| CCGSubSurf *uvss = _getSubSurf(NULL, ccgSubSurf_getSubdivisionLevels(ss), 2, CCG_USE_ARENA); | CCGSubSurf *uvss = _getSubSurf(NULL, ccgSubSurf_getSubdivisionLevels(ss), 2, CCG_USE_ARENA); | ||||
| Show All 13 Lines | static void set_subsurf_legacy_uv(CCGSubSurf *ss, DerivedMesh *dm, DerivedMesh *result, int n) | ||||
| for (ccgSubSurf_initFaceIterator(uvss, &fi); !ccgFaceIterator_isStopped(&fi); | for (ccgSubSurf_initFaceIterator(uvss, &fi); !ccgFaceIterator_isStopped(&fi); | ||||
| ccgFaceIterator_next(&fi)) { | ccgFaceIterator_next(&fi)) { | ||||
| CCGFace *f = ccgFaceIterator_getCurrent(&fi); | CCGFace *f = ccgFaceIterator_getCurrent(&fi); | ||||
| faceMap[POINTER_AS_INT(ccgSubSurf_getFaceFaceHandle(f))] = f; | faceMap[POINTER_AS_INT(ccgSubSurf_getFaceFaceHandle(f))] = f; | ||||
| } | } | ||||
| /* load coordinates from uvss into tface */ | /* load coordinates from uvss into tface */ | ||||
| MTFace *tf = tface; | MTFace *tf = tface; | ||||
| MLoopUV *mluv = mloopuv; | float(*mluv)[2] = mloopuv; | ||||
| for (index = 0; index < totface; index++) { | for (index = 0; index < totface; index++) { | ||||
| CCGFace *f = faceMap[index]; | CCGFace *f = faceMap[index]; | ||||
| int numVerts = ccgSubSurf_getFaceNumVerts(f); | int numVerts = ccgSubSurf_getFaceNumVerts(f); | ||||
| for (S = 0; S < numVerts; S++) { | for (S = 0; S < numVerts; S++) { | ||||
| float(*faceGridData)[2] = ccgSubSurf_getFaceGridDataArray(uvss, f, S); | float(*faceGridData)[2] = ccgSubSurf_getFaceGridDataArray(uvss, f, S); | ||||
| for (y = 0; y < gridFaces; y++) { | for (y = 0; y < gridFaces; y++) { | ||||
| for (x = 0; x < gridFaces; x++) { | for (x = 0; x < gridFaces; x++) { | ||||
| float *a = faceGridData[(y + 0) * gridSize + x + 0]; | float *a = faceGridData[(y + 0) * gridSize + x + 0]; | ||||
| float *b = faceGridData[(y + 0) * gridSize + x + 1]; | float *b = faceGridData[(y + 0) * gridSize + x + 1]; | ||||
| float *c = faceGridData[(y + 1) * gridSize + x + 1]; | float *c = faceGridData[(y + 1) * gridSize + x + 1]; | ||||
| float *d = faceGridData[(y + 1) * gridSize + x + 0]; | float *d = faceGridData[(y + 1) * gridSize + x + 0]; | ||||
| if (tf) { | if (tf) { | ||||
| copy_v2_v2(tf->uv[0], a); | copy_v2_v2(tf->uv[0], a); | ||||
| copy_v2_v2(tf->uv[1], d); | copy_v2_v2(tf->uv[1], d); | ||||
| copy_v2_v2(tf->uv[2], c); | copy_v2_v2(tf->uv[2], c); | ||||
| copy_v2_v2(tf->uv[3], b); | copy_v2_v2(tf->uv[3], b); | ||||
| tf++; | tf++; | ||||
| } | } | ||||
| if (mluv) { | if (mluv) { | ||||
| copy_v2_v2(mluv[0].uv, a); | copy_v2_v2(mluv[0], a); | ||||
| copy_v2_v2(mluv[1].uv, d); | copy_v2_v2(mluv[1], d); | ||||
| copy_v2_v2(mluv[2].uv, c); | copy_v2_v2(mluv[2], c); | ||||
| copy_v2_v2(mluv[3].uv, b); | copy_v2_v2(mluv[3], b); | ||||
| mluv += 4; | mluv += 4; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| ccgSubSurf_free(uvss); | ccgSubSurf_free(uvss); | ||||
| ▲ Show 20 Lines • Show All 1,335 Lines • ▼ Show 20 Lines | for (index = 0; index < totedge; index++) { | ||||
| } | } | ||||
| edgeNum += numFinalEdges; | edgeNum += numFinalEdges; | ||||
| } | } | ||||
| if (useSubsurfUv) { | if (useSubsurfUv) { | ||||
| CustomData *ldata = &ccgdm->dm.loopData; | CustomData *ldata = &ccgdm->dm.loopData; | ||||
| CustomData *dmldata = &dm->loopData; | CustomData *dmldata = &dm->loopData; | ||||
| int numlayer = CustomData_number_of_layers(ldata, CD_MLOOPUV); | int numlayer = CustomData_number_of_layers(ldata, CD_PROP_FLOAT2); | ||||
| int dmnumlayer = CustomData_number_of_layers(dmldata, CD_MLOOPUV); | int dmnumlayer = CustomData_number_of_layers(dmldata, CD_PROP_FLOAT2); | ||||
| for (i = 0; i < numlayer && i < dmnumlayer; i++) { | for (i = 0; i < numlayer && i < dmnumlayer; i++) { | ||||
| set_subsurf_uv(ss, dm, &ccgdm->dm, i); | set_subsurf_uv(ss, dm, &ccgdm->dm, i); | ||||
| } | } | ||||
| } | } | ||||
| for (index = 0; index < totvert; index++) { | for (index = 0; index < totvert; index++) { | ||||
| CCGVert *v = ccgdm->vertMap[index].vert; | CCGVert *v = ccgdm->vertMap[index].vert; | ||||
| ▲ Show 20 Lines • Show All 248 Lines • Show Last 20 Lines | |||||