Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Montagne <montagne29@wanadoo.fr>2012-03-19 02:06:57 +0400
committerBastien Montagne <montagne29@wanadoo.fr>2012-03-19 02:06:57 +0400
commit53b7078343c1fa0e9361e038163a6a17f52da4e4 (patch)
tree53f6f12a5d32dbd64d0c98b7fd369601b9d00a96 /source/blender/blenkernel/intern/subsurf_ccg.c
parent709ca0ece9b28858cea8084f8040ce0b7455958a (diff)
Fix [#30234] Various problems with CD layers and tesselation, related to modifiers stack.
Should also fix [#30266], [#29451], and partly [#30316]. Here are the changes made by this commit: * It adds a "dirty" flag to DerivedMesh struct (for now, only DM_DIRTY_TESS_CDLAYERS, but more might be added as needed). * It adds a new func, DM_update_tessface_data, which assumes tessfaces themselves are valid, but updates tessellated customdata from their poly/loop counter parts. * At end of modstack, when valid tessellated faces are present in finaldm , but the cdlayers dirty flag is set, call that function (instead of recomputing the whole tessellation). * Edits to the codes concerned (UVProject, DynamicPaint, and Subsurf modifiers). * Also add to subsurf dm generation code the creation of a CD_POLYINDEX layer (mandatory for DM_update_tessface_data to work well, and imho all tessellated dm should have one). Note: some pieces of old code are just #if 0’ed, will clean them later.
Diffstat (limited to 'source/blender/blenkernel/intern/subsurf_ccg.c')
-rw-r--r--source/blender/blenkernel/intern/subsurf_ccg.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c
index b968afa4d22..7fcb866d806 100644
--- a/source/blender/blenkernel/intern/subsurf_ccg.c
+++ b/source/blender/blenkernel/intern/subsurf_ccg.c
@@ -2888,7 +2888,7 @@ static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss,
int *vertOrigIndex, *faceOrigIndex, *polyOrigIndex, *base_polyOrigIndex; /* *edgeOrigIndex - as yet, unused */
short *edgeFlags;
DMFlagMat *faceFlags;
- int *loopidx = NULL, *vertidx = NULL;
+ int *loopidx = NULL, *vertidx = NULL, *polyidx = NULL;
BLI_array_declare(loopidx);
BLI_array_declare(vertidx);
int loopindex, loopindex2;
@@ -2922,6 +2922,7 @@ static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss,
if (
(numTex && CustomData_number_of_layers(&ccgdm->dm.faceData, CD_MTFACE) != numTex) ||
(numCol && CustomData_number_of_layers(&ccgdm->dm.faceData, CD_MCOL) != numCol) ||
+ (hasWCol && !CustomData_has_layer(&ccgdm->dm.faceData, CD_WEIGHT_MCOL)) ||
(hasOrigSpace && !CustomData_has_layer(&ccgdm->dm.faceData, CD_ORIGSPACE)) )
{
CustomData_from_bmeshpoly(&ccgdm->dm.faceData,
@@ -2930,6 +2931,10 @@ static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss,
ccgSubSurf_getNumFinalFaces(ss));
}
+ /* We absolutely need that layer, else it's no valid tesselated data! */
+ polyidx = CustomData_add_layer(&ccgdm->dm.faceData, CD_POLYINDEX, CD_CALLOC,
+ NULL, ccgSubSurf_getNumFinalFaces(ss));
+
ccgdm->dm.getMinMax = ccgDM_getMinMax;
ccgdm->dm.getNumVerts = ccgDM_getNumVerts;
ccgdm->dm.getNumEdges = ccgDM_getNumEdges;
@@ -3207,6 +3212,9 @@ static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss,
ccgdm->reverseFaceMap[faceNum] = index;
+ /* This is a simple one to one mapping, here... */
+ polyidx[faceNum] = faceNum;
+
faceNum++;
}
}
@@ -3297,6 +3305,9 @@ static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss,
ccgdm->dm.numLoopData = loopindex2;
ccgdm->dm.numPolyData = faceNum;
+ /* All tessellated CD layers were updated! */
+ ccgdm->dm.dirty &= ~DM_DIRTY_TESS_CDLAYERS;
+
BLI_array_free(vertidx);
BLI_array_free(loopidx);
free_ss_weights(&wtable);