subsurf-specific implementations of getVert/Edge/TessFaceData

This commit is contained in:
Andrew Wiggin 2011-11-29 13:11:14 +00:00
parent eb46f6bf0d
commit 198113b232

@ -2446,6 +2446,12 @@ static void *ccgDM_get_vert_data_layer(DerivedMesh *dm, int type)
int *origindex; int *origindex;
int a, index, totnone, totorig; int a, index, totnone, totorig;
/* Avoid re-creation if the layer exists already */
origindex = DM_get_vert_data_layer(dm, CD_ORIGINDEX);
if (origindex) {
return origindex;
}
DM_add_vert_layer(dm, CD_ORIGINDEX, CD_CALLOC, NULL); DM_add_vert_layer(dm, CD_ORIGINDEX, CD_CALLOC, NULL);
origindex= DM_get_vert_data_layer(dm, CD_ORIGINDEX); origindex= DM_get_vert_data_layer(dm, CD_ORIGINDEX);
@ -2477,6 +2483,12 @@ static void *ccgDM_get_edge_data_layer(DerivedMesh *dm, int type)
int a, i, index, totnone, totorig, totedge; int a, i, index, totnone, totorig, totedge;
int edgeSize= ccgSubSurf_getEdgeSize(ss); int edgeSize= ccgSubSurf_getEdgeSize(ss);
/* Avoid re-creation if the layer exists already */
origindex = DM_get_edge_data_layer(dm, CD_ORIGINDEX);
if (origindex) {
return origindex;
}
DM_add_edge_layer(dm, CD_ORIGINDEX, CD_CALLOC, NULL); DM_add_edge_layer(dm, CD_ORIGINDEX, CD_CALLOC, NULL);
origindex= DM_get_edge_data_layer(dm, CD_ORIGINDEX); origindex= DM_get_edge_data_layer(dm, CD_ORIGINDEX);
@ -2512,6 +2524,12 @@ static void *ccgDM_get_tessface_data_layer(DerivedMesh *dm, int type)
int a, i, index, totface; int a, i, index, totface;
int gridFaces = ccgSubSurf_getGridSize(ss) - 1; int gridFaces = ccgSubSurf_getGridSize(ss) - 1;
/* Avoid re-creation if the layer exists already */
origindex = DM_get_tessface_data_layer(dm, CD_ORIGINDEX);
if (origindex) {
return origindex;
}
DM_add_tessface_layer(dm, CD_ORIGINDEX, CD_CALLOC, NULL); DM_add_tessface_layer(dm, CD_ORIGINDEX, CD_CALLOC, NULL);
origindex= DM_get_tessface_data_layer(dm, CD_ORIGINDEX); origindex= DM_get_tessface_data_layer(dm, CD_ORIGINDEX);
@ -2532,6 +2550,36 @@ static void *ccgDM_get_tessface_data_layer(DerivedMesh *dm, int type)
return DM_get_tessface_data_layer(dm, type); return DM_get_tessface_data_layer(dm, type);
} }
static void *ccgDM_get_vert_data(DerivedMesh *dm, int index, int type)
{
if (type == CD_ORIGINDEX) {
/* ensure creation of CD_ORIGINDEX layer */
ccgDM_get_vert_data_layer(dm, type);
}
return DM_get_vert_data(dm, index, type);
}
static void *ccgDM_get_edge_data(DerivedMesh *dm, int index, int type)
{
if (type == CD_ORIGINDEX) {
/* ensure creation of CD_ORIGINDEX layer */
ccgDM_get_edge_data_layer(dm, type);
}
return DM_get_edge_data(dm, index, type);
}
static void *ccgDM_get_tessface_data(DerivedMesh *dm, int index, int type)
{
if (type == CD_ORIGINDEX) {
/* ensure creation of CD_ORIGINDEX layer */
ccgDM_get_tessface_data_layer(dm, type);
}
return DM_get_tessface_data(dm, index, type);
}
static int ccgDM_getNumGrids(DerivedMesh *dm) static int ccgDM_getNumGrids(DerivedMesh *dm)
{ {
CCGDerivedMesh *cgdm= (CCGDerivedMesh*)dm; CCGDerivedMesh *cgdm= (CCGDerivedMesh*)dm;
@ -2829,6 +2877,10 @@ static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss,
ccgdm->dm.copyTessFaceArray = ccgDM_copyFinalFaceArray; ccgdm->dm.copyTessFaceArray = ccgDM_copyFinalFaceArray;
ccgdm->dm.copyLoopArray = ccgDM_copyFinalLoopArray; ccgdm->dm.copyLoopArray = ccgDM_copyFinalLoopArray;
ccgdm->dm.copyPolyArray = ccgDM_copyFinalPolyArray; ccgdm->dm.copyPolyArray = ccgDM_copyFinalPolyArray;
ccgdm->dm.getVertData = ccgDM_get_vert_data;
ccgdm->dm.getEdgeData = ccgDM_get_edge_data;
ccgdm->dm.getTessFaceData = ccgDM_get_tessface_data;
ccgdm->dm.getVertDataArray = ccgDM_get_vert_data_layer; ccgdm->dm.getVertDataArray = ccgDM_get_vert_data_layer;
ccgdm->dm.getEdgeDataArray = ccgDM_get_edge_data_layer; ccgdm->dm.getEdgeDataArray = ccgDM_get_edge_data_layer;
ccgdm->dm.getTessFaceDataArray = ccgDM_get_tessface_data_layer; ccgdm->dm.getTessFaceDataArray = ccgDM_get_tessface_data_layer;