Multires: Remove unused function

It uses derived mesh, and relies on scene stored in modifier data.
So port is needed anyway.
This commit is contained in:
Sergey Sharybin 2018-06-18 11:14:00 +02:00
parent 4330027895
commit d5ec62a0c3
3 changed files with 0 additions and 181 deletions

View File

@ -97,14 +97,6 @@ int multiresModifier_reshapeFromDeformMod(struct Depsgraph *depsgraph, struct Sc
void multires_stitch_grids(struct Object *);
/*switch mdisp data in dm between tangent and object space*/
enum {
MULTIRES_SPACE_TANGENT,
MULTIRES_SPACE_OBJECT,
MULTIRES_SPACE_ABSOLUTE
};
void multires_set_space(struct DerivedMesh *dm, struct Object *ob, int from, int to);
/* Related to the old multires */
void multires_free(struct Multires *mr);
void multires_load_old(struct Object *ob, struct Mesh *me);

View File

@ -1333,126 +1333,6 @@ void multires_modifier_update_hidden(DerivedMesh *dm)
}
}
void multires_set_space(DerivedMesh *dm, Object *ob, int from, int to)
{
DerivedMesh *ccgdm = NULL, *subsurf = NULL;
CCGElem **gridData, **subGridData = NULL;
CCGKey key;
MPoly *mpoly = CustomData_get_layer(&dm->polyData, CD_MPOLY);
MDisps *mdisps;
MultiresModifierData *mmd = get_multires_modifier(NULL, ob, 1);
int *gridOffset, totlvl;
int i, k, numGrids, gridSize, dGridSize, dSkip;
if (!mmd)
return;
mdisps = CustomData_get_layer(&dm->loopData, CD_MDISPS);
if (!mdisps) {
goto cleanup;
}
totlvl = mmd->totlvl;
ccgdm = multires_dm_create_local(ob, dm, totlvl, totlvl, mmd->simple, false);
subsurf = subsurf_dm_create_local(ob, dm, totlvl,
mmd->simple, mmd->flags & eMultiresModifierFlag_ControlEdges, mmd->flags & eMultiresModifierFlag_PlainUv, 0);
numGrids = subsurf->getNumGrids(subsurf);
gridSize = subsurf->getGridSize(subsurf);
gridData = subsurf->getGridData(subsurf);
subsurf->getGridKey(subsurf, &key);
subGridData = MEM_calloc_arrayN(numGrids, sizeof(CCGElem *), "subGridData*");
for (i = 0; i < numGrids; i++) {
subGridData[i] = MEM_calloc_arrayN(key.elem_size, gridSize * gridSize, "subGridData");
memcpy(subGridData[i], gridData[i], key.elem_size * gridSize * gridSize);
}
/* numGrids = ccgdm->dm->getNumGrids((DerivedMesh *)ccgdm); */ /*UNUSED*/
gridSize = ccgdm->getGridSize((DerivedMesh *)ccgdm);
gridData = ccgdm->getGridData((DerivedMesh *)ccgdm);
gridOffset = ccgdm->getGridOffset((DerivedMesh *)ccgdm);
dGridSize = multires_side_tot[totlvl];
dSkip = (dGridSize - 1) / (gridSize - 1);
k = 0; /*current loop/mdisp index within the mloop array*/
/* TODO: Use BLI_task parallel range for that one too? */
for (i = 0; i < dm->numPolyData; ++i) {
const int numVerts = mpoly[i].totloop;
int S, x, y, gIndex = gridOffset[i];
for (S = 0; S < numVerts; ++S, ++gIndex, ++k) {
MDisps *mdisp = &mdisps[mpoly[i].loopstart + S];
/* CCGElem *grid = gridData[gIndex]; */ /* UNUSED */
CCGElem *subgrid = subGridData[gIndex];
float (*dispgrid)[3] = NULL;
/* when adding new faces in edit mode, need to allocate disps */
if (!mdisp->disps) {
mdisp->totdisp = gridSize * gridSize;
mdisp->level = totlvl;
mdisp->disps = MEM_calloc_arrayN(mdisp->totdisp, 3 * sizeof(float), "disp in multires_set_space");
}
dispgrid = mdisp->disps;
for (y = 0; y < gridSize; y++) {
for (x = 0; x < gridSize; x++) {
float *data = dispgrid[dGridSize * y * dSkip + x * dSkip];
float *co = CCG_grid_elem_co(&key, subgrid, x, y);
float mat[3][3], dco[3];
/* construct tangent space matrix */
grid_tangent_matrix(mat, &key, x, y, subgrid);
/* convert to absolute coordinates in space */
if (from == MULTIRES_SPACE_TANGENT) {
mul_v3_m3v3(dco, mat, data);
add_v3_v3(dco, co);
}
else if (from == MULTIRES_SPACE_OBJECT) {
add_v3_v3v3(dco, co, data);
}
else if (from == MULTIRES_SPACE_ABSOLUTE) {
copy_v3_v3(dco, data);
}
/*now, convert to desired displacement type*/
if (to == MULTIRES_SPACE_TANGENT) {
invert_m3(mat);
sub_v3_v3(dco, co);
mul_v3_m3v3(data, mat, dco);
}
else if (to == MULTIRES_SPACE_OBJECT) {
sub_v3_v3(dco, co);
mul_v3_m3v3(data, mat, dco);
}
else if (to == MULTIRES_SPACE_ABSOLUTE) {
copy_v3_v3(data, dco);
}
}
}
}
}
cleanup:
if (subsurf) {
subsurf->needsFree = 1;
subsurf->release(subsurf);
}
if (ccgdm) {
ccgdm->needsFree = 1;
ccgdm->release(ccgdm);
}
}
void multires_stitch_grids(Object *ob)
{
/* utility for smooth brush */

View File

@ -1041,59 +1041,6 @@ void BM_edges_sharp_from_angle_set(BMesh *bm, const float split_angle)
bm_mesh_edges_sharp_tag(bm, NULL, NULL, NULL, split_angle, true);
}
static void UNUSED_FUNCTION(bm_mdisps_space_set)(
Object *ob, BMesh *bm, int from, int to)
{
/* switch multires data out of tangent space */
if (CustomData_has_layer(&bm->ldata, CD_MDISPS)) {
BMEditMesh *em = BKE_editmesh_create(bm, false);
DerivedMesh *dm = CDDM_from_editbmesh(em, true, false);
MDisps *mdisps;
BMFace *f;
BMIter iter;
// int i = 0; // UNUSED
multires_set_space(dm, ob, from, to);
mdisps = CustomData_get_layer(&dm->loopData, CD_MDISPS);
BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) {
BMLoop *l;
BMIter liter;
BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) {
MDisps *lmd = CustomData_bmesh_get(&bm->ldata, l->head.data, CD_MDISPS);
if (!lmd->disps) {
printf("%s: warning - 'lmd->disps' == NULL\n", __func__);
}
if (lmd->disps && lmd->totdisp == mdisps->totdisp) {
memcpy(lmd->disps, mdisps->disps, sizeof(float) * 3 * lmd->totdisp);
}
else if (mdisps->disps) {
if (lmd->disps)
MEM_freeN(lmd->disps);
lmd->disps = MEM_dupallocN(mdisps->disps);
lmd->totdisp = mdisps->totdisp;
lmd->level = mdisps->level;
}
mdisps++;
// i += 1;
}
}
dm->needsFree = 1;
dm->release(dm);
/* setting this to NULL prevents BKE_editmesh_free from freeing it */
em->bm = NULL;
BKE_editmesh_free(em);
MEM_freeN(em);
}
}
/**
* \brief BMesh Begin Edit
*